Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Ortho mode rotation

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

I am writing a side scrolling space game and I was using ortho mode. My problem is that when I try to rotate my spaceship on the z axis it jumps to the upper left corner of the screen and makes orbits around it. I would like to know the proper way to get the ship to stay in the center of the screen and rotate on its own axis. I have tried to do this so far: 1. Push the matrix 2. LoadIdentity 3. Translate is to where I "think" I need it 4. Rotate on z axis 4. Draw quad 5. Pop the Matrix Sorry for not having the code. Its on my other computer, hope this will do for the time being. Thanks in advance guys.

Share this post

Link to post
Share on other sites
It didn''t work... but thanks for the help. Could you tell me some of the causes of having an object orbit around the origin instead of its own axis? This way I''ll be able to look for the cause in my code.

Share this post

Link to post
Share on other sites
I found the problem guys! I was translating to the screens origin then tranlating to draw my quad which moved it a set distnace for the origin,then I was rotating which makes everything spin on that origin. Since the quad was moved out from that spot it made it orbit it instead of spin. Hope that made sense? It kinda confusing now that I looks at it lol. Oh well, thanks again.

Share this post

Link to post
Share on other sites
Its kinda hard at the moment considering my codes a bit of a mess but here ya go. This is the bit that should help.

glTexCoord2f(0.0f, 0.0f); glVertex3f(-40.0f, 25.0f, -1.0f); // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f( 40.0f, 25.0f,-1.0f); // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f( 40.0f, -25.0f , -1.0f); // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f(-40.0f, -25.0f, -1.0f); // Top Left Of The Texture and Quad

when you call glRotated or f depending on what you want, it rotates the shape around the origin. After I called glLoadIdentity(); it made the origin the top left of the screen. By translating after I reset the screen I moved the quad off the origin so looked like it was orbiting instead of spinning.

To solve it I translated the origin then rotated over that new location. Notice that the quad straddles the translated origin. Hope this all helps... I know how annoying the problem is.

If you haven't noticed I use strange variables when I first try to get something to work.... "moo" lol.

[edited by - PlutoWarrior on July 26, 2003 4:36:21 PM]

Share this post

Link to post
Share on other sites

  • 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!