Ejemplo n.º 1
0
        public static HEMesh TestCreate()
        {
            var points = new List <Vector3D>()
            {
                new Vector3D(0, 0, 0), new Vector3D(100, 0, 0), new Vector3D(0, 100, 0), new Vector3D(100, 100, 0),
                new Vector3D(0, 0, 100), new Vector3D(100, 0, 100), new Vector3D(0, 100, 100), new Vector3D(100, 100, 100),
            };

            var indice = new List <int>()
            {
                0, 2, 1, 1, 2, 3,
                4, 5, 7, 4, 7, 6,
                0, 4, 2, 4, 6, 2,
                0, 1, 4, 1, 5, 4,
                1, 3, 7, 1, 7, 5,
                3, 2, 7, 2, 6, 7,
            };

            var mesh = new HEMesh();

            foreach (var p in points)
            {
                mesh.AddVertex(p);
            }

            for (int i = 0; i < indice.Count; i += 3)
            {
                mesh.AddFace(new IndexN <int>(indice[i], indice[i + 1], indice[i + 2]));
            }

            mesh.UpdateFaceNormals();
            mesh.UpdateVerticeNormals();
            return(mesh);
        }
Ejemplo n.º 2
0
        public static HEMesh ConvertTo(MeshData data)
        {
            if (data == null)
            {
                return(null);
            }
            var mesh = new HEMesh(data.Vertices.Count);

            foreach (var vertex in data.Vertices)
            {
                mesh.AddVertex(vertex.Position);
            }
            foreach (var face in data.Faces)
            {
                mesh.AddFace(face.Vertices);
            }
            mesh.UpdateFaceNormals();
            mesh.UpdateVerticeNormals();
            return(mesh);
        }