private static Animation CreateAnimation(SerializableAnimation animationContent) { Animation animation = new Animation(animationContent.name); animation.SetLength(animationContent.length); foreach (SerializableTrack trackContent in animationContent.tracks) { AnimationTrack track = animation.CreateTrack(trackContent.name); for (int i = 0; i < trackContent.keyframes.Count; i++) { SerializableKeyFrame keyFrameContent = trackContent.keyframes[i]; AnimationKeyFrame keyFrame = new AnimationKeyFrame { rotation = keyFrameContent.rotation, scale = keyFrameContent.scale, translation = keyFrameContent.translation, time = keyFrameContent.time }; track.AddKeyFrame(keyFrame); } } return(animation); }
static SerializableAnimation ProcessAnimation(AnimationContent xnaAnimation) { SerializableAnimation animation = new SerializableAnimation(); animation.name = xnaAnimation.Name; animation.length = (float)xnaAnimation.Duration.TotalSeconds; foreach (KeyValuePair <string, AnimationChannel> xnaAnimationChannelPair in xnaAnimation.Channels) { AnimationChannel xnaAnimationChannel = xnaAnimationChannelPair.Value; string xnaAnimationChannelName = xnaAnimationChannelPair.Key; SerializableTrack track = new SerializableTrack(); track.name = xnaAnimationChannelName; animation.tracks.Add(track); for (int i = 0; i < xnaAnimationChannel.Count; i++) { AnimationKeyframe xnaKeyframe = xnaAnimationChannel[i]; SerializableKeyFrame keyframe = new SerializableKeyFrame((float)xnaKeyframe.Time.TotalSeconds, xnaKeyframe.Transform); track.AddKeyFrame(keyframe); } } return(animation); }