PDA

View Full Version : Asteroids with OpenGL, matrix problem



07-06-2003, 10:21 AM
I'm running across an interesting problem in an Asteroids clone I'm working on. When I move my Ship by applying thrust, it moves as it should in the direction I'm pointed. However, when I rotate without applying thrust it behaves as if I do have thrust. In other words, I can make the ship move in a circle by applying thrust once and continually rotating.

I believe this has to do with the fact that in OpenGL the rotation and transformation matrices are cumulative. How do I separate these behaviors so that I could thrust in one direction and rotate without thrust and still go in the same direction, in other words without modifying the coordinate system UNLESS thrust is being applied?

chowe6685
07-06-2003, 12:02 PM
sounds to me like you are going about it the wrong way. Instead of using a series of transfomation calls to move the ship, simply store its position and angle, then call glTranslatef and glRotatef once each per frame. This means you will need to do out the thrust mechanics yourself with sin and cos, but thats not a big deal. I hope I interpreted your post correctly

07-06-2003, 12:20 PM
Interesting... Are you saying I should store X and Y on the ship, call glLoadIdentity to reset the coordinate system and then move it to X, Y (which is getting updated by me, not by modifying the coordinate system) performing the calculations myself?

Sounds like it's what I'm going to have to do...

Thanks