   CSG and OpenGL
  Hello everybody,I am programming a cement hydration code which involves a set of spherical particles immersed in a solid box. If I subtract the particles from the solid box, I then get the pores.My problem is how to visualize those pores. To this end, I wrote a small c program that uses the GLUT library to plot the box and the spheres.Everything is fine except the subtraction mentioned above.Could you please help me in(1) Does glut library support constructive solid geometry (CSG) so that the subtraction can be done?(2) If so, how to achieve this? There is one solid box and many many spheres.I appreciate deeply clear help since I am a newbie to OpenGL.Have a nice day.Phu   
  Create a 3D raster grid of high resolution.  This represents your box.  Set all the voxel values to 1.  For each sphere, determine those voxels inside (or on) the sphere and set the voxel values to 0.  Use Marching Cubes or some other surface extractor to triangulate the remaining 1-values voxels.  Display the triangle meshes using your favorite lighting method.;  Im a csg master, it depends on what you want, voxels do work but they take tonnes of ram, theres visual csg but that doesnt give you a hard solid body of model at the end you can modify, it just "looks" like csg.The method I like involves intersecting the planes together and chopping the shapes you need bit by bit.  Its extremely tricky but its rewarding because you end up with a bitching algorythm to make mechanical toys with. (csg is great for map makers)Visual csg is 10 times easier to code than object space csg (which is intersecting and chopping planes) unions are simply drawing both the models together in a soup, subtraction and intersection is a little more tricky.And you wanted subtraction right?if you render the first models depth render (you render the z coordinate in the shader) then when you render the subtracting sphere, compare the z's, if its more than the z drawn, then you draw the sphere (inside out too btw) and if its less than the z then you dont draw it.then you can pass the sphere through the cube and itll make a hole where the sphere is.Thats just the beginning tho and its already buggy, but if you continue thinking down this direction youll get view dependant csg, and its really quick and professional looking.;  If you do decide to use voxels (and I'm not saying you should, but they are one option) then check out the library in my signature. It'll handle the voxel representation and surface extraction for you. Otherwise, if you want to do real CSG then check out the following libraries:http://www.cgal.org/http://code.google.com/p/csgtestworld/Hope that helps...   ;  Hello all,Thank you very much for your posts. I am able to do CSG with the OpenCSG library found at http://www.opencsg.org/.Regards,Phu   