public JointAnm(EndianBinaryReader er, out bool OK) { er.SetMarkerOnCurrentOffset(nameof(JointAnm)); bool OK1; this.anmHeader = new AnmHeader(er, AnmHeader.Category0.J, AnmHeader.Category1.AC, out OK1); if (!OK1) { OK = false; } else { this.numFrame = er.ReadUInt16(); this.numNode = er.ReadUInt16(); this.annFlag = er.ReadUInt32(); this.ofsRot3 = er.ReadUInt32(); er.SetMarker(nameof(ofsRot3), (long)this.ofsRot3 + er.GetMarker(nameof(JointAnm))); this.ofsRot5 = er.ReadUInt32(); er.SetMarker(nameof(ofsRot5), (long)this.ofsRot5 + er.GetMarker(nameof(JointAnm))); this.ofsTag = er.ReadUInt16s((int)this.numNode); er.ReadBytes(4); this.tagData = new NSBCA.JointAnmSet.JointAnm.TagData[(int)this.numNode]; long position = er.BaseStream.Position; for (int index = 0; index < (int)this.numNode; ++index) { er.BaseStream.Position = (long)this.ofsTag[index] + er.GetMarker(nameof(JointAnm)); this.tagData[index] = new NSBCA.JointAnmSet.JointAnm.TagData(er, (int)this.numFrame); } er.BaseStream.Position = position; er.RemoveMarker(nameof(JointAnm)); er.RemoveMarker(nameof(ofsRot3)); er.RemoveMarker(nameof(ofsRot5)); OK = true; } }
private GameObject generateAnimation(GameObject obj) { var animation = obj.AddComponent <Animation>(); var SKN = System.IO.File.ReadAllBytes(this.ANMFiles[12]); BinaryReader reader = new BinaryReader(new MemoryStream(SKN)); AnmHeader header = new AnmHeader(reader); AnmData ad = new AnmData(reader); AnimationClip clip = new AnimationClip(); clip.name = "clip1"; clip.wrapMode = WrapMode.Once; clip.legacy = true; clip.frameRate = ad.FPS; foreach (var item in ad.Frames) { var curvex = new AnimationCurve(); var curvey = new AnimationCurve(); var curvez = new AnimationCurve(); var curvew = new AnimationCurve(); var boneExtra = sklData.Bones.Where(x => x.Hash == item.BoneHash).FirstOrDefault(); string boneName = "u" + item.BoneHash; if (boneExtra != null) { boneName = boneExtra.Name; } foreach (var k in item.Quaternion) { Vector3 v = k.Rotation.eulerAngles; curvex.AddKey(k.Time, v.x); curvey.AddKey(k.Time, v.y); curvez.AddKey(k.Time, v.z); //curvez.AddKey(k.Time, v.w); } var t = GetRelatedPath(obj, boneName); t = t.Replace(obj.name + "/", ""); //localRotation //rotation clip.SetCurve(t, typeof(Transform), "localEulerAnglesRaw.x", curvex); clip.SetCurve(t, typeof(Transform), "localEulerAnglesRaw.y", curvey); clip.SetCurve(t, typeof(Transform), "localEulerAnglesRaw.z", curvez); //clip.SetCurve(t, typeof(Transform), "m_LocalEulerAngles.w", curvew); } animation.AddClip(clip, clip.name); animation.Play(clip.name); return(obj); }
public VisAnm(EndianBinaryReader er, out bool OK) { bool OK1; this.anmHeader = new AnmHeader(er, AnmHeader.Category0.V, AnmHeader.Category1.AV, out OK1); if (!OK1) { OK = false; } else { this.numFrame = er.ReadUInt16(); this.numNode = er.ReadUInt16(); this.size = er.ReadUInt16(); this.Padding = er.ReadUInt16(); this.visData = er.ReadUInt32s(1 + ((int)this.numFrame * (int)this.numNode >> 5)); OK = true; } }
public MatColAnm(EndianBinaryReader er, out bool OK) { er.SetMarkerOnCurrentOffset(nameof(MatColAnm)); bool OK1; this.anmHeader = new AnmHeader(er, AnmHeader.Category0.M, AnmHeader.Category1.AM, out OK1); if (!OK1) { OK = false; } else { this.numFrame = er.ReadUInt16(); this.flag = er.ReadUInt16(); this.dict = new Dictionary <NSBMA.MatColAnmSet.MatColAnm.DictMatColAnmData>(er); er.RemoveMarker(nameof(MatColAnm)); OK = true; } }
public TexSRTAnm(EndianBinaryReader er, out bool OK) { er.SetMarkerOnCurrentOffset(nameof(TexSRTAnm)); bool OK1; this.anmHeader = new AnmHeader(er, AnmHeader.Category0.M, AnmHeader.Category1.AT, out OK1); if (!OK1) { OK = false; } else { this.numFrame = er.ReadUInt16(); er.SetMarker(nameof(numFrame), (long)this.numFrame); this.flag = er.ReadByte(); this.texMtxMode = er.ReadByte(); this.dict = new Dictionary <NSBTA.TexSRTAnmSet.TexSRTAnm.TexSRTAnmData>(er); er.RemoveMarker(nameof(TexSRTAnm)); er.RemoveMarker(nameof(numFrame)); OK = true; } }
public TexPatAnm(EndianBinaryReader er, out bool OK) { er.SetMarkerOnCurrentOffset(nameof(TexPatAnm)); bool OK1; this.anmHeader = new AnmHeader(er, AnmHeader.Category0.M, AnmHeader.Category1.PT, out OK1); if (!OK1) { OK = false; } else { this.numFrame = er.ReadUInt16(); this.numTex = er.ReadByte(); this.numPltt = er.ReadByte(); this.ofsTexName = er.ReadUInt16(); this.ofsPlttName = er.ReadUInt16(); this.dict = new Dictionary <NSBTP.TexPatAnmSet.TexPatAnm.DictTexPatAnmData>(er); long position = er.BaseStream.Position; er.BaseStream.Position = er.GetMarker(nameof(TexPatAnm)) + (long)this.ofsTexName; this.texName = new NSBTP.TexPatAnmSet.TexPatAnm.DictName[(int)this.numTex]; for (int index = 0; index < (int)this.numTex; ++index) { this.texName[index] = new NSBTP.TexPatAnmSet.TexPatAnm.DictName(er); } er.BaseStream.Position = er.GetMarker(nameof(TexPatAnm)) + (long)this.ofsPlttName; this.plttName = new NSBTP.TexPatAnmSet.TexPatAnm.DictName[(int)this.numPltt]; for (int index = 0; index < (int)this.numPltt; ++index) { this.plttName[index] = new NSBTP.TexPatAnmSet.TexPatAnm.DictName(er); } er.BaseStream.Position = position; er.RemoveMarker(nameof(TexPatAnm)); OK = true; } }