public void ParseTxt(string mapTxt) { using (StreamReader reader = new StreamReader(new FileStream(mapTxt, FileMode.Open, FileAccess.Read))) { string str = reader.ReadLine(); if (int.TryParse(str, out VertexNum)) { for (int i = 0; i < VertexNum; i++) { str = reader.ReadLine(); var tokens = str.Split(' '); Point3F vertex = new Point3F(); vertex.x = float.Parse(tokens[0]); vertex.y = float.Parse(tokens[1]); vertex.z = float.Parse(tokens[2]); Vertics.Add(vertex); } str = reader.ReadLine(); FaceNum = int.Parse(str); for (int i = 0; i < FaceNum; i++) { str = reader.ReadLine(); var tokens = str.Split(' '); MBWorldMapFace face = new MBWorldMapFace(); face.TerrainType = (MBWorldMapTerrainType)int.Parse(tokens[2]); face.indexFirst = int.Parse(tokens[7]); face.indexSecond = int.Parse(tokens[9]); face.indexThird = int.Parse(tokens[11]); Faces.Add(face); } if (AreTheAxisReversed()) { for (int i = 0; i < Vertics.Count; i++) { Vertics[i].y = Vertics[i].z; Vertics[i].z = Vertics[i].y * -1; } } } } }
public void Load(DataStreamPtr reader) { findex = MBOgreUtil.LoadInt32(reader); rot = MBOgreUtil.LoadPoint3F(reader); }
public void Load(BinaryReader reader) { findex = MBUtil.LoadInt32(reader); rot = MBUtil.LoadPoint3F(reader); }
public void Load(BinaryReader reader, string str = null) { string firstWord = null; if (string.IsNullOrEmpty(str)) { firstWord = MBUtil.LoadString(reader); } else { faces = new List <List <int> >(); firstWord = str; if (firstWord == "manifold") { type = Type.MANIFOLD; MBUtil.LoadVector(reader, ref pos); int k = MBUtil.LoadInt32(reader); for (int i = 0; i < k; i++) { ori = MBUtil.LoadInt32(reader); int h = MBUtil.LoadInt32(reader); List <int> v = new List <int>(); for (int j = 0; j < h; j++) { int pp = MBUtil.LoadInt32(reader); v.Add(pp); } faces.Add(v); } } else if (firstWord == "capsule") { type = Type.CAPSULE; radius = MBUtil.LoadFloat(reader); center = MBUtil.LoadPoint3F(reader); dir = MBUtil.LoadPoint3F(reader); flags = MBUtil.LoadUInt32(reader); } else if (firstWord == "sphere") { type = Type.SPHERE; radius = MBUtil.LoadFloat(reader); center = MBUtil.LoadPoint3F(reader); flags = MBUtil.LoadUInt32(reader); } else if (firstWord == "face") { type = Type.FACE; MBUtil.LoadVector(reader, ref pos); int k = pos.Count; List <int> aface = new List <int>(); for (int i = 0; i < k; i++) { aface.Add(i); } faces.Add(aface); flags = MBUtil.LoadUInt32(reader); } else { Console.WriteLine(string.Format("Unknown body (collision mesh) type `{0}`\n", firstWord)); } } }