private void LoadModels(Dictionary <Scene, VirtualFilesystemDirectory> archiveMap) { // We're going to search the archives for a specific list of meshes that the game supports and load those. List <string> supportedModelPaths = new List <string>(new string[] { "model", "model1", "model2", "model3" }); foreach (var kvp in archiveMap) { List <VirtualFilesystemFile> filesByExtension = kvp.Value.FindByExtension(".bmd", ".bdl"); foreach (var vfsFile in filesByExtension) { if (!supportedModelPaths.Contains(vfsFile.Name)) { continue; } using (EndianBinaryReader reader = new EndianBinaryReader(new System.IO.MemoryStream(vfsFile.File.GetData()), Endian.Big)) { WLog.Info(LogCategory.EntityLoading, null, "Loading {1} (3D Model) for {0}{1}...", vfsFile.Name, vfsFile.Extension); J3DLoader j3dLoader = new J3DLoader(); Mesh resultMesh = j3dLoader.LoadFromStream(reader); kvp.Key.MeshList.Add(resultMesh); WLog.Info(LogCategory.EntityLoading, null, "Finished loading {1} (3D Model) for {0}{1}.", vfsFile.Name, vfsFile.Extension); } } } }
private void LoadEntities(Map newMap, EditorCore core, Dictionary <Scene, VirtualFilesystemDirectory> archiveMap, WWorld world) { MapEntityLoader entityLoader = new MapEntityLoader(core, newMap); // For each room/scene, find the associated dzr/dzs file and load its // contents into the entityLoader. foreach (var kvp in archiveMap) { // Check to see if this Archive has stage/room entity data. var roomEntData = kvp.Value.FindByExtension(".dzr"); var stageEntData = kvp.Value.FindByExtension(".dzs"); VirtualFilesystemFile vfsFile = null; if (roomEntData.Count > 0) { vfsFile = roomEntData[0]; } else if (stageEntData.Count > 0) { vfsFile = stageEntData[0]; } else { continue; } using (EndianBinaryReader reader = new EndianBinaryReader(new System.IO.MemoryStream(vfsFile.File.GetData()), Endian.Big)) { WLog.Info(LogCategory.EntityLoading, null, "Loading .dzr/.dzs (Room/Stage Entity Dat) for {0}{1}...", vfsFile.Name, vfsFile.Extension); entityLoader.LoadFromStream(kvp.Key, reader); WLog.Info(LogCategory.EntityLoading, null, "Finished loading .dzr/.dzs (Room/Stage Entity Dat) for {0}{1}.", vfsFile.Name, vfsFile.Extension); } } // Once we've loaded all of the entities from the stream, we're going to // post-process them to resolve object references. entityLoader.PostProcessEntities(); // Finally, we can actually convert these into map objects foreach (var roomOrStageData in entityLoader.GetData()) { Stage stage = roomOrStageData.Key as Stage; Room room = roomOrStageData.Key as Room; if (stage != null) { PostProcessStage(stage, roomOrStageData.Value); foreach (var entity in stage.Entities) { entity.World = world; } } if (room != null) { PostProcessRoom(room, roomOrStageData.Value); foreach (var entity in room.Entities) { entity.World = world; } } } }