예제 #1
0
        static Mesh PerformOperation(Mesh a, Mesh b, CsgFunctionHandler fun)
        {
            CsgNode           A        = new CsgNode(PolygonsFromMesh(a));
            CsgNode           B        = new CsgNode(PolygonsFromMesh(b));
            CsgNode           AB       = fun(A, B);
            List <CsgPolygon> polygons = AB.GetAllPolygons();

            return(MeshFromPolygons(polygons));
        }
예제 #2
0
        // Return a new CSG solid representing space in either this solid or in the
        // solid `csg`. Neither this solid nor the solid `csg` are modified.
        //
        //     +-------+            +-------+
        //     |       |            |       |
        //     |   A   |            |       |
        //     |    +--+----+   =   |       +----+
        //     +----+--+    |       +----+       |
        //          |   B   |            |       |
        //          |       |            |       |
        //          +-------+            +-------+
        //
        public static CsgNode Union(CsgNode a1, CsgNode b1)
        {
            CsgNode a = a1.Clone();
            CsgNode b = b1.Clone();

            a.ClipTo(b);
            b.ClipTo(a);
            b.Invert();
            b.ClipTo(a);
            b.Invert();
            a.BuildFromPolygons(b.GetAllPolygons());
            CsgNode ret = new CsgNode(a.GetAllPolygons());

            return(ret);
        }