private string OCIOChunk(MapHeader info, string fname) { return($@" - !<Look> name: {GetValidFilename($"{info.GetName().ToUpperInvariant()}_{teResourceGUID.Index(info.MapGUID):X}")} process_space: linear transform: !<GroupTransform> children: - !<FileTransform> {{src: {fname}.spi3d, interpolation: linear}}"); }
public void SaveMaps(ICLIFlags toolFlags) { string basePath; if (toolFlags is ExtractFlags flags) { basePath = flags.OutputPath; } else { throw new Exception("no output path"); } Dictionary <string, Dictionary <string, ParsedArg> > parsedTypes = ParseQuery(flags, QueryTypes, QueryNameOverrides); if (parsedTypes == null) { QueryHelp(QueryTypes); return; } foreach (ulong key in TrackedFiles[0x9F]) { STUMapHeader map = GetInstance <STUMapHeader>(key); if (map == null) { continue; } MapHeader mapInfo = ListMaps.GetMap(key); mapInfo.Name = mapInfo.Name ?? "Title Screen"; Dictionary <string, ParsedArg> config = GetQuery(parsedTypes, mapInfo.Name, mapInfo.VariantName, mapInfo.GetUniqueName(), mapInfo.GetName(), teResourceGUID.Index(map.m_map).ToString("X"), "*"); if (config.Count == 0) { continue; } Map.Save(flags, mapInfo, map, key, basePath); SaveScratchDatabase(); } }
public void SaveMaps(ICLIFlags toolFlags) { string basePath; if (toolFlags is ExtractFlags extractFlags) { basePath = extractFlags.OutputPath; } else { throw new Exception("no output path"); } basePath = Path.Combine(basePath, "Environments"); if (!Directory.Exists(basePath)) { Directory.CreateDirectory(basePath); } var flags = extractFlags as ExtractMapEnvFlags ?? new ExtractMapEnvFlags(); if (!flags.SkipMapEnvironmentLUT && File.Exists(Path.Combine(basePath, "SPILUT", "config.ocio"))) { File.Delete(Path.Combine(basePath, "SPILUT", "config.ocio")); } HashSet <KeyValuePair <ulong, string> > done = new HashSet <KeyValuePair <ulong, string> >(); foreach (ulong metaKey in TrackedFiles[0x9F]) { STUMapHeader map = GetInstance <STUMapHeader>(metaKey); if (map == null) { continue; } MapHeader mapInfo = GetMap(metaKey); ulong dataKey = map.m_map; //if (teResourceGUID.Index(dataKey) != 0x7A4) continue; var mapName = GetValidFilename($"{mapInfo.GetName()}_{teResourceGUID.Index(mapInfo.MapGUID):X}"); string fname = $"ow_map_{mapName}"; var reflectionData = Map.GetPlaceableData(map, Enums.teMAP_PLACEABLE_TYPE.REFLECTIONPOINT); if (reflectionData != null) { foreach (var placeable in reflectionData.Placeables ?? Array.Empty <IMapPlaceable>()) { if (!(placeable is teMapPlaceableReflectionPoint reflectionPoint)) { continue; } if (done.Add(new KeyValuePair <ulong, string>(reflectionPoint.Header.Texture1, mapInfo.Name + "cube"))) { SaveTex(extractFlags, basePath, Path.Combine("Cubemap", fname), reflectionPoint.Header.Texture1.ToString(), reflectionPoint.Header.Texture1); } if (done.Add(new KeyValuePair <ulong, string>(reflectionPoint.Header.Texture2, mapInfo.Name + "cube"))) { SaveTex(extractFlags, basePath, Path.Combine("Cubemap", fname), reflectionPoint.Header.Texture2.ToString(), reflectionPoint.Header.Texture2); } } } using (Stream data = OpenFile(dataKey)) { if (data != null) { using (BinaryReader dataReader = new BinaryReader(data)) { teMap env = dataReader.Read <teMap>(); // using (Stream lightingStream = OpenFile(env.BakedLighting)) { // teLightingManifest lightingManifest = new teLightingManifest(lightingStream); //} if (!flags.SkipMapEnvironmentSound && done.Add(new KeyValuePair <ulong, string>(env.MapEnvironmentSound, mapInfo.Name))) { SaveSound(extractFlags, basePath, Path.Combine("Sound", mapName), env.MapEnvironmentSound); } if (!flags.SkipMapEnvironmentLUT && done.Add(new KeyValuePair <ulong, string>(env.LUT, mapInfo.Name))) { SaveTex(extractFlags, basePath, "LUT", fname + env.LUT, env.LUT); SaveLUT(extractFlags, basePath, "SPILUT", fname + env.LUT, env.LUT, Path.Combine(basePath, "SPILUT", "config.ocio"), mapInfo); } if (!flags.SkipMapEnvironmentBlendCubemap && done.Add(new KeyValuePair <ulong, string>(env.BlendEnvironmentCubemap, mapInfo.Name))) { SaveTex(extractFlags, basePath, "BlendCubemap", fname + env.BlendEnvironmentCubemap, env.BlendEnvironmentCubemap); } if (!flags.SkipMapEnvironmentGroundCubemap && done.Add(new KeyValuePair <ulong, string>(env.GroundEnvironmentCubemap, mapInfo.Name))) { SaveTex(extractFlags, basePath, "GroundCubemap", fname + env.GroundEnvironmentCubemap, env.GroundEnvironmentCubemap); } if (!flags.SkipMapEnvironmentSkyCubemap && done.Add(new KeyValuePair <ulong, string>(env.SkyEnvironmentCubemap, mapInfo.Name))) { SaveTex(extractFlags, basePath, "SkyCubemap", fname + env.SkyEnvironmentCubemap, env.SkyEnvironmentCubemap); } if (!flags.SkipMapEnvironmentSkybox && done.Add(new KeyValuePair <ulong, string>(env.SkyboxModel + env.SkyboxModelLook, mapInfo.Name))) { SaveMdl(extractFlags, basePath, Path.Combine("Skybox", mapName), env.SkyboxModel, env.SkyboxModelLook); } if (!flags.SkipMapEnvironmentEntity && done.Add(new KeyValuePair <ulong, string>(env.EntityDefinition, mapInfo.Name))) { SaveEntity(extractFlags, basePath, Path.Combine("Entity", mapName), env.EntityDefinition); } } } } InfoLog("Saved Environment data for {0}", mapInfo.GetUniqueName()); } }
public static void Save(ICLIFlags flags, MapHeader mapInfo, STUMapHeader mapHeader, ulong key, string basePath) { var name = mapInfo.GetName(); LoudLog($"Extracting map {name}/{teResourceGUID.Index(key):X}"); // TODO: MAP11 HAS CHANGED // TODO: MAP10 TOO? name = GetValidFilename(name); string mapPath = Path.Combine(basePath, "Maps", name, teResourceGUID.Index(key).ToString("X")) + Path.DirectorySeparatorChar; CreateDirectoryFromFile(mapPath); FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo(); LoudLog("\tFinding"); FindLogic.Combo.Find(info, mapHeader.m_map); //for (ushort i = 0; i < 255; i++) { // using (Stream mapChunkStream = OpenFile(mapHeader.GetChunkKey((byte)i))) { // if (mapChunkStream == null) continue; // WriteFile(mapChunkStream, Path.Combine(mapPath, $"{(Enums.teMAP_PLACEABLE_TYPE)i}.0BC")); // } //} //return; teMapPlaceableData placeableModelGroups = GetPlaceableData(mapHeader, Enums.teMAP_PLACEABLE_TYPE.MODEL_GROUP); teMapPlaceableData placeableSingleModels = GetPlaceableData(mapHeader, Enums.teMAP_PLACEABLE_TYPE.SINGLE_MODEL); teMapPlaceableData placeableModel = GetPlaceableData(mapHeader, Enums.teMAP_PLACEABLE_TYPE.MODEL); teMapPlaceableData placeableLights = GetPlaceableData(mapHeader, Enums.teMAP_PLACEABLE_TYPE.LIGHT); teMapPlaceableData placeableEntities = GetPlaceableData(mapHeader, Enums.teMAP_PLACEABLE_TYPE.ENTITY); teMapPlaceableData placeableSounds = GetPlaceableData(mapHeader, Enums.teMAP_PLACEABLE_TYPE.SOUND); teMapPlaceableData placeableEffects = GetPlaceableData(mapHeader, Enums.teMAP_PLACEABLE_TYPE.EFFECT); OverwatchMap exportMap = new OverwatchMap(name, info, placeableSingleModels, placeableModelGroups, placeableModel, placeableEntities, placeableLights, placeableSounds, placeableEffects); using (Stream outputStream = File.OpenWrite(Path.Combine(mapPath, $"{name}.{exportMap.Extension}"))) { exportMap.Write(outputStream); } { FindLogic.Combo.Find(info, mapHeader.m_86C1CFAB); FindLogic.Combo.Find(info, mapHeader.m_9386E669); FindLogic.Combo.Find(info, mapHeader.m_C6599DEB); if (mapHeader.m_D608E9F3 != null) { foreach (teResourceGUID gamemodeGUID in mapHeader.m_D608E9F3) { STUGameMode gameMode = GetInstance <STUGameMode>(gamemodeGUID); if (gameMode == null) { continue; } FindLogic.Combo.Find(info, gameMode.m_6EB38130); // 004 FindLogic.Combo.Find(info, gameMode.m_CF63B633); // 01B FindLogic.Combo.Find(info, gameMode.m_7F5B54B2); // game mode voice set foreach (STUGameModeTeam team in gameMode.m_teams) { FindLogic.Combo.Find(info, team.m_bodyScript); // 01B FindLogic.Combo.Find(info, team.m_controllerScript); // 01B } } } } FindLogic.Combo.Find(info, mapHeader.m_announcerWelcome); info.SetEffectName(mapHeader.m_announcerWelcome, "AnnouncerWelcome"); FindLogic.Combo.Find(info, mapHeader.m_musicTease); info.SetEffectName(mapHeader.m_musicTease, "MusicTease"); ulong announcerVoiceSet = 0; using (Stream stream = OpenFile(mapHeader.m_map)) { if (stream != null) { using (BinaryReader reader = new BinaryReader(stream)) { teMap map = reader.Read <teMap>(); STUVoiceSetComponent voiceSetComponent = GetInstance <STUVoiceSetComponent>(map.EntityDefinition); announcerVoiceSet = voiceSetComponent?.m_voiceDefinition; FindLogic.Combo.Find(info, announcerVoiceSet); info.SetEffectVoiceSet(mapHeader.m_announcerWelcome, announcerVoiceSet); } } } LoudLog("\tSaving"); var context = new Combo.SaveContext(info); Combo.Save(flags, mapPath, context); Combo.SaveLooseTextures(flags, Path.Combine(mapPath, "Textures"), context); context.Wait(); if (mapHeader.m_7F5B54B2 != 0) // map voice set. not announcer { FindLogic.Combo.Find(info, mapHeader.m_7F5B54B2); } if (announcerVoiceSet != 0) // whole thing in env mode, not here { info.m_voiceSets.Remove(announcerVoiceSet); } Combo.SaveAllVoiceSets(flags, Path.Combine(mapPath, "VoiceSets"), context); Combo.SaveAllSoundFiles(flags, Path.Combine(mapPath, "Sound"), context); context.Wait(); LoudLog("\tDone"); }
public void SaveMaps(ICLIFlags toolFlags) { string basePath; if (toolFlags is ExtractMapEnvFlags flags) { basePath = flags.OutputPath; } else { throw new Exception("no output path"); } basePath = Path.Combine(basePath, "Environments"); if (!Directory.Exists(basePath)) { Directory.CreateDirectory(basePath); } if (!flags.SkipMapEnvironmentLUT && File.Exists(Path.Combine(basePath, "SPILUT", "config.ocio"))) { File.Delete(Path.Combine(basePath, "SPILUT", "config.ocio")); } HashSet <KeyValuePair <ulong, string> > done = new HashSet <KeyValuePair <ulong, string> >(); foreach (ulong metaKey in TrackedFiles[0x9F]) { STUMapHeader map = GetInstance <STUMapHeader>(metaKey); if (map == null) { continue; } MapHeader mapInfo = GetMap(metaKey); ulong dataKey = map.m_map; //if (teResourceGUID.Index(dataKey) != 0x7A4) continue; using (Stream data = OpenFile(dataKey)) { if (data == null) { continue; } using (BinaryReader dataReader = new BinaryReader(data)) { teMap env = dataReader.Read <teMap>(); var mapName = GetValidFilename($"{mapInfo.GetName()}_{teResourceGUID.Index(mapInfo.MapGUID):X}"); string fname = $"ow_map_{mapName}"; //using (Stream lightingStream = OpenFile(env.BakedLighting)) { // teLightingManifest lightingManifest = new teLightingManifest(lightingStream); //} if (!flags.SkipMapEnvironmentSound && done.Add(new KeyValuePair <ulong, string>(env.MapEnvironmentSound, mapInfo.Name))) { SaveSound(flags, basePath, Path.Combine("Sound", mapName), env.MapEnvironmentSound); } if (!flags.SkipMapEnvironmentLUT && done.Add(new KeyValuePair <ulong, string>(env.LUT, mapInfo.Name))) { SaveTex(flags, basePath, "LUT", fname, env.LUT); SaveLUT(flags, basePath, "SPILUT", fname, env.LUT, Path.Combine(basePath, "SPILUT", "config.ocio"), mapInfo); } if (!flags.SkipMapEnvironmentBlendCubemap && done.Add(new KeyValuePair <ulong, string>(env.BlendEnvironmentCubemap, mapInfo.Name))) { SaveTex(flags, basePath, "BlendCubemap", fname, env.BlendEnvironmentCubemap); } if (!flags.SkipMapEnvironmentGroundCubemap && done.Add(new KeyValuePair <ulong, string>(env.GroundEnvironmentCubemap, mapInfo.Name))) { SaveTex(flags, basePath, "GroundCubemap", fname, env.GroundEnvironmentCubemap); } if (!flags.SkipMapEnvironmentSkyCubemap && done.Add(new KeyValuePair <ulong, string>(env.SkyEnvironmentCubemap, mapInfo.Name))) { SaveTex(flags, basePath, "SkyCubemap", fname, env.SkyEnvironmentCubemap); } if (!flags.SkipMapEnvironmentSkybox && done.Add(new KeyValuePair <ulong, string>(env.SkyboxModel ^ env.SkyboxModelLook, mapInfo.Name))) { SaveMdl(flags, basePath, Path.Combine("Skybox", mapName), env.SkyboxModel, env.SkyboxModelLook); } if (!flags.SkipMapEnvironmentEntity && done.Add(new KeyValuePair <ulong, string>(env.EntityDefinition, mapInfo.Name))) { SaveEntity(flags, basePath, Path.Combine("Entity", mapName), env.EntityDefinition); } InfoLog("Saved Environment data for {0}", mapInfo.GetUniqueName()); } } } }