Jump to content
  • Advertisement
Sign in to follow this  

OpenGL, drawing a rotated object

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

I have a point (x,y,z) in space. The point can be anywhere in space. I need to draw an object (basic stretched cube), which starts out facing (1,0,0), to face that the x,y,z point in space using a rotation matrix. The object's roll should remain in a consistent position (ie. I can't have the cube flip around so that its top faces down after the rotation). What is the best way to do this? I tried using cross and dot products to find an axis rotation between the objects, and the angle, then rotate using that. But that brings up the problem that the cube spins in strange directions even though it faces the right way. I also tried finding out the angle on the XY plane and the XZ plane and then rotating across known axes once by each, but I think I have problems with my algorithm because it doesn't end up facing the point it needs to some of the time. I'm using OpenGL implemented in C++. Any ideas would be apreciated.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!