【发布时间】:2015-09-14 23:23:32
【问题描述】:
我尝试为粒子圆盘的全视图设置一个合适的距离,同时具有一个有效的线比例,它表示作为鼠标缩放功能的圆盘比例的当前值。
场景有以下参数:
w_width = 600;
w_height = 600;
g_nearPlane = 0.1f;
g_farPlane = 1000.0f;
我使用以下代码示例对 3D 场景进行图形初始化:
// Reset line scale value
lineScaleValue = 100.0f;
// Initialize View
glViewport(0, 0, w_width, w_height);
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
// Perspective with angle set to 45 degrees
gluPerspective(45.0f, (float) w_width / w_height, g_nearPlane, g_farPlane);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrixi
gluLookAt (0.0, 0.0, 3, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glScalef(0.03f, 0.03f, 0.03f);
gluLookAt 和 glScalef 的上述值是近似选择的,即手动选择,没有精确计算。
我只想查看磁盘的完整视图(白色颗粒)。
为此,我知道磁盘 (x,y) 平面中的最大值和最小值:
-25 < x <25 和 -22 < y < 22。
从这个帖子set z good distance,我可以做到(Fov/2 = 45 度):
z_distance = 25*tan(pi/4) + dist = 50
dist = 25 位于磁盘前面。
所以我可以直接在我的示例代码中做(而不是
gluLookAt (0.0, 0.0, 3, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glScalef(0.03f, 0.03f, 0.03f);
) :
gluLookAt (0.0, 0.0, 50, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
?
谢谢
【问题讨论】:
-
磁盘的确切尺寸是多少,您在哪个世界空间位置绘制它?
-
磁盘的确切尺寸是 -25