Example #1
0
        protected virtual void LoadLevelEntitiesFromFile(string filePath)
        {
            SceneDataLoader actorLoader = new SceneDataLoader(filePath, m_world);

            Console.WriteLine(Path.GetFileName(filePath));
            List <WDOMNode> loadedActors = actorLoader.GetMapEntities();

            foreach (var child in loadedActors)
            {
                var fourCCEntity = (SerializableDOMNode)child;

                if (child is Actor)
                {
                    child.SetParent(m_fourCCGroups[FourCC.ACTR].Children[(int)fourCCEntity.Layer]);
                }
                else if (child is ScaleableObject)
                {
                    child.SetParent(m_fourCCGroups[FourCC.SCOB].Children[(int)fourCCEntity.Layer]);
                }
                else if (child is TreasureChest)
                {
                    child.SetParent(m_fourCCGroups[FourCC.TRES].Children[(int)fourCCEntity.Layer]);
                }
                else
                {
                    child.SetParent(m_fourCCGroups[fourCCEntity.FourCC]);
                }

                //m_fourCCGroups[fourCCEntity.FourCC].Children.Add(fourCCEntity);
                //child.SetParent(m_fourCCGroups[fourCCEntity.FourCC]);
                child.IsVisible = true;
            }

            List <KeyValuePair <string, FourCC> > dispFourCCs = new List <KeyValuePair <string, FourCC> >();

            foreach (var item in m_fourCCGroups)
            {
                dispFourCCs.Add(new KeyValuePair <string, FourCC>(item.Value.ToString(), item.Key));
            }

            // Sort the FourCCs alphabetically by their ToString() value
            for (int i = 0; i < dispFourCCs.Count; i++)
            {
                for (int j = i; j < dispFourCCs.Count; j++)
                {
                    if (dispFourCCs[i].Key.CompareTo(dispFourCCs[j].Key) > 0)
                    {
                        KeyValuePair <string, FourCC> temp = dispFourCCs[i];
                        dispFourCCs[i] = dispFourCCs[j];
                        dispFourCCs[j] = temp;
                    }
                }
            }

            // Add entities to the DOM in the sorted order
            foreach (KeyValuePair <string, FourCC> keyVal in dispFourCCs)
            {
                m_fourCCGroups[keyVal.Value].SetParent(this);
            }
        }
Example #2
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];
                //}
            }
        }
Example #3
0
        protected virtual void LoadLevelEntitiesFromFile(string filePath)
        {
            SceneDataLoader actorLoader = new SceneDataLoader(filePath, m_world);

            Console.WriteLine(Path.GetFileName(filePath));
            List <WActorNode> loadedActors = actorLoader.GetMapEntities();

            foreach (var actor in loadedActors)
            {
                actor.SetParent(this);
            }
        }