예제 #1
0
        public override void SetTimeOfDay(float timeOfDay)
        {
            base.SetTimeOfDay(timeOfDay);

            if (m_skybox == null)
            {
                return;
            }

            WRoom first_room = null;

            foreach (var node in m_world.Map.SceneList)
            {
                if (node is WRoom)
                {
                    first_room = (WRoom)node;
                    break;
                }
            }

            if (first_room == null || first_room.EnvironmentLighting == null)
            {
                return;
            }

            var envrData = GetChildrenOfType <EnvironmentLightingConditions>();

            var curLight = envrData[0].Lerp(EnvironmentLightingConditions.WeatherPreset.Default, true, timeOfDay);

            m_skybox.SetColors(curLight.SkyboxPalette);
        }
예제 #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 PostLoadProcessing(string mapDirectory, List <WRoom> mapRooms)
        {
            string dzsFilePath = Path.Combine(mapDirectory, "Stage/dzs/stage.dzs");

            if (File.Exists(dzsFilePath))
            {
                SceneDataLoader sceneData = new SceneDataLoader(dzsFilePath, m_world);
                // Load Room Translation info. Wind Waker stores collision and entities in world-space coordinates,
                // but models all of their rooms around 0,0,0. To solve this, there is a chunk labeled "MULT" which stores
                // the room model's translation and rotation.
                var multTable = sceneData.GetRoomTransformTable();
                if (mapRooms.Count != multTable.Count)
                {
                    Console.WriteLine("WStage: Mismatched number of entries in Mult Table ({0}) and number of loaded rooms ({1})!", multTable.Count, mapRooms.Count);
                }

                for (int i = 0; i < multTable.Count; i++)
                {
                    WRoom room = mapRooms.Find(x => x.RoomIndex == multTable[i].RoomNumber);
                    if (room != null)
                    {
                        room.RoomTransform = multTable[i];
                    }
                }

                // Load Room Memory Allocation info. How much extra memory do these rooms allocate?
                var allocTable = sceneData.GetRoomMemAllocTable();
                if (mapRooms.Count != allocTable.Count)
                {
                    Console.WriteLine("WStage: Mismatched number of entries in Meco Table ({0}) and number of loaded rooms ({1})!", allocTable.Count, mapRooms.Count);
                }

                for (int i = 0; i < allocTable.Count; i++)
                {
                    WRoom room = mapRooms.Find(x => allocTable[i].RoomIndex == x.RoomIndex);
                    if (room != null)
                    {
                        room.MemoryAllocation = allocTable[i].MemorySize;
                    }
                }

                // Extract our EnvR data.
                // var envrData = sceneData.GetLightingData();
                //
                // // This doesn't always match up, as sea has 52 EnvR entries but only 50 rooms, but meh.
                // if (mapRooms.Count != envrData.Count)
                //     Console.WriteLine("WStage: Mismatched number of entries in Envr ({0}) and number of loaded rooms ({1})!", envrData.Count, mapRooms.Count);
                //
                // if (envrData.Count > 0)
                //     foreach (var room in mapRooms)
                //         room.EnvironmentLighting = envrData[0];
                //for (int i = 0; i < envrData.Count; i++)
                //{
                //    WRoom room = mapRooms.Find(x => x.RoomIndex == i);
                //    if (room != null)
                //        room.EnvironmentLighting = envrData[i];
                //}
            }
        }
예제 #4
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);
            }
        }
예제 #5
0
        private void UpdateModel()
        {
            WDOMNode cur_object = this;

            while (cur_object.Parent != null)
            {
                cur_object = cur_object.Parent;
            }
            WRoom  currRoom      = cur_object as WRoom;
            string currStageName = World.Map.MapName;

            string model_path;

            switch (Type)
            {
            case TypeEnum.Grass:
                if (currStageName.StartsWith("kin") || currStageName == "Xboss1")
                {
                    // Forbidden Woods grass
                    model_path = "resources/models/foliage/grass_Vmori.obj";
                }
                else
                {
                    model_path = "resources/models/foliage/grass.obj";
                }
                break;

            case TypeEnum.Tree:
                model_path = "resources/models/foliage/tree.obj";
                break;

            case TypeEnum.White_Flower:
                model_path = "resources/models/foliage/flower.obj";
                break;

            case TypeEnum.Pink_Flower:
                if (currStageName == "sea" && currRoom.RoomIndex == 33)
                {
                    // Private Oasis flowers
                    model_path = "resources/models/foliage/pflower_oasis.obj";
                }
                else
                {
                    model_path = "resources/models/foliage/pflower_pink.obj";
                }
                break;

            default:
                model_path = "resources/editor/EditorCube.obj";
                break;
            }

            m_objRender = WResourceManager.LoadObjResource(model_path, new OpenTK.Vector4(1, 1, 1, 1), true, false, TextureWrapMode.MirroredRepeat);
        }
예제 #6
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);
        }
예제 #7
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);
        }
예제 #8
0
        public override void PopulateDefaultProperties()
        {
            Name        = "Link";
            EnemyNumber = -1;
            Event       = null;
            Unknown4    = -1;
            Unknown6    = -1;

            // Try to assign the room index automatically if this is a room spawn.
            WDOMNode cur_object = this;

            while (cur_object.Parent != null)
            {
                cur_object = cur_object.Parent;
            }
            WScene scene = cur_object as WScene;

            if (scene is WRoom)
            {
                WRoom room = scene as WRoom;
                Room = room.RoomIndex;
            }

            // Automatically assign it the first unused spawn ID in this scene.
            List <int>        possibleSpawnIDs = Enumerable.Range(0, 256).ToList();
            List <SpawnPoint> otherSpawns      = scene.GetChildrenOfType <SpawnPoint>();

            foreach (var spawn in otherSpawns)
            {
                if (spawn == this)
                {
                    continue;
                }
                possibleSpawnIDs.Remove(spawn.SpawnID);
            }

            if (possibleSpawnIDs.Count == 0)
            {
                SpawnID = 255;
            }
            else
            {
                SpawnID = possibleSpawnIDs.First();
            }
        }
예제 #9
0
        public override void SetTimeOfDay(float timeOfDay)
        {
            base.SetTimeOfDay(timeOfDay);

            WRoom room = Parent as WRoom;

            if (room != null)
            {
                var envLighting = room.EnvironmentLighting;
                if (envLighting != null)
                {
                    var curLight = envLighting.Lerp(EnvironmentLightingConditions.WeatherPreset.Default, true, timeOfDay);

                    // ToDo: Once Room Lighting works again, it can be applied per-frame to actors here if you
                    // override m_actorMesh.SetHardwareLight for main and secondary lighting based on what is in the
                    // actual environment lighting.
                }
            }
        }
예제 #10
0
파일: Map.cs 프로젝트: magcius/Winditor
        public void LoadFromDirectory(string inPath, string sourcePath)
        {
            if (!Directory.Exists(inPath))
            {
                throw new ArgumentException("Cannot load map from non-existant directory", "filePath");
            }


            m_mapName  = Path.GetFileName(inPath);
            m_savePath = Path.GetFullPath(sourcePath);

            Console.WriteLine("Loading map {0}...", m_mapName);

            // Sort them alphabetically so we always load the Stage last.
            List <string> sortedScenes = new List <string>(Directory.GetDirectories(inPath));

            sortedScenes.Sort();

            WStage stage = null;

            foreach (var sceneFolder in sortedScenes)
            {
                string sceneName = Path.GetFileName(sceneFolder);
                WScene scene     = null;

                if (sceneName.ToLower().StartsWith("room")) //
                {
                    string roomNumberStr = sceneName.Substring(4);
                    int    roomNumber;

                    if (int.TryParse(roomNumberStr, out roomNumber))
                    {
                        scene = new WRoom(m_world, roomNumber);
                    }
                    else
                    {
                        Console.WriteLine("Unknown Room Number for Room: \"{0}\", Skipping!", sceneName);
                    }
                }
                else if (string.Compare(sceneName, "Stage", true) == 0)
                {
                    stage = new WStage(m_world);
                    scene = stage;
                }
                else
                {
                    Console.WriteLine("Unknown Map Folder: {0}", sceneFolder);
                }

                if (scene != null)
                {
                    m_sceneList.Add(scene);
                    scene.Load(sceneFolder);
                }
            }

            // Now that we've loaded all of the data, we'll do some post processing.
            if (stage != null)
            {
                List <WRoom> allRooms = new List <WRoom>();
                foreach (var scene in m_sceneList)
                {
                    if (scene is WRoom)
                    {
                        allRooms.Add((WRoom)scene);
                    }
                }

                stage.PostLoadProcessing(inPath, allRooms);
            }

            if (m_sceneList.Count > 0)
            {
                FocusedScene = m_sceneList[m_sceneList.Count - 1];
            }
        }
