Search code examples
c#openglsharpgl

Problems using camera in OpenGL


render preview

Hi, I am making an application which can make camera rotate around the model, I have successfully imported the obj format model
But I meet the problem when rotate the camera, the model will disappear as you can see

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
);

Solution

  • Try modifying the near clipping plane to be much closer to the camera, and also lower the FoV angle. Try this:

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