简体   繁体   English

在 OpenGL 中使用相机的问题

[英]Problems using camera in OpenGL

渲染预览

Hi, I am making an application which can make camera rotate around the model, I have successfully imported the obj format model嗨,我正在制作一个可以让相机围绕 model 旋转的应用程序,我已经成功导入了 obj 格式 model
But I meet the problem when rotate the camera, the model will disappear as you can see但是我在旋转相机时遇到问题,model 会消失,如您所见

gl.Perspective(180, (double)Width / (double)Height, 100, 50000f);

The key code for rotating camera:旋转相机的关键代码:

Calculate the center point of the model    
currentX = Math.Sin(angle) * radius;
currentZ = Math.Cos(angle) * radius;

gl.LookAt(currentX,0,currentZ,
          centerPoint.X, centerPoint.Y, centerPoint.Z,
          0, 1, 0
);

Check if the model is not closer than the near clipping plane.检查 model 是否不比近剪裁平面更近。 Check also the face culling: if your camera is inside the mesh, you are looking at the back faces of the polygons, which probably are not rendered.还要检查面剔除:如果您的相机在网格内,您正在查看多边形的背面,这些面可能没有被渲染。

Try modifying the near clipping plane to be much closer to the camera, and also lower the FoV angle.尝试修改近剪裁平面,使其更靠近相机,并降低 FoV 角度。 Try this:尝试这个:

gl.Perspective(90, (double)Width/(double)Height, 0.01f, 100.0f);  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM