Object outside the OpenGL camera

I am using Perspective View with gluPerspective and gluLookAt, and I have the x, y object coordinates. How to determine if an object is out of scope? Please note that the camera always moves.

+3
source share
2 answers

First of all, OpenGL does not have a camera. It just transforms the peaks around. And gluLookAt just applies the transformation of objects that refer to the movement of the mental camera.

The solution was already given in the first comment by Robert Masaioli: In OpenGL, the perspective transformation is described in terms of truncation (gluPerpective simply calculates the truncation parameters and passes them to glFrustum). Thus, defining a sample of truncated objects, i.e. If they are rejected, you determine whether they are all visible.

+5
source

When you say that they exit the camera, do you mean that they are from the side, because you are looking at a fixed distance? .. or do you mean that they simply disappear.

If this is the first case (from the side of the picture), you should be able to calculate how far from the x, y plane you need to move the camera based on the current perspective settings.

, , , Z, .

[ 1] gluPerspective . , . , , - , , , .

[ 2] , .

0

All Articles