be.saltwater.jaqel.scheduler
Class WeightCalculator
java.lang.Object
be.saltwater.jaqel.scheduler.WeightCalculator
- public class WeightCalculator
- extends java.lang.Object
Calculates an array of doubles of which the sum is always 1.0. From here on this resulting array will be called the weights. The only input of the function that calculates these weights is the value of an javax.media.j3d.Alpha object. The alpha value is divided into a number of steps. This is equal to to length of the weight array. Each weight rises from 0 to 1 and then drops again from 1 to 0. When a weight is dropping, the next weight is rising. This creates a wave-like effect that can be used a input for the javax.media.j3d.Morph class. When the alpha value is 0, weight[0] is 1.0. When alpha has reached 1.0, weight[0] is 1.0 again. Because of this, it can be used for looped animations.
Alpha:
0----->------->------>-----1
Weights:
\ /\ /\ /\ /\ /\ /\ /
\/ \/ \/ \/ \/ \/ \/
[0] [1] [2] [3] [4] [..] [0]
[steps-1]
- Author:
- Bruno Windels
|
Constructor Summary |
WeightCalculator(javax.media.j3d.Alpha duration,
int steps)
Constucts a new WeightBehavior with "steps" steps. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WeightCalculator
public WeightCalculator(javax.media.j3d.Alpha duration,
int steps)
- Constucts a new WeightBehavior with "steps" steps.
getWeights
public double[] getWeights()
calculateWeights
public void calculateWeights()
- Calculates and returns the weights according to the alpha value. This should be used by subclasses to get the current weights.
getIndex
public int getIndex()
getNextIndex
public int getNextIndex()