Jump to content
  • Advertisement
Sign in to follow this  
qingrui

OpenGL What convention do you use for entity angle?

This topic is 3772 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

When I was using the old left-handed Direct3D before, there's no doubt that the angle of a entity is defined as Yaw (of yaw, pitch, and roll). Angle 0 is +Z (north) and it goes up clockwise. However, after switched to right-handed to be consistent with XNA, WPF, and OpenGL, there's no single popular choice. I saw Quake/WarCraft use positive X as angle 0. This is the same as in math and sin/cos. It really simplifies the computation but it feels so strange the model should be posed facing positive X by default. NeverWinterNights uses similar convention as the left-handed Direct3D way, with model facing +Y (north) as angle 0. How do you define your angles for entities?

Share this post


Link to post
Share on other sites
Advertisement
the only difference between left-handed and right-handed projections are that the Z-axis are signed/unsigned

LH +Z
RH -Z

Share this post


Link to post
Share on other sites
Well, I'm not concerned with the axes. I'm concerned with the angle.

[Edited by - qingrui on June 22, 2008 10:25:04 PM]

Share this post


Link to post
Share on other sites
left-handed has nothing to do with which axis that are the up axis.

I'm not sure what you mean by "defining angles for entities"

Share this post


Link to post
Share on other sites
I mean, when working with the old Direct3D, most people use the same rule for orientation models and cameras. So models are prepared to facing +Z, and that's the angle 0 in the game world, and by left-hand rule it rotates clockwise.

But for right-handed game engines, I found they use many different conventions. I'd like to follow the most commonly used convention but it seems there's no such one. Or I'm wrong?

The angle I'm talking about is the Yaw angle in horizontal plane. To avoid confusion, do you use north or east as 0 for Yaw, in right-handed world?

Share this post


Link to post
Share on other sites
there are none...

Maya uses Y for up axis
3D Studio Max uses Z for up axis
(might be other way around)

use which ever you like best.

you can just swap the Y and Z axis when you load a model if you want a character to stand up no matter which modeling software you use.

LoadModel( char* file, bool swapYZ = false );

It's actually the modeler that should export the model with the right up axis

Share this post


Link to post
Share on other sites
No, I don't have a problem with which axis is up. My problem is which direction should I use for angle 0 on horizontal plane.

Share this post


Link to post
Share on other sites
Quote:
Original post by qingrui
No, I don't have a problem with which axis is up. My problem is which direction should I use for angle 0 on horizontal plane.


umm.... 0 compared to what?

Share this post


Link to post
Share on other sites
Lol at all the answers =)

The direction of the zero angle can be anything you want, since it has no real meaning in the 3D world. If you design two models, one facing +X and one facing +Z by default, looking at the models will give different impressions of what direction is zero. Does one consider one model to simply have it's side facing zero, or rather that the models have different zero directions?
It's just a choice you can think of however you like.
Usually it will solve itself, just have your models made in the way that feels best for you. I usually make them so that they face +Z, which in the OpenGL and righthanded coordinate system is facing a camera with an identity matrix if the model is moved backwards. That way the camera looks straight into the front of the model which is what I usually think of as normal without rotations.
On the other hand that doesn't match the camera, which is facing -Z, or it would not see the front of the model. Perhaps it is better to have the models face the same way as the camera with the same rotation.
Pick the one you feel is better. It might be preferable to give all rotations the same meaning, keeping the same zero and positive/negative rotation directions for everything, the camera and models etc. For consistency.

Share this post


Link to post
Share on other sites
I think he means what angle = 0 degree rotation = default orientation of any model. All rotations of the model will be offsets of yaw, pitch, roll from the model's default state. The default facing of models is arbitrary but imho it's best to make them all the same.

Personally, I always use (0,0,-1) and edit all models before loading so that is their default orientation. Then yaw, pitch, roll calculations are done based on that assumption.

Is that what you are asking? =)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!