public static void SaveMesh(string dataName, MTMeshData data) { string path = string.Format("{0}/{1}/{1}_{2}.bytes", s_DataPath, dataName, data.meshId); FileHelper.CreateDirctory(path); if (FileHelper.IsExists(path)) { FileHelper.DeleteFile(path); } FileStream stream = File.Open(path, FileMode.Create); //lods byte[] uBuff = BitConverter.GetBytes(data.lods.Length); stream.Write(uBuff, 0, uBuff.Length); foreach (var lod in data.lods) { //vertices uBuff = BitConverter.GetBytes(lod.vertices.Length); stream.Write(uBuff, 0, uBuff.Length); foreach (var v in lod.vertices) { WriteVector3(stream, v); } //normals uBuff = BitConverter.GetBytes(lod.normals.Length); stream.Write(uBuff, 0, uBuff.Length); foreach (var n in lod.normals) { WriteVector3(stream, n); } //uvs uBuff = BitConverter.GetBytes(lod.uvs.Length); stream.Write(uBuff, 0, uBuff.Length); foreach (var uv in lod.uvs) { WriteVector2(stream, uv); } //faces uBuff = BitConverter.GetBytes(lod.faces.Length); stream.Write(uBuff, 0, uBuff.Length); foreach (var face in lod.faces) { uBuff = BitConverter.GetBytes(face); stream.Write(uBuff, 0, uBuff.Length); } } stream.Close(); }
public void Update() { if (IsDone) { return; } mesh[curIdx] = new MTMeshData(curIdx, scanners[0].Trees[curIdx].Center); mesh[curIdx].lods = new MTMeshData.LOD[scanners.Length]; for (int lod = 0; lod < scanners.Length; ++lod) { mesh[curIdx].lods[lod] = new MTMeshData.LOD(); RunTessellation(scanners[lod].Trees[curIdx].Vertices, mesh[curIdx].lods[lod]); } //update idx ++curIdx; }