コード例 #1
0
ファイル: Mesh.CSG.cs プロジェクト: iniside/CryCIL
        /// <summary>
        /// Subtracts another mesh from this one.
        /// </summary>
        /// <param name="anotherMesh">Another mesh.</param>
        /// <seealso cref="ConstructiveSolidGeometry.Subtract"/>
        public virtual void Subtract(IMesh anotherMesh)
        {
            BspNode <SplittableTriangle> a = this.ToBspTree();
            BspNode <SplittableTriangle> b = anotherMesh.ToBspTree();

            a.Invert();
            a.Unite(b);
            a.Invert();
            this.SetBsp(a);
        }
コード例 #2
0
ファイル: Mesh.CSG.cs プロジェクト: iniside/CryCIL
        /// <summary>
        /// Intersects this mesh with another.
        /// </summary>
        /// <param name="anotherMesh">Another mesh.</param>
        /// <seealso cref="ConstructiveSolidGeometry.Intersection"/>
        public virtual void Intersect(IMesh anotherMesh)
        {
            BspNode <SplittableTriangle> a = this.ToBspTree();
            BspNode <SplittableTriangle> b = anotherMesh.ToBspTree();

            a.Invert();                                 // Cut geometry that is not common for the meshes.
            b.CutTreeOut(a);                            //
            b.Invert();                                 //
            a.CutTreeOut(b);                            //
            // Clean up remains.
            b.CutTreeOut(a);
            // Combine geometry.
            a.AddElements(b.AllElements);
            // Invert everything.
            a.Invert();
            this.SetBsp(a);
        }