Axiom.Animating.AnimationTrack.CreateKeyFrame C# (CSharp) Метод

CreateKeyFrame() публичный Метод

Creates a new KeyFrame and adds it to this animation at the given time index.
It is better to create KeyFrames in time order. Creating them out of order can result in expensive reordering processing. Note that a KeyFrame at time index 0.0 is always created for you, so you don't need to create this one, just access it using KeyFrames[0];
public CreateKeyFrame ( float time ) : KeyFrame
time float Time within the animation at which this keyframe will lie.
Результат KeyFrame
		public KeyFrame CreateKeyFrame( float time )
		{
			KeyFrame keyFrame = CreateKeyFrameImpl( time );

			if ( time > maxKeyFrameTime || ( time == 0 && keyFrameList.Count == 0 ) )
			{
				keyFrameList.Add( keyFrame );
				maxKeyFrameTime = time;
			}
			else
			{
				// search for the correct place to insert the keyframe
				int i = 0;

				while ( keyFrameList[ i ].Time < time && i != keyFrameList.Count )
				{
					i++;
				}

				keyFrameList.Insert( i, keyFrame );
			}

			// ensure a spline rebuild takes place
			OnKeyFrameDataChanged();

			return keyFrame;
		}

Usage Example

        protected void ReadKeyFrame(XmlNode node, AnimationTrack track)
        {
            float time = float.Parse(node.Attributes["time"].Value);
            // create a new keyframe with the specified length
            TransformKeyFrame keyFrame = (TransformKeyFrame)track.CreateKeyFrame(time);

            foreach (XmlNode childNode in node.ChildNodes) {
                switch (childNode.Name) {
                    case "translate":
                        keyFrame.Translate = ReadVector3(childNode);
                        break;
                    case "rotate":
                        ReadRotate(childNode, keyFrame);
                        break;
                    default:
                        DebugMessage(childNode);
                        break;
                }
            }
        }
All Usage Examples Of Axiom.Animating.AnimationTrack::CreateKeyFrame