Archived

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

PlutoWarrior

Ortho mode rotation

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
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.


glLoadIdentity();
glPushMatrix();
glTranslatef(200.0f,250.0f,-1.0f);
glRotated(moo,0,0,1);
glBegin(GL_QUADS);
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
glEnd();
glPopMatrix();


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