Methods Summary |
---|
public java.lang.Object[] | compute(int si, float p)Computes the value for the input interpolated values.
There should be as many entries in the return array as there
are components in the RefValues.
segments[si].compute(p, w);
return w;
|
public int | getComponents()
return segments[0].getStart().length;
|
public float | getLength()Computes the length of the RefValues. This is meant for paced timing
computation.
return length;
|
public float | getLength(int si)Computes the length of segment at index si
return segLength[si];
|
public Segment | getSegment(int i)
return segments[i];
|
public void | getSegmentAtDist(float[] sisp, float dist)Computes the segment index for the given normalized distance.
if (dist >= 1) {
sisp[0] = segments.length - 1;
sisp[1] = 1;
return;
}
if (dist < 0) {
sisp[0] = 0;
sisp[1] = 0;
return;
}
int i = 0;
float prevSegLength = 0;
for (; i < nSegLength.length - 1; i++) {
if (dist < nSegLength[i]) {
break;
}
prevSegLength = nSegLength[i];
}
// Now, compute the penetration in the segment.
float p = 1;
if (nSegLength[i] > prevSegLength) {
p =
(dist - prevSegLength)
/
(nSegLength[i] - prevSegLength);
}
sisp[0] = i;
sisp[1] = p;
|
public int | getSegments()
return segments.length;
|
public void | initialize()Should be called after the RefValue's configuration is complete
to give the implementation a chance to initialize
internal data and cache values.
// Initialize the working buffer
final int nc = segments[0].getStart().length;
w = new float[nc][];
for (int ci = 0; ci < nc; ci++) {
// There is one dimension per component for motion
// values, which are matrix values.
w[ci] = new float[1];
}
// Initialize sub-segments.
final int ns = segments.length;
for (int si = 0; si < ns; si++) {
segments[si].initialize();
}
// Initialize cached length values.
nSegLength = new float[ns];
segLength = new float[ns];
for (int si = 0; si < segments.length; si++) {
segLength[si] = segments[si].getLength();
length += segLength[si];
}
// Now, initialize the normalized segment lengths array
if (length > 0) {
float curLength = 0;
for (int si = 0; si < ns - 1; si++) {
curLength += segLength[si];
nSegLength[si] = curLength / length;
}
} else {
for (int si = 0; si < ns - 1; si++) {
nSegLength[si] = 0;
}
}
// Make sure that, in all cases, the last value is 1.
nSegLength[nSegLength.length - 1] = 1;
|
public void | makeDiscrete()Adds a new time segment so accomodate for discreet behavior.
If there is only one segment for discreet animations, the
last value is never shown. To accomodate for that, this
method should add a segment to the RefValues so that the
last animation value is shown during the last value interval
of a discreet animation.
MotionSegment[] tmpSegments = new MotionSegment[segments.length + 1];
System.arraycopy(segments, 0, tmpSegments, 0, segments.length);
Segment lastSeg = segments[segments.length - 1];
float[][] end = (float[][]) lastSeg.getEnd();
LeafMotionSegment newSeg = new LeafMotionSegment(end[4][0],
end[5][0],
end[4][0],
end[5][0],
motion);
tmpSegments[tmpSegments.length - 1] = newSeg;
segments = tmpSegments;
|