xna 中的斜投影
我试图实现倾斜投影( http://en.wikipedia.org/wiki/Oblique_projection )在xna框架中:
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;
正如你所看到的,我只是将正交投影与倾斜投影相乘。
我得到的是这样的:
http://imageshack.us/photo/my- images/835/oblique1.png/
它基本上就是正交投影的样子,但有一些奇怪的远剪裁。
如何实现正确的倾斜投影? 提前谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Diki 回答: http://forums.create.msdn.com /forums/p/85032/513412.aspx#513412
代码需要更改如下:
Answered by Diki: http://forums.create.msdn.com/forums/p/85032/513412.aspx#513412
Code needs to be changed like this:
对于初学者,您可以实施正确的公式。
维基百科文章说投影矩阵使用
0.5 * cos
和0.5 * sin
而您的版本仅使用cos
和sin
>。For starters, you can implement the proper formula.
The wikipedia article says the projection matrix uses
0.5 * cos
and0.5 * sin
while your version uses justcos
andsin
.