This one is probably as old as the hills - I have a model on
several layers, I have grouped the models and assigned the 'rotate
model XY' behaviour that exists within the Director 3d commands
library and have slightly modified to rotate the group of models
collectively, this would give say vector( 24.0384, 20.0094, 6.8364
) after the user has turned the model. Now I would like to reset
the models original XYZ rotation, so I have approached this with
repeat while loop as I would like to see the animation, the target
being vector(00.0000, 00.0000, 00.0000) First of all I've forced
the rotation to vector( integer(24.0384), integer(20.0094 etc.
giving me vector(24.0000 etc.
I then repeat while themodels.transform.rotation <>
vector(00.0000, 00.0000, 00.0000) with
if integer(theGroup.transform.rotation) > 0 then
theGroup.rotate(-1, 0, 0, #world)
if integer(theGroup.transform.rotation) <0 then
theGroup.rotate(+1, 0, 0, #world) // and following the other
It gets stuck in a loop and the resultant rotation becomes -
vector( 0.4957, -0.3695, 0.0527 )
why a decimal position less than 1 despite me rounding them
in the beginning with integer??
... to set the transform of the group to a position of (0, 0,
0), a scale of 1 and no rotation. You can then use translate(),
rotate() and scale() - in that order - to obtain the transform that
Setting the rotation of a transform can lead to strange
results if the rotation is around the y axis.
To answer your question in more detail: your rounding
technique means that any number between -0.4999 and 0.4999 will get
rounded to 0. 0 is neither greater than nor less than 0, so no
further rotations will be applied.
If you want the rotation to return to precisely 0, then you
will need to check...
else if theGroup.transform.rotation <> 0
... to force the final fractional rotation to occur.
Another solution would be to use the behavior that
you can find
here to animate the rotation back to the identity transform for