Beispiel #1
0
        public void UpdateRotationPointAtTimestamp(
            float timestamp,
            Vector3 newPosition,
            Action callback)
        {
            // Check if timestamp passed as argument matches any in the
            // rotation path.
            var foundMatch = RotationPath.NodeAtTimeExists(timestamp);

            // If timestamp was not found..
            if (!foundMatch)
            {
                Debug.Log(
                    "You're trying to change rotation for nonexistent " +
                    "node.");

                return;
            }

            RotationPath.MovePointToPosition(timestamp, newPosition);

            callback();

            OnRotationPointPositionChanged();
        }
Beispiel #2
0
 public void OffsetRotationPathNodeTangents(
     int nodeIndex,
     Vector3 tangentDelta)
 {
     RotationPath.OffsetNodeTangents(nodeIndex, tangentDelta);
     OnNodeTangentsChanged();
 }
Beispiel #3
0
        public void UpdateRotationPathWithRemovedKeys()
        {
            var pathTimestamps = GetPathTimestamps();
            // Get values from rotationPath.
            var rotationCurvesTimestamps = RotationPath.Timestamps;

            // For each timestamp in rotationPath..
            for (var i = 0; i < rotationCurvesTimestamps.Length; i++)
            {
                // Check if same timestamp exist in rotationPath.
                var keyExists = pathTimestamps.Any(
                    nodeTimestamp => Utilities.FloatsEqual(
                        rotationCurvesTimestamps[i],
                        nodeTimestamp,
                        GlobalConstants.FloatPrecision));

                // If key exists check next timestamp.
                if (keyExists)
                {
                    continue;
                }

                // Remove node from rotationPath.
                RotationPath.RemoveNode(i);

                break;
            }
        }
Beispiel #4
0
        /// <summary>
        ///     Set rotation path node positions to the same as in anim. object
        ///     path.
        /// </summary>
        private void ResetRotationPathValues()
        {
            var animPathNodePositions = GetNodePositions();

            for (var i = 0; i < animPathNodePositions.Count; i++)
            {
                RotationPath.MovePointToPosition(i, animPathNodePositions[i]);
            }
        }
Beispiel #5
0
        private void InitializeRotationPath()
        {
            var firstNodePos = new Vector3(0, 0, 0);

            RotationPath.CreateNewNode(0, firstNodePos);

            var lastNodePos = new Vector3(1, 0, 1);

            RotationPath.CreateNewNode(1, lastNodePos);
        }
Beispiel #6
0
        /// <summary>
        ///     Create rotation point for given path node.
        /// </summary>
        /// <param name="nodeTimestamp"></param>
        private void CreateRotationPoint(float nodeTimestamp)
        {
            // Calculate value for new rotation point.
            var rotationValue =
                RotationPath.GetVectorAtTime(nodeTimestamp);

            // Create new rotation point.
            RotationPath.CreateNewNode(
                nodeTimestamp,
                rotationValue);
        }
Beispiel #7
0
 public void OffsetRotationPathPosition(Vector3 moveDelta)
 {
     // For each node..
     for (var i = 0; i < NodesNo; i++)
     {
         var oldPosition = GetRotationPointPosition(i);
         var newPosition = oldPosition + moveDelta;
         // Update node positions.
         RotationPath.MovePointToPosition(i, newPosition);
     }
 }
Beispiel #8
0
        public void UpdateRotationPathWithAddedKeys()
        {
            var pathTimestamps = GetPathTimestamps();

            // For each timestamp in the path..
            foreach (var pathTimestamp in pathTimestamps)
            {
                // Check if key at timestamp exists in rotation path.
                var keyExists = RotationPath.NodeAtTimeExists(pathTimestamp);

                // If not..
                if (!keyExists)
                {
                    CreateRotationPoint(pathTimestamp);
                }
            }
        }
Beispiel #9
0
 public void UpdateRotationPathTimestamps(
     List <float> distributedTimestamps)
 {
     RotationPath.ReplaceTimestamps(distributedTimestamps);
 }
Beispiel #10
0
 public void SmoothRotationPathNodeTangents(int nodeIndex)
 {
     RotationPath.SmoothNodeInOutTangents(nodeIndex, 0);
 }
Beispiel #11
0
 public void SmoothAllRotationPathNodes()
 {
     RotationPath.SmoothAllNodes();
 }
Beispiel #12
0
 public List <Vector3> SampleRotationPathForPoints(
     int samplingFrequency)
 {
     return(RotationPath.SamplePathForPoints(samplingFrequency));
 }
Beispiel #13
0
 public Vector3 GetRotationPointPosition(int nodeIndex)
 {
     return(RotationPath.GetVectorAtKey(nodeIndex));
 }
Beispiel #14
0
 public Vector3 GetRotationAtTime(float timestamp)
 {
     return(RotationPath.GetVectorAtTime(timestamp));
 }
Beispiel #15
0
 public AnimationPath()
 {
     movementPath = new MovementPath();
     rotationPath = new RotationPath();
 }