Jump to content
  • Advertisement
Sign in to follow this  
phil67rpg

resetting rotational axis

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

well I am working on an asteroids game, well I am able to rotate my space ship to the left but I want to reset my rotational axis when I move a second space ship. here is my code I am working on.
[font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][color="#000000"] RenderSceneLeft()[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]{[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glMatrixMode(GL_MODELVIEW);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glRotatef(1.0f,0.0f,0.0f,1.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glPushMatrix();[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glColor3f(0.0f,1.0f,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glBegin(GL_LINE_LOOP);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(0.0f,-0.25f,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(-0.25f,-0.5f,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(-0.5f,-0.5f,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(0.0f,0.5f,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(0.5f,-0.5f,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(0.25f,-0.5f,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glVertex3f(0.0f,-0.25f,0.0f);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glEnd();[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glPopMatrix();[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]glutSwapBuffers();[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]}[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]I think my answer is how I am using the push and pop matrix functions.[/font][/font]

Share this post


Link to post
Share on other sites
Advertisement
Push the matrix before you rotate (glRotatef modifies the current matrix), then pop it to restore it to the state it was in when you pushed it.

(Its a stack, so a push copies the current matrix and puts the copy at the top of the stack, a pop removes the top matrix from the stack and makes it the currently active one).

(You could also use glLoadIdentiy to reset the matrix completely)

Share this post


Link to post
Share on other sites
rotate the first ship then use [color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

glLoadIdentity() then rotate the second ship.

[/font]

[font="helvetica, arial, verdana, tahoma, sans-serif"][size="2"][color="#282828"]make sure you apply any translation after you rotate it[/font]

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.

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!