食人魔/魔女:相机两点视角 [英] Ogre/Mogre: Camera two point perspective

查看:114
本文介绍了食人魔/魔女:相机两点视角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在显示一个场景,其中包含一些立方体。相机使用逼迫感。一切都很好,但我希望垂直线平行(两点视角:


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);

解决方案

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

这篇关于食人魔/魔女:相机两点视角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