Jump to content
  • Advertisement

Archived

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

The Kid

math, math, math

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

Okay peoples, here''s my problem, I hope you can help. I have a program that loades a ship from a model, and I can use the keys to rotate it. I use the keys to rotate the world around the model. But when it come to moving the world, thats where I get lost. When I press a key, I want the ship to have the illusion of moving forward, (actually moving the terrain backwards). But when the world rotates around the ship, I can''t just modify the z coordinates on the terrain, because it looks like the ship is sliding sideways. How could I make the terrain move in the right direction, so it looks like the ship is moving forward, instead of sideways. Thanks in advance. The Kid I don''''t know what the future holds, but I know who holds the future.

Share this post


Link to post
Share on other sites
Advertisement
Have you tried translating before rotating? That is, modifying the z coordinates before you rotate the world around the ship?

/riley

Share this post


Link to post
Share on other sites
Elixer - I''m only using 4DOF, and I''m using glCalls. Matrix transformations are a little difficult for me now. But I''m learning.

rileyriley - whether I modify the z axis before or after I rotate the world, it still isn''t going to change the ships location on the x axis correctly. Thats what I''m having problems with. Thanks anyway, though.

The Kid


I don''''t know what the future holds, but I know who holds the future.

Share this post


Link to post
Share on other sites
It''s just some simple trig to make your ship move in the direction it is facing:

shipZ = shipZ + (movementDistance * cos(shipHeadingAngle))
shipX = shipX + (movementDistance * sin(shipHeadingAngle))

Similarly, to move backward, turn the + signs into - signs.
Strafing is a little more involved, but I''m sure you can work it out if you need it later...

NOTE: You may have to tinker with the sign of the Z value you get from this (depending on what handed coord system you are working in for your world coords).
Also, this is locked in the XZ plane... you can modify/add to it to include movement in the Y direction as well (invloves using the pitch angle of the ship as well).

Hope that helps a bit

Share this post


Link to post
Share on other sites
Not to sound like an idiot (but I probably will anyway!)
I only know of 3 degrees of freedom ,Yaw, Pitch and Roll.
What would the others be in eather 4 or 6DOF ???

Share this post


Link to post
Share on other sites
quote:
Original post by avianRR

Not to sound like an idiot (but I probably will anyway!)
I only know of 3 degrees of freedom ,Yaw, Pitch and Roll.
What would the others be in eather 4 or 6DOF ???


6DOF = Movement on X, Y, Z & Rotation on X, Y, Z.
4DOF would probably be the same minus one axis.

Share this post


Link to post
Share on other sites

  • 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!