Sign in to follow this  

Yaw, pitch and Friggin roll

This topic is 4108 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all I am trying to implement a mouse behavior in java3d that is similar to plain looking around: Yaw, and pitch. Pitch works perfectly, but unfortunately the yaw is a different story. I cannot seem to adjust the yaw without getting some roll adjustment as well... I think the yaw gets applied relative to the pitch (i.e. relative to the views y-axis, not the scenes y-axis) I've tried pretty much everything mentioned in posts about this, but that dang roll keeps popping up... this is what I currently have (note the roll adjustment that makes it _almost_ right): private void adjust(float pitchIncrement, float yawIncrement){ tempRotTransform.setEuler(new Vector3d(pitchIncrement, yawIncrement, 0.5*yawIncrement)); viewTransform.mul(tempRotTransform); viewTransformGroup.setTransform(viewTransform); } Thanks in advance!

Share this post


Link to post
Share on other sites
Quote:
Original post by the_skp
Hi all

I am trying to implement a mouse behavior in java3d that is similar to plain looking around:
Yaw, and pitch.

Pitch works perfectly, but unfortunately the yaw is a different story. I cannot seem to adjust the yaw without getting some roll adjustment as well...

I think the yaw gets applied relative to the pitch (i.e. relative to the views y-axis, not the scenes y-axis)

I've tried pretty much everything mentioned in posts about this, but that dang roll keeps popping up... this is what I currently have (note the roll adjustment that makes it _almost_ right):

private void adjust(float pitchIncrement, float yawIncrement){
tempRotTransform.setEuler(new Vector3d(pitchIncrement, yawIncrement, 0.5*yawIncrement));
viewTransform.mul(tempRotTransform);
viewTransformGroup.setTransform(viewTransform);
}


Thanks in advance!
Your thread title made me laugh - that's how a lot of people end up feeling when working with Euler angles :-)

Anyway, it looks like you have the opposite problem of what most people have: you're using incremental rotations whereas you actually want a from-scratch rotation built from an Euler angle sequence.

Another thing I notice is that in setEuler() you seem to be submitting yaw/2 as the roll argument. What's that for?

Ultimately I think you'll want something like this:
viewTransform.setEuler(new Vector3d(pitch, yaw, 0));
viewTransformGroup.setTransform(viewTransform);
Where pitch and yaw are persistent from frame to frame and are updated in response to user input. Assuming correct Euler concatenation order, this will give you pure 'mouse look' motion with no unwanted roll.

Share this post


Link to post
Share on other sites
Thanks for the reply!

I was hoping to get away from having to persist the pitch and yaw, as the user might switch between viewing modes...

Maybe come up with a way to get the euler rotation from the transformation matrix on initialisation...

Share this post


Link to post
Share on other sites

This topic is 4108 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this