public FSKAKey GetLeft(int frame) { FSKAKey prev = keys[0]; for (int i = 0; i < keys.Count - 1; i++) { FSKAKey key = keys[i]; if (key.frame > frame && prev.frame <= frame) { break; } prev = key; } return(prev); }
public FSKAKey GetRight(int frame) { FSKAKey cur = keys[0]; FSKAKey prev = keys[0]; for (int i = 1; i < keys.Count; i++) { FSKAKey key = keys[i]; cur = key; if (key.frame > frame && prev.frame <= frame) { break; } prev = key; } return(cur); }
public override void nextFrame(Skeleton s) { foreach (TreeNode node in Nodes) { FSKANode key = (FSKANode)(node); // find bone foreach (TreeNode b in s.Nodes) { if (((Bone)b).Text.Equals(key.Text)) { Bone bone = ((Bone)b); if (frame == 0) { ((Bone)b).pos = key.pos; ((Bone)b).rot = key.rot; ((Bone)b).sca = key.sca; } foreach (FSKATrack track in key.tracks) { // get left and right key FSKAKey left = track.GetLeft(frame); FSKAKey right = track.GetRight(frame); float value; //float value = Interpolate.Herp(left.unk1, right.unk1, left.unk2, left.unk4, frame - left.frame, right.frame - left.frame); value = Interpolate.interHermite(frame, left.frame, right.frame, 0, 0, left.unk1, right.unk1); Vector3 pos = bone.pos, rot = bone.rot, sca = bone.sca; // interpolate the value and apply switch (track.flag) { case (int)TrackType.XPOS: pos.X = value; break; case (int)TrackType.YPOS: pos.Y = value; break; case (int)TrackType.ZPOS: pos.Z = value; break; case (int)TrackType.XROT: rot.X = value; break; case (int)TrackType.YROT: rot.Y = value; break; case (int)TrackType.ZROT: rot.Z = value; break; case (int)TrackType.XSCA: sca.X = value; break; case (int)TrackType.YSCA: sca.Y = value; break; case (int)TrackType.ZSCA: sca.Z = value; break; } bone.pos = pos; bone.rot = rot; bone.sca = sca; } break; } } } frame++; if (frame > frameCount) { frame = 0; } s.Update(); }