Jump to content
  • Advertisement
Sign in to follow this  
Sweeney

Rotation in space

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

Hi everyone! This is probably to be considered a newbee question. I've done a lot of work on a 3d RPG now but one thing eludes me: There is a space sim part to the game and I want it to be so that instead of moving the camera in space, I want to move everything else (planets, ships, etc). This is so that there can be a ship interior model in the middle with windows and stuff and instead of moving everything in the ship (consoles, crew, camera, etc) I want to move the stuff outside. This is fine for simple forward motion, etc but when it comes to turning, the issue is more complex. When you turn the ship along a specific axis, then the planets and stuff should move along that axis in a circular orbit and this is the catch! I have not been able to find a good way of doing this. I've read articles and downloaded sample code but I still can't get it to work right. Does anyone have any suggestions? By the way, I'm coding in Visual Basic but I reckon I can understand examples in other languages too. It's the math that bothers me. Thanx for any advice.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Sweeney
Hi everyone!
This is probably to be considered a newbee question. I've done a lot of work on a 3d RPG now but one thing eludes me: There is a space sim part to the game and I want it to be so that instead of moving the camera in space, I want to move everything else (planets, ships, etc). This is so that there can be a ship interior model in the middle with windows and stuff and instead of moving everything in the ship (consoles, crew, camera, etc) I want to move the stuff outside. This is fine for simple forward motion, etc but when it comes to turning, the issue is more complex. When you turn the ship along a specific axis, then the planets and stuff should move along that axis in a circular orbit and this is the catch! I have not been able to find a good way of doing this. I've read articles and downloaded sample code but I still can't get it to work right. Does anyone have any suggestions? By the way, I'm coding in Visual Basic but I reckon I can understand examples in other languages too. It's the math that bothers me.
Thanx for any advice.


No no no. You don't want to do this. I assure you that it is far easier to move both the camera and the space ship.

If you still want to do this, then what you have to do is rather simple: let M be the transformation matrix and S the ship position in space. For every vertex V oustide the ship (I hope there isn't too many...), do:

Vresult = (M * (V - S)) + S
// or ((V - S) * M) + S, depending on your matrix type

To simplify, and to put it the right way:
1) translate the world to have the origin of the world == the position of the ship
2) apply your rotation
3) translate back the world

HTH,

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!