How would I go about simulating a planes movement in DirectX 9 using transforms (i.e. matrices).
For example flying around an open space. When it moves it faces the direction it is going and stimulates flight semi-realistically.
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.Sign up to join this community
When using a R/H Cartesian coordinate system with the Y axis as vertical and row major matrix transforms (common for DX9), and you set your model in your world such that when rendered using an Identity matrix, the nose of the aircraft will be pointing down the -Z axis:
then the negate of the third row of the transform matrix can be used as a direction vector which when multiplied by a speed variable can be used as a velocity vector.
So as you rotate your matrix as the aircraft is turning, that 3rd row will always be reset to the new direction the tail of the aircraft is pointing (which is the negate of the direction the nose is pointing).
//rotate matrix using DX math to simulate turning Vector3 direction = new Vector3(matrix.m31, matrix.m32, matrix.m33);//or however the data is presentable Vector3 velocity = -direction * speedPerSecond * timeSinceLastFrame; // translate matrix by velocity using DX math
This does not account for aerodynamic affect on the aircraft but will give a semi-realistic approximation of flight.