Converting a 2D Affine Transformation Matrix to a 3D Affine Transformation Matrix

I have an error somewhere in my code, it was interesting if this is not true.

I have a 2D matrix in my code, but to display my world on the screen, I need to convert the 2D viewing matrix to three-dimensional. This is the process I'm using:

| abc | | abc 0 | | def | => | def 0 | | ghi | | ghi 0 | | 0 0 0 1 | 

This works when I use the identity matrix for a 2D matrix, but as soon as I apply any transformations to the 2D matrix, all of my objects that are drawn disappear.

For drawing in 2D using 3D, I use this projection matrix:

 _basicEffect.Projection = Matrix.CreateOrthographicOffCenter(0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height, 0, 0, 1); 

What is the correct way to convert a 2D matrix to 3D?

+6
c # matrix xna linear-algebra transformation
source share
1 answer

Affine transformations use an extra row / column of the transformation matrix to translate. So I think that you want to move the last row / column down / right, and then for the new axis just insert the identity transformation.

 | abc | | ab 0 c | | def | => | de 0 f | | ghi | | 0 0 1 0 | | gh 0 i | 

I'm not sure, but try at least.

+15
source share

All Articles