Sign in to follow this  
johnnyBravo

How to do space physics with 3d spaceship spinning?

Recommended Posts

johnnyBravo    100
Hi, I've got my spaceship in 3d. When the user presses left I yaw left on my ship. But what I also want to do is when they press left and take their finger off, the ship keeps spinning, ie space physics. I am rotating the ship by rotating its vertices around the ship's yAxis. ie rotating points around a line. So any ideas on how to keep the ship spinning? Thanks

Share this post


Link to post
Share on other sites
Ra    1062
You could use the left and right keys to modify a yaw variable which contains the rate and direction of rotation; you'd then rotate the ship each frame based on that variable.

Share this post


Link to post
Share on other sites
johnnyBravo    100
But just say the ship's x,y,z axis are lined up with the world's axises.
And the ship is spinning on the yAxis(of the world and its own axises).

And then I decide to pitch the ship 30 degrees from what it was.

From what you are saying to do, the ship would now spin on a pitched angle of 30degrees(because of the yaw spinning), instead of just around the yAxis of the World like it was before pitching 30 degrees.

So basically I don't believe that would be proper space physics.
Correct me if I'm wrong.

Thanks

Share this post


Link to post
Share on other sites
Ra    1062
It won't do that if you have variables for pitch, roll, and yaw and rotate the ship by them each time.

Share this post


Link to post
Share on other sites
johnnyBravo    100
I see, I sorta got that implemented, but it doesn't look right. Ill post screenshots later when I get home.

I thought maybe somehow I could have a direction vector + a speed variable to determine which way the ship is spinning, and how fast it is spinning.

Would that work? Right now I'm finding it hard to imagine how the ship is supposed to move/react with rotations.

Thanks

Share this post


Link to post
Share on other sites
QRebound    196
well, im not maths expert (14, in algebra 1, but im teaching myself ^^) and i have a XRotV, XRot, YRotV, YRot, and ZRotV, ZRot, and every frame i add:
XRot += XRotV;
YRot += YRotV;
ZRot += ZRotV;

and i set the translation matrix to (XRot, YRot, ZRot) render, then move the the next object, set it to that objects (XRot, YRot, ZRot), etc.

and then i modify the *RotV variables on key presses, (with fancy sin/cos functions and stuffs :-D) and if i have friction, i multiply it by a friction fraction :-D anyway, i hope that helps

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this