PDA

View Full Version : 2D texture in front of 3D object



Ellusion
01-22-2016, 01:47 PM
I'm fairly new to OpenGL. I have 3D object and 2D image drew as HUD. What I want to do now is to put 2D texture from HUD on a visible part of 3D object (in this case - front of a skull). As far as I know what I need to do is:


check which vertices are visible (again, as far as I know and after StackOverflow searching I think that checking if vertex is occluded can solve this problem (if vertex is not occluded then it's front vertex))
If vertex is visible transform this 3D point into 2D point (just use gluProject to get 2D coordinates)
I know 2D coordinates of vertex, so I can compare it to pixels on texture, which brings me directly to texturing.

And here's the problem - I don't have any idea how to do action in point 3. I have of visible 3D vertices in 2D, I have 2D texture and no idea how to use this. I was thinking to use it in similar way as 2D draw, but I have much more restrictive points than in 2D quad texturing.