Skip to main content
gamedev.net
🔒 Locked

[java] rotating stuff in Java3d

Started by k0d3rk1dd33 Nov 3, 2004 at 11:49 PM 1 replies 2.2k views
Original Post
k0d3rk1dd33
k0d3rk1dd33
I have a cylinder that I am trying to rotate about a point at the end of the cylinder, but I only know how to rotate about an axis.... so, i was considering translating to origin, rotating, and translating back, but I dont know how to translate in Java3d to a point in space, all i can see from the docs are ways to translate using a vector that you want to add to your current position, but what if i dont know the current position of the cylinder? How would you go about doing this? Thanks much
Strife
Strife
That should be what you need. The only thing a vector really is is a set of values. It has many different geometric representations, one of which happens to be a point.

The nice thing about using a vector instead of a point is that it generalizes the concept.
misterX
misterX
i recommend you to go back to the very first tutorials of j3d. You're missing very basic stuff!

if i understood right, you simply want to rotate cylinder which is somewhere is space. (correct me if i'm wrong)
The simpliest is then to use 2 transform groups, one for the position, and one for the rotation.

TransformGroup posTG = new TransformGroup();
TransformGroup rotTG = new TransformGroup();
Cylinder myCylinder = new Cylinder();

posTG.addChild(rotTG);
rotTG.addChild(myCylinder);

Transform3D rot = new Transform3D();
rot.rotX(Math.PI/3);
rotTG.setTransform(rot);


...really, read sun's tutorials, they are quite good and will certainly help you a lot.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.