0

I have a GL_QUAD which is basically a big field that the player is able to walk on. However, I want the player to have the abilty to 'jump,' meaning when he returns to his original y position he must stop falling. How do I access the world coordinates of a GL_QUAD so I can compare the y values of the quad and the player to determine whether he should stop falling?

Fitzy
  • 1,871
  • 6
  • 23
  • 40
  • 3
    Your program does not sound like it is structured correctly for collision detection. Usually you would have some sort of spatial partitioning structure so you do not have to get coordinates back from GL. In fact, most of the time the collision geometry is a simplification of render geometry. Why do you not have access to the original geometry in this situation? – Andon M. Coleman Nov 16 '13 at 01:24
  • @AndonM.Coleman So you're saying I should, for example, use the translation matrix to determine whether the 'ground' or GL_QUAD has returned to the position relative to the world y axis as it was originally? – Fitzy Nov 16 '13 at 01:48
  • 1
    Well, to me `GL_QUAD` represents the render view of your world. It may be identical to the geometry you use for collision detection, but if you talk about getting the coordinates of a `GL_QUAD` this implies reading something back from the GL. Don't you have the geometry you originally used to create your `GL_QUAD`(s) stored somewhere in client (CPU) memory? – Andon M. Coleman Nov 16 '13 at 02:09
  • @AndonM.Coleman I do have access to the coordinates indirectly through the translation matrix (negating translations so the `GL_QUAD` is rendered at the world origin), which does work, but should I have the coordinates stored elsewhere, too? – Fitzy Nov 16 '13 at 02:37
  • 3
    `GL_QUAD` is an OpenGL primitive. You should have the actual vertices used to create the primitive in client memory if you want to implement collision detection. Otherwise you have to use pixel read-backs (I see this ***far too often*** in 2D games) to do collision detection or transform feedback. Your description indicates that you would have to use transform feedback to get the points for your `GL_QUAD` primitive, which is not going to be efficient. – Andon M. Coleman Nov 16 '13 at 02:57
  • @AndonM.Coleman Ah, ok, So rather than transforming the matrix I store the vertices of the quad. Makes sense now. Thanks for clearing that up, really helpful! – Fitzy Nov 16 '13 at 03:03

0 Answers0