hi Peter,
you must perform the intepolator in the local coord system of the cube. see
changes below.

Gernot Veith

janet Ges. f. interaktive Medien mbH
Garmischer Str. 19/21
D-81377 Muenchen
www.janet.de
fon:       +49 (0) 89 - 54 26 21 - 19
fax :      +49 (0) 89 - 54 26 21 - 15
mail:      [EMAIL PROTECTED]



                    Peter Schuller
                    <peter.schuller@INFI        To:     [EMAIL PROTECTED]
                    DYNE.COM>                   cc:
                    Sent by: Discussion         Subject:     [JAVA3D] Translating and 
then rotating
                    list for Java 3D API
                    <JAVA3D-INTEREST@JAV
                    A.SUN.COM>


                    15.07.00 17:17
                    Please respond to
                    Discussion list for
                    Java 3D API






Hello,

I am just getting started with Java3D, so I am just trying to do some
simple
things with the help of the utility classes (while reading Sun's tutorial),
but I quickly got stuck.

What I tried to do was to rotate two cubes, but I wanted to apply a simple
translation to one of them so that they wouldn't be in the exact same spot.
This translation works as long as I don't rotate the cube, but as soon as I
rotate it it seems to move back to it's original position (0,0,0).

The following code builds the scene graph. I'd appreciate any pointers as
to
what I am missing.

Thanks!

BranchGroup objRoot = new BranchGroup();

TransformGroup objSpin1 = new TransformGroup();
objSpin1.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
objRoot.addChild(objSpin1);
objSpin1.addChild(new ColorCube(0.1));

Transform3D translate2 = new Transform3D();
Vector3f vector2 = new Vector3f(0.0f, 0.5f, 0.0f);
translate2.setTranslation(vector2);//new: ---------------
TransformGroup translateTG = new TransformGroup();
translateTG.setTransform(translate2);
//-------------------

TransformGroup objSpin2 = new TransformGroup();
objSpin2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);//new ------
translateTG.addChild(objSpin2);
objRoot.addChild(translateTG);
//objRoot.addChild(objSpin2);

objSpin2.addChild(new ColorCube(0.1));

Alpha rotationAlpha = new Alpha(-1, 4000);
RotationInterpolator rotator1 =
        new RotationInterpolator(rotationAlpha, objSpin1);
RotationInterpolator rotator2 =
        new RotationInterpolator(rotationAlpha, objSpin2);

BoundingSphere bounds = new BoundingSphere();
rotator1.setSchedulingBounds(bounds);
rotator2.setSchedulingBounds(bounds);
objSpin1.addChild(rotator1);
objSpin2.addChild(rotator2);

--
/ Peter Schuller, InfiDyne Technologies HB

PGP userID: 0x5584BD98 or 'Peter Schuller <[EMAIL PROTECTED]>'
Key retrival: Send an E-Mail to [EMAIL PROTECTED]
E-Mail: [EMAIL PROTECTED] Web: http://scode.infidyne.com

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