Пример #1
0
        private void Start()
        {
            IntegrationTestManager testManager = new IntegrationTestManager();
            Mesh mesh = testManager.mesh;

            testManager.CreateBox();

            mesh.vertices.BuildVertices();
            mesh.triangles.BuildTriangles();

            ExportObj exportObj = new ExportObj();

            exportObj.vertices      = mesh.uMesh.vertices;
            exportObj.triangles     = mesh.triangles.triangles.ToArray();
            exportObj.materials     = mesh.materials.GetMaterials();
            exportObj.materialNames = mesh.materials.MaterialNames();
            exportObj.Save("Temp/test.obj");

            ImportObj importObj = new ImportObj();

            importObj.Load("Temp/test.obj");
            testManager.Assert(importObj.vertices.Count == 8);
            testManager.Assert(importObj.triangles.Count == 12 * 3);
            testManager.Assert(importObj.materialNames.Count == 12);
            testManager.Assert(importObj.materials.Count == 1);

            testManager.Assert(File.Exists("Temp/test.obj"));
            File.Delete("Temp/test.obj");
            testManager.Assert(File.Exists("Temp/test.mtl"));
            File.Delete("Temp/test.mtl");

            IntegrationTest.Pass(gameObject);
        }
Пример #2
0
        public void Load(string filePath = null)
        {
            if (filePath == null)
            {
                filePath = defaultFilename;
            }

            ImportObj importObj = new ImportObj();

            importObj.Load(filePath);
            lastFilePath = filePath;

            if (importObj.materials != null)
            {
                mesh.materials.SetMaterials(importObj.materials);
            }
            mesh.vertices.SetVertices(mesh.vertices.ListVertexOfVector3Array(importObj.vertices, importObj.uvs));
            mesh.triangles.triangles = importObj.triangles;
            mesh.materials.PopulateTriangleMaterialsByMaterialNames(importObj.materialNames);
            mesh.vertices.CreateVertexInstances();
            mesh.vertices.verticesChanged   = true;
            mesh.triangles.trianglesChanged = true;
            //mesh.GetComponent<AlignmentToolsController>().Load();
            //mesh.alignmentTools.UpdateAlignmentTools();
            //mesh.alignmentTools.SetActiveCollidersOnAlignmentTools(false);
            changedSinceLastSave = false;
        }