/// <summary> /// /// </summary> /// <param name="node"></param> /// <returns></returns> private static HSD_MatAnimJoint GenerateMatAnimJointFromJOBJ(HSD_JOBJ node) { HSD_MatAnimJoint joint = new HSD_MatAnimJoint(); if (node.Dobj != null) { foreach (var v in node.Dobj.List) { if (joint.MaterialAnimation == null) { joint.MaterialAnimation = new HSD_MatAnim(); } else { joint.MaterialAnimation.Add(new HSD_MatAnim() { }); } } } foreach (var v in node.Children) { joint.AddChild(GenerateMatAnimJointFromJOBJ(v)); } return(joint); }
/// <summary> /// /// </summary> /// <param name="icons"></param> /// <returns></returns> public static Tuple <HSD_JOBJ, HSD_AnimJoint, HSD_MatAnimJoint> GenerateIconModel(MEX_CSSIconEntry[] icons) { 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(); foreach (var ico in icons) { ico.Joint.Next = null; ico.AnimJoint.Next = null; ico.MatAnimJoint.Next = null; position_joint.AddChild(ico.Joint); anim_joint.AddChild(ico.AnimJoint); matanim_joint.AddChild(ico.MatAnimJoint); } return(new Tuple <HSD_JOBJ, HSD_AnimJoint, HSD_MatAnimJoint>(position_joint, anim_joint, matanim_joint)); }
/// <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); }