OpenGL Quaternion problem: wrong rotation

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

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 on other sites
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 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

1. 1
2. 2
3. 3
Rutin
20
4. 4
khawk
14
5. 5

• 9
• 11
• 11
• 23
• 12
• Forum Statistics

• Total Topics
633655
• Total Posts
3013186
×

Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!