我有一个程序来做增强现实,我在 OpenGL 中使用:
glFrustum(-near*centerImageX/(GLfloat)fx, near*(imageWidth-centerImageX)/(GLfloat)fx, near*(centerImageY-imageHeight)/(GLfloat)fy, near*centerImageY/(GLfloat)fy, near, far);
没关系,我得到了很好的视角,并且我的 3D 对象很好地插入了我的照片。现在我希望能够放大/缩小。通常,它是通过更改 gluPerspective 中的 fov 来完成的,但我不使用 gluPerspective,因为我无法获得良好的插入。
使用http://dmi.uib.es/~josemaria/files/OpenGLFAQ/transformations.htm,问题“9.085 如何调用与我对 gluPerspective() 的调用相匹配的 glFrustum()?”,我尝试了:
fov=360.0*atan(imageHeight/(2*fy))/Pi; //computed with parameters top and bottom of my glFrustum
aspect=-centerImageY*fx/(fy*(centerImageX-imageWidth)); //computed with parameters left and bottom of my glFrustum
void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far);
void gluPerspective(GLdouble fovy, GLdouble aspect,GLdouble near, GLdouble far);
接着 :
gluPerspective(fov, aspect, near, far);
但是我的对象被扭曲了,它没有在所有轴上正确缩放,没有保持比例。
那么我需要做什么/修改我的 glFrustum 参数以获得放大/缩小效果?