AddTriangles() 공개 메소드

public AddTriangles ( List triangles ) : void
triangles List
리턴 void
예제 #1
0
        /**
         * Create a new BSPTree instance from @mesh using @transform
         * to transform all vertices, normals, and tangents.
         */
        public static BSPTree FromMesh(Mesh mesh, Matrix4x4 transform)
        {
            BSPTree tree = new BSPTree();

            // get a list of all triangles in @mesh
            List <Triangle> meshTriangles = GetMeshTriangles(mesh);

            // loop through each triangle and transform its vertices by @transform
            for (int i = 0; i < meshTriangles.Count; i++)
            {
                Triangle tri = meshTriangles[i];

                for (int vi = 0; vi < 3; vi++)
                {
                    Vertex vtx = TransformVertex(tri.GetVertexByIndex(vi), transform);
                    tri.SetVertexByIndex(vi, vtx);
                }

                tri.RebuildOrientationPlane();
                meshTriangles[i] = tri;
            }

            tree.AddTriangles(meshTriangles);
            return(tree);
        }
예제 #2
0
        /**
         * Returns geometry corresponding to volume @a that is divided into
         * two separate pieces by @b. Return results in the form of two BSPTree
         * instances: @side and @side2.
         */
        public static void Slice(BSPTree a, BSPTree b, out BSPTree side1, out BSPTree side2)
        {
            side1 = a.Clone();
            BSPTree bClone = b.Clone();

            List <Triangle> side1Discarded = new List <Triangle>();

            bClone.Invert();
            bClone.ClipByTree(a, false);
            side1.ClipByTree(b, true, side1Discarded);
            side1.AddTriangles(bClone.GetAllTriangles());

            bClone.Invert();
            side2 = new BSPTree();
            side2.AddTriangles(bClone.GetAllTriangles());
            side2.AddTriangles(side1Discarded);
        }
예제 #3
0
        /**
         * Returns geometry corresponding to volume that is occupied by @a,
         * but not by @b.
         */
        public static BSPTree Subtract(BSPTree a, BSPTree b)
        {
            BSPTree aClone = a.Clone();
            BSPTree bClone = b.Clone();

            float startTime = Time.realtimeSinceStartup;

            bClone.Invert();
            bClone.ClipByTree(a, false);
            aClone.ClipByTree(b);
            aClone.AddTriangles(bClone.GetAllTriangles());

            return(aClone);
        }
예제 #4
0
        /**
         * Returns geometry corresponding to volume @a that is divided into
         * two separate pieces by @b. Return results in the form of two BSPTree
         * instances: @side and @side2.
         */
        public static void Slice(BSPTree a, BSPTree b, out BSPTree side1, out BSPTree side2)
        {
            side1 = a.Clone();
            BSPTree bClone = b.Clone();

            List<Triangle> side1Discarded = new List<Triangle>();

            bClone.Invert ();
            bClone.ClipByTree (a, false);
            side1.ClipByTree (b, true, side1Discarded);
            side1.AddTriangles(bClone.GetAllTriangles());

            bClone.Invert();
            side2 = new BSPTree();
            side2.AddTriangles(bClone.GetAllTriangles());
            side2.AddTriangles(side1Discarded);
        }