3D Math
I have objects in my 3d scene(ships) that I want to turn towards eachother, Im not sure how to do this. I use matrixes for my rotations. What I need is to have a vector interpolating its rotation so its faces a given point in 3d space. Help is much appriciated :)
Stefan
Quote:Original post by VeslefrikkThere are a number of ways to do this, ranging from potential functions to simple vector math.
I have objects in my 3d scene(ships) that I want to turn towards eachother, Im not sure how to do this. I use matrixes for my rotations. Help is much appriciated :)
Stefan
A few questions:
1. How is the motion of your ships handled? Is it more or less 'ad hoc', or are you using a physics engine of some sort?
2. How are your object orientations represented? You mentioned matrices, but are the rotation operations applied directly to the rotation matrix? Or is there an intermediate representation, such as Euler angles?
3. Is the motion of the ships 'free' (6DOF), or is it constrained in some way?
Motions of the ships are very basic atm, I will write some simple physics later on.
I do my rotation by adding the new rotation to a stored matrix and then keep that matrix orthoganised.
And there is no constrains on the ships whatsoever in terms of movement or rotation.
Thanks for quick response.
Stefan
I do my rotation by adding the new rotation to a stored matrix and then keep that matrix orthoganised.
And there is no constrains on the ships whatsoever in terms of movement or rotation.
Thanks for quick response.
Stefan
Quote:Original post by VeslefrikkHere is one way you could proceed (this is the simplest method I can think of at the moment):
Motions of the ships are very basic atm, I will write some simple physics later on.
I do my rotation by adding the new rotation to a stored matrix and then keep that matrix orthoganised.
And there is no constrains on the ships whatsoever in terms of movement or rotation.
1. Transform the target position into the local space of the ship (by multiplying the target position with the ship's inverse model matrix).
2. Check the components of the transformed point corresponding to the ship's local-space side and up vector to see if the target is to the left or right, and whether it is 'up' or 'down'.
3. Apply local pitch and yaw as appropriate.
This may need fine tuning, but the basic idea should be sound.
Let me know if you have any questions.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement