The server didnt send my first message so I sent this the next day. Looks like the server sent this out again. Anyway, thanks for the response I got on it about multiplying the tranform. But that is not all. It turns out that the rotation doesnt work properly when you do this.
Do get a correct rotation, instead of using the rotY, etc you setEuler(rotation). This does the Euler equations for you. These can be a real pain so it was nice when I found this. I know this has been a big topic and has confused many people. Well, here's the solution! How to move the view.
 
******************************************************************************
SimpleUniverse u = new SimpleUniverse(c);
u.getViewingPlatform().setNominalViewingTransform();
Transform3D t = new Transform3D();
viewTransformGroup.getTransform(t);
Vector3f viewDir = new Vector3f(0f, 0f, 0f);
Vector3f translation = new Vector3f();
Vector3d rotView = new Vector3d(0d, 0d, 0d);
newTrans.transform(viewDir);
// TRANSLATION
if (event.getKeyCode() == KeyEvent.VK_I) {
      viewDir.y += .5;
  } // continue for x, y and z + and -
// ROTATION
else if (event.getKeyCode() == KeyEvent.VK_D) {
            rotView.z = -.05d;
  } // continue for x, y and z + and -
// THIS IS WHAT CORRECTLY DOES THE ROTATION RELATIVE
// TO THE VIEW INSTEAD OF WORLD COORDINATES
newTrans.setEuler(rotView);
 
// This does the translation
translation.x += viewDir.x;
translation.y += viewDir.y;
translation.z += viewDir.z;
// This sets the new transform
newTrans.setTranslation(translation);
// This puts the new rotation or tranlation into the view's Transform3D
t.mul(newTrans);
viewTransformGroup.setTransform(t);
******************************************************************************
enjoy
 
-----Original Message-----
From: Michael Lee <[EMAIL PROTECTED]>
To: Java3D Group <[EMAIL PROTECTED]>
Date: Friday, December 18, 1998 12:20 PM
Subject: [java3d] Moving the view

I want to move the view. I get the transform group from the simple universe...
But when i translate or scale it, it does it in world coordinates. I only want to do it relatively from the camera or view.
If i rotate on the y axis, i want it on the y axis relative to the view, not the world. The code below is what I have but it translates/rotates on the world coordinates.
 
TransformGroup t = u.getViewingPlatform().getViewPlatformTransform()
Transform3D trans = new Transform3d();
t.getTransform(trans);
Vector3f viewDir = new Vector3f(0f, 0f, 0f);
Vector3f translation = new Vector3f();
trans.get(translation);
trans.transform(viewDir);
if (event.getKeyCode() == KeyEvent.VK_I) {
    viewDir.y += 1;
}
    etc....
else if (event.getKeyCode() == KeyEvent.VK_D) {
             rotation += -.1;
         trans.rotZ(rotation);
}
        etc....

translation.x += viewDir.x;
translation.y += viewDir.y;
translation.z += viewDir.z;
trans.setTranslation(translation);
t.setTransform(trans);
thanks,
mike

Reply via email to