我有一个程序做增强现实技术在OpenGL使用:glFrustum,gluPerspective和FOV
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怎样才能做出glFrustum(通话),我调用gluPerspective()匹配”,我试着用:
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
无效glFrustum(GLdouble左,GLdouble右,GLdouble底部,GLdouble顶部,GLdouble近,GLdouble远);
void gluPerspective(GLdouble fovy,GLdouble aspect,GLdouble near,GLdouble far);
然后:
gluPerspective(fov, aspect, near, far);
但我的目标是扭曲的,这不是正确的所有轴缩放比例不存。
那么我需要做什么/修改我的glFrustum参数来获得放大/缩小效果?
我觉得你的边界的计算在'glOrtho(近平面...)'可能是错的。你的左和底锥台从中心开始。通常该中心将是...中心。我期望看到* near(*)*(centerImageX-imageWidth/2.0)/(GLfloat)如果你正确导出它们,纵横比应该与'imageHeight'和'imageWidth'的比率相关,并且与'centerImageX'无关。除非我在这里错过了一些基本的东西 –