Пример #1
0
        public static void Import(ref MeshModel mesh)
        {
            AbstractMeshImporter import;
            String ext = Path.GetExtension(mesh.FilePath);
            if (!s_importers.TryGetValue(Path.GetExtension(mesh.FilePath), out import)) {
                throw new IOException("MeshImport not found for this file type. Extension: " + ext);
            }
            import.Import(ref mesh);
            //float len = Math.Abs(mesh.BoundBox.PMax.Y - mesh.BoundBox.PMin.Y);
            //mesh.Scale(50 / len);
            //mesh.Translate(-mesh.BoundBox.Center.X, -mesh.BoundBox.Center.Y, -mesh.BoundBox.Center.Z);

            //manager = new NoAccerelationStructure<MeshTriangle>(mesh.Triangles);
            manager = new Octree<MeshTriangle>(mesh.BoundBox, mesh.Triangles);
            //manager = new TriangleKDTree(new List<MeshTriangle>(mesh.Triangles));
            mesh.AccelerationManager = manager;
            DateTime antes = DateTime.Now;
            if (OnInitBuild != null) {
                OnInitBuild(mesh);
            }
            manager.Optimize();
            if (OnEndBuild != null) {
                OnEndBuild(DateTime.Now.Subtract(antes));
            }
        }
Пример #2
0
        public static void Import(ref MeshModel mesh)
        {
            AbstractMeshImporter import;
            String ext = Path.GetExtension(mesh.FilePath);

            if (!s_importers.TryGetValue(Path.GetExtension(mesh.FilePath), out import))
            {
                throw new IOException("MeshImport not found for this file type. Extension: " + ext);
            }
            import.Import(ref mesh);
            //float len = Math.Abs(mesh.BoundBox.PMax.Y - mesh.BoundBox.PMin.Y);
            //mesh.Scale(50 / len);
            //mesh.Translate(-mesh.BoundBox.Center.X, -mesh.BoundBox.Center.Y, -mesh.BoundBox.Center.Z);

            //manager = new NoAccerelationStructure<MeshTriangle>(mesh.Triangles);
            manager = new Octree <MeshTriangle>(mesh.BoundBox, mesh.Triangles);
            //manager = new TriangleKDTree(new List<MeshTriangle>(mesh.Triangles));
            mesh.AccelerationManager = manager;
            DateTime antes = DateTime.Now;

            if (OnInitBuild != null)
            {
                OnInitBuild(mesh);
            }
            manager.Optimize();
            if (OnEndBuild != null)
            {
                OnEndBuild(DateTime.Now.Subtract(antes));
            }
        }