views:

145

answers:

1

Hi, 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.

+2  A: 

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.

mikera
Stencil buffer would be quickest. If not the ray intersection will suffice.
tm1rbrt