#147889 - iainprice - Sat Dec 29, 2007 11:10 pm
I am making a 3d drive around game but am having problems with nice rotations.......
main loop:
[code]
while(1)
{
scanKeys();
u16 keys = keysHeld();
if((keys & KEY_UP)) rotateX += 3;
if((keys & KEY_DOWN)) rotateX -= 3;
if((keys & KEY_LEFT)) rotateZ -= 3;
if((keys & KEY_RIGHT)) rotateZ += 3;
if((keys & KEY_A)) thrustspeed -= 0.01f;
if((keys & KEY_B)) thrustspeed += 0.01f;
//first - player
glPushMatrix();
glMatrixMode(GL_MODELVIEW);
RenderMD2Model(frame,0);
glPopMatrix(1);
//second, third and track
glPushMatrix();
glRotateY(rotateX);
glRotateZ(rotateZ);
glTranslatef(thrustspeed,0.0,0.0);
glMatrixMode(GL_MODELVIEW);
RenderMD2Model(frame,1);
RenderMD2Model(frame,2);
RenderTrack();
glPopMatrix(1);
glFlush(0);
}
[/code]
with the current order of things.... it draws the player, then rotates the track and other players so it appears that the player is rotating. If you move forwards it only goes along the axis, not the direction of the rotated matrix........
I know I could keep the track and players stationary and move the main player and camera but I thought that would be more maths intensive....
any ideas, comments.. suggestions?
cheers.
main loop:
[code]
while(1)
{
scanKeys();
u16 keys = keysHeld();
if((keys & KEY_UP)) rotateX += 3;
if((keys & KEY_DOWN)) rotateX -= 3;
if((keys & KEY_LEFT)) rotateZ -= 3;
if((keys & KEY_RIGHT)) rotateZ += 3;
if((keys & KEY_A)) thrustspeed -= 0.01f;
if((keys & KEY_B)) thrustspeed += 0.01f;
//first - player
glPushMatrix();
glMatrixMode(GL_MODELVIEW);
RenderMD2Model(frame,0);
glPopMatrix(1);
//second, third and track
glPushMatrix();
glRotateY(rotateX);
glRotateZ(rotateZ);
glTranslatef(thrustspeed,0.0,0.0);
glMatrixMode(GL_MODELVIEW);
RenderMD2Model(frame,1);
RenderMD2Model(frame,2);
RenderTrack();
glPopMatrix(1);
glFlush(0);
}
[/code]
with the current order of things.... it draws the player, then rotates the track and other players so it appears that the player is rotating. If you move forwards it only goes along the axis, not the direction of the rotated matrix........
I know I could keep the track and players stationary and move the main player and camera but I thought that would be more maths intensive....
any ideas, comments.. suggestions?
cheers.