public void WriteCurrentMeshOBJ()
 {
     if (objFilenameField.text == "")
     {
         Debug.Log("file name empty");
         return;
     }
     OBJWriter.ExportToOBJ(currentMesh.mesh, objFilenameField.text);
 }
예제 #2
0
        public static void WriteTestOutputMesh(IMesh mesh, string sFilename)
        {
            OBJWriter writer = new OBJWriter();
            var       s      = new System.IO.StreamWriter(Program.TEST_OUTPUT_PATH + sFilename, false);

            writer.Write(s, new List <WriteMesh> {
                new WriteMesh(mesh)
            }, new WriteOptions()
            {
                bWriteGroups = true
            });
            s.Close();
        }
예제 #3
0
        public static void WriteTestOutputMesh(IMesh mesh, string sFilename, bool write_groups = true, bool write_vtxcolors = false, bool write_vtxuv = false)
        {
            OBJWriter writer = new OBJWriter();
            var       s      = new System.IO.StreamWriter(Program.TEST_OUTPUT_PATH + sFilename, false);

            writer.Write(s, new List <WriteMesh> {
                new WriteMesh(mesh)
            },
                         new WriteOptions()
            {
                bPerVertexNormals = true, bWriteGroups = write_groups, bPerVertexColors = write_vtxcolors, bPerVertexUVs = write_vtxuv
            });
            s.Close();
        }
예제 #4
0
        public static void WriteDebugMesh(IMesh mesh, string sfilename)
        {
            OBJWriter        writer = new OBJWriter();
            var              s      = new System.IO.StreamWriter(WRITE_PATH + sfilename, false);
            List <WriteMesh> meshes = new List <WriteMesh>()
            {
                new WriteMesh(mesh)
            };

            writer.Write(s, meshes, new WriteOptions()
            {
                bWriteGroups = true
            });
            s.Close();
        }
예제 #5
0
        public static void WriteDebugMesh(IMesh mesh, string sfilename, bool write_groups = true, bool write_vtxcolors = false, bool write_vtxuv = false)
        {
            OBJWriter        writer = new OBJWriter();
            var              s      = new System.IO.StreamWriter(WRITE_PATH + sfilename, false);
            List <WriteMesh> meshes = new List <WriteMesh>()
            {
                new WriteMesh(mesh)
            };

            writer.Write(s, meshes, new WriteOptions()
            {
                bWriteGroups = write_groups, bPerVertexColors = write_vtxcolors, bPerVertexUVs = write_vtxuv
            });
            s.Close();
        }
예제 #6
0
        public static void WriteDebugMeshes(List <IMesh> meshes, string sfilename)
        {
            OBJWriter        writer = new OBJWriter();
            var              s      = new System.IO.StreamWriter(WRITE_PATH + sfilename, false);
            List <WriteMesh> wm     = new List <WriteMesh>();

            foreach (var m in meshes)
            {
                wm.Add(new WriteMesh(m));
            }
            writer.Write(s, wm, new WriteOptions()
            {
                bWriteGroups = true
            });
            s.Close();
        }
예제 #7
0
        public static void WriteDebugMeshes(List <IMesh> meshes, string sfilename, bool write_groups = true, bool write_vtxcolors = false, bool write_vtxuv = false)
        {
            OBJWriter        writer = new OBJWriter();
            var              s      = new System.IO.StreamWriter(WRITE_PATH + sfilename, false);
            List <WriteMesh> wm     = new List <WriteMesh>();

            foreach (var m in meshes)
            {
                wm.Add(new WriteMesh(m));
            }
            writer.Write(s, wm, new WriteOptions()
            {
                bCombineMeshes = false, bWriteGroups = write_groups, bPerVertexColors = write_vtxcolors, bPerVertexUVs = write_vtxuv
            });
            s.Close();
        }
