Hello,

I wrote some code that allows the user to use the left and right arrow
keys to rotate around the axis at a radius equal to the minimum distance
from the camera to the axis.  It does this while looking at a fixed
point.

In mine, I just extended the new keyboard behavior off of the behavior
class.  Here's some sample code.  I hope it helps!

private void performHorizontalRotation()
{
    vp.getViewPlatformTransform().getTransform(transform3D);

    //compute normal vector wrt earth to rotate about
    Vector3d u = new Vector3d(rotationCenter.x/EARTH_MEAN_RADIUS,
                              rotationCenter.y/EARTH_MEAN_RADIUS,
                              rotationCenter.z/EARTH_MEAN_RADIUS);

    //get current view platform transform
    Vector3d translate = new Vector3d();
    transform3D.get(translate);

    //set eye location to translation component
    Point3d eye = new Point3d(translate.x, translate.y, translate.z);
    
    //rotate eye horizontally about normal vector wrt earth
    Point3d newEye =
CoordinateConversions.rotatePointAboutArbitraryAxis(u,    
                                                     eye,
rotationAngle);

    //reset view platform transform data
    transform3D.lookAt(newEye, rotationCenter, u);
    transform3D.invert();

    vp.getViewPlatformTransform().setTransform(transform3D);
}

best,
Brian


-----Original Message-----
From: Discussion list for Java 3D API
[mailto:[EMAIL PROTECTED] On Behalf Of JXrn Cornelius Olsen
Sent: Wednesday, December 03, 2003 4:34 PM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] Rotating view transform

Hi again.

Regarding my earlier message (below):
By now I've made several different attempts. Here's my latest:

  protected void update(float t, Transform3D transform)  /*This
transform
comes from universe.getViewingPlatform().getViewPlatformTransform
().getTransform(...) */
  {
    float angle=startAngle+t*deltaAngle;
    Matrix3f rotationMat=new Matrix3f();
    Quat4f rotationQuat=new Quat4f();
    Vector3f translationVec=new Vector3f();

    rotationMat.rotY(angle);
    rotationQuat.set(rotationMat);

    translationVec.set(radius*(float)Math.cos(angle), 0f,
radius*(float)Math.sin(angle));  //I rotate the position manually, just
to
seperate the actions
    translationVec.add(center);

    transform.set(rotationQuat, translationVec, 1f);
  }

This successfully rotates the view point around center, but I'd like the
direction to change also. How can I do this?

Regards
/Jørn

From: Jørn Cornelius Olsen <[EMAIL PROTECTED]>
I've made a behavior that extends ViewPlatformBehavior. It rotates the
view
about the y-axis. This works, yet the direction of view is not changed.
I
would have thought that if I rotate the view transform, the direction of
view (which direction I look in) would also be rotated, but apparently
not
so. Can anyone show me how to rotate the direction of view? I've tried
lookAt() but that one does not seem to work as I would expect.

Regards
/Jørn

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

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