> From: Ken Warner <[EMAIL PROTECTED]>
>
> This will rotate the thingy at [20,20,20] around the origin -- right??  Not
> around
> the thingy's position at [20,20,20]-- right??

The code in the messge below will translate the object to 20,20,20 and then 
rotate the translated object around the origin (that is, it won't rotate around 
it's center, it will "orbit" the origin by the specified rotation).  To rotate 
and then translate, apply the transforms in that order.

To rotate an object at X,Y,Z around it's center:

        translate by -X, -Y, -Z (moves the object to the origin)
        rotate (all rotations happen around the origin)
        translate by X,Y,Z (moves the object back)
        
Of course, these three transforms should be concatinated into one.


> BTW:  Is Java3d Y up or Z up?

To quote the spec (section 3.4);

By default, Java3D coordinate systems are right-handed, with the orienation 
semantics being that =Y is the local gravitational up, +X is horizontal to the 
right, and +Z is directly towards the viewer.  The default units are meters.

Doug Gehringer
Sun Microsystems

> Doug Gehringer wrote:
> 
> > > From: Justin <[EMAIL PROTECTED]>
> > > I want to:
> > >
> > >   1) translate to [20, 20, 20]
> > >   2) rotate on the x -45 degrees (I do convert this to radians)
> > >   3) rotate on the y 45 degrees (also converted to radians)
> > >
> > > I can't do this with your Transform3D class because it resets the
> > > values, so previous steps don't carry over to the next step.  I don't
> > > understand enough about matrices to apply the steps to a matrix.
> >
> > You need to multiply the matrices into a result. Try this:
> >
> >         Transform3D result = new Transform3D();
> >         Transform3D temp = new Transform3D();
> >         result.setTranslation(new Vector3d(20, 20, 20)); // set translation
> >         temp.set(new AxisAngle4d(1.0, 0.0, 0.0, toRadians(-45)));
> >         result.mul(temp); // post-concatinate rotation
> >         temp.set(new AxisAngle4d(0.0, 1.0, 0.0, toRadians(45)));
> >         result.mul(temp);
> >
> >         transformGroup.setTransform(result);
> >
> >

=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/

Reply via email to