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

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
ErUs
Posts: 165
Joined: Thu Oct 07, 2004 6:13 pm

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

Post 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.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post 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!
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Post 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/
Post Reply