private void btn_load_Click(object sender, EventArgs e) { setButtons(false); String filePath = tb_path.Text; file = filePath; String extention = Path.GetExtension(filePath); List <Mesh> renderableMeshes = new List <Mesh>(); drawString = "File: " + file; updateBitmap(drawString); //Try and find the model file if (extention == ".mmh") { GFF tempGFF = new GFF(filePath); ModelHierarchy mh = new ModelHierarchy(tempGFF); currentlyShowing = Showing.Model; meshes = mh.mesh.toModel().meshes; setButtons(true); if (meshes.Length > 0) { setMeshNum(0); } } else if (extention == ".msh") { GFF tempGFF = new GFF(filePath); ModelMesh mm = new ModelMesh(tempGFF); currentlyShowing = Showing.Model; meshes = mm.toModel().meshes; setButtons(true); if (meshes.Length > 0) { setMeshNum(0); } } else if (extention == ".tga") { texture = new Targa(filePath); currentlyShowing = Showing.Texture; } else if (extention == ".lvl") { level = new LevelScene(filePath); currentlyShowing = Showing.Level; List <Patch> patchList = new List <Patch>(); List <Triangle> tris = new List <Triangle>(); foreach (ModelInstance m in level.lightmapModels) { for (int i = 0; i < m.meshes.Length; i++) { if (m.meshes[i].isLightmapped) { //Make the lightmap LightMap temp = new LightMap(m, m.meshes[i]); //For each patch instance in the lightmap foreach (Patch p in temp.patches) { patchList.Add(p); } } } if (m.baseModel.castsShadows) { tris.AddRange(m.tris); } } octree = new Octree(tris); patches = patchList.ToArray(); } else if (extention == ".xml") { level = new XMLScene(filePath); currentlyShowing = Showing.Level; List <Patch> patchList = new List <Patch>(); List <Triangle> tris = new List <Triangle>(); foreach (ModelInstance m in level.lightmapModels) { for (int i = 0; i < m.meshes.Length; i++) { if (m.meshes[i].isLightmapped) { //Make the lightmap LightMap temp = new LightMap(m, m.meshes[i]); //For each patch instance in the lightmap foreach (Patch p in temp.patches) { patchList.Add(p); } } } if (m.baseModel.castsShadows) { tris.AddRange(m.tris); } } octree = new Octree(tris); patches = patchList.ToArray(); } //If its not the right type of file then print an error else { drawString = "This is not a valid model (.mmh or .msh), texture (.tga), level (.lvl), or scene (.xml) file!"; } refreshView(); }
private void btn_load_Click(object sender, EventArgs e) { setButtons(false); String filePath = tb_path.Text; file = filePath; String extention = Path.GetExtension(filePath); List<Mesh> renderableMeshes = new List<Mesh>(); drawString = "File: " + file; updateBitmap(drawString); //Try and find the model file if (extention == ".mmh") { GFF tempGFF = new GFF(filePath); ModelHierarchy mh = new ModelHierarchy(tempGFF); currentlyShowing = Showing.Model; meshes = mh.mesh.toModel().meshes; setButtons(true); if (meshes.Length > 0) { setMeshNum(0); } } else if (extention == ".msh") { GFF tempGFF = new GFF(filePath); ModelMesh mm = new ModelMesh(tempGFF); currentlyShowing = Showing.Model; meshes = mm.toModel().meshes; setButtons(true); if (meshes.Length > 0) { setMeshNum(0); } } else if (extention == ".tga") { texture = new Targa(filePath); currentlyShowing = Showing.Texture; } else if (extention == ".lvl") { level = new LevelScene(filePath); currentlyShowing = Showing.Level; List<Patch> patchList = new List<Patch>(); List<Triangle> tris = new List<Triangle>(); foreach (ModelInstance m in level.lightmapModels) { for (int i = 0; i < m.meshes.Length; i++) { if (m.meshes[i].isLightmapped) { //Make the lightmap LightMap temp = new LightMap(m, m.meshes[i]); //For each patch instance in the lightmap foreach (Patch p in temp.patches) { patchList.Add(p); } } } if (m.baseModel.castsShadows) tris.AddRange(m.tris); } octree = new Octree(tris); patches = patchList.ToArray(); } else if (extention == ".xml") { level = new XMLScene(filePath); currentlyShowing = Showing.Level; List<Patch> patchList = new List<Patch>(); List<Triangle> tris = new List<Triangle>(); foreach (ModelInstance m in level.lightmapModels) { for (int i = 0; i < m.meshes.Length; i++) { if (m.meshes[i].isLightmapped) { //Make the lightmap LightMap temp = new LightMap(m, m.meshes[i]); //For each patch instance in the lightmap foreach (Patch p in temp.patches) { patchList.Add(p); } } } if (m.baseModel.castsShadows) tris.AddRange(m.tris); } octree = new Octree(tris); patches = patchList.ToArray(); } //If its not the right type of file then print an error else { drawString = "This is not a valid model (.mmh or .msh), texture (.tga), level (.lvl), or scene (.xml) file!"; } refreshView(); }