开发者

3D intersection test

I have this 开发者_开发技巧3D model loaded.Then on the same screen, I have many points draw on it.. how Can I determine whether the points are on the model or not.Only take the XY plane for consideration.

Anyone can teach me how to do a 3D intersection test only on the XY plane, because Im really clueless.


There are several ways you could do this. Most practical options are probably:

a) Use a stencil buffer that you write to when you render your model and glReadPixels(...) to see if the stencil buffer is set for the particular (x,y) point on the screen.

b) Convert the (x,y) point into a line in 3D space from the camera position. Then do a line intersection test with your model (the simple but slow way would be to test against each polygon, you can clearly get faster results by using bounding volumes etc.)

c) Use glReadPixels(...) to read the colour of the (x,y) point on the screen. Obviously this will will only work if you are able to accurately distinguish which colours are part of the model or not.

If you are able to set up and use a stencil buffer for this purpose, then a) is probably the simplest to implement. Otherwise b) is probably the most useful general solution.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