Skip to main content
GameDev.net gamedev.net
🔒 Locked

Rotation Woes

Started by ethorteran Dec 21, 2001 at 10:54 AM 6 replies 550+ views
Original Post
ethorteran
ethorteran
I am attempting to write a 3D space flight sim engine, i have run into troubles however. When maneuvering at all, my rotation code can take rotation along two axes, but breaks down on three. I have tried every order of rotations, but none work. The way i am doing this is i have a blank matrix, which i load, apply the three rotations (which don''t work in any order), and save the matrix for loading in the next frame. So i have xRotSpeed and y and z versions of that (so keypresses accelerate and decelerate the rotation speed, as opposed to incrementing the speed directly). However, no order of rotation combines them all in a plausible fashion. Has anybody else done something like this before? Any help would be a godsend.... Erik
GalaxyQuest
GalaxyQuest
Your explanation is a lil confusing. Anyways, first thing I suggest is looking at some articles/tutorials on "camera movement" or a camera class someone has written.

I believe you rotate in this order: z, y, x.

You may be doing a whole slew of things wrong, i dont know. So, do some searching on gdnet on how camera''s operate and hopefully that will help you understand how to rotate your ship as well.
strtok
strtok
You probably shouldn''t be saving your rotation matrix for use in the next frame. Save your angle, and build the rotation matrix from scratch each frame. My guess is that you are rotating an already rotated matrix, and that is going to give you problems.
ethorteran
ethorteran
The problem with building it from scratch, is that the rotation has to work ON the last state. As you know, when a spaceship is in a random rotation, and you fire the thruster in the front, you turn relative to the spaceship''s X axis, not an adittion to the X rotation. Hence my conundrum, i need to build on old rotations, have the rotations keep going between frames. Bleh. Has anybody done something like this?

Erik
siaspete
siaspete
You shouldn''t really store the matrix and restore it next frame, you should create the matrix every frame. This stops cumulative errors (floats aren''t infinitely accurate). Also it''s easier, and you won''t notice a speed hit. An extra matrix calculation per frame is nothing.

Another thing to look into would be quaternions, as you WILL get problems using standard rotations. Do a web search on google for them and you''ll get loads of good stuff.
ethorteran
ethorteran
I''ll check it out. However, i still don''t think that even Quaternions will solve my problem.

Erik

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.