0

I have been using the 3D perspective projection formula:

sx = wx*scale/wz
sy = wy*scale/wz

It projects things sort-of alright, but for example a cube looks more like a rectangular prism and is really stretched out.

It looks like this:

enter image description here

I have done research on it and looked at the other pages on it on stackoverflow, but I don't really understand why it is stretching it out.

I've also tried other alternatives like dividing the z-value by 2 or 4, or some arbitrary value to make it look more cube-ish but for more complex objects it doesn't really do the trick.

Any help is appreciated.

Thanks.

4

2 回答 2

2

Your projection looks like an extreme wide-angle view. It's a "correct" perspective projection - your formula is the right one, but the key is in the scale variable/constant.

The value for scale is generally

screen_width_in_pixels * focal_length

where focal_length is the ratio of the distance from the viewer's eyes from the screen, to the width of the screen. Of course you can't control how close someone sits in front of their monitor, so you guess. 1.0 - 1.5 is generally a good range.

When you change that value to something less wide-angle, a side-effect will be that the 'camera' will 'zoom in' on your object, and probably fill up the screen. So you will need to compensate by moving the object further away from the camera.

There is (of course) a nice long Wikipedia article on the subject.

于 2012-04-28T04:58:15.340 回答
0

尝试在 html5 的画布上渲染一个框时,我遇到了同样的“问题”。使拉伸框对我来说看起来“正常”的原因是将相机位置的z值设置相机公式为 -250 而不是我使用的 -50。然后,根据您用于计算 x,y 坐标的公式,您可以调整查看器的 z 位置 (ez)

查看器

或从记录表面到入射光瞳 (rz) 的距离以放大您的对象。

一个公式

我知道这个问题是半年前提出的,但由于我找不到任何对我有帮助的答案,我决定分享我自己的经验。希望它可以帮助某人。

于 2012-12-28T09:41:50.043 回答