Quaternion problem: wrong rotation

Started by
1 comment, last by almondega 15 years, 4 months ago
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]
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").
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

This topic is closed to new replies.

Advertisement