gracia marco, ill try this but isnt this for setting a view transform
only?  i think i need a transformation/model transform..  maybe they are
the same?  im not sure obviously... but ill give it a try... ciao, wayne


Marco Lohse wrote:
>
> hello Wayne,
> I have not checked out your code yet, but maybe you should take a look
> at Transform3D.lookAt(..).
>
> Marco.
>
> "wayne c deprince jr." wrote:
> >
> > ciao all,
> >   just need some help with a simple problem..  i want to set the
> > direction (or orientation i guess) of an object (box, camera, whatever)
> > from a direction vector.. i thought i could get it done but i havent
> > been able to... i can do it if i know the angles already, but figuring
> > the angles im messing up somewhere..  ive attached the code im trying..
> > i know its not efficient but i just want to get it working.. thanks in
> > advance, wayne
> >
> >   /**
> >    * Updates the Tranform3D in the TransformGroup according to the
> >    * position, direction, normal.  The transform is updated in place.
> >    * !NOT IMPLEMENTED!
> >    *
> >    * @param t the Transform3D to update.
> >    * @param p The new position.
> >    * @param d The new direction.
> >    * @param n The new normal.
> >    */
> >   private void _updateTransform(Transform3D t, Point3d p, Vector3f d,
> >                                 Vector3f n)
> >     {
> >
> >       // First apply the position changes.
> >       t.setTranslation(new Vector3d((Tuple3d)p));
> >
> >       // Now set the direction which this should be pointing.
> >       // We will do the rotations here.
> >       // Normalize the direction first.
> >       //d.normalize();
> >       Vector3f x = new Vector3f(1.0f, 0.0f, 0.0f);
> >       Vector3f y = new Vector3f(0.0f, 1.0f, 0.0f);
> >       Vector3f z = new Vector3f(0.0f, 0.0f, 1.0f);
> >
> >       System.err.println("dir = " + d);
> >
> >       Matrix3d rot = new Matrix3d();
> >       rot.setIdentity();
> >
> >       Matrix3d x_rot = new Matrix3d();
> >       Vector3f temp = new Vector3f();
> >       x_rot.setIdentity();
> >       temp.set(0.0f, d.y, d.z);
> >       x_rot.rotX(z.angle(temp));
> >       System.err.println("x angle = " + z.angle(temp));
> >
> >       Matrix3d y_rot = new Matrix3d();
> >       y_rot.setIdentity();
> >       temp.set(d.x, 0.0f, d.z);
> >       y_rot.rotZ(x.angle(temp));
> >       System.err.println("y angle = " + x.angle(temp));
> >
> >       Matrix3d z_rot = new Matrix3d();
> >       z_rot.setIdentity();
> >       temp.set(d.x, d.y, 0.0f);
> >       z_rot.rotZ(y.angle(d));
> >       System.err.println("z angle = " + y.angle(temp));
> >
> >       rot.mul(x_rot);
> >       rot.mul(y_rot);
> >       rot.mul(z_rot);
> >       //rot.rotZ(1.57);
> >
> >       // Now set the rotation of this transform.
> >       t.setRotation(rot);
> >     }
>
> ===========================================================================
> 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".
begin:vcard
n:deprince jr.;wayne c.
tel;cell:215.630.5146
tel;home:610.997.0147
tel;work:610.758.4785
x-mozilla-html:TRUE
url:http://www.lehigh.edu/~wcd2
org:Lehigh University;Electrical Engineering and Computer Science
adr:;;328 Adams Street Apt. #204;Bethlehem;PA;18015;USA
version:2.1
email;internet:[EMAIL PROTECTED]
title:MS/Phd Student - T.A.
note;quoted-printable:Instant Messenger Name - mrgrimm55=0D=0A
end:vcard

Reply via email to