private void LoadRoomModels(string filePath) { // Search the bmd and bdl folders for valid model names. Then search for a matching brk and btk for those models. string[] modelNames = new[] { "model", "model1", "model2", "model3" }; string[] folderNames = new[] { "bmd", "bdl" }; bool[] validModels = new bool[modelNames.Length]; CategoryDOMNode col_category = new CategoryDOMNode("Models", m_world); col_category.SetParent(this); foreach (var subFolder in folderNames) { string folderPath = Path.Combine(filePath, subFolder); foreach (var modelName in modelNames) { J3D mesh = LoadModel(folderPath, modelName); if (mesh != null) { J3DNode j3d_node = new J3DNode(mesh, m_world); j3d_node.SetParent(col_category); } } } }
public void OnRequestExportCollision() { View.CollisionExportWindow window = new View.CollisionExportWindow(MainWorld.Map); window.FileSelector.IsFilePicker = true; window.FileSelector.IsFileSaver = true; window.FileSelector.FileExtension = "dae"; if (window.ShowDialog() == true) { if (window.FileName == "") { MessageBox.Show("No filename entered!", "Collision Export Error"); return; } if (window.SceneNumber == -1 || window.SceneNumber > MainWorld.Map.SceneList.Count - 1) { MessageBox.Show("Invalid room number entered!", "Collision Export Error"); return; } WRoom room = GetRoomFromDropdownIndex(window.SceneNumber); CategoryDOMNode colCategory = room.GetChildrenOfType <CategoryDOMNode>().Find(x => x.Name == "Collision"); WCollisionMesh mesh = colCategory.Children[0] as WCollisionMesh; mesh.ToDAEFile(window.FileName); MessageBox.Show("Successfully saved collision to file.", "Success"); } }
public void OnRequestImportCollision() { View.CollisionImportWindow window = new View.CollisionImportWindow(MainWorld.Map); window.FileSelector.IsFilePicker = true; if (window.ShowDialog() == true) { if (window.FileName == "" || !File.Exists(window.FileName)) { MessageBox.Show("Invalid filename entered!", "Collision Import Error"); return; } if (window.SceneNumber == -1 || window.SceneNumber > MainWorld.Map.SceneList.Count - 1) { MessageBox.Show("Invalid room number entered!", "Collision Import Error"); return; } string ext = Path.GetExtension(window.FileName); if (ext != ".dae" && ext != ".dzb") { MessageBox.Show($"Input file { window.FileName } was not a supported format.", "Collision Import Error"); return; } WRoom room = GetRoomFromDropdownIndex(window.SceneNumber); CategoryDOMNode colCategory = room.GetChildrenOfType <CategoryDOMNode>().Find(x => x.Name == "Collision"); List <WCollisionMesh> originalMeshList = room.GetChildrenOfType <WCollisionMesh>(); int origRootRoomTableIndex = 0; if (originalMeshList.Count > 0) { origRootRoomTableIndex = originalMeshList[0].RootNode.RoomTableIndex; } WCollisionMesh newMesh = new WCollisionMesh(MainWorld, window.FileName, room.RoomIndex, origRootRoomTableIndex); newMesh.Name = "room"; if (originalMeshList.Count > 0) { originalMeshList[0].ReleaseResources(); colCategory.Children.Remove(originalMeshList[0]); if (MainWorld.CollisionMode.ActiveCollisionMesh == originalMeshList[0]) { newMesh.IsRendered = true; MainWorld.CollisionMode.ClearSelection(); MainWorld.CollisionMode.ActiveCollisionMesh = newMesh; } } colCategory.Children.Add(newMesh); } }
public void ExportVisualMeshFromRoom(View.VisualMeshExportWindow exportWindow) { WRoom room = GetRoomFromDropdownIndex(exportWindow.SceneNumber - 1); CategoryDOMNode meshCategory = room.GetChildrenOfType <CategoryDOMNode>().Find(x => x.Name == "Models"); string newMeshName = "model"; if (exportWindow.SlotNumber > 0) { newMeshName += exportWindow.SlotNumber; } ExportVisualMeshToCategory(exportWindow, meshCategory, newMeshName); }
private void ImportVisualMeshToRoom(View.VisualMeshImportWindow importWindow) { WRoom room = GetRoomFromDropdownIndex(importWindow.SceneNumber - 1); CategoryDOMNode meshCategory = room.GetChildrenOfType <CategoryDOMNode>().Find(x => x.Name == "Models"); string newMeshName = "model"; if (importWindow.SlotNumber > 0) { newMeshName += importWindow.SlotNumber; } ImportVisualMeshToCategory(importWindow, meshCategory, newMeshName); }
protected virtual void LoadLevelCollisionFromFile(string filePath) { if (!File.Exists(filePath)) { return; } CategoryDOMNode col_category = new CategoryDOMNode("Collision", m_world); col_category.SetParent(this); WCollisionMesh collision = new WCollisionMesh(m_world, filePath); collision.SetParent(col_category); }
public override void Load(string filePath) { base.Load(filePath); foreach (var folder in Directory.GetDirectories(filePath)) { string folderName = Path.GetFileNameWithoutExtension(folder); switch (folderName.ToLower()) { case "dzs": { string fileName = Path.Combine(folder, "stage.dzs"); if (File.Exists(fileName)) { LoadLevelEntitiesFromFile(fileName); } } break; //case "bmd": case "bdl": { LoadStageModels(folder); } break; case "dat": { string fileName = Path.Combine(folder, "event_list.dat"); if (File.Exists(fileName)) { WEventList evlist = new WEventList(m_world, fileName); CategoryDOMNode evCategory = new CategoryDOMNode("Event List", m_world); evCategory.SetParent(this); evlist.SetParent(evCategory); } } break; } } }
private void ImportVisualMeshToStage(View.VisualMeshImportWindow importWindow) { WStage stage = GetStage(); if (importWindow.SlotNumber == 4) { ImportVisualMeshToSkybox(importWindow, stage); } else { CategoryDOMNode meshCategory = stage.GetChildrenOfType <CategoryDOMNode>().Find(x => x.Name == "Models"); string meshName = ""; switch (importWindow.SlotNumber) { case 0: meshName = "vr_sky"; break; case 4: meshName = "door10"; break; case 5: meshName = "door20"; break; case 6: meshName = "key10"; break; case 7: meshName = "stop10"; break; } ImportVisualMeshToCategory(importWindow, meshCategory, meshName); } }
private void LoadStageModels(string filepath) { m_skybox = new WSkyboxNode(m_world); m_skybox.LoadSkyboxModelsFromFixedModelList(filepath); m_skybox.SetParent(this); CategoryDOMNode meshCategory = new CategoryDOMNode("Models", m_world); meshCategory.SetParent(this); string[] files = Directory.GetFiles(filepath, "*.bdl"); foreach (string str in files) { J3D mesh = LoadModel(filepath, Path.GetFileNameWithoutExtension(str)); if (mesh != null) { J3DNode j3d_node = new J3DNode(mesh, m_world, str); j3d_node.IsRendered = false; j3d_node.SetParent(meshCategory); } } }
private void ExportVisualMeshToCategory(View.VisualMeshExportWindow exportWindow, CategoryDOMNode category, string meshName) { List <J3DNode> meshList = category.GetChildrenOfType <J3DNode>(); J3DNode meshNode = meshList.Find(x => x.Name == meshName); if (meshNode == null) { MessageBox.Show("No mesh in the selected slot!", "Mesh Export Error"); return; } ExportVisualMesh(exportWindow, meshNode.Filename); }
private void ImportVisualMeshToCategory(View.VisualMeshImportWindow importWindow, CategoryDOMNode category, string meshName) { List <J3DNode> meshList = category.GetChildrenOfType <J3DNode>(); bool isBDL = true; J3DNode oldMeshNode = meshList.Find(x => x.Name == meshName); if (oldMeshNode != null) { category.Children.Remove(oldMeshNode); isBDL = oldMeshNode.Model.StudioType == "bdl4"; } string fileExt = Path.GetExtension(importWindow.FileName); string loadFilename = ""; if (fileExt == ".bmd" || fileExt == ".bdl") { loadFilename = importWindow.FileName; } else { loadFilename = ImportVisualMesh(importWindow, isBDL); } JStudio.J3D.J3D newMesh = WResourceManager.LoadResource(loadFilename); newMesh.Name = meshName; J3DNode newNode = new J3DNode(newMesh, MainWorld, loadFilename); category.Children.Add(newNode); }