0

I'm having trouble going from the explanation of gluPerspective found here: http://unspecified.wordpress.com/2012/06/21/calculating-the-gluperspective-matrix-and-other-opengl-matrix-maths/ to the actual input parameters needed for the function.

I have a cube that I'm displaying stuff in. The coordinates of the cube range from -10 to 10 in every direction.

Can someone give me an example of the gluPerspective() call needed to display that region? I've tried gluPerspective(26,w/h,10,30) thinking that the angle of 26 degrees is in the angle from the focal point (10 units from the box) to the middle of the box's top side, which means I have 10 units to the close edge and 30 to the far. However when I change from glOrtho(-10.0f, 10.0f, -10.0f, 10.0f, -10.0f, 10.0f); to gluPerspective(...) nothing is displayed on the screen.

4

1 回答 1

0

您可能会错过将模型放入视锥的翻译,并且您的裁剪参数可能会更好一些。当您使用 glPerspective 时,相机从原点开始,因此您的相机位于您正在绘制的立方体内部。您可能无法分辨,因为 z=-10 处的面被剪掉了;将您的近剪裁平面更改为 5 或 1 或其他内容,您应该会看到它。

默认情况下,相机向下看负 Z 轴,因此您应该将模型平移 (0, 0, -20) 左右。near=5 和 far=40 的裁剪参数应该让它可见;确保 near 至少大于 0。

希望这可以帮助!

于 2013-09-06T01:32:34.307 回答