You guys remember when I had the laser problems with XSpace?
Well I was reading Game Coding Complete, 2nd ed., and came across two things that stuck in my mind.
1. I was not using 4x4 matrices to represent rotation and
translation. I've written software 3D systems and they all used 4x4 matrices so I dunno why I was using D3DXVec3TransformCoord().
2. I was using D3DXMatrixLookAtLH() which does not work for straight up and straight down.
Also given I've had more experience now with vectors I believe this might work as well.
To fire a laser in the direction the ship is travelling, take the cross product of the up vector and the right vector. This will create a vector perpendicular to those two vectors, which form a plane in themselves. My question is, which direction will the cross product vector point?
Also I'm totally scrapping Euler angles. I've had enough of them and I'm moving to quaternions. I don't fully understand how they work but most of the math is already done anyways. It will make rotating guns to face targets, ships to face other ships, etc, etc...much much easier.
What's the difference between these two?
Code:D3DXMATRIX matResult,mat1,mat2; matResult=mat1*mat2;Code:D3DXMATRIX matResult,mat1,mat2; D3DXMatrixMultiply(&matResult,&mat1,&mat2);