但在OpenGL世界中我看到了这个方向
此代码清楚地解释了它。我只画了轴
gl.glBegin(gl.GL_QUADS);
//z
gl.glColor3f(0,0,1);
gl.glVertex3f(-width,0,length);
gl.glColor3f(0,0,1);
gl.glVertex3f(width,0,length);
gl.glColor3f(0,0,0);
gl.glVertex3f(width,0,-length);
gl.glColor3f(0,0,0);
gl.glVertex3f(-width,0,-length);
//x
gl.glColor3f(1,0,0);
gl.glVertex3f(length,0,-width);
gl.glColor3f(1,0,0);
gl.glVertex3f(length,0,width);
gl.glColor3f(0,0,0);
gl.glVertex3f(-length,0,width);
gl.glColor3f(0,0,0);
gl.glVertex3f(-length,0,-width);
//y
gl.glColor3f(0,1,0);
gl.glVertex3f(-width,length,0);
gl.glColor3f(0,1,0);
gl.glVertex3f(width,length,0);
gl.glColor3f(0,0,0);
gl.glVertex3f(width,-length,0);
gl.glColor3f(0,0,0);
gl.glVertex3f(-width,-length,0);
gl.glEnd();
因此,线条的彩色部分位于世界的正面部分,而暗部位则处于负面。 观看下一张图片
你看到了吗? 当我得到截图时,这是相机和兴趣点位置
Camara: (-18.778223, 26.576332, -77.65113)
Point of interest: (-18.571165, 26.34204, -76.672806)
那么如何反转X轴?
答案 0 :(得分:4)
我想你的矩阵相关代码如下:
...
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Matrix calculations
...
然后,你可以这样做:
...
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glScalef(-1, 1, 1); // Each number represents scale for one axis
// Matrix calculations
...
此外,您需要在OpenGL初始化后调用glFrontFace(GL_CW);
一次,以补偿多边形绕组方向反转。
当引擎中的坐标系与OpenGL中的坐标系相同时更容易:
+Y
_______
/ -Z \
-X / \ +X
/ \
/ +Z \
"""""""""""""""
-Y