Jump to content
  • Advertisement
Sign in to follow this  
almondega

OpenGL Quaternion problem: wrong rotation

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

this is for a college project i want to shoot a bullet from my looking at camera like a FPS game the bullet comes from the camera and move foward toward the camera orientation so, i do this to orientate the object: Get the camera orientation Convert to a matrix 4x4 Apply this matrix to the opengl matrix "glMultMatrixf" but, this is the result: http://nov20.imgshare.us/fai.png disired result: http://nov20.imgshare.us/fxZ.png sbdy know whats wrong =/ ? piece of code: glPushMatrix(); glMultMatrixf((float*)direction.toMatrix4().mtx); glTranslatef(position.x,position.y,position.z); gluSphere(quad,radius,slices,stacks); glPopMatrix(); direction: Quaternion class toMatrix4: Matrix4 class mtx: float[4][4]

Share this post


Link to post
Share on other sites
Advertisement
I don't know if this is related to your problem, but you should know that there are some potential problems with storing matrices using float[4][4]. float[16] is the preferred method. See here for more info (under "General-Purpose Transformation Commands").

Share this post


Link to post
Share on other sites
i created a function to tranform the float[4][4] to a float[16]
the problem still continue...

=/

here is the pseudo code of the draw with orientation

push matrix
glMultMatrixf by the camera orientation quaternion -> matrix[4][4] -> float[16] representation
translate the object few Z-axis foward the camera (to see the object in front of the camera)
draw the object
pop matrix

this should do the object to follow the camera no matter the camera orientation right?
like a 2D image in the viewport

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!