Archived

This topic is now archived and is closed to further replies.

Finding if a point is inside a mesh...

This topic is 5131 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a way to see if a point is inside of a mesh (ID3DXMesh)? I''m currently creating a "mesh" of planes from the triangles of the mesh (not effecient, I''m sure), and testing the point with a dot product, but it''s constantly failing to detect a point is inside the mesh. I''m thinking its because planes don''t exactly have normals and so my dot product check is checking to see if the point is "in front" of a plane when it should be checking to see if it''s "behind" the plane. I really need to find a tutorial on mesh-to-mesh collision detection (spheres and bounding boxes are good first and second level checks, but I need it more accurate)...

Share this post


Link to post
Share on other sites
well if you are in the model there should be precisely one more poly faceing away from your point thaan faceing twards it in any direction.
so you could draw (noy draw, you know make a line for checking) a line from your point to all polys and see how many faces it passes through

(mee just thinking aloud)

theres probly a better way of dooing it though

Bobboau, bringing you products that work... in theory

Share this post


Link to post
Share on other sites
so, for a basic collision detection like you are looking for, here is what a logical step would be.

If you want INSIDE, that is a little different, but if you want collided, here is how it is.


Calculate the plane from the mesh triangle

figure out which ones are close enough to collide with

find the distance to each of these

if(Point+(Velocity*Distance) collides with the triangle, then you collided.

//////////////////////////////////////////////////////////////

for INSIDE,

you would first test to see of the point+velocity is on the backside of the plane, and if so, shoot a ray from the intersecting point along the plane normal.

If that ray intersects with your bounding sphere (or ellipse, or whatever) then this case is true.

Share this post


Link to post
Share on other sites