public void Reload(VisibilityAnim anim) { Name = anim.Name; FrameCount = anim.FrameCount; FrameRate = 60.0f; Loop = anim.Flags.HasFlag(VisibilityAnimFlags.Looping); if (anim.Names == null) { return; } AnimGroups.Clear(); for (int i = 0; i < anim.Names.Count; i++) { var baseValue = anim.BaseDataList[i]; BoneAnimGroup group = new BoneAnimGroup(); group.Name = anim.Names[i]; AnimGroups.Add(group); group.Track.KeyFrames.Add(new STKeyFrame() { Frame = 0, Value = baseValue ? 1 : 0 }); foreach (var curve in anim.Curves) { if (curve.AnimDataOffset == i) { BfresAnimations.GenerateKeys(group.Track, curve); } } } }
private void ParseKeyTrack(STBone bone, BoneAnimGroup group) { float value = group.Track.GetFrameValue(this.Frame); bool isVisible = value != 0; bone.Visible = isVisible; }
public void Reload(SkeletalAnim anim) { SkeletalAnim = anim; Name = anim.Name; FrameCount = anim.FrameCount; FrameRate = 60.0f; Loop = anim.Loop; AnimGroups.Clear(); foreach (var boneAnim in anim.BoneAnims) { var group = new BoneAnimGroup(); AnimGroups.Add(group); group.Name = boneAnim.Name; if (anim.FlagsRotate == SkeletalAnimFlagsRotate.Quaternion) { group.UseQuaternion = true; } float scale = GLContext.PreviewScale; //Set the base data for the first set of keys if used if (boneAnim.FlagsBase.HasFlag(BoneAnimFlagsBase.Translate)) { group.Translate.X.KeyFrames.Add(new STKeyFrame(0, boneAnim.BaseData.Translate.X)); group.Translate.Y.KeyFrames.Add(new STKeyFrame(0, boneAnim.BaseData.Translate.Y)); group.Translate.Z.KeyFrames.Add(new STKeyFrame(0, boneAnim.BaseData.Translate.Z)); } if (boneAnim.FlagsBase.HasFlag(BoneAnimFlagsBase.Rotate)) { group.Rotate.X.KeyFrames.Add(new STKeyFrame(0, boneAnim.BaseData.Rotate.X)); group.Rotate.Y.KeyFrames.Add(new STKeyFrame(0, boneAnim.BaseData.Rotate.Y)); group.Rotate.Z.KeyFrames.Add(new STKeyFrame(0, boneAnim.BaseData.Rotate.Z)); group.Rotate.W.KeyFrames.Add(new STKeyFrame(0, boneAnim.BaseData.Rotate.Z)); } if (boneAnim.FlagsBase.HasFlag(BoneAnimFlagsBase.Scale)) { group.Scale.X.KeyFrames.Add(new STKeyFrame(0, boneAnim.BaseData.Scale.X)); group.Scale.Y.KeyFrames.Add(new STKeyFrame(0, boneAnim.BaseData.Scale.Y)); group.Scale.Z.KeyFrames.Add(new STKeyFrame(0, boneAnim.BaseData.Scale.Z)); } if (boneAnim.ApplySegmentScaleCompensate) { group.UseSegmentScaleCompensate = true; } //Generate keyed data from the curves foreach (var curve in boneAnim.Curves) { switch ((TrackType)curve.AnimDataOffset) { case TrackType.XPOS: BfresAnimations.GenerateKeys(group.Translate.X, curve); break; case TrackType.YPOS: BfresAnimations.GenerateKeys(group.Translate.Y, curve); break; case TrackType.ZPOS: BfresAnimations.GenerateKeys(group.Translate.Z, curve); break; case TrackType.XROT: BfresAnimations.GenerateKeys(group.Rotate.X, curve); break; case TrackType.YROT: BfresAnimations.GenerateKeys(group.Rotate.Y, curve); break; case TrackType.ZROT: BfresAnimations.GenerateKeys(group.Rotate.Z, curve); break; case TrackType.WROT: BfresAnimations.GenerateKeys(group.Rotate.W, curve); break; case TrackType.XSCA: BfresAnimations.GenerateKeys(group.Scale.X, curve); break; case TrackType.YSCA: BfresAnimations.GenerateKeys(group.Scale.Y, curve); break; case TrackType.ZSCA: BfresAnimations.GenerateKeys(group.Scale.Z, curve); break; } } } }