public GetResourcesCommand(OpenTagCache info, TagInstance tag, ModelAnimationGraph definition) : base(CommandFlags.None, "getresources", "", "getresources", "") { Info = info; Tag = tag; Definition = definition; }
public AnimationExtractor(ModelAnimationGraph modelAnimationGraph, GameCache cacheContext) { ModelAnimationGraph = modelAnimationGraph; CacheContext = cacheContext; Scene = new Scene(); Nodes = new List <Node>(); for (int i = 0; i < ModelAnimationGraph.SkeletonNodes.Count; i++) { Nodes.Add(new Node(CacheContext.StringTable.GetString(ModelAnimationGraph.SkeletonNodes[i].Name))); } }
public SortModesCommand(HaloOnlineCacheContext cacheContext, ModelAnimationGraph definition) : base(false, "SortModes", "Sorts all \"modes\" block elements in the current model_animation_graph based on their name's string_id set and index.", "SortModes", "Sorts all \"modes\" block elements in the current model_animation_graph based on their name's string_id set and index.") { CacheContext = cacheContext; Definition = definition; }
public GetResourceInfoCommand(HaloOnlineCacheContext cacheContext, CachedTagInstance tag, ModelAnimationGraph definition) : base(false, "GetResourceInfo", "Gets information about a model_animation_graph's resources.", "GetResourceInfo", "Gets information about a model_animation_graph's resources.") { CacheContext = cacheContext; Tag = tag; Definition = definition; }
public ResourceDataCommand(HaloOnlineCacheContext cacheContext, CachedTagInstance tag, ModelAnimationGraph definition) : base(false, "ResourceData", "ResourceData Extract/Import [Cache Type] <Resource group Index (decimal)> <Filename>", "ResourceData Extract 0 warthog.raw\n" + "ResourceData Import resources_b 0 ones_0.raw", "ResourceData Extract/Import an animation raw resource and update the tag resource index.") { CacheContext = cacheContext; Tag = tag; Definition = definition; }
public override object Execute(List <string> args) { if (args.Count != 1) { return(false); } if (!CacheContext.TryGetTag(args[0], out var instance) || !instance.IsInGroup <ModelAnimationGraph>()) { Console.WriteLine($"ERROR: Invalid model_animation_graph tag specifier: {args[0]}"); return(true); } ModelAnimationGraph definition = null; using (var stream = CacheContext.OpenTagCacheRead()) definition = CacheContext.Deserialize <ModelAnimationGraph>(stream, instance); foreach (var resourceGroup in definition.ResourceGroups) { var resource = CacheContext.Deserialize <ModelAnimationTagResource>(resourceGroup.Resource); using (var stream = new MemoryStream()) using (var reader = new EndianReader(stream)) { CacheContext.ExtractResource(resourceGroup.Resource, stream); foreach (var groupMember in resource.GroupMembers) { reader.BaseStream.Position = groupMember.AnimationData.Address.Offset; var header = CacheContext.Deserialize <AnimatedCodecHeader>( new DataSerializationContext(reader)); if (header.Type == AnimationCodecType.UncompressedStatic) { continue; } //var data = new AnimationData(groupMember, header); //data.Read(reader); } } } return(true); }
private static bool ExtractResource(ModelAnimationGraph Definition, HaloOnlineCacheContext CacheContext, IReadOnlyList <string> args) { int groupIndex = -1; if (!Int32.TryParse(args[0], out groupIndex)) { return(false); } var filePath = args[1]; // warthog.raw if (groupIndex == -1) { Console.WriteLine("Resource is null."); return(false); } try { Definition.ResourceGroups[groupIndex].Resource.GetLocation(out var location); using (var stream = File.OpenRead(CacheContext.TagCacheFile.DirectoryName + "\\" + CacheContext.ResourceCacheNames[location])) { var cache = new ResourceCache(stream); using (var outStream = File.Open(filePath, FileMode.Create, FileAccess.Write)) { cache.Decompress(stream, Definition.ResourceGroups[groupIndex].Resource.Page.Index, 0x7FFFFFFF, outStream); Console.WriteLine("Wrote 0x{0:X} bytes to {1}.", outStream.Position, filePath); } } } catch (Exception ex) { Console.WriteLine("Failed to extract resource: {0}", ex.Message); } return(true); }
public static CommandContext Create(CommandContext parent, GameCache cache, CachedTag tag, ModelAnimationGraph animation) { var groupName = cache.StringTable.GetString(tag.Group.Name); var context = new CommandContext(parent, string.Format("{0:X8}.{1}", tag.Index, groupName)); Populate(context, cache, tag, animation); return(context); }
public static void Populate(CommandContext context, GameCache cache, CachedTag tag, ModelAnimationGraph animation) { context.AddCommand(new SortModesCommand(cache, animation)); context.AddCommand(new ApplySprintFixupsCommand(cache)); }
public ModelAnimationGraph ConvertModelAnimationGraph(Stream cacheStream, Dictionary <ResourceLocation, Stream> resourceStreams, ModelAnimationGraph definition) { if (BlamCache.ResourceGestalt == null) { BlamCache.LoadResourceTags(); } definition.ResourceGroups = ConvertModelAnimationGraphResourceGroups(cacheStream, resourceStreams, definition.ResourceGroups); definition.Modes = definition.Modes.OrderBy(a => a.Name.Set).ThenBy(a => a.Name.Index).ToList(); foreach (var mode in definition.Modes) { mode.WeaponClass = mode.WeaponClass.OrderBy(a => a.Label.Set).ThenBy(a => a.Label.Index).ToList(); foreach (var weaponClass in mode.WeaponClass) { weaponClass.WeaponType = weaponClass.WeaponType.OrderBy(a => a.Label.Set).ThenBy(a => a.Label.Index).ToList(); foreach (var weaponType in weaponClass.WeaponType) { weaponType.Actions = weaponType.Actions.OrderBy(a => a.Label.Set).ThenBy(a => a.Label.Index).ToList(); weaponType.Overlays = weaponType.Overlays.OrderBy(a => a.Label.Set).ThenBy(a => a.Label.Index).ToList(); weaponType.DeathAndDamage = weaponType.DeathAndDamage.OrderBy(a => a.Label.Set).ThenBy(a => a.Label.Index).ToList(); weaponType.Transitions = weaponType.Transitions.OrderBy(a => a.FullName.Set).ThenBy(a => a.FullName.Index).ToList(); foreach (var transition in weaponType.Transitions) { transition.Destinations = transition.Destinations.OrderBy(a => a.FullName.Set).ThenBy(a => a.FullName.Index).ToList(); } } } } return(definition); }
private static bool ImportResource(ModelAnimationGraph Definition, HaloOnlineCacheContext CacheContext, IReadOnlyList <string> args) { var locationName = args[0].Split(".".ToCharArray()).First().ToLower(); int index = -1; if (!Int32.TryParse(args[1], out index)) { Console.WriteLine($"ERROR: resource index could not be parsed."); return(false); } var filePath = args[2]; if (index > Definition.ResourceGroups.Count && index != -1) { Console.WriteLine($"ERROR: bitmap index higher than the bitmaps count or == -1."); return(false); } using (var stream = File.Open(filePath, FileMode.Open, FileAccess.ReadWrite)) { var location = ResourceLocation.None; switch (locationName) { case "textures": location = ResourceLocation.Textures; break; case "textures_b": location = ResourceLocation.TexturesB; break; case "resources": location = ResourceLocation.Resources; break; case "resources_b": location = ResourceLocation.ResourcesB; break; case "audio": location = ResourceLocation.Audio; break; case "lightmaps": location = ResourceLocation.Lightmaps; break; case "render_models": location = ResourceLocation.RenderModels; break; default: Console.WriteLine($"ERROR: invalid resource location: {locationName}"); break; } Definition.ResourceGroups[index].Resource.ChangeLocation(location); CacheContext.AddResource(Definition.ResourceGroups[index].Resource, stream); Console.WriteLine($"New resource info: " + $"Index 0x{Definition.ResourceGroups[index].Resource.Page.Index:X4}, " + $"Index {Definition.ResourceGroups[index].Resource.Page.Index:D8}, " + $"Compressed size: 0x{Definition.ResourceGroups[index].Resource.Page.CompressedBlockSize:X8}, " + $"Decompressed size: 0x{Definition.ResourceGroups[index].Resource.Page.UncompressedBlockSize:X8}, " + $""); } return(true); }
public static CommandContext Create(CommandContext parent, OpenTagCache info, TagInstance tag, ModelAnimationGraph animation) { var groupName = info.StringIDs.GetString(tag.Group.Name); var context = new CommandContext(parent, string.Format("{0:X8}.{1}", tag.Index, groupName)); Populate(context, info, tag, animation); return(context); }
public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, ModelAnimationGraph animation) { context.AddCommand(new GetResourcesCommand(info, tag, animation)); }
public static CommandContext Create(CommandContext parent, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, ModelAnimationGraph animation) { var groupName = cacheContext.GetString(tag.Group.Name); var context = new CommandContext(parent, string.Format("{0:X8}.{1}", tag.Index, groupName)); Populate(context, cacheContext, tag, animation); return(context); }
public static void Populate(CommandContext context, HaloOnlineCacheContext cacheContext, CachedTagInstance tag, ModelAnimationGraph animation) { context.AddCommand(new GetResourceInfoCommand(cacheContext, tag, animation)); context.AddCommand(new ResourceDataCommand(cacheContext, tag, animation)); context.AddCommand(new SortModesCommand(cacheContext, animation)); }
public ModelAnimationGraph ConvertModelAnimationGraph(Stream cacheStream, Stream blamCacheStream, Dictionary <ResourceLocation, Stream> resourceStreams, ModelAnimationGraph definition) { definition.ResourceGroups = ConvertModelAnimationGraphResourceGroups(cacheStream, blamCacheStream, resourceStreams, definition.ResourceGroups); var resolver = CacheContext.StringTable.Resolver; definition.Modes = definition.Modes.OrderBy(a => resolver.GetSet(a.Name)).ThenBy(a => resolver.GetIndex(a.Name)).ToList(); foreach (var mode in definition.Modes) { mode.WeaponClass = mode.WeaponClass.OrderBy(a => resolver.GetSet(a.Label)).ThenBy(a => resolver.GetIndex(a.Label)).ToList(); foreach (var weaponClass in mode.WeaponClass) { weaponClass.WeaponType = weaponClass.WeaponType.OrderBy(a => resolver.GetSet(a.Label)).ThenBy(a => resolver.GetIndex(a.Label)).ToList(); foreach (var weaponType in weaponClass.WeaponType) { weaponType.Actions = weaponType.Actions.OrderBy(a => resolver.GetSet(a.Label)).ThenBy(a => resolver.GetIndex(a.Label)).ToList(); weaponType.Overlays = weaponType.Overlays.OrderBy(a => resolver.GetSet(a.Label)).ThenBy(a => resolver.GetIndex(a.Label)).ToList(); weaponType.DeathAndDamage = weaponType.DeathAndDamage.OrderBy(a => resolver.GetSet(a.Label)).ThenBy(a => resolver.GetIndex(a.Label)).ToList(); weaponType.Transitions = weaponType.Transitions.OrderBy(a => resolver.GetSet(a.FullName)).ThenBy(a => resolver.GetIndex(a.FullName)).ToList(); foreach (var transition in weaponType.Transitions) { transition.Destinations = transition.Destinations.OrderBy(a => resolver.GetSet(a.FullName)).ThenBy(a => resolver.GetIndex(a.FullName)).ToList(); } } } } return(definition); }