示例#1
0
        /// <summary>
        /// Crear a partir de un mesh
        /// </summary>
        public static TgcTriangleArray fromMesh(TgcMesh mesh)
        {
            TgcTriangleArray triangleArray = new TgcTriangleArray();

            Vector3[] vertices = mesh.getVertexPositions();
            int triCount = vertices.Length / 3;
            List<TgcTriangle> triangles = new List<TgcTriangle>(triCount);
            for (int i = 0; i < triCount; i++)
            {
                Vector3 v1 = vertices[i * 3];
                Vector3 v2 = vertices[i * 3 + 1];
                Vector3 v3 = vertices[i * 3 + 2];

                TgcTriangle t = new TgcTriangle();
                t.A = v1;
                t.B = v2;
                t.C = v3;
                t.Color = Color.Red;
                t.updateValues();
                triangles.Add(t);
            }

            triangleArray.triangles.AddRange(triangles);
            return triangleArray;
        }
        /// <summary>
        /// Crear a partir de un mesh
        /// </summary>
        public static TgcTriangleArray fromMesh(TgcMesh mesh)
        {
            TgcTriangleArray triangleArray = new TgcTriangleArray();

            Vector3[]          vertices  = mesh.getVertexPositions();
            int                triCount  = vertices.Length / 3;
            List <TgcTriangle> triangles = new List <TgcTriangle>(triCount);

            for (int i = 0; i < triCount; i++)
            {
                Vector3 v1 = vertices[i * 3];
                Vector3 v2 = vertices[i * 3 + 1];
                Vector3 v3 = vertices[i * 3 + 2];

                TgcTriangle t = new TgcTriangle();
                t.A     = v1;
                t.B     = v2;
                t.C     = v3;
                t.Color = Color.Red;
                t.updateValues();
                triangles.Add(t);
            }

            triangleArray.triangles.AddRange(triangles);
            return(triangleArray);
        }