private void ReadMaterialAnimations(ANIM animFile, AnimGroup animGroup, SBAnimation animation) { var decoder = new SSBHAnimTrackDecoder(animFile); foreach (AnimNode animNode in animGroup.Nodes) { foreach (AnimTrack track in animNode.Tracks) { SBMaterialAnimation matAnim = new SBMaterialAnimation() { MaterialName = animNode.Name, AttributeName = track.Name }; object[] MaterialAnim = decoder.ReadTrack(track); // only get vectors for now if (MaterialAnim == null || MaterialAnim.Length == 0 || MaterialAnim[0] == null || MaterialAnim[0].GetType() != typeof(AnimTrackCustomVector4)) { continue; } animation.MaterialNodes.Add(matAnim); for (int i = 0; i < MaterialAnim.Length; i++) { var vec = (AnimTrackCustomVector4)MaterialAnim[i]; matAnim.Keys.AddKey(i, new Vector4(vec.X, vec.Y, vec.Z, vec.W)); } } } }
private void ReadVisibilityAnimations(ANIM animFile, AnimGroup animGroup, SBAnimation animation) { var decoder = new SSBHAnimTrackDecoder(animFile); foreach (AnimNode animNode in animGroup.Nodes) { SBVisibilityAnimation visAnim = new SBVisibilityAnimation() { MeshName = animNode.Name }; foreach (AnimTrack track in animNode.Tracks) { if (track.Name.Equals("Visibility")) { object[] Visibility = decoder.ReadTrack(track); for (int i = 0; i < Visibility.Length; i++) { visAnim.Visibility.AddKey(i, (bool)Visibility[i]); } } } animation.VisibilityNodes.Add(visAnim); } }
private void ReadTransformAnimations(ANIM animFile, AnimGroup animGroup, SBAnimation animation) { var decoder = new SSBHAnimTrackDecoder(animFile); foreach (AnimNode animNode in animGroup.Nodes) { SBTransformAnimation tfrmAnim = new SBTransformAnimation() { Name = animNode.Name }; foreach (AnimTrack track in animNode.Tracks) { object[] Transform = decoder.ReadTrack(track); if (track.Name.Equals("Transform")) { for (int i = 0; i < Transform.Length; i++) { AnimTrackTransform t = (AnimTrackTransform)Transform[i]; tfrmAnim.Transform.Keys.Add(new SBAnimKey <Matrix4>() { Frame = i, Value = GetMatrix((AnimTrackTransform)Transform[i]), }); } } } animation.TransformNodes.Add(tfrmAnim); } }
protected void PlayAnim(ANIM a) { switch (a) { case ANIM.Attack: anim.SetTrigger("Attack"); break; } }
public override void Open() { if (SSBH.TryParseSSBHFile(AbsolutePath, out ISSBH_File SSBHFile)) { if (SSBHFile is ANIM anim) { animation = anim; } } }
public override void Open(string Path) { ISSBH_File SSBHFile; if (SSBH.TryParseSSBHFile(Path, out SSBHFile)) { if (SSBHFile is ANIM anim) { animation = anim; } } }
private void ReadTransformAnimations(ANIM animFile, AnimGroup animGroup, SBAnimation animation) { var decoder = new SSBHAnimTrackDecoder(animFile); foreach (AnimNode animNode in animGroup.Nodes) { SBTransformAnimation tfrmAnim = new SBTransformAnimation() { Name = animNode.Name }; SBTransformTrack X = new SBTransformTrack(SBTrackType.TranslateX); SBTransformTrack Y = new SBTransformTrack(SBTrackType.TranslateY); SBTransformTrack Z = new SBTransformTrack(SBTrackType.TranslateZ); SBTransformTrack RX = new SBTransformTrack(SBTrackType.RotateX); SBTransformTrack RY = new SBTransformTrack(SBTrackType.RotateY); SBTransformTrack RZ = new SBTransformTrack(SBTrackType.RotateZ); SBTransformTrack SX = new SBTransformTrack(SBTrackType.ScaleX); SBTransformTrack SY = new SBTransformTrack(SBTrackType.ScaleY); SBTransformTrack SZ = new SBTransformTrack(SBTrackType.ScaleZ); SBTransformTrack CompensateScale = new SBTransformTrack(SBTrackType.CompensateScale); tfrmAnim.Tracks.AddRange(new SBTransformTrack[] { X, Y, Z, RX, RY, RZ, SX, SY, SZ, CompensateScale }); foreach (AnimTrack track in animNode.Tracks) { object[] Transform = decoder.ReadTrack(track); if (track.Name.Equals("Transform")) { for (int i = 0; i < Transform.Length; i++) { AnimTrackTransform t = (AnimTrackTransform)Transform[i]; SBBone transform = new SBBone(); transform.Transform = GetMatrix((AnimTrackTransform)Transform[i]); X.AddKey(i, transform.X); Y.AddKey(i, transform.Y); Z.AddKey(i, transform.Z); RX.AddKey(i, transform.RX); RY.AddKey(i, transform.RY); RZ.AddKey(i, transform.RZ); SX.AddKey(i, transform.SX); SY.AddKey(i, transform.SY); SZ.AddKey(i, transform.SZ); CompensateScale.AddKey(i, t.CompensateScale); } } } animation.TransformNodes.Add(tfrmAnim); } }
IEnumerator WaitEndOfAttack() { //等待一帧,让怪兽开始播放攻击动画 //yield return null; while (true) { //if (ANIM.IsInTransition(0)) //{ // yield return null; //} //获取当前的动画信息 AnimatorStateInfo asi = ANIM.GetCurrentAnimatorStateInfo(0); //判定当前动画是否是idle动画 if (asi.fullPathHash == Animator.StringToHash("Base Layer.Idle")) { break; } //else if (asi.fullPathHash == Animator.StringToHash("Base Layer.Locomotion")) //{ // yield return null; //} //else if (asi.fullPathHash == Animator.StringToHash("Base Layer.Attack")) //{ // yield return null; //} else { yield return(null); } } //代表攻击完毕, 需要转回去 ANIM.SetFloat("Speed", 1.0f); //标识旋转方向 m_eTurn = eTurnDirection.eTurn_Right; //标识旋转状态 m_eState = eMonsterState.Monster_Turn; //标识旋转终点 m_qCurStateQuaternion = m_qBirthQuaternion; }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Knife") { asi = ANIM.GetCurrentAnimatorStateInfo(0); if (asi.fullPathHash == Animator.StringToHash("Base Layer.Attack")) { int num = Random.Range(10, 30); //执行加分动画 m_delHitMonster(num); UI_BasePlayerInfos.TakeDamage(num); Destroy(BC); //添加特效 Instantiate(Resources.Load("IGSoft_Projects/SceneEffects/Common/E_Babble"), new Vector3(transform.position.x, transform.position.y + BC.size.y / 2f, transform.position.z) , Quaternion.identity); AudioManager.PlayAudio(gameObject, eAudioType.Audio_Skill, "skill_addbuff"); m_eState = eMonsterState.Monster_Dead; ANIM.SetTrigger("Base Layer.Die"); } } }
public void ChangeAnimation() { int seed = Random.Range(0, 100); if (seed < 30) { if (m_last_anim != ANIM.WALK) { this.Walk(); m_last_anim = ANIM.WALK; } } else if (seed < 50) { this.Damage(); m_last_anim = ANIM.DAMAGE; } else if (seed < 60) { this.Death(); m_last_anim = ANIM.DEATH; } else { switch (actor.main_weapon_type) { case PACKAGE_TYPE.WEAPON_BOW: this.Shoot(); break; default: if (seed < 80) this.Attack1(); else this.Attack2(); break; } m_last_anim = ANIM.ATTACK; } }
public AnimViewModel(GenericRCOLResource rcolResource) { IsSaving = false; mANIM = (ANIM) rcolResource.ChunkEntries.FirstOrDefault().RCOLBlock; CurrentFrameIndex = -1; SyncFrames(); CommitCommand = new UserCommand<AnimViewModel>(x => true, y => { IsSaving = true; Application.Current.Shutdown(); }); CancelCommand = new UserCommand<AnimViewModel>(x => true, y => { IsSaving = false; Application.Current.Shutdown(); }); RemoveFrameCommand = new UserCommand<AnimViewModel>(x => CurrentFrameIndex >= 0, RemoveFrame); AddFrameCommand = new UserCommand<AnimViewModel>(x => true, AddFrame); ShiftFrameUpCommand = new UserCommand<AnimViewModel>(x => x != null && x.CurrentFrameIndex > 0, ShiftFrameUp); ShiftFrameDownCommand = new UserCommand<AnimViewModel>(x => x != null && x.CurrentFrameIndex < x.Frames.Count - 1 && x.CurrentFrameIndex != -1, ShiftFrameDown); ImportCommand = new UserCommand<AnimViewModel>(x => x != null && x.GetSelectedFrame() != null, ImportDds); ExportCommand = new UserCommand<AnimViewModel>(x => x != null && x.GetSelectedFrame() != null && x.GetSelectedFrame().Frame.Stream.Length > 0, ExportDds); }
public AnimViewModel(GenericRCOLResource rcolResource) { IsSaving = false; mANIM = (ANIM)rcolResource.ChunkEntries.FirstOrDefault().RCOLBlock; CurrentFrameIndex = -1; SyncFrames(); CommitCommand = new UserCommand <AnimViewModel>(x => true, y => { IsSaving = true; Application.Current.Shutdown(); }); CancelCommand = new UserCommand <AnimViewModel>(x => true, y => { IsSaving = false; Application.Current.Shutdown(); }); RemoveFrameCommand = new UserCommand <AnimViewModel>(x => CurrentFrameIndex >= 0, RemoveFrame); AddFrameCommand = new UserCommand <AnimViewModel>(x => true, AddFrame); ShiftFrameUpCommand = new UserCommand <AnimViewModel>(x => x != null && x.CurrentFrameIndex > 0, ShiftFrameUp); ShiftFrameDownCommand = new UserCommand <AnimViewModel>(x => x != null && x.CurrentFrameIndex < x.Frames.Count - 1 && x.CurrentFrameIndex != -1, ShiftFrameDown); ImportCommand = new UserCommand <AnimViewModel>(x => x != null && x.GetSelectedFrame() != null, ImportDds); ExportCommand = new UserCommand <AnimViewModel>(x => x != null && x.GetSelectedFrame() != null && x.GetSelectedFrame().Frame.Stream.Length > 0, ExportDds); }
public SSBHAnimTrackDecoder(ANIM AnimFile) { this.AnimFile = AnimFile; }
public override void Export(string FileName) { string ext = Utils.GetExtension(FileName); if (ext == ".bfska") { if (GetResFileU() != null) { SkeletalAnimU.Export(FileName, GetResFileU()); } else { SkeletalAnim.Export(FileName, GetResFile()); } } else if (ext == ".chr0") { STSkeleton skeleton = GetActiveSkeleton(); if (SkeletalAnimU != null) { BrawlboxHelper.FSKAConverter.Fska2Chr0(BfresPlatformConverter.FSKAConvertWiiUToSwitch(SkeletalAnimU), FileName); } else { BrawlboxHelper.FSKAConverter.Fska2Chr0(SkeletalAnim, FileName); } // BrawlboxHelper.FSKAConverter.Fska2Chr0(this, skeleton, FileName); } else if (ext == ".smd") { STSkeleton skeleton = GetActiveSkeleton(); if (skeleton != null) { SMD.Save(this, skeleton, FileName); } else { throw new Exception("No skeleton found to assign!"); } } else if (ext == ".anim") { STSkeleton skeleton = GetActiveSkeleton(); if (skeleton != null) { ANIM.CreateANIM(FileName, this, skeleton); } else { throw new Exception("No skeleton found to assign!"); } } else if (ext == ".seanim") { STSkeleton skeleton = GetActiveSkeleton(); if (skeleton != null) { SEANIM.SaveAnimation(FileName, this, skeleton); } else { throw new Exception("No skeleton found to assign!"); } } }
// Update is called once per frame private void Update() { if (!isRegistered) { // print("registering ennemy"); GameManager.registerEnemy(gameObject); isRegistered = true; } if (!gotPlayerPoint && GameManager.isFreePoints()) { _enemyInfoHolder = GameManager.getInfo4Enemy(gameObject.transform); } if (!stop) { if (GameManager.isFreePoints()) { range = Vector3.Distance(transform.position, _enemyInfoHolder.point.dockPoint.position); if (range <= 0.2f) // checks when enemy is near the player dock point and then occupies it { if (!gotPlayerPoint) { GameManager.OccupyPoint(_enemyInfoHolder.point); gotPlayerPoint = true; pointHolding = _enemyInfoHolder.point.name; } if (STATE != ANIM.ATTACKING) { // print(gameObject.name); STATE = ANIM.ATTACKING; } timer += Time.deltaTime; if (gotPlayerPoint && timer >= timeBetweenAttacks) { AttackPlayer(); } else { // animator.Play("stand"); } } else if (range > 0.3f) { timer = 0f; if (STATE != ANIM.WALKING) { if (gotPlayerPoint) { GameManager.ReleasePoint(_enemyInfoHolder.point); } gotPlayerPoint = false; isMoving = true; STATE = ANIM.WALKING; animator.Play("Walking"); } } if (STATE == ANIM.WALKING) { if (dodging) { dodge(); } else if (MOVEMENT == BLOCKED.NULL) { float oldY = transform.position.y; transform.position = Vector3.MoveTowards(transform.position, _enemyInfoHolder.point.dockPoint.position, moveSpeed * Time.deltaTime); isMoving = true; if (transform.position.y >= 1.76f) { transform.position = new Vector3(transform.position.x, oldY, transform.position.z); MOVEMENT = BLOCKED.UP; TURN = DODGE.DOWN; dodging = true; isMoving = true; } else if (transform.position.y <= 0.18f) { transform.position = new Vector3(transform.position.x, oldY, transform.position.z); MOVEMENT = BLOCKED.DOWN; TURN = DODGE.UP; dodging = true; isMoving = true; } } else { rayHit(); } } } } CheckSide(_enemyInfoHolder); // this changes rotation according to player location }
public void PlayAnim(ANIM a) { sprite.PlayAnim(a.ToString() + "_" + facing.ToString()); anim = a; }
public override void Export(string FileName) { string ext = Utils.GetExtension(FileName); if (ext == ".bfska") { if (GetResFileU() != null) { SkeletalAnimU.Export(FileName, GetResFileU()); } else { SkeletalAnim.Export(FileName, GetResFile()); } } else if (ext == ".chr0") { STSkeleton skeleton = GetActiveSkeleton(); if (SkeletalAnimU != null) { BrawlboxHelper.FSKAConverter.Fska2Chr0(BfresPlatformConverter.FSKAConvertWiiUToSwitch(SkeletalAnimU), FileName); } else { BrawlboxHelper.FSKAConverter.Fska2Chr0(SkeletalAnim, FileName); } } else if (ext == ".smd") { STSkeleton skeleton = GetActiveSkeleton(); if (skeleton != null) { SMD.Save(this, skeleton, FileName); } else { throw new Exception("No skeleton found to assign!"); } } else if (ext == ".anim") { STSkeleton skeleton = GetActiveSkeleton(); if (skeleton != null) { ANIM.CreateANIM(FileName, this, skeleton); } else { throw new Exception("No skeleton found to assign!"); } } else if (ext == ".seanim") { STSkeleton skeleton = GetActiveSkeleton(); if (skeleton != null) { SEANIM.SaveAnimation(FileName, this, skeleton); } else { throw new Exception("No skeleton found to assign!"); } } else if (ext == ".json") { if (SkeletalAnimU != null) { System.IO.File.WriteAllText(FileName, Newtonsoft.Json.JsonConvert.SerializeObject(SkeletalAnimU, Newtonsoft.Json.Formatting.Indented)); } else { System.IO.File.WriteAllText(FileName, Newtonsoft.Json.JsonConvert.SerializeObject(SkeletalAnim, Newtonsoft.Json.Formatting.Indented)); } } }
/// <summary> /// Creates decoder for given ANIM file /// </summary> /// <param name="animFile"></param> public SSBHAnimTrackDecoder(ANIM animFile) { this.animFile = animFile; }
void RunAttackRun() { if (CheckEndOfMove()) { return; } //计算当前运动的百分比进度 m_fCurentPercentage = CalculateCurPercentage(); switch (m_eState) { case eMonsterState.Monster_RunAway: { /* * 怪兽运动进度, 是否是第一次播放攻击动画 : 只有满足上述两个条件,当前运动进度 > 设定运动进度 && 是第一次进行攻击 -> 执行攻击逻辑 * */ if (m_fCurentPercentage > m_fPercentage && m_bIsFirstAttack) { m_bIsFirstAttack = false; //设置转身模式 m_eState = eMonsterState.Monster_Turn; //设置转身朝向 m_eTurn = eTurnDirection.eTurn_Left; //设置当前状态旋转终点 m_qCurStateQuaternion = m_qTurnQuaternion; return; } //播放前进动画 ANIM.SetFloat("Speed", 1.0f); //修改怪兽位置 MoveMononster(); break; } case eMonsterState.Monster_Dead: { //判定透明度 if (m_alpha <= 0) { Destroy(gameObject); return; } if (null == m_sDeadShader) { m_sDeadShader = Shader.Find("Custom/SimpleAlpha"); m_smr.materials[0].shader = m_sDeadShader; } m_smr.materials[0].SetFloat("_TransVal", m_alpha); m_alpha -= Time.deltaTime * 0.5f; transform.Translate(new Vector3(0f, 2 * Time.deltaTime, 0f)); break; } case eMonsterState.Monster_Attack: { //获取当前的动画信息 asi = ANIM.GetCurrentAnimatorStateInfo(0); //判定当前动画是否是idle动画 if (asi.fullPathHash == Animator.StringToHash("Base Layer.Idle")) { //代表攻击完毕, 需要转回去 ANIM.SetFloat("Speed", 1.0f); //标识旋转方向 m_eTurn = eTurnDirection.eTurn_Right; //标识旋转状态 m_eState = eMonsterState.Monster_Turn; //标识旋转终点 m_qCurStateQuaternion = m_qBirthQuaternion; return; } break; } case eMonsterState.Monster_Turn: { //旋转怪兽到制定位置 -> Lerp的原理 : Beizier Line. transform.rotation = Quaternion.Lerp(transform.rotation, m_qCurStateQuaternion, 10 * Time.deltaTime); //判定当前旋转是否到达指定角度 if (Mathf.Abs(transform.rotation.eulerAngles.y - m_qCurStateQuaternion.eulerAngles.y) < 0.1f) { //左转 if (m_eTurn == eTurnDirection.eTurn_Left) { //设置当前状态为攻击状态 m_eState = eMonsterState.Monster_Attack; //播放攻击动画 ANIM.SetTrigger("Base Layer.Attack"); //AudioManager.PlayAudio(gameObject, eAudioType.Audio_Skill, "BI_sound"); //开启协程等待攻击结束 //StartCoroutine(WaitEndOfAttack()); } //右转 else { m_eState = eMonsterState.Monster_RunAway; } } break; } } }
private void button1_Click(object sender, EventArgs e) { if (animLoaded is true && bmdLoaded is true) { toolStripLabel3.Text = "Application: Exporting..."; toolStripLabel4.Visible = false; System.IO.FileStream fs = System.IO.File.Create(openFile.FileName.Replace(".anim", ".bck")); fs.Close(); EndianBinaryWriter bw = new EndianBinaryWriter(File.Open(openFile.FileName.Replace(".anim", ".bck"), FileMode.Open)); FileInfo bck = new FileInfo(openFile.FileName.Replace(".anim", ".bck")); anim = new Form1.ANIM(); readAnim(); readBMD(); // -- // J3D1bck1 section bw.Write(0x4A33443162636B31); // J3D1bck1 bw.Write((Int32)bck.Length); // size bw.Write(0x00000001); // sections bw.Write(0xFFFFFFFFFFFFFFFF); // --v bw.Write(0xFFFFFFFFFFFFFFFF); // padding //-- // J3D1bck1 parsing ends here // -- //ANK1 section bw.Write(0x414E4B31); // ANK1 bw.Write((Int32)bck.Length - 0x20); // size if (radioButton1.Checked) { bw.BaseStream.WriteByte(0); // play once } if (radioButton2.Checked) { bw.BaseStream.WriteByte(1); // unknown } if (radioButton3.Checked) { bw.BaseStream.WriteByte(2); // loop } if (radioButton4.Checked) { bw.BaseStream.WriteByte(3); // mirror } if (radioButton5.Checked) { bw.BaseStream.WriteByte(4); // ping pong loop } bw.BaseStream.WriteByte(1); // angle multiplier float t = float.Parse(animHead.endTime); bw.Write(Convert.ToInt16(t)); int joints = jnt1.joints; bw.Write((UInt16)joints); bw.Write(anim.scaleCount); // scale count bw.Write(anim.rotCount); // rotation count bw.Write(anim.transCount); // translation count bw.Write((Int32)64); // joint off bw.Write(anim.scalesOff); bw.Write(anim.rotsOff); bw.Write(anim.transOff); insertPadding(bw, 32, true); int pos = (int)bw.BaseStream.Position; bw.Close(); parseAnimationTable(pos); }
/** アニメを設定する*/ public static void SetAnim(ANIM state) { instance.anim.SetInteger("animation", (int)state); }
public FrameViewModel(AnimViewModel parent, ANIM.TextureFrame frame) { mParent = parent; mFrame = frame; }