PDA

View Full Version : Convert a DirectX pitch, yaw, roll into an OpenGL rotation



halo
02-01-2004, 01:14 PM
How is this done? I know one uses one coord system and one uses the other, but how are these three numbers converted into the opposite system?

Thanks.

halo
02-01-2004, 02:31 PM
I am trying to use the projection matrix to do this, but it doesn't seem to do anything:


wglMakeCurrent_(hDC,hRC)
glclear_(#GL_COLOR_BUFFER_BIT|#GL_DEPTH_BUFFER_BIT )
glLoadIdentity_()

;Flip the third row of the matrix
glmatrixmode_(#GL_PROJECTION)
buffer=createbank(16*4)
glgetfloatv_(#GL_PROJECTION_MATRIX,buffer)
PokeFloat(buffer,2*4,-PeekFloat(buffer,2*4))
PokeFloat(buffer,6*4,-PeekFloat(buffer,6*4))
PokeFloat(buffer,10*4,-PeekFloat(buffer,10*4))
PokeFloat(buffer,14*4,-PeekFloat(buffer,14*4))
glloadmatrixf_(buffer)
freebank(buffer)

gluPerspective__(45.0,w/h,nearrange.f,farrange.f)

glPushMatrix_()

;Set up the camera
glRotatef_(EntityRoll_(camera),0.0,0.0,1.0)
glRotatef_(EntityPitch_(camera),1.0,0.0,0.0)
glRotatef_(EntityYaw_(camera),0.0,1.0,0.0)
glTranslatef_(-EntityX_(camera,0),-EntityY_(camera,0),EntityZ_(camera,0))

For n=1 To countentities()
...draw your meshes...

SirKnight
02-01-2004, 08:09 PM
glRotatef( pitch, 1.0f, 0.0f, 0.0f );
glRotatef( yaw, 0.0f, 1.0f, 0.0f );
glRotatef( roll, 0.0f, 0.0f, 1.0f );

You may have to compensate for OpenGL using the right handed system as D3D uses the left handed system. Also why are you trying to rotate an object by setting up the rotations in the projection matrix!?


-SirKnight

halo
02-01-2004, 10:47 PM
I was trying to flip something around or other. I wrote a Half-Life model viewer. The Rotations display fine in Blitz3D, but are all screwed up in OpenGL. The code should be pretty clear. Look at the render function in BlitzPlusVersion.bb: http://www.leadwerks.com/hl.zip