Download presentation
Presentation is loading. Please wait.
1
Chapter 10 Three-Dimensional Viewing (三维观察)
OpenGL 三维观察函数 2018/11/23 交通运输学院CAD/CAM研究所
2
10.10 OpenGL三维观察函数 使用glMatrixMode(GL_MODELVIEW)和glMatrixMode(GL_PROJECTION)分别设定建模观察模式和投影模式 默认的OpenGL观察设置是: 观察参考点P0(0,0,0) 观察方向由P0(0,0,0)指向Pref(0,0,-1),N=(0,0,1) 观察向上向量V=(0,1,0) OpenGL默认的投影设置是: glOrtho(-1, 1, -1, 1, -1, 1); 即对称规范化观察体,正投影。 OpenGL中观察平面永远是近裁剪平面。 2018/11/23 交通运输学院CAD/CAM研究所
3
xv zv yv 1 近裁剪平面 远裁剪平面 裁剪窗口 2018/11/23 交通运输学院CAD/CAM研究所
4
7.10.1 OpenGL三维观察函数 视点变换(观察参数设定)
void gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz); 2018/11/23 交通运输学院CAD/CAM研究所
5
观察参考点E、参考点C、向上向量U实际上就是设定了一个观察坐标系。这个观察坐标系的原点是E,N=E-C,视线的方向-N(即-z轴)是C-E,y轴方向就是视点向上的方向U,剩下的x轴方向就是向量((E-C) U)。由于y轴和x轴是垂直的,所以也要求向量(E-C)和U互相垂直。这点在设置该函数参数时必须注意。 2018/11/23 交通运输学院CAD/CAM研究所
6
OpenGL正投影函数 void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far); 近裁剪平面(right, top, -near). (left, bottom, -near) 远裁剪平面 (left, bottom, -far) and (right, top, -far). Both near and far can be positive or negative. 2018/11/23 交通运输学院CAD/CAM研究所
7
OpenGL对称透视投影函数 void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); The fovy argument is the angle of the field of view in the x-z plane; its value must be in the range [0.0,180.0]. The aspect ratio is the width of the frustum divided by its height. The zNear and zFar values are the distances between the viewpoint and the clipping planes, along the negative z-axis. They should always be positive. 2018/11/23 交通运输学院CAD/CAM研究所
8
2018/11/23 交通运输学院CAD/CAM研究所
9
OpenGL通用透视投影函数 void glFrustum(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble near,GLdouble far); 定义截头锥体,这个取景体积可以是不对称的(The frustum doesnt have to be symmetrical, and its axis isnt necessarily aligned with the z-axis.),并计算透视投影矩阵M,乘以当前矩阵C,使C=CM。 The frustum's viewing volume is defined by the parameters: (left, bottom, -near) and (right, top, -near) specify the (x, y, z) coordinates of the lower left and upper right corners of the near clipping plane; near and far give the distances from the viewpoint to the near and far clipping planes. They should always be positive. 2018/11/23 交通运输学院CAD/CAM研究所
10
例子 prog7O-3view.txt prog7O-3view.exe cubeview.exe cubeview.c
2018/11/23 交通运输学院CAD/CAM研究所
Similar presentations