I'd go with ray triangle intersection for mouse picking. There are other methods like using a "color" buffer, but I'm not very fond of them because of the lack of speed with glReadPixels(). Ray triangle picking(if optimized properly) is faster and there are more things you can do with it.
Here's a nice article that uses ray triangle intersection for some ray tracing if you're interested. https://www.scratchapixel.com/lessons/3 ... c-solution
OpenGL Gadget: How to make mesh edges more defined?
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: OpenGL Gadget: How to make mesh edges more defined?
.... That is a nice article. I will study it carefully, but I notice in the description a kind of chicken and egg situation when testing to see if "the" triangle face is hit, parallel to the ray or behind the ray - in real time, that's thousands of triangles tested to find "the" triangle.
Edit: ...and the User pick could be a vertex point
Edit: ...and the User pick could be a vertex point

IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: OpenGL Gadget: How to make mesh edges more defined?
There needs to be optimizations for real time use. Without an acceleration structure (Octrees, BSD trees, K-d trees, etc...) it isn't really usable for real time. Add in multi threading with that and you end up with a very fast system. Even in cases where there are millions of polygons.
For vertex points I'd use ray sphere intersection instead.
https://www.scratchapixel.com/lessons/3 ... tersection
For vertex points I'd use ray sphere intersection instead.
https://www.scratchapixel.com/lessons/3 ... tersection