예제 #8
0
        public static void test_local_param()
        {
            //DMesh3 mesh = TestUtil.LoadTestInputMesh("plane_250v.obj");
            //DMesh3 mesh = TestUtil.LoadTestInputMesh("hemisphere_nicemesh_3k.obj");
            DMesh3 mesh = TestUtil.LoadTestInputMesh("bunny_open_base.obj");

            mesh.EnableVertexUVs(Vector2f.Zero);

            DMeshAABBTree3 spatial = new DMeshAABBTree3(mesh);

            spatial.Build();

            //int tid = spatial.FindNearestTriangle(Vector3d.Zero);
            //Frame3f seedF = new Frame3f(Vector3d.Zero, Vector3d.AxisY);
            int     tid   = 3137;
            Frame3f seedF = mesh.GetTriFrame(tid);

            Index3i seedNbrs = mesh.GetTriangle(tid);

            MeshLocalParam param = new MeshLocalParam(mesh.MaxVertexID,
                                                      mesh.GetVertexf, mesh.GetVertexNormal, mesh.VtxVerticesItr);

            param.ComputeToMaxDistance(seedF, seedNbrs, float.MaxValue);

            float fR = param.MaxUVDistance;

            param.TransformUV(0.5f / fR, 0.5f * Vector2f.One);

            param.ApplyUVs((vid, uv) => { mesh.SetVertexUV(vid, uv); });

            TestUtil.SetColorsFromScalarF(mesh, (vid) => { return(param.GetUV(vid).Distance(0.5f * Vector2f.One)); }, new Vector2f(0, 0.5f));

            OBJWriter        writer = new OBJWriter();
            var              s      = new System.IO.StreamWriter(Program.TEST_OUTPUT_PATH + "mesh_local_param.obj", false);
            List <WriteMesh> wm     = new List <WriteMesh>()
            {
                new WriteMesh(mesh)
            };
            WriteOptions opt = new WriteOptions()
            {
                bCombineMeshes  = false, bWriteGroups = false, bPerVertexColors = true, bPerVertexUVs = true,
                AsciiHeaderFunc = () => { return("mttllib checkerboard.mtl\r\nusemtl checkerboard\r\n"); }
            };

            writer.Write(s, wm, opt);
            s.Close();
        }
예제 #9
0
        public static void WriteTestOutputMeshes(List <IMesh> meshes, string sFilename, bool write_groups = true, bool write_vtxcolors = false, bool write_vtxuv = false)
        {
            OBJWriter        writer = new OBJWriter();
            var              s      = new System.IO.StreamWriter(Program.TEST_OUTPUT_PATH + sFilename, false);
            List <WriteMesh> wm     = new List <WriteMesh>();

            foreach (var m in meshes)
            {
                wm.Add(new WriteMesh(m));
            }
            WriteOptions opt = new WriteOptions()
            {
                bCombineMeshes = false, bPerVertexNormals = true, bWriteGroups = write_groups, bPerVertexColors = write_vtxcolors, bPerVertexUVs = write_vtxuv
            };

            writer.Write(s, wm, opt);
            s.Close();
        }
예제 #10
0
 private void saveObj(string filename, List <WriteMesh> meshes)
 {
     using (TextWriter writer = File.CreateText(filename)) {
         OBJWriter objWriter = new OBJWriter();
         try {
             WriteOptions opts = new WriteOptions()
             {
                 bWriteBinary      = false,
                 bPerVertexColors  = meshes[0].Mesh.HasVertexColors,
                 bPerVertexNormals = meshes[0].Mesh.HasVertexNormals,
                 bPerVertexUVs     = meshes[0].Mesh.HasVertexUVs
             };
             objWriter.Write(writer, meshes, opts);
         } catch (Exception e) when(
             e is UnauthorizedAccessException ||
             e is DirectoryNotFoundException ||
             e is FileNotFoundException ||
             e is NotSupportedException
             )
         {
             Debug.LogError("Failed to Write" + filename + " : " + e.ToString());
         }
     }
 }
예제 #11
0
        public static void ExportModelToOBJ(ModelBase model, string fileName)
        {
            AbstractModelWriter objWriter = new OBJWriter(model, fileName);

            objWriter.WriteModel();
        }
예제 #12
0
        public void ExportJunctureToOBJ()
        {
            string objName = name + ".obj";

            OBJWriter.ExportToOBJ(mFilter.mesh, objName);
        }