Hi, I am quite new to java 3d, and have so far managed to get a cube to rotate around the y axis. What I would like to do now is get it to rotate around a different axis - still the y axis, but not at (0,0,0). I can't see any way to do this easily! You can do it with a rotationInterpolator but I understand that they are more for timed animation. My rotation is triggered by a user clicking a button, where it just rotates about 1/8 of a full circle. The method I currently use is rotY(angle), but this doesn't let me change the axis. Any ideas? Thanks, Hazel
What I would like to do now is get it to rotate around a different axis - still the y axis, but not at (0,0,0).
What do you mean by that? Rotating about y axis is called Yaw in computer graphics, my understanding to your presentation is: the object yawed at (0,0,0), now you still want a yaw, but the object�s initial coordinate is not at (0,0,0) right? :roll: If that is the case, just try to do some translation before the rotation--that means, slide the object in camera coordinate left/right/up/down--I never tried java 3D API, only studied some 3D Transformation and Camera positioning in OpenGL. It�s not difficult with OpenGL, Java 3D API is in higher level than OpenGL, I think there must be some methods for object translation. You may have a look at the documentation.
Regards, Ellen [ January 15, 2003: Message edited by: Ellen Fu ]
Joined: Feb 12, 2002
Hi Ellen, thanks for your reply. I have tried translating it first, but it always springs back to (0,0,0) after the first rotation. If I combine the translation with the rotation it translates every time the rotation is performed. Here is a method I am trying at the moment, in case anyone else ever has a similar problem: Using 3 different TransformGroups and 3 different Transform3Ds: 1. Move the object to be rotated to the origin ( in my case, (0,0,0). 2. Perform the rotation. 3. Move the object back to where it was. If you would like to see code for this, it's a thread marked "reference point for rotation" from sep 2002 on the Sun Java3D forum!
if i understand what you're saying, you are trying to rotate the cube around a different axis than the centre - for example, around one of the corners. I am just learning J3D now, so i can't recite the code for you, but i think you need to transform the cube and then rotate the transform. So, say if the cube is at 0,0,0 and is sixe 2 all round, transforming it 1,0,0 will move it so that the side is now where the centre used to be - call this transform tmove. Instead of rotating t1, make another transform (say, tRot), which holds the first transform. Rotating tRot will rotate tMove, which will rotate the cube around its side. Basically, use a seperate TransformGroup for each step (rotation & movement). You can do it in the same one, but having two keeps it simple.