Esempio n. 1
0
        /// <summary>
        /// Returns a new mesh by subtracting @lhs with @rhs.
        /// </summary>
        /// <param name="lhs">The base mesh of the boolean operation.</param>
        /// <param name="rhs">The input mesh of the boolean operation.</param>
        /// <returns>A new mesh if the operation succeeds, or null if an error occurs.</returns>
        public static CSG_Model Subtract(GameObject lhs, GameObject rhs)
        {
            CSG_Model csg_model_a = new CSG_Model(lhs);
            CSG_Model csg_model_b = new CSG_Model(rhs);

            CSG_Node a = new CSG_Node(csg_model_a.ToPolygons());
            CSG_Node b = new CSG_Node(csg_model_b.ToPolygons());

            List <CSG_Polygon> polygons = CSG_Node.Subtract(a, b).AllPolygons();

            return(new CSG_Model(polygons));
        }
Esempio n. 2
0
        public static Mesh Subtract(Mesh lhs, Mesh rhs)
        {
            CSG_Model csg_model_a = new CSG_Model(lhs);
            CSG_Model csg_model_b = new CSG_Model(rhs);

            CSG_Node a = new CSG_Node(csg_model_a.ToPolygons());
            CSG_Node b = new CSG_Node(csg_model_b.ToPolygons());

            List <CSG_Polygon> polygons = CSG_Node.Subtract(a, b).AllPolygons();

            CSG_Model result = new CSG_Model(polygons);

            return(result.ToMesh());
        }
Esempio n. 3
0
        internal CSG_Node render_tree()
        {
            if (operation == CSG_Operation.no_op)
            {
                CSG_Model csg_model_a = new CSG_Model(m);
                current_object = new CSG_Node(csg_model_a.ToPolygons());
                return(current_object);
            }
            else
            {
                switch (operation)
                {
                case CSG_Operation.Inner:
                    current_object = CSG_Node.Inner(left.render_tree());
                    return(current_object);

                case CSG_Operation.Outer:
                    current_object = CSG_Node.Outer(left.render_tree());
                    return(current_object);

                case CSG_Operation.On:
                    current_object = CSG_Node.On(left.render_tree());
                    return(current_object);

                case CSG_Operation.Compliment:
                    current_object = CSG_Node.Compliment(left.render_tree());
                    return(current_object);

                case CSG_Operation.Union:
                    current_object = CSG_Node.Union(left.render_tree(),
                                                    right.render_tree());
                    return(current_object);

                case CSG_Operation.Intersect:
                    current_object = CSG_Node.Intersect(left.render_tree(),
                                                        right.render_tree());
                    return(current_object);

                case CSG_Operation.Subtract:
                    current_object = CSG_Node.Subtract(left.render_tree(),
                                                       right.render_tree());
                    return(current_object);
                }
            }
            return(null);
        }