Like Jeff Lander said, I keep track of 2D Euler angles. I use heading
and pitch (I keep roll to 0), and update the transform with these
angles. Here is my function to set up a transform given the heading,
pitch (ud_angle), position, and scale.
-Lee
J. Lee Dixon
Software Engineer
SAIC - Celebration, FL
[EMAIL PROTECTED]
static
public void setupTransform(double heading, double ud_angle, Vector3d
pos,
double scale, Transform3D xform)
{
Quat4d rotQuat = new Quat4d();
Quat4d lrQuat = new Quat4d();
Quat4d udQuat = new Quat4d();
// Generate the independent rotation quaternions.
genRotQuat(ud_angle, 0, udQuat);
genRotQuat(heading, 2, lrQuat);
// Multiply to get the total rotation quaternion.
rotQuat.mul(lrQuat, udQuat);
xform.set(rotQuat, pos, scale);
}
static
private void genRotQuat(double av, int axis, Quat4d q)
{
double b;
q.x = q.y = q.z = 0.0;
q.w = Math.cos(av * 0.5);
b = 1.0 - q.w*q.w;
if (b > 0.0)
b = Math.sqrt(b);
else
return;
if (av < 0.0)
b = -b;
if (axis == 0)
q.x = b;
else if (axis == 1)
q.y = b;
else
q.z = b;
}
-----Original Message-----
From: Pondrom, Pierre L [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 28, 2000 8:40 AM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] MouseNavigatorApp flaw
Now that you mention it, I believe my program acts the same way.
I think the way to fix it would be to extend the KeyNav behavior so
that it uses two angles instead of what ever its doing now. X to yaw
the object and Y to pitch it. It seems that X,Y combinations are
causing a roll angle. What do you think?
> ----------
> From: Kristyn Fayette[SMTP:[EMAIL PROTECTED]]
> Reply To: Discussion list for Java 3D API
> Sent: Tuesday, June 27, 2000 4:33 PM
> To: [EMAIL PROTECTED]
> Subject: [JAVA3D] MouseNavigatorApp flaw
>
> <<File: MouseNavigatorApp.java>>
> This example comes from the Java3D Tutorial. It has a flaw in it that
I
> ran into when I was learning about Quaternions under OpenGL. When
holding
> down the left mouse button, one should be able to move the
camera/platform
> around as if they are looking in different directions -- what's
commonly
> known as "mouse-look" in games. If you do this a little, you may not
> immediately see the problem. However, if you hold down the left mouse
> button and move the mouse in a circular motion (clockwise, for
example)
> and then try to re-center your view, you'll see that you're now
tilted.
> The only way to re-center is to 'unwind' your view by moving the mouse
in
> the opposite direction.
>
> When I had this problem, it was because I was using a quaternion for
my
> rotation. I wrote to Jeff Lander (a frequent writer in Game
Developer's
> Magazine), his advice to me was to use a 2D Euler rotation rather that
> quats. At about that time, I changed jobs, languages (C++ to Java) and
> didn't touch any 3D code for a year, so I never got to fixing my app.
>
> As I pointed out earlier, I'm a complete Java3D newbie. Does anyone
know
> how to fix this example?
>
>
========================================================================
===
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".