Objects converge as they are translated
January 23, 2014  Posted by forumadmin under TechQns 
Comments off

I am fooling around with OpenGL as an attempt to get some bases for a game.
The problem I am facing is that upon translating the cubes enough they start “bunching up” along a similar z coordinate.
The steps I take are as follows:

I create a view matrix (which represents the position of the “camera”)
view_matrix = vmath::translate(0.0f, 0.5f, 2.0f);

I translate the “camera”:
//move is a vector generated by a function that i wrote based on key presses. view_matrix = view_matrix * vmath::translate(move);

For each cube it is randomly translated to create the space on which you navigate (where a is a random number from minus to plus 10 and b from 5 to 25).
matrix = vmath::translate( a, 0.0f, b);
The matrix passed to the shader to render is as follows:
glUniformMatrix4fv(mv_location, 1, GL_FALSE, view_matrix * matrix);
This produces the following:
When a cube get behind the camera it gets relocated using the same process as before (where b now ranges from 30 to 60f)
Perfect, but after a while this happens:
As you can see they are all bunching together.
What I have seen happens is that the view matrix reaches a point where it “engulfs” the model matrix but I have no idea what to do to get around it.
Asked By – NoobLevler  Read Answers 