I'm working on a Java project witch is really killing me. After several days of researching on different forums, looking for what I really need, I come to ask your help.
My data :
- A .ply file (containing a 3D shape made of a lot of triangles)
- A point (3D coordinates)
I would like to know if this point is contained inside the complex 3D shape.
I have split this problem in 2 smaller problems :
How can I represent the complex 3D shape in memory? (I found several libraries, but it seems really complex for the task I want to do : Java3D, JBullet, JME3...) I do not want my java application to show the object for now.
How can I know if this point is inside the 3D shape or not? (I thought to make a 3D vector starting from the point and to count the number of intersections with the shape, but I don't see how to do and witch library can I use?)
Maybe there are easier ways to do it, that's also why I come to you. I am really stuck now and I would like if this is possible without writing customs libraries...
(Sorry for my writing, I'm not English ^^)
Thanks for helping me.
Here is one approach. Not the best or the fastest, but once you have something working, it will be easier to improve upon.
Implement a quick and dirty PLY file format parser. Here is the PLY format spec. Load the data up and store it internally: an array for each X, Y, and Z. This is all just plain Java.
Define a line based on your point and some other arbitrary point. For each polygon, determine where it intersects the plane (some help) and if the intersection point is inside or outside the polygon (some help). As you suggested, then count the number of intersections to determine if the point is inside or outside your 3d shape.