Carving in a mesh

Blitz3D Forums/Blitz3D Programming/Carving in a mesh

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Because I suck at 3D ;) this is the only way I can think of to tell if a polygon from MeshB is inside MeshA.

1. Find the furthest point from MeshA on MeshB.
2. Create a pivot (PivotB) there.
3. Find the XYZ coordinates of the vertex on MeshB that you're testing.
4. Create a pivot (PivotA) there.
5. Find the vector angle between the two points.
6. Move PivotB towards PivotA along this vector until it collides.
7. Move PivotB back one frame to where it was before it collided.
8. Hide MeshB.
9. Use EntityPick to find the nearest entity to the PivotA.
10. If it returns MeshA, the polygon is inside MeshA. If it returns PivotB, the polygon is outside MeshA.

While that process would only take a hundredth of a second to process, it seems a very long and cubersome method of checking what should be a simple process. Anyone got a better method?

+BlackD

[edit:]
Actually, just realised afterward, you could shorten that to:
1. Using vectors, find the furthest polygon from MeshA on MeshB.
2. Create a pivot there.
4. Move the pivot towards the polygon you're checking, testing for collision with MeshA.
5. If it never collides, then the polygon is outside MeshA. If a collision with MeshA does occur, then obviously the polygon is inside MeshB. Though you'll probably want to test individual vertices, not triangles, as part of a triangle may be inside while the center of it is outside.

This assumes that there is some point of meshB outside meshA. If there isn't, then the carve won't happen as it won't find any polygons which meet - which they shouldn't.. they're all inside.[/edit]