|
3D Meshes and CSG operations |
| category: code |
|
|
|
How to realize CSG operations in 3D mesh objects? Please, discuss the principles. |
|
|
Depends.exe on what you are doing.
3D mesh objects as in triangle meshes? I guess there are tons of papers on that topic and a lot of different approaches... google it.
Or just take distance fields instead - in distance fields CSG is trivial ;) |
|
|
|
Clip the triangles against each other, check inside/outside rules for each resulting polygon. Simple in theory, but turns into absolute hell in reality due to floating point accuracy. There's a reason why there's very few CSG-packages out there that can eat it's own dog-food. |
|
|
|
Maybe an easier place to start: Screen Space CSG? |
|
|
|
OpenCSG uses some image-based method. |
|
|
|
Indeed, screen-space CSG is much easier to get robust. |
|
|
|
This reminds me.. I wonder if anyone ever made a .pov ---> random-polygon-object-format converter, e.g. something that would eat povray's script (even with limited set of primites) and output an approximation as a mesh. |
|
|
Just a first random pick... http://www.nigels.com/research/ there's really a huge amount of academic research out there... Or if you wanna just cut out planes, you have it nearly for free in OpenGL, see for instance http://www.cs.duke.edu/courses/fall00/cps124/web/links.html. Hmm, distance functions are lovely... must... download... framework... and play! |
|
|
The easiest one to implement is:
http://www.opengl.org/resources/code/samples/advanced/advanced97/notes/node11. html |
|
|
Easy peasy. Intersect all edges of mesh A with triangles of mesh B and vice versa. Then just connect the dots :)
Bonus points doing the intersection stuff so that each pair or triangles intersect at either 0 or 2 points, retriangulating without nasty singularities and getting intuitive results on non-perfect input meshes. |
|
|
bsp trees will help you with csg:
A Tutorial on Binary Space Partitioning Trees BSP FAQ flipcode article
also there's example code in Game Programming Gems 5, if you need it, I'll send you the source code |
|
|
Weeks struggling for a stable connection...
Thanks for the answers.
Ized: Would you mail me it? dang...@gmail.com |
|
|
|
http://www.opengl.org/resources/code/samples/advanced/advanced97/programs/csg.c |
|
|
|
with something resembling to an authority, i can confirm that you really don't want to code triangle-mesh CSG yourself. However, if you still insist to do it, I can recommend 216's method above :) |
|
|
|
I need it and I want it. D: |
|
|
|
|