|Home||Log In||Contact||Keep Me Posted||Public Meshes||Source Code||Articles||API & Applications|
Source code for this project is in GitHub It's an MIT license.
This code is a set of classes for handling Constructive Solid Geometry (CSG) of a polygon mesh in C# and some helper code to render the results in ASP.NET MVC using three.js
The CSG work is done in the CSG classes, files beginning with CSG. There are a few other files to help render the results in ASP.NET MVC, but I've intentionally kept the classes pure code not dependent on what kind of app they are run in.
The code contains a cube, sphere and cylinder for testing but you can load any polygon mesh into the classes and it will work -- the code doesn't know that the mesh came from a sphere, cylinder or cube. The meshes do need to be closed meshes in order to work properly.
The output of the operations is a list of CSGPolygons, they can be sent to wherever they are needed. In my case I convert them to a JSON object and send them to the viewer to render in three.js. The polyons may have more than three sides but they are convex and easy to tesselate.
If you only want the CSG code and want to see how its called get all of the CSG*.cs files and the file P0830Controller.cs to see how its called and used.
If you want to build an MVC app there is a controller file: P0830Controller.cs
View file P0830.cshtml and _Layout.cshtml file The include files required for the view are
The MVC app assumes the presence Newtonsoft JSON library a JSON object to pass data from the controller to the view.
ThreeJS, JQuery and Newtonsoft are all available via NuGet.
To see a working sample visit http://meshola.com/prototype/p0830