Hello e b,

the RotationInterpolator class always performs a rotation about its
local y-Axis. In order to rotate about an arbitrary axis you need a
matrix that transforms your desired axis into the y-Axis. For that
purpose the RotationInterpolator constructor provides a Transform3D
parameter. In your example program you can achieve a rotation around
the z-Axis by replacing:

rotate.rotZ(1.0);

by

rotate.rotX( -Math.PI / 2 );


(Btw. I think RotationInterpolator overwrites the transformation
data of its target TransformGroup. Therefore your translation
vector "tgTrans" will have no effect.)

Although I haven't tried I doubt whether you could improve performance
by implementing your own brute force "Interpolator". What the
RotationInterpolator class probably does is to update a transformation
matrix every x milliseconds. The coordinates of your geometry remain
as they are. Instead the transformation of your 3D coordinates is done
in Hardware as a part of the rendering process (along with projection
and so on).

Sincerely,

Ernst Sikora.


e b wrote:

> Hello everyone. I'm having a little trouble with this
> RotationInterpolator.
> I want the transformGroup tg to rotate around the z-axis. I thought
> this is
> how it's done, but when I run it, it only rotates around the y-axis. I
> don't
> know what I'm doing wrong please help.
>
> Transform3D rotate = new Transform3D();
>      rotate.rotZ(1.0);
>      Vector3f tgTrans   = new Vector3f(0.0f, -0.6f, 0.0f);
>      Transform3D tgtr   = new Transform3D();
>      tgtr.setTranslation(tgTrans);
>      TransformGroup tg  = new TransformGroup(tgtr);
>      tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
>
> // other objects previously created.
>      tg.addChild(c1);
>      tg.addChild(c2);
>      tg.addChild(b1);
>      tg.addChild(b2);
>      tg.addChild(l1);
>
>      RotationInterpolator rotator = new RotationInterpolator(new
> Alpha(-1,
> 2000), tg, rotate, 0.0f, (float)(2 * Math.PI));
>      rotator.setSchedulingBounds(new BoundingSphere());
>
> Also is this the better way to do animations, or is it better
> (performance
> wise) to do it the old fashion way, with a timer to repaint or rerender
> every x milliseconds?
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at
> http://explorer.msn.com/intl.asp.
>
> ===========================================================================
>
> 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".
>

===========================================================================
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".

Reply via email to