• Create Account

### #Actualmwkenna

Posted 21 December 2012 - 07:04 AM

Hi Aimee

I have taken what you said on board and looked into the correct ordering for matrix transformations, I fully understand the concept of Matrices and their application to coordinates but I think I am having trouble grasping how they should be correctly used for transformations.

I have modified the method to become:

public Matrix GetTransformation()
{
Matrix viewMatrix = Matrix.CreateTranslation(-_viewportWidth / 2, -_viewportHeight / 2, 0) * //translate to origin
Matrix.CreateRotationZ(Rotation) * //apply the rotation
Matrix.CreateScale(new Vector3(Zoom, Zoom, 1)) * //apply the scale
Matrix.CreateTranslation(new Vector3(-_pos.X, -_pos.Y, 0)) * //apply the positional movement
Matrix.CreateTranslation(_viewportWidth / 2, _viewportHeight / 2, 0); //translate back to the position
return viewMatrix;
} 

My next step is to make the rotation happen around the center of the viewport as opposed to the center of the world (0, 0)

Thanks, Mark.

### #1mwkenna

Posted 21 December 2012 - 06:59 AM

Hi Aimee I have taken what you said on board and looked into the correct ordering for matrix transformations, I fully understand the concept of Matrices and their application to coordinates but I think I am having trouble grasping how they should be correctly used for transformations. I have modified the method to become: public Matrix GetTransformation() { Matrix viewMatrix = Matrix.CreateTranslation(-_viewportWidth / 2, -_viewportHeight / 2, 0) * //translate to origin Matrix.CreateRotationZ(Rotation) * //apply the rotation Matrix.CreateScale(new Vector3(Zoom, Zoom, 1)) * //apply the scale Matrix.CreateTranslation(new Vector3(-_pos.X, -_pos.Y, 0)) * //apply the positional movement Matrix.CreateTranslation(_viewportWidth / 2, _viewportHeight / 2, 0); //translate back to the position return viewMatrix; } My next step is to make the rotation happen around the center of the viewport as opposed to the center of the world (0, 0) Thanks, Mark.

PARTNERS