Jump to content
  • Advertisement
Sign in to follow this  
cossie

calculating the direction an object is facing

This topic is 4063 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, Apologies if this is a really dumb question, but after calculating the normal to an object, say a cube, and then I want that cube to move, how to I find out what direction the cube is actually facing? I just can't figure it out over the last hour or so, I'm only getting to grips with 3D maths. thanks for any help Cossie

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by cossie
after calculating the normal to an object, say a cube, and then I want that cube to move, how to I find out what direction the cube is actually facing?

I don't follow. Normals aren't defined for meshes, only for planes (and hence polygons) and vertices. Could you provide a deeper explanation of the problem, maybe with an example?

Admiral

Share this post


Link to post
Share on other sites
Okay,

What I'm trying to do is work out which direction an object is facing, Right / Left / Towards the viewer / Away from the viewer.

I've drawn a cube (using 6 GL_QUADS), and calculated a normal (cross product of 2 vectors and then normalized) on the quad that what I want to be the "face" (like a person's face) of the cube.

So, then say, the cube is rotated or moved some random value, is there a way I can work out in what direction the cube's "face" is looking in? (which I guess would be what direction it's normal is pointing in?)

Share this post


Link to post
Share on other sites
Sure there is. You apply the rotational component of the transformation to the normal. The result is the new 'facing' vector.

At least that covers the 'orientation' case. If you actually have a viewer in your scene, then things get a little more complicated:
For instance, suppose the cube is three feet in front of me, facing me directly. Now translate it some distance laterally. It is still has the same orientation, but it is no longer 'facing me'. If this is your situation, then we'll need to know more. In particular, how are you representing the positions of the bodies and the transformation being applied to them.

Admiral

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!