math, math, math

Started by
5 comments, last by The Kid 23 years, 3 months ago
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.
I don''t know what the future holds, but I know who holds the future.
Advertisement
Are you using a matrix for rotations/translations, or gl calls? Do you have 4DOF or 6 or ??

Have you tried translating before rotating? That is, modifying the z coordinates before you rotate the world around the ship?

/riley
--Riley
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.
I don''t know what the future holds, but I know who holds the future.
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

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 ???
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]
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.

This topic is closed to new replies.

Advertisement