The irrlicht function looks like this
Code: Select all
inline void matrix4::rotateVect( vector3df& vect ) const
{
vector3df tmp = vect;
vect.X = -(tmp.X*M[0] + tmp.Y*M[1] + tmp.Z*M[2]);
vect.Y = -(tmp.X*M[4] + tmp.Y*M[5] + tmp.Z*M[6]);
vect.Z = -(tmp.X*M[8] + tmp.Y*M[9] + tmp.Z*M[10]);
}
Code: Select all
//This function is modeled after Newton function in their tutorials
vector3df rotateVector(matrix4& mat, vector3df& vec)
{
return vector3df(vec.X*mat.M[0] + vec.Y*mat.M[4] +vec.Z*mat.M[8],
vec.X*mat.M[1] + vec.Y*mat.M[5] + vec.Z * mat.M[9],
vec.X*mat.M[2] + vec.Y*mat.M[6] + vec.Z * mat.M[10]);
}
My matirx math is not good, so it's possible I made a mistake somewhere and the irrlicht function is actually correct, but it diodn't work for me and my new one did.