Page 2 of 2
Re: OpenGL Gadget: How to make mesh edges more defined?
Posted: Mon Dec 16, 2019 2:32 am
by Samuel
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
Re: OpenGL Gadget: How to make mesh edges more defined?
Posted: Mon Dec 16, 2019 6:46 am
by IdeasVacuum
.... 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

Re: OpenGL Gadget: How to make mesh edges more defined?
Posted: Mon Dec 16, 2019 7:22 am
by Samuel
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