Oblique projection in xna
-
29-10-2019 - |
Question
Im trying to achieve oblique projection ( http://en.wikipedia.org/wiki/Oblique_projection ) in the xna framework:
float cos = (float)Math.Cos(DegreeToRadian(45)) * -1;
float sin = (float)Math.Sin(DegreeToRadian(45)) * -1;
Matrix obliqueProjection = new Matrix(
1, 0, cos, 0,
0, 1, sin, 0,
0, 0, 1, 0,
0, 0, 0, 1);
Matrix orthographicProjection = Matrix.CreateOrthographic(10, 10, -1, 100000);
projection = orthographicProjection*obliqueProjection;
As you can see im just multiplying orthographic with oblique projection.
What i get is this:
http://imageshack.us/photo/my-images/835/oblique1.png/
Its basically what orthographic projection would look like, but with some weird far clipping.
How can i achieve proper oblique projection? Thx in advance
Solution
Answered by Diki: http://forums.create.msdn.com/forums/p/85032/513412.aspx#513412
Code needs to be changed like this:
Matrix obliqueProjection = new Matrix(
1, 0, 0, 0,
0, 1, 0, 0,
cos, sin, 1, 0,
0, 0, 0, 1);
projection = obliqueProjection * orthographicProjection;
OTHER TIPS
For starters, you can implement the proper formula.
The wikipedia article says the projection matrix uses 0.5 * cos
and 0.5 * sin
while your version uses just cos
and sin
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow