Ogre/Mogre: Camera two point perspective

隐身守侯 提交于 2019-12-01 07:22:17

问题


I'm displaying a scene with some cubes in it. The camera uses persective. Everything works great, but I'd like the vertical lines to be parallel (two point perspective: http://en.wikipedia.org/wiki/Perspective_(graphical)#Two-point_perspective).

When viewing a cube from the front:

What I want:

+-----+
|     |
|     |
+-----+

What I'm getting (exaggerated):

+--------+
 \      /
  \    /
   +--+

I've tried fiddling with the camera's FOV, but to no avail.

My attempt so far:

Camera = SceneManager.CreateCamera(CameraName);
float q = 45;
float d = 5000f;
Matrix4 m = new Matrix4(
    1, 0, 0, (float)(Math.Sin(q)/d),
    0, 1, 0, 0,
    0, 0, 1, (float)(Math.Cos(q)/d),
    0, 0, 0, 0
    );
Camera.SetCustomProjectionMatrix(true, m);

回答1:


The University of Berkeley has a page on the different perspective transformations and the matrices you need to use. The two-point perspective transformation is:

  _                    _
 |  1   0   0 sin(q)/d  |
 |  0   1   0     0     |
 |  0   0   1 cos(q)/d  |
 |_ 0   0   0     0    _|

Where q is the angle used to rotate the points (rather than the axes) and d is unexplained(!) but I think it's the distance of the camera from the focal plane.

Source



来源:https://stackoverflow.com/questions/10869603/ogre-mogre-camera-two-point-perspective

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!