The entity is a convex hull representation of a model.
When I click left I want to rotate the entity to the left and when I click right rotate it right. (Around the Y axis.)
I have managed to rotate it by working out the rotation matrix and then just setting the OrientationMatrix as it:
Code: Select all
ConvexHull Body;
float totalRotation;
public void rotate(float angle) {
totalRotation += angle; //keeps track of total rotation of object so far
float cosRotate = (float)Math.Cos(angle);
float sinRotate = (float)Math.Sin(angle);
Matrix3X3 orientation = new Matrix3X3(cosRotate, 0f, sinRotate, 0f, 1f, 0f, -sinRotate, 0, cosRotate);
Body.OrientationMatrix = orientation;
}
I therefore, tried to use the Orientation matrix of the entity and add a rotation to that but I just can't get it to work.
How would you therefore go about rotating an entity so that you always know the orientation of the entity and can then rotate that when arrows are pressed?