private static int RunUnpack(UnpackOptions options) { Directory.CreateDirectory(options.TargetDir); using (var ifs = new FileStream(options.SourceFile, FileMode.Open, FileAccess.Read)) { var box = CzBox.Load(ifs); var def = box.GetContentDefinition(); if (def != null) { using (var cnBoxFs = new FileStream(Path.Combine(options.TargetDir, "contentDefinition.json"), FileMode.Create, FileAccess.Write)) AuthoringUtil.JsonSerialize(def, cnBoxFs); } foreach (var(name, srcResFs) in box.GetDataEnumerator()) { using (var resFs = new FileStream(Path.Combine(options.TargetDir, name), FileMode.Create, FileAccess.Write)) srcResFs.CopyTo(resFs); } } return(0); }
private static int RunTemplate(TemplateOptions options) { switch (options.Type.ToLowerInvariant()) { case "definition": var def = new ContentDefinition(); def.MeshConfigs.Add("yourConfigName", new MeshConfig { Mesh = "yourMeshName", Materials = new List <Material> { new Material { Textures = new Dictionary <string, string> { { "yourShaderParameterName", "yourTextureName" } } } }, CustomAttachPoints = new List <AttachPoint> { new AttachPoint { BoneName = "yourBoneName" } } }); def.MeshPaths.Add("yourMeshName", "yourPath"); def.ResourcePaths.Add("yourResourceName", "yourPath"); def.TexturePaths.Add("yourTextureName", "yourPath"); def.TranslationPaths.Add("yourTranslationName", "yourPath"); def.CoTextures.Add("yourCoTextureName", new CoTextureDefinition { Height = 1024, Width = 1024, Textures = new List <SubTextureDefinition> { new SubTextureDefinition { Mask = "yourTextureName", Texture = "yourTextureName" } } }); using (var ofs = new FileStream(options.TargetFile, FileMode.Create, FileAccess.Write)) AuthoringUtil.JsonSerialize(def, ofs); break; case "matchfile": var matchFile = new MatchRules(); foreach (var t in (BoneType[])Enum.GetValues(typeof(BoneType))) { matchFile.Bones.Add($"boneRegex{t.ToString()}", t); } foreach (var t in (AttachPointType[])Enum.GetValues(typeof(AttachPointType))) { matchFile.AttachPoints.Add($"boneRegex{t.ToString()}", t); } using (var ofs = new FileStream(options.TargetFile, FileMode.Create, FileAccess.Write)) AuthoringUtil.JsonSerialize(matchFile, ofs); break; default: Console.Error.WriteLine("Template type not recognized"); return(0x10103040); } return(0); }