Quote:
voidglutReshape(int width, intheight)
{
staticconstdouble kPI =3.1415926535897932384626433832795;
staticconstdouble kFovY =40;
doublenearDist, farDist, aspect;
glViewport(0, 0, width, height);
// Compute theviewing parameters based on a fixed fov and viewing
// a canonicalbox centered at the origin.
nearDist = 2.0 / tan((kFovY / 2.0) * kPI /180.0);
farDist = nearDist + 50.0;
aspect = (double)width / height;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(kFovY, aspect, nearDist,farDist);
// first point of the path
camera[0] = (*path)[0].vert[0];
camera[1] = (*path)[0].vert[1];
camera[2] = (*path)[0].vert[2];
// second point of the path
center[0] = (*path)[1].vert[0];
center[1] = (*path)[1].vert[1];
center[2] = (*path)[1].vert[2];
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
updateCamera();
}
voidupdateCamera()
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(camera[0], camera[1],camera[2], center[0], center[1],
center[2], 0, 1, 0);
glTranslatef(gCameraTranslationX,gCameraTranslatio nY, 0);
glMultMatrixd(gCameraRotation);
glScaled(gCameraScale, gCameraScale,gCameraScale);
glutPostRedisplay();
}