Im having some trouble rotating around a pivot point.
Would the process be to create the following Matrices and multiply them:
Offset1: Create a translation matrix based on pivot.Multiply(-1)
Offset2: Create a translation matrix based on pivot to move it back.
Create a rotate matrix by multiplying
(Offset1 * myrotation * Offset2) * existing rotation matrix
This sample code takes the original matrix, pivot point, and a vector change and creates a new matrix based on the above logic:
private Matrix GetRotateMatrix(Matrix inmat, Vector3 pivot, Vector3 change)
Matrix offset1 = Matrix.Identity;
Matrix offset2 = Matrix.Identity;
Matrix rot = Matrix.Identity;
// Setup offsets.
//Setup Rotation matrix.
rot.RotateYawPitchRoll(change.X, change.Y, change.Z);
Matrix final = Matrix.Identity;
It seems to work but I have problems with objects that don't have a pivot at the origin. ANy ideas?