예제 #11
0
파일: Map.cs 프로젝트: LordNed/Winditor
        public void LoadFromDirectory(string inPath, string sourcePath)
        {
            if (!Directory.Exists(inPath))
            {
                throw new ArgumentException("Cannot load map from non-existant directory", "filePath");
            }

            m_mapName  = Path.GetFileName(inPath);
            m_savePath = Path.GetFullPath(sourcePath);

            Console.WriteLine("Loading map {0}...", m_mapName);

            // Sort them alphabetically to guarantee rooms are in order, then move the Stage folder to the start of the list so we always load it first.
            List <string> sortedScenes = new List <string>(Directory.GetDirectories(inPath));

            sortedScenes.Sort();
            var stageFolder = sortedScenes[sortedScenes.Count - 1];

            sortedScenes.RemoveAt(sortedScenes.Count - 1);
            sortedScenes.Insert(0, stageFolder);

            WStage stage = null;

            foreach (var sceneFolder in sortedScenes)
            {
                string sceneName = Path.GetFileName(sceneFolder);

                VirtualFilesystemDirectory src_dir = new VirtualFilesystemDirectory(sceneFolder);
                src_dir.ImportFromDisk(sceneFolder);

                WScene scene = null;

                if (sceneName.ToLower().StartsWith("room")) //
                {
                    string roomNumberStr = sceneName.Substring(4);
                    int    roomNumber;

                    if (int.TryParse(roomNumberStr, out roomNumber))
                    {
                        scene = new WRoom(m_world, roomNumber);
                        scene.SourceDirectory = src_dir;
                    }
                    else
                    {
                        Console.WriteLine("Unknown Room Number for Room: \"{0}\", Skipping!", sceneName);
                    }
                }
                else if (string.Compare(sceneName, "Stage", true) == 0)
                {
                    stage = new WStage(m_world);
                    scene = stage;
                    scene.SourceDirectory = src_dir;
                }
                else
                {
                    Console.WriteLine("Unknown Map Folder: {0}", sceneFolder);
                }

                if (scene != null)
                {
                    m_sceneList.Add(scene);
                    scene.Load(sceneFolder);
                }
            }

            // Now that we've loaded all of the data, we'll do some post processing.
            if (stage != null)
            {
                List <WRoom> allRooms = new List <WRoom>();
                foreach (var scene in m_sceneList)
                {
                    if (scene is WRoom)
                    {
                        allRooms.Add((WRoom)scene);
                    }
                }

                stage.PostLoadProcessing(inPath, allRooms);
            }

            if (m_sceneList.Count > 1)
            {
                // Default to selecting the second item in the list, which will be the lowest-numbered room.
                FocusedScene = m_sceneList[1];
            }
            else if (m_sceneList.Count > 0)
            {
                // If no rooms are loaded, select the stage by default instead.
                FocusedScene = m_sceneList[0];
            }
        }
예제 #12
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);
            }
        }
예제 #13
0
        public override void SetTimeOfDay(float timeOfDay)
        {
            base.SetTimeOfDay(timeOfDay);

            if (m_skybox == null)
            {
                return;
            }

            WRoom first_room = null;

            foreach (var node in m_world.Map.SceneList)
            {
                if (node is WRoom)
                {
                    first_room = (WRoom)node;
                    break;
                }
            }

            if (first_room == null || first_room.EnvironmentLighting == null)
            {
                return;
            }

            var envrData = GetChildrenOfType <EnvironmentLightingConditions>();

            var curLight = envrData[0].Lerp(EnvironmentLightingConditions.WeatherPreset.Default, true, timeOfDay);

            m_skybox.SetColors(curLight.SkyboxPalette);


            // Set color overrides for certain stage actors that have parameters specifying what room they belong in.
            var childActors = GetChildrenOfType <VisibleDOMNode>();

            foreach (var child in childActors)
            {
                var possibleRoomNums = new List <int>();

                if (child is tbox)
                {
                    var chest = child as tbox;
                    possibleRoomNums.Add(chest.RoomNumber);
                }
                else if (child is door10)
                {
                    var door = child as door10;
                    possibleRoomNums.Add(door.FromRoomNumber);
                    possibleRoomNums.Add(door.ToRoomNumber);
                }
                else if (child is door12)
                {
                    var door = child as door12;
                    possibleRoomNums.Add(door.FromRoomNumber);
                    possibleRoomNums.Add(door.ToRoomNumber);
                }

                if (possibleRoomNums.Count == 0)
                {
                    continue;
                }

                WRoom containingRoom = null;
                foreach (var node in m_world.Map.SceneList)
                {
                    if (node is WRoom)
                    {
                        WRoom room = node as WRoom;
                        if (possibleRoomNums.Contains(room.RoomIndex))
                        {
                            containingRoom = room;
                        }
                    }
                }

                if (containingRoom == null)
                {
                    continue;
                }

                var containingRoomLight = containingRoom.EnvironmentLighting.Lerp(EnvironmentLightingConditions.WeatherPreset.Default, true, timeOfDay);
                child.ColorOverrides.SetTevColorOverride(0, containingRoomLight.ShadowColor);
                child.ColorOverrides.SetTevkColorOverride(0, containingRoomLight.ActorAmbientColor);
            }
        }