Ejemplo n.º 1
0
        internal static ThreeMfMesh ParseMesh(XElement element, Dictionary <int, ThreeMfResource> resourceMap)
        {
            if (element == null)
            {
                throw new ThreeMfParseException("Missing element <mesh>.");
            }

            var vertices = new List <ThreeMfVertex>();

            foreach (var vertexElement in element.Element(VerticesName).Elements(ThreeMfVertex.VertexName))
            {
                var vertex = ThreeMfVertex.ParseVertex(vertexElement);
                vertices.Add(vertex);
            }

            var mesh = new ThreeMfMesh();

            foreach (var triangleElement in element.Element(TrianglesName).Elements(ThreeMfTriangle.TriangleName))
            {
                var triangle = ThreeMfTriangle.ParseTriangle(triangleElement, vertices, resourceMap);
                mesh.Triangles.Add(triangle);
            }

            return(mesh);
        }
Ejemplo n.º 2
0
 public ThreeMfTriangle(ThreeMfVertex v1, ThreeMfVertex v2, ThreeMfVertex v3)
 {
     V1 = v1;
     V2 = v2;
     V3 = v3;
     PropertyResource = null;
     V1PropertyIndex  = null;
     V2PropertyIndex  = null;
     V3PropertyIndex  = null;
 }
Ejemplo n.º 3
0
        public ThreeMfVertex Transform(ThreeMfVertex v)
        {
            //                       [ M00 M01 M02 0.0 ]
            // [ v.X v.Y v.Z 1.0 ] * [ M10 M11 M12 0.0 ]
            //                       [ M20 M21 M22 0.0 ]
            //                       [ M30 M31 M32 1.0 ]

            var x = v.X * M00 + v.Y * M10 + v.Z * M20 + M30;
            var y = v.Y * M01 + v.Y * M11 + v.Z * M21 + M31;
            var z = v.Z * M02 + v.Y * M12 + v.Z * M22 + M32;

            return(new ThreeMfVertex(x, y, z));
        }