Installation near a plane in OpenGL

I implemented the first-person camera in OpenGL, but when I get closer to the object, it starts to disappear, so I want to set it near a plane close to zero so I can get closer to the objects. Therefore, if anyone can tell me this is the best way to do this. Thank.

+3
source share
4 answers

So if anyone can tell me

gluPerspective .

+2
source

The closest plane is set when you set the projection matrix with either glFrustum or glOrtho. One of the parameters is the nearest plane. Note that the distance to the nearest plane must be> 0.

+2

.

  • (, 4 ), , > 0. 0.1f .
  • , , ! , , -, , ( , , . Super Mario Galaxy )

nearPlane. z-. FarPlane . (0,1, 1000) .

+1

. , OP - OpenGL. , :

zNear, , :

Projection matrix

SYMBOL  MEANING                   TYPICAL VALUE
------  --------------           -------------
fov     vertical field of view   45 – 90 degrees
aspect  Aspect ratio             around 1.8 (frame buffer Width / Height)
znear   near clip plane          +1
zfar    far clip plane.          10

SYMBOL      MEANING                          FORMULA
----------  -------------------------------  --------------
halfHeight  half of frustum height at znear  znear∗tan(fov/2)
halfWidth   half of frustum width at znear   halfHeight×aspect
depth       depth of view frustum            zfar−znear

( http://davidlively.com/programming/graphics/opengl-matrices/perspective-projection/)

- - (NDC), " ". , 2x2x1 (x, y, z). , (-1, -1, 0) - (+1, +1, +1), .

, zNear zFar, , zFar → zNear.

Your collision detection and response system is responsible for ensuring that the camera does not get too close to geometry. Too close is a function of your zNear and geometry boundaries. Even if you have a zNear 1E-9, the geometry will be cropped when it gets too close to where the clip comes from.

So: fix the collision detection and stop worrying about your zNear.

0
source

Source: https://habr.com/ru/post/1758099/


All Articles