Exemplo n.º 1
0
 public void OffsetPathNodeTangents(
     int nodeIndex,
     Vector3 tangentDelta)
 {
     AnimatedObjectPath.OffsetNodeTangents(nodeIndex, tangentDelta);
     OnNodeTangentsChanged();
 }
Exemplo n.º 2
0
 public void SetNodeTangents(
     int index,
     float inTangent,
     float outTangent)
 {
     AnimatedObjectPath.ChangeNodeTangents(index, inTangent, outTangent);
 }
Exemplo n.º 3
0
        public void MoveNodeToPosition(
            int nodeIndex,
            Vector3 position)
        {
            AnimatedObjectPath.MovePointToPosition(nodeIndex, position);

            OnNodePositionChanged();
        }
Exemplo n.º 4
0
        public void RemoveNode(int nodeIndex)
        {
            var nodeTimestamp = GetNodeTimestamp(nodeIndex);

            AnimatedObjectPath.RemoveNode(nodeIndex);

            OnNodeRemoved(nodeIndex, nodeTimestamp);
        }
Exemplo n.º 5
0
        public void CreateNodeAtTime(float timestamp)
        {
            AnimatedObjectPath.AddNodeAtTime(timestamp);

            var nodeIndex = AnimatedObjectPath.GetNodeIndexAtTime(timestamp);

            OnNodeAdded(nodeIndex);
        }
Exemplo n.º 6
0
        public void CreateNewNode(float timestamp, Vector3 position)
        {
            AnimatedObjectPath.CreateNewNode(timestamp, position);

            var nodeIndex = AnimatedObjectPath.GetNodeIndexAtTime(timestamp);

            OnNodeAdded(nodeIndex);
        }
Exemplo n.º 7
0
        private void InitializeAnimatedObjectPath()
        {
            var firstNodePos = new Vector3(0, 0, 0);

            AnimatedObjectPath.CreateNewNode(0, firstNodePos);

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

            AnimatedObjectPath.CreateNewNode(1, lastNodePos);
        }
Exemplo n.º 8
0
        public void OffsetNodePositions(Vector3 moveDelta)
        {
            // For each node..
            for (var i = 0; i < NodesNo; i++)
            {
                var oldPosition = GetNodePosition(i);
                var newPosition = oldPosition + moveDelta;
                // Update node positions.
                AnimatedObjectPath.MovePointToPosition(i, newPosition);

                OnNodePositionChanged();
            }
        }
Exemplo n.º 9
0
        public void DistributeTimestamps(Action <List <float> > callback)
        {
            var newTimestamps = CalculateUpdatedTimestamps();

            AnimatedObjectPath.ReplaceTimestamps(newTimestamps);

            Asserts.AssertEnabledToolsListInSync(
                NodesNo,
                EaseToolState.Count,
                "ease");

            callback(newTimestamps);
            OnNodeTimeChanged();
        }
Exemplo n.º 10
0
        public float[] GetPathTimestamps()
        {
            // Output array.
            var result = new float[NodesNo];

            // For each key..
            for (var i = 0; i < NodesNo; i++)
            {
                // Get key time.
                result[i] = AnimatedObjectPath.GetTimeAtKey(i);
            }

            return(result);
        }
Exemplo n.º 11
0
        /// <summary>
        ///     Got positions of all path nodes.
        /// </summary>
        /// <param name="nodesNo">
        ///     Number of nodes to return. If not specified, all nodes will be
        ///     returned.
        /// </param>
        /// <returns></returns>
        public List <Vector3> GetNodePositions(int nodesNo = -1)
        {
            // Specify number of nodes to return.
            var returnNodesNo = nodesNo > -1 ? nodesNo : NodesNo;
            // Create empty result array.
            var result = new List <Vector3>();

            // Fill in array with node positions.
            for (var i = 0; i < returnNodesNo; i++)
            {
                // Get node 3d position.
                result.Add(AnimatedObjectPath.GetVectorAtKey(i));
            }

            return(result);
        }
Exemplo n.º 12
0
        /// <summary>
        ///     Returns list of object path node timestamps. Timestamps to section
        ///     length ration will be equal for all timestamps.
        /// </summary>
        /// <returns></returns>
        // todo refactor
        private List <float> CalculateUpdatedTimestamps()
        {
            var pathLength = AnimatedObjectPath.CalculatePathLength(
                PathLengthSampling);

            // Calculate time for one meter of curve length.
            var timeForMeter = 1 / pathLength;

            // Helper variable.
            float prevTimestamp = 0;

            // New timestamps for non-extreme nodes.
            var newTimestamps = new List <float>();

            // For each node calculate and apply new timestamp.
            for (var i = 1; i < NodesNo - 1; i++)
            {
                // Calculate section curved length.
                var sectionLength = AnimatedObjectPath
                                    .CalculateSectionLength(i - 1, i, PathLengthSampling);

                // Calculate time interval for the section.
                var sectionTimeInterval = sectionLength * timeForMeter;

                // Calculate new timestamp.
                var newTimestamp = prevTimestamp + sectionTimeInterval;

                newTimestamps.Add(newTimestamp);

                // Update previous timestamp.
                prevTimestamp = newTimestamp;

                if (newTimestamp > 1)
                {
                    throw new Exception("Node timestamp overflow.");
                }
            }

            // Insert timestamps for extreme nodes.
            newTimestamps.Insert(0, 0);
            newTimestamps.Add(1);

            return(newTimestamps);
        }
Exemplo n.º 13
0
 /// <summary>
 ///     Returns animated object node index at the specified timestamp.
 /// </summary>
 /// <param name="timestamp">Timestamp to search for.</param>
 /// <returns>Node index.</returns>
 public int GetNodeIndexAtTime(float timestamp)
 {
     return(AnimatedObjectPath.GetNodeIndexAtTime(timestamp));
 }
Exemplo n.º 14
0
 public float GetNodeTimestamp(int nodeIndex)
 {
     return(AnimatedObjectPath.GetTimeAtKey(nodeIndex));
 }
Exemplo n.º 15
0
 public void SmoothAllPathNodeTangents(int nodeIndex)
 {
     AnimatedObjectPath.SmoothNodeInOutTangents(
         nodeIndex,
         DefaultSmoothWeight);
 }
Exemplo n.º 16
0
 public float GetPathLength(int sampling)
 {
     return(AnimatedObjectPath.CalculatePathLength(sampling));
 }
Exemplo n.º 17
0
 public float GetPathLinearLength()
 {
     return(AnimatedObjectPath.CalculatePathLinearLength());
 }
Exemplo n.º 18
0
 public Vector3 GetVectorAtTime(float timestamp)
 {
     return(AnimatedObjectPath.GetVectorAtTime(timestamp));
 }
Exemplo n.º 19
0
 public List <float> SampleObjectPathForTimestamps(
     int samplingFrequency)
 {
     return(AnimatedObjectPath.SamplePathForTimestamps(samplingFrequency));
 }
Exemplo n.º 20
0
 public Vector3 GetNodePosition(int nodeIndex)
 {
     return(AnimatedObjectPath.GetVectorAtKey(nodeIndex));
 }