Methods Summary |
---|
public void | addToEnd(java.lang.Object[] by)Adds the input value to this Segment's end value.
segments[segments.length - 1].addToEnd(by);
|
public void | collapse(Segment seg, Animation anim)Collapses this segment with the one passed as a parameter.
Note that if the input segment is not of the same class
as this one, an IllegalArgumentException is thrown. The
method also throws an exception if the input segment's
end does not have the same number of components as this
segment's end.
After this method is called, this segment's end value
is the one of the input seg parameter.
CompositeMotionSegment cseg = (CompositeMotionSegment) seg;
MotionSegment[] newSegments =
new MotionSegment[segments.length + cseg.segments.length];
System.arraycopy(segments,
0,
newSegments,
0,
segments.length);
System.arraycopy(cseg.segments,
0,
newSegments,
segments.length,
cseg.segments.length);
segments = newSegments;
|
public void | compute(float p, float[][] w)Computes an interpolated value for the given penetration in the
segment.
// First, identify the child MotionSegment at the desired
// normalized distance.
int si = segments.length - 1;
float prevSegLength = 0;
if (p < 1) {
for (si = 0; si < segments.length; si++) {
if (p < nSegLength[si]) {
break;
}
prevSegLength = nSegLength[si];
}
} else {
if (si > 0) {
prevSegLength = nSegLength[si - 1];
}
}
// The sub-segment is at index si. Now, we need to
// compute the penetration in that segment.
if (nSegLength[si] > prevSegLength) {
p = (p - prevSegLength) / (nSegLength[si] - prevSegLength);
} else {
p = 1;
}
segments[si].compute(p, w);
|
public java.lang.Object[] | getEnd()
return segments[segments.length - 1].getEnd();
|
public float | getLength()Computes this segment's length
return length;
|
public java.lang.Object[] | getStart()
return segments[0].getStart();
|
public void | initialize()Should be called after the segment's configuration is complete
to give the segment's implementation a chance to initialize
internal data and cache values.
// Initialize the component segments.
final int ns = segments.length;
for (int si = 0; si < ns; si++) {
segments[si].initialize();
}
// Now, initialize the length cache.
length = 0;
nSegLength = new float[ns];
for (int si = 0; si < segments.length; si++) {
nSegLength[si] = segments[si].getLength();
length += nSegLength[si];
}
// Now, initialize the normalized segment lengths array
if (length > 0) {
float curLength = 0;
for (int si = 0; si < ns - 1; si++) {
curLength += nSegLength[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[ns - 1] = 1;
|
public boolean | isAdditive()
return segments[0].isAdditive();
|
public void | setStart(java.lang.Object[] newStart)Sets the start value.
segments[0].setStart(newStart);
|
public void | setZeroStart()Sets the start value to its notion of 'zero'
segments[0].setZeroStart();
|