"Inside" a mesh

BlitzMax Forums/MiniB3D Module/"Inside" a mesh

Hezkore(Posted 2009) [#1]
Is there any way to test if a position (X,Y,Z) is inside a certain mesh?
I'd like to use it like ValidPosition(X,Y,Z) which would return True or False depending on if that position is inside or outside a mesh.


slenkar(Posted 2009) [#2]
I think there is something like that in the code archives for Blitz3d


Hezkore(Posted 2009) [#3]
I can't just be inside a box, the model is quite complex.


Warner(Posted 2009) [#4]
I believe there is a method where you perform a line test in each direction (XYZ positive and negative): 6 in total.
You count the number of times that such a line intersects the mesh.
If all six numbers are odd, then the point is inside the mesh, else it is outside.
The mesh has to be closed in order for this to work.

In the code archive, there is a function that calculates if a ray intersects a mesh. It can be adjusted for this purpose:
http://www.blitzbasic.com/codearcs/codearcs.php?code=793