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