I noticed that the current MorphBehavior class is limited to 3 morphs, I
created a piece of code that will allow it to extend that amount to the
number of weights...
by replacing this code snippet...
double val = alpha.value();
if (val < 0.5) {
double a = val * (double)(weights.length-1);//2.0;
weights[0] = 1.0 - a;
weights[1] = a;
weights[2] = 0.0;
}
else {
double a = (val - 0.5) * 2.0;
weights[0] = 0.0;
weights[1] = 1.0f - a;
weights[2] = a;
}
with this code snippet
double val = alpha.value();
int ia = (int)(val * (double)(weights.length-1));
double a = val * (double)(weights.length-1) - (double)ia;
for(int i=0;i<weights.length;i++) weights[i] = 0.0;
weights[ia] = 1.0 - a;
if(ia != (weights.length-1) ) weights[ia+1] = a;
It basicly clears the weights to zeros, and calculates where the alpha is or
inbetween in the array of weights (int ia), and calculates the alpha between
morphs (double a), and alters the values of weights accordingly, making a
special case at the end of list, to not go overboard. It worked with the demo
Morph.java, and I even added another morph target and it still worked.
One question I have though, should the general behavior of casting a double
to an int, be fine? Because the code depends upon this, in my opinion even if
it does not truncate properly going from a double to int, it should not cause
an exception, at least I dont think so.
But anyway if you would like, add this to the Morph Demos MorphBehavior.java,
it could prove usefull, maybe in the future for creating a viewer and going
through all the morph animations. It might even be usefull in the j3d utility
classes now that the 3 morph target limit is gone.
Leyland
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".