Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

How to use glunproject in my android app?

I have the following parts in my engine:

  • A projection matrix
  • A view matrix for the camera
  • A model matrix for each of the objects in my world. This matrix is calculated from the parent objects model matrix and the objects own model matrix. These matrices are calculated from a translation, rotation and scale matrix. (this all works fine)

These matrices are then multiplied and passed to my vertex shader.

Now I understand glunproject needs the model matrix and the projection matrix and can caluclate a near and far 3d coordinate depending on the camera viewport settings ( for the near and far plane)

Do I need to use glunproject for each of the objects in my world and then check if the ray produced by these near and far coords intersects my object? This seems quite expensive on the cpu?

What is the proper use for glunproject

share|improve this question
    
glUnProject is used to transform windows-/screen-space-coordinates into world space. Do you want to make hit-tests using a ray given the screen coordinates? –  Maik Semder Apr 1 '13 at 14:46
    
Btw. you are using the term "identity matrix" wrong. What you call the "identity matrix" is the object- or model-matrix. The identity matrix is something else. –  Maik Semder Apr 1 '13 at 14:48
    
What i want to achieve called 'Picking' i believe. All i want to do is be able to tell what object i 'pressed' on. I was under the impressing this is done by translating the screen coords to 3d coords using glunproject? –  Thomas Apr 1 '13 at 15:28
    
I've update my question to use the right terms –  Thomas Apr 1 '13 at 15:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.