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); } } } }
public void Reload(CameraAnim anim) { Name = anim.Name; FrameCount = anim.FrameCount; FrameRate = 60.0f; Loop = anim.Flags.HasFlag(CameraAnimFlags.Looping); CameraAnimGroup group = new CameraAnimGroup(); group.Name = anim.Name; group.IsOrtho = !anim.Flags.HasFlag(CameraAnimFlags.Perspective); group.IsLookat = !anim.Flags.HasFlag(CameraAnimFlags.EulerZXY); group.PositionX.KeyFrames.Add(new STKeyFrame(0, anim.BaseData.Position.X)); group.PositionY.KeyFrames.Add(new STKeyFrame(0, anim.BaseData.Position.Y)); group.PositionZ.KeyFrames.Add(new STKeyFrame(0, anim.BaseData.Position.Z)); group.RotationX.KeyFrames.Add(new STKeyFrame(0, anim.BaseData.Rotation.X)); group.RotationY.KeyFrames.Add(new STKeyFrame(0, anim.BaseData.Rotation.Y)); group.RotationZ.KeyFrames.Add(new STKeyFrame(0, anim.BaseData.Rotation.Z)); group.Twist.KeyFrames.Add(new STKeyFrame(0, anim.BaseData.Twist)); group.ClipNear.KeyFrames.Add(new STKeyFrame(0, anim.BaseData.ClipNear)); group.ClipFar.KeyFrames.Add(new STKeyFrame(0, anim.BaseData.ClipFar)); group.AspectRatio.KeyFrames.Add(new STKeyFrame(0, anim.BaseData.AspectRatio)); group.FieldOfView.KeyFrames.Add(new STKeyFrame(0, anim.BaseData.FieldOfView)); AnimGroups.Clear(); AnimGroups.Add(group); for (int i = 0; i < anim.Curves.Count; i++) { var curve = anim.Curves[i]; switch ((CameraAnimDataOffset)curve.AnimDataOffset) { case CameraAnimDataOffset.PositionX: BfresAnimations.GenerateKeys(group.PositionX, curve); break; case CameraAnimDataOffset.PositionY: BfresAnimations.GenerateKeys(group.PositionY, curve); break; case CameraAnimDataOffset.PositionZ: BfresAnimations.GenerateKeys(group.PositionZ, curve); break; case CameraAnimDataOffset.RotationX: BfresAnimations.GenerateKeys(group.RotationX, curve); break; case CameraAnimDataOffset.RotationY: BfresAnimations.GenerateKeys(group.RotationY, curve); break; case CameraAnimDataOffset.RotationZ: BfresAnimations.GenerateKeys(group.RotationZ, curve); break; case CameraAnimDataOffset.Twist: BfresAnimations.GenerateKeys(group.Twist, curve); break; case CameraAnimDataOffset.ClipNear: BfresAnimations.GenerateKeys(group.ClipNear, curve); break; case CameraAnimDataOffset.ClipFar: BfresAnimations.GenerateKeys(group.ClipFar, curve); break; case CameraAnimDataOffset.AspectRatio: BfresAnimations.GenerateKeys(group.AspectRatio, curve); break; case CameraAnimDataOffset.FieldOFView: BfresAnimations.GenerateKeys(group.FieldOfView, curve); break; } } }
public void Reload(ShapeAnim anim) { Name = anim.Name; FrameCount = anim.FrameCount; FrameRate = 60.0f; Loop = anim.Flags.HasFlag(ShapeAnimFlags.Looping); AnimGroups.Clear(); foreach (var shapeAnim in anim.VertexShapeAnims) { var group = new ShapeAnimGroup(); AnimGroups.Add(group); group.Name = shapeAnim.Name; //Get the shape keys used for animating int baseIndex = 0; for (int i = 0; i < shapeAnim.KeyShapeAnimInfos.Count; i++) { int startBaseIndex = shapeAnim.KeyShapeAnimInfos.Count - shapeAnim.BaseDataList.Length; var keyShapeInfo = shapeAnim.KeyShapeAnimInfos[i]; //Get the curve index for animated indices int curveIndex = keyShapeInfo.CurveIndex; //Make a new sampler track using step interpolation var track = new KeyShapeTrack(); track.InterpolationType = STInterpoaltionType.Step; track.Name = keyShapeInfo.Name; if (group.BaseTarget == null && curveIndex == -1) { group.BaseTarget = track; } if (curveIndex != -1) { BfresAnimations.GenerateKeys(track, shapeAnim.Curves[curveIndex]); } else if (i >= startBaseIndex) { float baseWeight = shapeAnim.BaseDataList[baseIndex]; track.KeyFrames.Add(new STKeyFrame(0, baseWeight)); baseIndex++; } group.Tracks.Add(track); } } }
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; } } } }
public void Reload(MaterialAnim anim) { Name = anim.Name; FrameCount = anim.FrameCount; FrameRate = 60.0f; Loop = anim.Loop; if (anim.TextureNames != null) { TextureList = anim.TextureNames.Keys.ToList(); } if (anim.MaterialAnimDataList == null) { return; } AnimGroups.Clear(); foreach (var matAnim in anim.MaterialAnimDataList) { var group = new MaterialAnimGroup(); AnimGroups.Add(group); group.Name = matAnim.Name; //Get the material animation's texture pattern animation lists //Each sampler has their own info for (int i = 0; i < matAnim.PatternAnimInfos.Count; i++) { var patternInfo = matAnim.PatternAnimInfos[i]; //Get the curve index for animated indices int curveIndex = patternInfo.CurveIndex; //Get the base index for starting values int textureBaseIndex = matAnim.BaseDataList.Length > i ? matAnim.BaseDataList[i] : 0; //Make a new sampler track using step interpolation var samplerTrack = new SamplerTrack(); samplerTrack.InterpolationType = STInterpoaltionType.Step; samplerTrack.Sampler = patternInfo.Name; group.Tracks.Add(samplerTrack); if (curveIndex != -1) { BfresAnimations.GenerateKeys(samplerTrack, matAnim.Curves[curveIndex], true); } else //Use the base data and make a constant key { samplerTrack.KeyFrames.Add(new STKeyFrame(0, textureBaseIndex)); } } //Get the list of animated parameters for (int i = 0; i < matAnim.ParamAnimInfos.Count; i++) { ParamAnimGroup paramGroup = new ParamAnimGroup(); paramGroup.Name = matAnim.ParamAnimInfos[i].Name; group.SubAnimGroups.Add(paramGroup); var paramInfo = matAnim.ParamAnimInfos[i]; //Params have int and float curves int curveIndex = paramInfo.BeginCurve; int constantIndex = paramInfo.BeginConstant; int numFloats = paramInfo.FloatCurveCount; int numInts = paramInfo.IntCurveCount; int numConstants = paramInfo.ConstantCount; //Each constant and curve get's their own value using a value offset for (int j = 0; j < numConstants; j++) { var constant = matAnim.Constants[constantIndex + j]; float value = constant.Value; //A bit hacky, convert int32 types by value range SRT modes use if (constant.Value.Int32 > 0 && constant.Value.Int32 < 6) { value = constant.Value.Int32; } paramGroup.Tracks.Add(new ParamTrack() { Name = constant.AnimDataOffset.ToString("X"), ValueOffset = constant.AnimDataOffset, //Not the best way, but 4 is typically the stride size for each value ChannelIndex = (int)(constant.AnimDataOffset / 4), KeyFrames = new List <STKeyFrame>() { new STKeyFrame(0, value) }, InterpolationType = STInterpoaltionType.Constant, }); } //Loop through all int and float curve values for (int j = 0; j < numInts + numFloats; j++) { var curve = matAnim.Curves[curveIndex + j]; var paramTrack = new ParamTrack() { Name = curve.AnimDataOffset.ToString("X") }; paramTrack.ValueOffset = curve.AnimDataOffset; //Not the best way, but 4 is typically the stride size for each value paramTrack.ChannelIndex = (int)(curve.AnimDataOffset / 4); paramGroup.Tracks.Add(paramTrack); BfresAnimations.GenerateKeys(paramTrack, curve); } } } }