2012-11-03 16 views
0

我有一些麻烦试图用平截头体视角包裹我的天空机智天空盒。创建一个带有平截头体视角和GLKit的天空盒

GLKMatrix4 projectionMatrix = GLKMatrix4MakeFrustum(-50, 50, -50, 50, 0.1, 100); 

GLKMatrix4 baseModelViewMatrix = GLKMatrix4MakeTranslation(0.0f, -0.8f, 0.0); 
baseModelViewMatrix = GLKMatrix4Scale(baseModelViewMatrix, 0.5f, 0.5f, 0.5f); 

self.effect.transform.projectionMatrix = projectionMatrix; 
self.effect.transform.modelviewMatrix = GLKMatrix4Multiply(camera, baseModelViewMatrix); 

GLKMatrix4 camera = GLKMatrix4MakeLookAt(
             self.cameraEye.x, 
             self.cameraEye.y, 
             self.cameraEye.z, 
             0.0, 
             0.0, 
             0.0, 
             0, 1, 0); 


self.effect.transform.modelviewMatrix = GLKMatrix4Multiply(camera, baseModelViewMatrix); 

self.skyBoxEffect.center = self.cameraEye; 
self.skyBoxEffect.transform.projectionMatrix = self.effect.transform.projectionMatrix; 
self.skyBoxEffect.transform.modelviewMatrix = self.effect.transform.modelviewMatrix; 

,我在场景渲染的物体看起来相当不错与感觉或深度,但是天空盒根本不起作用不错,图像可能失真,因为视锥角度。这里有什么窍门吗?我怎样才能用一个平截头体的角度来制作GLKit的天空盒?谢谢!

回答

0

它通常需要一些调整,以获得相对于场景设置的平截头体变量。我可能是错的,但我认为目前你的平截头体的数学给你一个160度左右的视野。正常的fov大约在45到80度之间。检查http://www.songho.ca/opengl/gl_projectionmatrix.html了解定义一个合适的平截头体的更多信息。