Пример #1
0
        public override void Close()
        {
            Nodes.RemoveAt(0);
            Nodes.RemoveAt(Nodes.Count - 1);

            if (Nodes[0] != Nodes[Nodes.Count - 1])
            {
                Nodes.Add(Nodes[0]);
            }

            var distanceToFirstNode = Vector3.Distance(Nodes[0].Position, Nodes[1].Position);
            var distanceToLastNode  = Vector3.Distance(Nodes[0].Position, Nodes[Nodes.Count - 2].Position);

            var distanceToFirstTarget = distanceToLastNode / Vector3.Distance(Nodes[1].Position, Nodes[0].Position);
            var lastControlNode       = (Nodes[0].Position + (Nodes[1].Position - Nodes[0].Position) * distanceToFirstTarget);

            var distanceToLastTarget = distanceToFirstNode / Vector3.Distance(Nodes[Nodes.Count - 2].Position, Nodes[0].Position);
            var firstControlNode     = (Nodes[0].Position + (Nodes[Nodes.Count - 2].Position - Nodes[0].Position) * distanceToLastTarget);

            var firstControlKeyframe = new SplineKeyframe();

            firstControlKeyframe.Position = firstControlNode;

            var lastControlKeyframe = new SplineKeyframe();

            lastControlKeyframe.Position = lastControlNode;

            Nodes.Insert(0, firstControlKeyframe);
            Nodes.Add(lastControlKeyframe);
        }
		public override void Close()
		{
			base.Nodes.RemoveAt(0);
			base.Nodes.RemoveAt(base.Nodes.Count - 1);
			if (base.Nodes[0] != base.Nodes[base.Nodes.Count - 1])
			{
				base.Nodes.Add(base.Nodes[0]);
			}
			float num = Vector3.Distance(base.Nodes[0].Position, base.Nodes[1].Position);
			float num2 = Vector3.Distance(base.Nodes[0].Position, base.Nodes[base.Nodes.Count - 2].Position);
			float d = num2 / Vector3.Distance(base.Nodes[1].Position, base.Nodes[0].Position);
			Vector3 position = base.Nodes[0].Position + (base.Nodes[1].Position - base.Nodes[0].Position) * d;
			float d2 = num / Vector3.Distance(base.Nodes[base.Nodes.Count - 2].Position, base.Nodes[0].Position);
			Vector3 position2 = base.Nodes[0].Position + (base.Nodes[base.Nodes.Count - 2].Position - base.Nodes[0].Position) * d2;
			SplineKeyframe splineKeyframe = new SplineKeyframe();
			splineKeyframe.Position = position2;
			SplineKeyframe splineKeyframe2 = new SplineKeyframe();
			splineKeyframe2.Position = position;
			base.Nodes.Insert(0, splineKeyframe);
			base.Nodes.Add(splineKeyframe2);
		}
 /// <summary>
 /// Use this method to remove an existing keyframe. You can pass the keyframe you'd like to remove.
 /// </summary>
 /// <param name="keyframe">Keyframe.</param>
 public void RemoveKeyframe(SplineKeyframe keyframe)
 {
     keyframes.Remove(keyframe);
     BuildCurveFromKeyframes();
 }
 /// <summary>
 /// You can call this method to add a new keyframe before an existing keyframe.
 /// </summary>
 /// <param name="keyframe">The new keyframe.</param>
 /// <param name="index">The index of the existing keyframe that you'd like to add before.</param>
 public void AddBeforeKeyframe(SplineKeyframe keyframe, int index)
 {
     keyframes.Insert(index - 1, keyframe);
     BuildCurveFromKeyframes();
 }
 /// <summary>
 /// You can call this method to add a new keyframe after an existing keyframe.
 /// </summary>
 /// <param name="keyframe">The new keyframe.</param>
 /// <param name="index">The index of the existing keyframe that you'd like to add after.</param>
 public void AddAfterKeyframe(SplineKeyframe keyframe, int index)
 {
     keyframes.Insert(index + 1, keyframe);
     BuildCurveFromKeyframes();
 }
 /// <summary>
 /// You can use this method to add a new keyframe to this Object Path Timeline, simply call this method and pass the new keyframe.
 /// </summary>
 /// <param name="keyframe">The new Keyframe.</param>
 public void AddKeyframe(SplineKeyframe keyframe)
 {
     keyframes.Add(keyframe);
     BuildCurveFromKeyframes();
 }
 public void AddKeyframe(SplineKeyframe keyframe)
 {
     this.keyframes.Add(keyframe);
     this.BuildCurveFromKeyframes();
 }