示例#1
0
        static void Main(string[] args)
        {
            var inputFilename = args[0];
            var outputFilename = args.Length < 2 ? "output.mesh" : args[1];

            PlyFile ply;
            using(var inputFile = File.OpenText(inputFilename)) {
                ply = new PlyParser().Parse(inputFile);
            }

            var vertex = GetRequiredElementType(ply, "vertex");
            var face = GetRequiredElementType(ply, "face");

            VerifySimplePropertiesExist(vertex, "x", "y", "z");
            VerifyListPropertiesExist(face, "vertex_indices");

            var vertices =
                ply.Elements[vertex]
                    .Select(el => new Point(
                        (float)el.GetValue("x"),
                        (float)el.GetValue("y"),
                        (float)el.GetValue("z")));

            var triangles = from el in ply.Elements[face]
                            let indices = (object[]) el.GetValue("vertex_indices")
                            select new MeshTriangle((int) indices[0], (int) indices[1], (int) indices[2], null); // HACK

            var mesh = new Mesh(vertices, triangles);

            using(var outputFile = File.Create(outputFilename)) {
                new MeshSerializer().Serialize(outputFile, mesh);
            }
        }
示例#2
0
        public BvhNode Build(Mesh mesh)
        {
            var rootBounds = mesh.GetBoundingBox();

            var splitAxis = rootBounds.Extents.LongestAxis;
            var splitAxisLength = rootBounds.Extents[splitAxis];

            //var splitPlane = splitAxisLength / 2;

            //return new BvhNode();
            throw new NotImplementedException();
        }
示例#3
0
 public void Serialize(Stream stream, Mesh mesh)
 {
     var formatter = CreateFormatter();
     formatter.Serialize(stream, mesh);
 }
示例#4
0
 public MeshTriangle(int aIndex, int bIndex, int cIndex, Mesh mesh)
 {
     AIndex = aIndex;
     BIndex = bIndex;
     CIndex = cIndex;
 }