예제 #1
0
        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);
            }
        }
예제 #2
0
        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");
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        private void OnRequestImportIsland()
        {
            View.IslandImportWindow window = new View.IslandImportWindow(MainWorld.Map);
            window.FileSelector.IsFilePicker  = true;
            window.FileSelector.FileExtension = "arc";

            if (window.ShowDialog() == true)
            {
                if (window.FileName == "")
                {
                    MessageBox.Show("No filename entered!", "Island Import Error");
                    return;
                }

                if (window.SceneNumber == -1)
                {
                    MessageBox.Show("Invalid room number entered!", "Island Import Error");
                    return;
                }

                WRoom oldRoom = GetRoomFromDropdownIndex(window.SceneNumber);
                if (oldRoom != null)
                {
                    MainWorld.Map.SceneList.Remove(oldRoom);
                }

                List <WCollisionMesh> colList = oldRoom.GetChildrenOfType <WCollisionMesh>();

                if (colList.Count > 0)
                {
                    colList[0].ReleaseResources();
                }

                string tempMapPath = Path.Combine(GetStageDumpPath(), Path.GetFileName(window.FileName));

                VirtualFilesystemDirectory archiveRoot = ArchiveUtilities.LoadArchive(window.FileName);
                if (archiveRoot == null)
                {
                    MessageBox.Show("Invalid archive selected!", "Island Import Error");
                    return;
                }

                string tempArcPath = $"{tempMapPath}\\{archiveRoot.Name}";

                if (!Directory.Exists(tempArcPath))
                {
                    Directory.CreateDirectory(tempMapPath);
                }

                DumpContents(archiveRoot, tempArcPath);

                WRoom newRoom = new WRoom(MainWorld, oldRoom.RoomIndex);
                newRoom.Load(tempArcPath);
                newRoom.RoomTransform = oldRoom.RoomTransform;
                newRoom.ApplyTransformToObjects();

                newRoom.Name            = "room" + oldRoom.RoomIndex;
                archiveRoot.Name        = "room" + oldRoom.RoomIndex;
                newRoom.SourceDirectory = archiveRoot;

                MainWorld.Map.SceneList.Add(newRoom);
            }
        }