void LoadMesh() { string[] line; mesh = new Md5Mesh(); int i; while ((line = ReadLineTokens()) != null && line[0] != "}") { switch (line[0]) { case "shader": mesh.Shader = line[1]; break; case "numverts": mesh.Vertices = new Md5Vertex[int.Parse(line[1])]; break; case "vert": i = int.Parse(line[1]); mesh.Vertices[i].TextureU = float.Parse(line[2]); mesh.Vertices[i].TextureV = float.Parse(line[3]); mesh.Vertices[i].WeightIndex = int.Parse(line[4]); mesh.Vertices[i].WeightCount = int.Parse(line[5]); break; case "numtris": mesh.Triangles = new Md5Triangle[int.Parse(line[1])]; break; case "tri": i = int.Parse(line[1]); mesh.Triangles[i][0] = int.Parse(line[2]); mesh.Triangles[i][1] = int.Parse(line[3]); mesh.Triangles[i][2] = int.Parse(line[4]); break; case "numweights": mesh.Weights = new Md5Weight[int.Parse(line[1])]; break; case "weight": i = int.Parse(line[1]); mesh.Weights[i].JointIndex = int.Parse(line[2]); mesh.Weights[i].Value = float.Parse(line[3]); if (Flip) { mesh.Weights[i].Position = new Vector3(float.Parse(line[4]), float.Parse(line[6]), float.Parse(line[5])); } else { mesh.Weights[i].Position = new Vector3(float.Parse(line[4]), float.Parse(line[5]), float.Parse(line[6])); } break; case "//": try { mesh.Name = line[2]; } catch (Exception) { } break; } } for (i = 0;; ++i) { if (model.Meshes[i] == null) { model.Meshes[i] = mesh; break; } } }
void LoadMesh() { string[] line; mesh = new Md5Mesh(); int i; while ((line = ReadLineTokens()) != null && line[0] != "}") { switch (line[0]) { case "shader": mesh.Shader = line[1]; break; case "numverts": mesh.Vertices = new Md5Vertex[int.Parse(line[1])]; break; case "vert": i=int.Parse(line[1]); mesh.Vertices[i].TextureU = float.Parse(line[2]); mesh.Vertices[i].TextureV = float.Parse(line[3]); mesh.Vertices[i].WeightIndex = int.Parse(line[4]); mesh.Vertices[i].WeightCount = int.Parse(line[5]); break; case "numtris": mesh.Triangles = new Md5Triangle[int.Parse(line[1])]; break; case "tri": i = int.Parse(line[1]); mesh.Triangles[i][0] = int.Parse(line[2]); mesh.Triangles[i][1] = int.Parse(line[3]); mesh.Triangles[i][2] = int.Parse(line[4]); break; case "numweights": mesh.Weights = new Md5Weight[int.Parse(line[1])]; break; case "weight": i = int.Parse(line[1]); mesh.Weights[i].JointIndex = int.Parse(line[2]); mesh.Weights[i].Value = float.Parse(line[3]); if(Flip) mesh.Weights[i].Position = new Vector3(float.Parse(line[4]), float.Parse(line[6]), float.Parse(line[5])); else mesh.Weights[i].Position = new Vector3(float.Parse(line[4]), float.Parse(line[5]), float.Parse(line[6])); break; case "//": try { mesh.Name = line[2]; } catch (Exception) { } break; } } for(i=0;;++i) { if (model.Meshes[i] == null) { model.Meshes[i] = mesh; break; } } }