0

I am new to OpenGL android, but know some basic concepts like projection and camera views. we can change the position and orientation of camera. But,when i move camera more away from an object the object disappears . For example: Below is my camera view and the co-ordinates of rectangle.

Matrix.setLookAtM(mViewMatrix, 0, 0, 0, -7, 0f, 0f, 0f, 0f, 1.0f, 0.0f);

float rectCoords[] = {  
        -0.5f, 0.5f, 0.0f,
        -0.5f, -0.5f, 0.0f,
        0.5f, 0.5f, 0.0f,
        0.5f, -0.5f, 0.0f,
};

if I am correct the camera is 7 units away from the rectangle which is on XY plane and camera is 7 units away from rectangle on negative z axis looking towards the origin whose top is pointing towards positive y-axis.

When I change -7.0f i.e the z coordinate of the camera, to -7.1f(i.e i am moving the camera away from the rectangle) the rectangle disappears, that means the maximum distance the camera can see is 7 units from it. Correct me if i am wrong, if not then how can i make to see the object more than 7 units visible from camera

genpfault
  • 51,148
  • 11
  • 85
  • 139
murali kurapati
  • 1,510
  • 18
  • 23

2 Answers2

1

The vanishing point of objects based on camera distance in OpenGL (and 3D graphics in general), is the 'far plane distance'. It is part of the definition of the view frustum, which is a general term in geometry, and is used to describe the 3D viewing volume. See this question (Why does OpenGL have a far clipping plane, and what idioms are used to deal with this?) for an explanation of why the far-plane exists. Most fixed function rendering pipelines also add the ability to add user-defined clip planes (including OpenGL's glClipPlane), so the far plane may not be the only explanation for objects vanishing based on distance. Programmable shader pipelines usually do not respect user-defined clip-planes, so their use is less popular recently.

The 'far plane distance' is part of the equation that forms the projection matrix. See here for a very detailed description for calculating the projection matrix, and its usage. You haven't shown your projection matrix, but presumably the far plane is either directly or indirectly defined as 7.0.

Community
  • 1
  • 1
MuertoExcobito
  • 9,741
  • 2
  • 37
  • 78
  • yes you are correct, i haven't checked that ,indeed i don't know that plane exists. Thank you for correcting me,this is my frustum Matrix.frustumM(mProjectionMatrix1, 0, -ratio, ratio, -1, 1, 3, 7); – murali kurapati Jun 02 '15 at 12:13
0

bro!if u hav a myReshape function in your code,,,just go to gluperspective() function,,in that increase the last value...ur issue will be solved.

ex: gluPerspective (60, (GLfloat)w / (GLfloat)h, 0.1, 500.0);

increase 500.0 to 1000.0

tso
  • 4,732
  • 2
  • 22
  • 32
  • Please, format your code [properly](https://stackoverflow.com/editing-help), and read [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer) – Dwhitz Jun 05 '17 at 18:53