Page 1 of 1

Any ideas how todo mesh to mesh union, difference...

Posted: Sat May 14, 2011 8:13 pm
by ErUs
Any ideas how todo mesh to mesh union, difference and intersection.

Has someone already managed this?

basicly I would like to take a mesh and cut it into two (like in modeling software) but all programaticly.

Posted: Sat May 14, 2011 8:30 pm
by Radikalizm
This can be a difficult problem to tackle since you'll always have situations where vertex addition/removal is needed, maintaining a correct (and optimal) triangulation

I've never done anything like this before (I always do these kinds of things in modelling applications), but I assume the functionality you'd have to implement would be something like this:

1. Define a plane to slice the mesh and find all edge intersections
2. Create a second mesh (or meshbuffer) and move over one half of the sliced mesh
3. Create new vertices in both meshes at the intersection points, and recalculate your indices so your triangulation is correct
4. If you need closed meshes, calculate vertex positions to create a fill-plane where the mesh was sliced for both meshes
5. Recalculate normals, etc. where needed

As I said, I've never attempted this before so I could be missing something here, I can't really help you out with specifics, but designing and implementing these kinds of algorithms is part of the job ;)

EDIT:
Yay! Post #600!

Posted: Sun May 15, 2011 8:51 am
by nespa
Constructive Solid Geometry operations (union, difference, intersection)

an useful link:

http://createuniverses.blogspot.com/200 ... ogram.html


and an open library CSG:

http://www.opencsg.org/