我有一个场景,基本上是一个15x15的正方形地面(具有坐标(0,0,0) (0,0,15) (15,0,15) (15,0,0)的四边形)。
我将场景中心设置为(7.5,0,7.5)。问题是我不知道如何在该场景中心水平旋转相机(即使相机围绕中心场景做一个水平360圆)。我知道需要使用sin和cos,但不确定具体如何操作。
下面是代码(纯C):
我将场景中心设置为(7.5,0,7.5)。问题是我不知道如何在该场景中心水平旋转相机(即使相机围绕中心场景做一个水平360圆)。我知道需要使用sin和cos,但不确定具体如何操作。
下面是代码(纯C):
//set camera position
//camera height is 17
GLfloat camx=0, camy=17, camz=0;
//set center of scene
GLfloat xref=7.5, yref=0, zref=7.5;
gluLookAt(camx, camy, camz, xref, yref, zref, 0, 1, 0);
//projection is standard gluPerspective, nothing special
gluPerspective(45, (GLdouble)width/(GLdouble)height, 1, 1000);