开发者

Intersect picked Ray with shapes in OpenGL

开发者 https://www.devze.com 2023-03-23 14:08 出处:网络
I am trying to perform picking in O开发者_如何学编程penGL, and have 3 questions in 1. I use twice the Unproject command, once with 0 and once with 1 as near/end planes.

I am trying to perform picking in O开发者_如何学编程penGL, and have 3 questions in 1.

  1. I use twice the Unproject command, once with 0 and once with 1 as near/end planes. Some article say that 0 and 1 are ok, some others say that I should use a calculated depth. Which one should I take ?

  2. Then, assuming I could substract both results, that gives me a ray (the ray is going from my "camera" to the direction indicated as x,y,z, right ? x,y,z are absolute values or relative to my "camera" ?

  3. Now that I have the ray, how can I intersect it with shapes ? By the way, how can I list existing shapes and calculate their coordinates vs the ray ?


2 - Your ray will be relative to the camera, just multiply it by the inverse camera transform.

3 - For just about all purposes, you need a spatial subdivision algorithm (Binary Space Partition, Bounding Volume Hierarchy, etc.) And you should maintain a list of the shapes you have created...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号