/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonClone_Click(object sender, EventArgs e) { if (mxListBox1.SelectedItem is MEXCostume costume) { _costumes.Add(new MEXCostume() { Costume = HSDAccessor.DeepClone <HSDRaw.MEX.MEX_CostumeFileSymbol>(costume.Costume), Icon = HSDAccessor.DeepClone <HSD_TOBJ>(costume.Icon), CSP = costume.CSP == null ? null : HSDAccessor.DeepClone <HSD_TOBJ>(costume.CSP) }); } }
/// <summary> /// /// </summary> /// <param name="filePath"></param> private void LoadMnSlMap(HSDRawFile hsd) { if (StageMenuFile != null) { return; } var org = hsd["MnSelectStageDataTable"]; var mex = hsd["mexMapData"]; if (org != null && mex == null) { MessageBox.Show("MexMapData symbol not found. One will now be generated", "Symbol Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // load and convert data from vanilla MexMapGenerator.LoadIconDataFromVanilla(org.Data as SBM_MnSelectStageDataTable, Icons); // generate mex data node hsd.Roots.Add(new HSDRootNode() { Name = "mexMapData", Data = MexMapGenerator.GenerateMexMap(org.Data as SBM_MnSelectStageDataTable, Icons) }); mex = hsd["mexMapData"]; } if (org != null && mex != null) { var stage = org.Data as SBM_MnSelectStageDataTable; var mexMap = mex.Data as MEX_mexMapData; //StageMenuFilePath = filePath; StageMenuFile = hsd; // Load Data from Mex Symbol MexMapGenerator.LoadIconDataFromSymbol(mexMap, Icons); // Load Dummy Icon Model IconJOBJManager.RefreshRendering = true; var icon = HSDAccessor.DeepClone <HSD_JOBJ>(mexMap.IconModel); IconJOBJManager.SetJOBJ(icon); // Load Dummy Stage Name Model StageNameJOBJManager.RefreshRendering = true; var name = HSDAccessor.DeepClone <HSD_JOBJ>(stage.StageNameModel); StageNameJOBJManager.SetJOBJ(name); StageNameJOBJManager.SetAnimJoint(stage.StageNameAnimJoint); StageNameJOBJManager.Frame = 10; Enabled = true; } }
/// <summary> /// /// </summary> public static void ImportTextures(HSD_JOBJ jobj) { var folder = Tools.FileIO.OpenFolder(); if (!string.IsNullOrEmpty(folder)) { // get all tobjs Dictionary <int, HSD_TOBJ> hashToImage = new Dictionary <int, HSD_TOBJ>(); // load all textures from file foreach (var tf in System.IO.Directory.GetFiles(folder)) { if (tf.ToLower().EndsWith(".png")) { var fn = System.IO.Path.GetFileNameWithoutExtension(tf); if (fn.Length >= 8 && int.TryParse(fn.Substring(0, 8), System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int hash) && TOBJConverter.FormatFromString(fn, out HSDRaw.GX.GXTexFmt texFmt, out HSDRaw.GX.GXTlutFmt tlutFmt)) { hashToImage.Add(hash, TOBJConverter.ImportTOBJFromFile(tf, texFmt, tlutFmt)); } } } // get all tobjs foreach (var j in jobj.BreathFirstList) { if (j.Dobj != null) { foreach (var dobj in j.Dobj.List) { if (dobj.Mobj != null && dobj.Mobj.Textures != null) { foreach (var tobj in dobj.Mobj.Textures.List) { // generate hashes and export textures and formatting var hash = ComputeHash(tobj.GetDecodedImageData()); if (hashToImage.ContainsKey(hash)) { var imgClone = HSDAccessor.DeepClone <HSD_TOBJ>(hashToImage[hash]); tobj.ImageData = imgClone.ImageData; tobj.TlutData = imgClone.TlutData; } } } } } } } }
/// <summary> /// /// </summary> /// <param name="mobj"></param> /// <returns></returns> public HSD_Material GetMaterialState(HSD_MOBJ mobj) { HSD_Material mat = HSDAccessor.DeepClone <HSD_Material>(mobj.Material); if (Nodes.Count > JOBJIndex && Nodes[JOBJIndex].Nodes.Count > DOBJIndex) { var node = Nodes[JOBJIndex].Nodes[DOBJIndex]; foreach (var t in node.Tracks) { switch ((MatTrackType)t.TrackType) { case MatTrackType.HSD_A_M_ALPHA: mat.Alpha = t.GetValue(node.Frame); break; case MatTrackType.HSD_A_M_AMBIENT_R: mat.AMB_R = (byte)(t.GetValue(node.Frame) * 0xFF); break; case MatTrackType.HSD_A_M_AMBIENT_G: mat.AMB_G = (byte)(t.GetValue(node.Frame) * 0xFF); break; case MatTrackType.HSD_A_M_AMBIENT_B: mat.AMB_B = (byte)(t.GetValue(node.Frame) * 0xFF); break; case MatTrackType.HSD_A_M_DIFFUSE_R: mat.DIF_R = (byte)(t.GetValue(node.Frame) * 0xFF); break; case MatTrackType.HSD_A_M_DIFFUSE_G: mat.DIF_G = (byte)(t.GetValue(node.Frame) * 0xFF); break; case MatTrackType.HSD_A_M_DIFFUSE_B: mat.DIF_B = (byte)(t.GetValue(node.Frame) * 0xFF); break; case MatTrackType.HSD_A_M_SPECULAR_R: mat.SPC_R = (byte)(t.GetValue(node.Frame) * 0xFF); break; case MatTrackType.HSD_A_M_SPECULAR_G: mat.SPC_G = (byte)(t.GetValue(node.Frame) * 0xFF); break; case MatTrackType.HSD_A_M_SPECULAR_B: mat.SPC_B = (byte)(t.GetValue(node.Frame) * 0xFF); break; } } } return(mat); }
/// <summary> /// /// </summary> /// <param name="stage"></param> /// <param name="icons"></param> public static MEX_mexMapData GenerateMexMap(SBM_MnSelectStageDataTable stage, IEnumerable <MEXStageIconEntry> icons) { MEX_mexMapData mapData = new MEX_mexMapData(); var nameTexAnim = new HSD_TexAnim(); var nameKeys = new List <FOBJKey>(); var iconTexAnim = new HSD_TexAnim(); var iconKeys = new List <FOBJKey>(); HSD_JOBJ root = new HSD_JOBJ() { SX = 1, SY = 1, SZ = 1, Flags = JOBJ_FLAG.CLASSICAL_SCALING }; HSD_AnimJoint animRoot = new HSD_AnimJoint(); // extra { var tobjs = stage.IconLargeMatAnimJoint.Child.MaterialAnimation.Next.TextureAnimation.ToTOBJs(); var index = iconTexAnim.AddImage(tobjs[0]); iconKeys.Add(new FOBJKey() { Frame = index, Value = index, InterpolationType = GXInterpolationType.HSD_A_OP_CON }); index = iconTexAnim.AddImage(tobjs[1]); iconKeys.Add(new FOBJKey() { Frame = index, Value = index, InterpolationType = GXInterpolationType.HSD_A_OP_CON }); } foreach (var v in icons) { var index = iconTexAnim.AddImage(v.IconTOBJ); if (index == -1) { index = 0; } iconKeys.Add(new FOBJKey() { Frame = index, Value = index, InterpolationType = GXInterpolationType.HSD_A_OP_CON }); index = nameTexAnim.AddImage(v.NameTOBJ); if (index == -1) { index = 0; } nameKeys.Add(new FOBJKey() { Frame = index, Value = index, InterpolationType = GXInterpolationType.HSD_A_OP_CON }); v.Joint.Next = null; v.Joint.Child = null; v.AnimJoint.Next = null; v.AnimJoint.Child = null; root.AddChild(v.Joint); animRoot.AddChild(v.AnimJoint); } iconKeys.Add(new FOBJKey() { Frame = 1600, Value = 0, InterpolationType = GXInterpolationType.HSD_A_OP_CON }); iconTexAnim.GXTexMapID = HSDRaw.GX.GXTexMapID.GX_TEXMAP0; iconTexAnim.AnimationObject = new HSD_AOBJ(); iconTexAnim.AnimationObject.EndFrame = 1600; iconTexAnim.AnimationObject.FObjDesc = new HSD_FOBJDesc(); iconTexAnim.AnimationObject.FObjDesc.SetKeys(iconKeys, (byte)TexTrackType.HSD_A_T_TIMG); iconTexAnim.AnimationObject.FObjDesc.Next = new HSD_FOBJDesc(); iconTexAnim.AnimationObject.FObjDesc.Next.SetKeys(iconKeys, (byte)TexTrackType.HSD_A_T_TCLT); var iconJOBJ = HSDAccessor.DeepClone <HSD_JOBJ>(stage.IconDoubleModel); iconJOBJ.Child = iconJOBJ.Child.Next; var iconAnimJoint = HSDAccessor.DeepClone <HSD_AnimJoint>(stage.IconDoubleAnimJoint); iconAnimJoint.Child = iconAnimJoint.Child.Next; var iconMatAnimJoint = HSDAccessor.DeepClone <HSD_MatAnimJoint>(stage.IconDoubleMatAnimJoint); iconMatAnimJoint.Child = iconMatAnimJoint.Child.Next; iconMatAnimJoint.Child.MaterialAnimation.Next.TextureAnimation = iconTexAnim; var iconNameAnim = HSDAccessor.DeepClone <HSD_MatAnimJoint>(stage.StageNameMatAnimJoint); nameTexAnim.AnimationObject = new HSD_AOBJ(); nameTexAnim.AnimationObject.EndFrame = 1600; nameTexAnim.AnimationObject.FObjDesc = new HSD_FOBJDesc(); nameTexAnim.AnimationObject.FObjDesc.SetKeys(nameKeys, (byte)TexTrackType.HSD_A_T_TIMG); iconNameAnim.Child.Child.MaterialAnimation.TextureAnimation = nameTexAnim; mapData.IconModel = iconJOBJ; mapData.IconAnimJoint = iconAnimJoint; mapData.IconMatAnimJoint = iconMatAnimJoint; mapData.PositionModel = root; mapData.PositionAnimJoint = animRoot; mapData.StageNameMaterialAnimation = iconNameAnim; return(mapData); }
/// <summary> /// /// </summary> /// <param name="table"></param> /// <param name="icons"></param> /// <returns></returns> private static MEX_mexSelectChr GenerateMexSelectChrSymbol(SBM_SelectChrDataTable table, MEX_CSSIcon[] cssIcons) { // create mexSelectChr struct MEX_mexSelectChr mex = new MEX_mexSelectChr(); // generate icon model var icon_joint = HSDAccessor.DeepClone <HSD_JOBJ>(table.MenuModel.Children[2].Child); icon_joint.TX = 0; icon_joint.TY = 0; icon_joint.TZ = 0; icon_joint.Next = null; var center = RegenerateIcon(icon_joint); // generate material_anim_joint var icon_matanim_joint = HSDAccessor.DeepClone <HSD_MatAnimJoint>(table.MenuMaterialAnimation.Children[2].Child); icon_matanim_joint.Next = null; // general base models HSD_JOBJ position_joint = new HSD_JOBJ(); position_joint.Flags = JOBJ_FLAG.CLASSICAL_SCALING | JOBJ_FLAG.ROOT_XLU; position_joint.SX = 1; position_joint.SY = 1; position_joint.SZ = 1; HSD_AnimJoint anim_joint = new HSD_AnimJoint(); HSD_MatAnimJoint matanim_joint = new HSD_MatAnimJoint(); // create icon data var joints = table.MenuModel.BreathFirstList; var matanims = table.MenuAnimation.BreathFirstList; foreach (var ico in cssIcons) { if (joints[ico.JointID].Dobj == null) { continue; } HSD_JOBJ joint = HSDAccessor.DeepClone <HSD_JOBJ>(icon_joint); joint.Dobj.Pobj.Attributes = icon_joint.Dobj.Pobj.Attributes; joint.Dobj.Next.Pobj.Attributes = icon_joint.Dobj.Pobj.Attributes; joint.Dobj.Next.Mobj.Textures = HSDAccessor.DeepClone <HSD_TOBJ>(joints[ico.JointID].Dobj.Next.Mobj.Textures); var worldPosition = new GXVector3(joints[ico.JointID].TX, joints[ico.JointID].TY, joints[ico.JointID].TZ); // get anim var anim = matanims[ico.JointID].AOBJ; // if it's a clone get parent location if (ico.JointID < 15) { worldPosition = new GXVector3(joints[ico.JointID - 1].TX, joints[ico.JointID - 1].TY, joints[ico.JointID - 1].TZ); anim = matanims[ico.JointID - 1].AOBJ; } // check animation for world position if (anim != null) { foreach (var v in anim.FObjDesc.List) { System.Diagnostics.Debug.WriteLine(v.JointTrackType); if (v.JointTrackType == JointTrackType.HSD_A_J_TRAX) { var keys = v.GetDecodedKeys(); worldPosition.X = keys[keys.Count - 1].Value; } } } joint.TX = worldPosition.X + center.X; joint.TY = worldPosition.Y + center.Y; joint.TZ = worldPosition.Z + center.Z; position_joint.AddChild(joint); anim_joint.AddChild(new HSD_AnimJoint()); matanim_joint.AddChild(HSDAccessor.DeepClone <HSD_MatAnimJoint>(icon_matanim_joint)); } mex.IconModel = position_joint; mex.IconAnimJoint = anim_joint; mex.IconMatAnimJoint = matanim_joint; mex.CSPMatAnim = HSDAccessor.DeepClone <HSD_MatAnim>(table.MenuMaterialAnimation.Children[6].Child.MaterialAnimation); var cspkeys = mex.CSPMatAnim.TextureAnimation.AnimationObject.FObjDesc.GetDecodedKeys(); foreach (var k in cspkeys) { if ((k.Frame % 30) >= 19) { k.Frame++; } } mex.CSPMatAnim.TextureAnimation.AnimationObject.FObjDesc.SetKeys(cspkeys, (byte)TexTrackType.HSD_A_T_TIMG); mex.CSPMatAnim.TextureAnimation.AnimationObject.FObjDesc.Next.SetKeys(cspkeys, (byte)TexTrackType.HSD_A_T_TCLT); mex.CSPStride = 30; return(mex); }
/// <summary> /// /// </summary> /// <param name="stage"></param> /// <returns></returns> public static MEX_mexMapData LoadIconDataFromVanilla(SBM_MnSelectStageDataTable stage) { List <HSD_TOBJ> nameTags = new List <HSD_TOBJ>(); List <HSD_TOBJ> iconTOBJs = new List <HSD_TOBJ>(); HSD_JOBJ root = new HSD_JOBJ() { SX = 1, SY = 1, SZ = 1, Flags = JOBJ_FLAG.CLASSICAL_SCALING }; HSD_AnimJoint animRoot = new HSD_AnimJoint(); var tex0 = stage.IconDoubleMatAnimJoint.Child.Next.MaterialAnimation.Next.TextureAnimation.ToTOBJs(); var tex0_extra = stage.IconDoubleMatAnimJoint.Child.MaterialAnimation.Next.TextureAnimation.ToTOBJs(); var tex1 = stage.IconLargeMatAnimJoint.Child.MaterialAnimation.Next.TextureAnimation.ToTOBJs(); var tex2 = stage.IconSpecialMatAnimJoint.Child.MaterialAnimation.Next.TextureAnimation.ToTOBJs(); var nameTOBJs = stage.StageNameMatAnimJoint.Child.Child.MaterialAnimation.TextureAnimation.ToTOBJs(); var nameTOBJsAnim = stage.StageNameMatAnimJoint.Child.Child.MaterialAnimation.TextureAnimation.AnimationObject.FObjDesc.GetDecodedKeys(); var positionAnimation = new List <HSD_AnimJoint>(); foreach (var c in stage.PositionAnimation.Children) { var pos = new HSD_AnimJoint(); pos.AOBJ = HSDAccessor.DeepClone <HSD_AOBJ>(c.AOBJ); positionAnimation.Add(pos); } var g1 = tex0.Length - 2; var g2 = tex0.Length - 2 + tex1.Length - 2; var g3 = tex0.Length - 2 + tex1.Length - 2 + tex2.Length - 2; for (int i = 0; i < stage.PositionModel.Children.Length; i++) { var childIndex = i; if (unswizzle.ContainsKey(i)) { childIndex = unswizzle[i]; } HSD_TOBJ icon = null; HSD_TOBJ name = null; var keys = positionAnimation[childIndex].AOBJ.FObjDesc.GetDecodedKeys(); var Y = stage.PositionModel.Children[childIndex].TY; var Z = stage.PositionModel.Children[childIndex].TZ; var SX = 1f; var SY = 1f; if (i >= g3) { //RandomIcon name = nameTOBJs[(int)nameTOBJsAnim[nameTOBJsAnim.Count - 1].Value]; } else if (i >= g2) { name = nameTOBJs[(int)nameTOBJsAnim[24 + (i - g2)].Value]; icon = tex2[i - g2 + 2]; SX = 0.8f; SY = 0.8f; } else if (i >= g1) { name = nameTOBJs[(int)nameTOBJsAnim[22 + texunswizzle[i - g1]].Value]; icon = tex1[i - g1 + 2]; SY = 1.1f; } else { icon = tex0[texunswizzle[i] + 2]; name = nameTOBJs[(int)nameTOBJsAnim[texunswizzle[i]].Value * 2]; root.AddChild(new HSD_JOBJ() { TX = keys[keys.Count - 1].Value, TY = Y, TZ = Z, SX = SX, SY = SY, SZ = 1, Flags = JOBJ_FLAG.CLASSICAL_SCALING }); iconTOBJs.Add(icon); nameTags.Add(name); animRoot.AddChild(HSDAccessor.DeepClone <HSD_AnimJoint>(positionAnimation[childIndex])); Y -= 5.6f; Z = 0; icon = tex0_extra[texunswizzle[i] + 2]; name = nameTOBJs[(int)nameTOBJsAnim[texunswizzle[i]].Value * 2 + 1]; } root.AddChild(new HSD_JOBJ() { TX = keys[keys.Count - 1].Value, TY = Y, TZ = Z, SX = SX, SY = SY, SZ = 1, Flags = JOBJ_FLAG.CLASSICAL_SCALING }); iconTOBJs.Add(icon); nameTags.Add(name); animRoot.AddChild(HSDAccessor.DeepClone <HSD_AnimJoint>(positionAnimation[childIndex])); } var extraIcons = stage.IconLargeMatAnimJoint.Child.MaterialAnimation.Next.TextureAnimation.ToTOBJs(); iconTOBJs.Insert(0, extraIcons[0]); iconTOBJs.Insert(0, extraIcons[1]); iconTOBJs.Add(extraIcons[0]); var iconJOBJ = HSDAccessor.DeepClone <HSD_JOBJ>(stage.IconDoubleModel); iconJOBJ.Child = iconJOBJ.Child.Next; var iconAnimJoint = HSDAccessor.DeepClone <HSD_AnimJoint>(stage.IconDoubleAnimJoint); iconAnimJoint.Child = iconAnimJoint.Child.Next; var iconMatAnimJoint = HSDAccessor.DeepClone <HSD_MatAnimJoint>(stage.IconDoubleMatAnimJoint); iconMatAnimJoint.Child = iconMatAnimJoint.Child.Next; iconMatAnimJoint.Child.MaterialAnimation.Next.TextureAnimation.FromTOBJs(iconTOBJs.ToArray(), true); var mapdata = new MEX_mexMapData(); mapdata.IconModel = iconJOBJ; mapdata.IconAnimJoint = iconAnimJoint; mapdata.IconMatAnimJoint = iconMatAnimJoint; mapdata.PositionModel = root; mapdata.PositionAnimJoint = animRoot; mapdata.StageNameMaterialAnimation = HSDAccessor.DeepClone <HSD_MatAnimJoint>(stage.StageNameMatAnimJoint); mapdata.StageNameMaterialAnimation.Child.Child.MaterialAnimation.TextureAnimation.FromTOBJs(nameTags, true); return(mapdata); }
/// <summary> /// /// </summary> private void InstallUI(ZipFile pack, MEXFighterEntry fighter) { Console.WriteLine($"Installing UI data..."); // LOAD Stock Icons var icons = pack.Where(e => Regex.IsMatch(e.FileName, "Icon/ico..\\.png")).ToArray(); HSD_TOBJ[] iconTOBJs = new HSD_TOBJ[icons.Length]; foreach (var c in icons) { var index = int.Parse(Regex.Match(c.FileName, @"\d\d").Value); using (MemoryStream stream = new MemoryStream(GetBytes(c))) using (var bmp = new System.Drawing.Bitmap(stream)) iconTOBJs[index] = TOBJConverter.BitmapToTOBJ(bmp, HSDRaw.GX.GXTexFmt.CI4, HSDRaw.GX.GXTlutFmt.RGB5A3); } // Load Menu Icon // Load Emblem var emblemPack = pack["UI/emblem.obj"]; HSD_TOBJ emblemTexture = null; HSD_JOBJ emblemModel = null; if (emblemPack != null) { EmblemModel model; using (MemoryStream stream = new MemoryStream()) { emblemPack.Extract(stream); stream.Position = 0; model = Converters.EmblemConverter.GenerateEmblemModelFromOBJ(stream); } emblemModel = Converters.EmblemConverter.GenerateEmblemModel(model); emblemTexture = Converters.EmblemConverter.GenerateEmblemIconImage(model); } // Load Misc Name Tags and icons var largeName = pack["UI/result_victory_name.png"]; var smallName = pack["UI/result_name.png"]; HSD_TOBJ largeNameTexture = null; HSD_TOBJ smallNameTexture = null; if (largeName != null) { using (MemoryStream stream = new MemoryStream(GetBytes(largeName))) using (var bmp = new System.Drawing.Bitmap(stream)) largeNameTexture = TOBJConverter.BitmapToTOBJ(bmp, HSDRaw.GX.GXTexFmt.I4, HSDRaw.GX.GXTlutFmt.IA8); } if (smallName != null) { using (MemoryStream stream = new MemoryStream(GetBytes(smallName))) using (var bmp = new System.Drawing.Bitmap(stream)) smallNameTexture = TOBJConverter.BitmapToTOBJ(bmp, HSDRaw.GX.GXTexFmt.I4, HSDRaw.GX.GXTlutFmt.IA8); } // -------------------------------------------------------------------------- var root = Path.GetDirectoryName(MainForm.Instance.FilePath); int stride = editor.FighterControl.FighterEntries.Count - 3; int internalID = editor.FighterControl.FighterEntries.IndexOf(fighter); var externalId = MEXIdConverter.ToExternalID(internalID, editor.FighterControl.FighterEntries.Count); int GroupID = externalId - (externalId > 18 ? 1 : 0); // Inject CSPs and Stock Icons into Character Select //var chrSelPath = Path.Combine(root, "MnSlChr.usd"); //if (File.Exists(chrSelPath)) // InjectCharSelectImages(pack, chrSelPath, iconTOBJs, emblemTexture, fighter, stride, GroupID); // Inject Stock Icons into IfAll, GmRst var ifallPath = Path.Combine(root, "IfAll.usd"); if (File.Exists(ifallPath)) { var datFile = new HSDRawFile(ifallPath); var mark = datFile.Roots.Find(e => e.Name.Equals("Stc_scemdls")).Data as HSDNullPointerArrayAccessor <HSD_JOBJDesc>; for (int i = 0; i < 7; i++) // first 7 { InjectIntoMatTexAnim(mark[0].MaterialAnimations[0].Children[i].MaterialAnimation.TextureAnimation, iconTOBJs, GroupID, stride, MAX_COSTUME_COUNT); } var emblemGroup = datFile.Roots.Find(e => e.Name.Equals("DmgMrk_scene_models")).Data as HSDNullPointerArrayAccessor <HSD_JOBJDesc>; InjectIntoMatTexAnim(emblemGroup[0].MaterialAnimations[0].Child.MaterialAnimation.TextureAnimation, new HSDRaw.Common.HSD_TOBJ[] { emblemTexture }, GroupID, stride, 1, fighter.InsigniaID); editedFiles.Add(new Tuple <HSDRawFile, string, bool>(datFile, ifallPath, true)); } var gmRst = Path.Combine(root, "GmRst.usd"); if (File.Exists(gmRst)) { var datFile = new HSDRawFile(gmRst); var flmsce = datFile.Roots.Find(e => e.Name.Equals("flmsce")).Data as HSD_SOBJ; var pnlsce = datFile.Roots.Find(e => e.Name.Equals("pnlsce")).Data as HSD_SOBJ; // Stock Icons------------------------------------- for (int i = 5; i <= 8; i++) // at 5-8, 2nd mat anim { InjectIntoMatTexAnim( pnlsce.JOBJDescs[0].MaterialAnimations[0].Children[i].MaterialAnimation.Next.TextureAnimation, iconTOBJs, GroupID, stride, MAX_COSTUME_COUNT); } // Emblem Textures-------------------------------------- var matgroup = pnlsce.JOBJDescs[0].MaterialAnimations[0].Children[17]; for (int i = 0; i < 4; i++) { InjectIntoMatTexAnim(matgroup.Children[i].MaterialAnimation.TextureAnimation, new HSDRaw.Common.HSD_TOBJ[] { emblemTexture }, GroupID, stride, 1, fighter.InsigniaID); } // Emblem Model-------------------------------------- var emblemGroup = flmsce.JOBJDescs[0]; if (emblemModel != null) { var modelIndex = emblemGroup.RootJoint.Children[4].Children.Length; fighter.InsigniaID = (byte)modelIndex; var jointClone = HSDAccessor.DeepClone <HSDRaw.Common.Animation.HSD_AnimJoint>(emblemGroup.JointAnimations[0].Children[4].Child); jointClone.Next = null; var matjointClone = HSDAccessor.DeepClone <HSDRaw.Common.Animation.HSD_MatAnimJoint>(emblemGroup.MaterialAnimations[0].Children[4].Child); matjointClone.Next = null; emblemGroup.JointAnimations[0].Children[4].AddChild(jointClone); emblemGroup.MaterialAnimations[0].Children[4].AddChild(matjointClone); emblemGroup.RootJoint.Children[4].AddChild(emblemModel); } // name textures var largenameGroup = pnlsce.JOBJDescs[0].MaterialAnimations[0].Children[0].Children[2].MaterialAnimation.Next.TextureAnimation; InjectIntoMatTexAnim(largenameGroup, new HSD_TOBJ[] { largeNameTexture }, GroupID, stride, 1); var smallnameGroup = pnlsce.JOBJDescs[0].MaterialAnimations[0]; for (int i = 9; i < 13; i++) { InjectIntoMatTexAnim(smallnameGroup.Children[i].Children[1].MaterialAnimation.TextureAnimation, new HSD_TOBJ[] { smallNameTexture }, GroupID, stride, 1); } editedFiles.Add(new Tuple <HSDRawFile, string, bool>(datFile, gmRst, true)); } // Inject Emblem // Generate Emblem Models and Inject // Inject Misc Name Tags and icons }
/// <summary> /// /// </summary> /// <param name="table"></param> /// <param name="icons"></param> /// <returns></returns> public static MEX_mexSelectChr GenerateMEXMapFromVanilla(SBM_SelectChrDataTable table, MEX_CSSIconEntry[] icons) { // generate icon model var icon_joint = HSDAccessor.DeepClone <HSD_JOBJ>(table.MenuModel.Children[2].Child); icon_joint.TX = 0; icon_joint.TY = 0; icon_joint.TZ = 0; icon_joint.Next = null; var center = RegenerateIcon(icon_joint); var icon_matanim_joint = HSDAccessor.DeepClone <HSD_MatAnimJoint>(table.MenuMaterialAnimation.Children[2].Child); icon_matanim_joint.Next = null; // generate mat anim node var joints = table.MenuModel.BreathFirstList; HSD_TOBJ[] tobjs = new HSD_TOBJ[icons.Max(e => e.FighterExternalID) + 1]; JOBJManager m = new JOBJManager(); m.SetJOBJ(table.MenuModel); m.SetAnimJoint(table.MenuAnimation); m.Frame = 600; m.UpdateNoRender(); var csps = table.MenuMaterialAnimation.Children[6].Child.MaterialAnimation.TextureAnimation.ToTOBJs(); var cspKeys = table.MenuMaterialAnimation.Children[6].Child.MaterialAnimation.TextureAnimation.AnimationObject.FObjDesc.GetDecodedKeys(); var stride = 30; foreach (var ico in icons) { if (joints[ico.icon.JointID].Dobj == null) { continue; } HSD_JOBJ pos = HSDAccessor.DeepClone <HSD_JOBJ>(icon_joint); pos.Dobj.Pobj.Attributes = icon_joint.Dobj.Pobj.Attributes; pos.Dobj.Next.Pobj.Attributes = icon_joint.Dobj.Pobj.Attributes; pos.Dobj.Next.Mobj.Textures = HSDAccessor.DeepClone <HSD_TOBJ>(joints[ico.icon.JointID].Dobj.Next.Mobj.Textures); var worldPosition = Vector3.TransformPosition(Vector3.Zero, m.GetWorldTransform(ico.icon.JointID)); pos.TX = worldPosition.X + center.X; pos.TY = worldPosition.Y + center.Y; pos.TZ = worldPosition.Z + center.Z; ico.Joint = pos; ico.Animation = new MexMenuAnimation(); ico.MatAnimJoint = HSDAccessor.DeepClone <HSD_MatAnimJoint>(icon_matanim_joint); // load csps // find key at stride var icocsps = new List <HSD_TOBJ>(); int cspIndex = 0; while (true) { var key = ico.FighterExternalID + (cspIndex * stride); if (ico.FighterExternalID > 0x13) { key = ico.FighterExternalID + (cspIndex * stride) - 1; } var k = cspKeys.Find(e => e.Frame == key); if (k == null) { break; } icocsps.Add(csps[(int)k.Value]); cspIndex++; } ico.CSPs = icocsps.Select(e => new TOBJProxy() { TOBJ = e }).ToArray(); } m.RefreshRendering = true; MEX_mexSelectChr mex = new MEX_mexSelectChr(); SetMexNode(mex, icons); return(mex); }