예제 #1
0
        public override void RefreshUI()
        {
            object value = Binding.GetBoundValue();

            if (value is Vector)
            {
                Vector pos = (Vector)value;

                // Animate (if applicable):
                var smoothie = GetComponent <SmoothMoves>();
                if (smoothie == null)
                {
                    transform.localPosition = pos.ToUnityVector3();
                }
                else
                {
                    var animation = new PropertyAnimation(smoothie.gameObject, "transform.localPosition",
                                                          pos.ToUnityVector3(), 0.1,
                                                          Interpolation.Sin,
                                                          delegate(object v1, object v2, double t, Interpolation i)
                    {
                        Vector pt1 = ((Vector3)v1).ToNucleusVector();
                        Vector pt2 = ((Vector3)v2).ToNucleusVector();
                        return(i.Interpolate(pt1, pt2, t).ToUnityVector3());
                    });
                    smoothie.Animation = animation;
                }
            }
        }
예제 #2
0
        public EffectPropertyBuildersTests()
        {
            slide        = new SlideAnimation();
            slideBuilder = new AnimationBuilder(slide);

            property        = new PropertyAnimation();
            propertyBuilder = new AnimationBuilder(property);
        }
예제 #3
0
 private static void AddAnimationKeys(DocumentData data, PropertyAnimation propertyAnimation, Domain.Animations.PropertyAnimation domainPropertyAnimation)
 {
     foreach (var key in propertyAnimation.Keys)
     {
         var interpolation = MapInterpolationData(key.InterpolationType, key.Curve);
         var domainKey     = new Domain.Animations.Key(data.MessageBus, key.Id, propertyAnimation.Id, key.Frame, key.Value, interpolation);
         domainPropertyAnimation.InternalAdd(domainKey);
         data.Keys.Add(domainKey);
     }
 }
예제 #4
0
        private RTSegment[] BuildPropertyAnimationSegments(PropertyAnimation propertyAnimation, Animation animation)
        {
            // we convert the keys on a propertyanimation into a series of Segments. Each segment takes up the gap between two keys and therefore has a begintime and endtime.
            // The segments don't overlap but lie edge to edge along the timeline. All segments together take up the entire timeline of the animation.
            //
            //
            // ---------|------|--|-------|------------
            //
            // --- segment    | key
            //
            // The animation runtime will find the single segment that the current time is in, and can use the Interpolation info of the segment to find the correct animation value.
            //
            // For the first and last segment, we don't have two surrounding keys to interpolate between. So, we need to fabricate the interpolation data a bit differently:
            // * for non loops: we create an interpolation of type Hold (constant value through time) using the value of the one key that is touching the segment.
            // * for loops: loops wrap the animation around from the last key to the first key of the next repetition as if that is just a normal segment.
            //              So, we create interpolation data to interpolate between the last and first key in the outer-segments of the timeline.


            var segments   = new List <RTSegment>();
            var sortedKeys = propertyAnimation.Keys.OrderBy(k => k.Frame).ToList();

            if (sortedKeys[0].Frame != animation.BeginFrame)
            {
                // first key is not on first frame -> add a segment for the part before the first key
                segments.Add(CreatePreFirstKeySegment(sortedKeys, animation));
            }

            for (var i = 0; i < sortedKeys.Count; i++)
            {
                var leftKey     = sortedKeys[i];
                var leftKeyTime = FrameToTime(leftKey.Frame - animation.BeginFrame, animation);

                segments.Add(i < sortedKeys.Count - 1
                    ? CreateSegment(animation, sortedKeys, i, leftKeyTime, leftKey) // normal segment
                    : CreatePostLastKeySegment(sortedKeys, animation));             // last segment
            }

            return(segments.ToArray());
        }
예제 #5
0
        private static void AddAnimations(IEnumerable <Domain.Animations.Animation> animations, Document doc)
        {
            foreach (var animation in animations)
            {
                var anim = new Animation
                {
                    Id              = animation.Id,
                    Name            = animation.Name,
                    BeginFrame      = animation.BeginFrame,
                    EndFrame        = animation.EndFrame,
                    FramesPerSecond = animation.FramesPerSecond,
                    IsLoop          = animation.IsLoop
                };

                foreach (var nodeAnimation in animation.AnimationsPerNode.Values)
                {
                    var nodeAnim = new NodeAnimation
                    {
                        NodeId = nodeAnimation.Node.Id
                    };
                    foreach (var propertyAnimation in nodeAnimation.PropertyAnimations.Values)
                    {
                        var propAnim = new PropertyAnimation
                        {
                            Id       = propertyAnimation.Id,
                            Property = (uint)propertyAnimation.Property,
                            Vertex   = propertyAnimation.Vertex
                        };
                        AddAnimationKeys(propertyAnimation.Keys, propAnim);
                        nodeAnim.PropertyAnimations.Add(propAnim);
                    }
                    anim.NodeAnimations.Add(nodeAnim);
                }
                doc.Animations.Add(anim);
            }
        }
예제 #6
0
 private static void AddAnimationKeys(IEnumerable <Domain.Animations.Key> keys, PropertyAnimation propertyAnimation)
 {
     foreach (var key in keys)
     {
         propertyAnimation.Keys.Add(new Key
         {
             Id                = key.Id,
             Frame             = key.Frame,
             Value             = key.Value,
             InterpolationType = GetCurveType(key.Interpolation.Type),
             Curve             = MapCurve(key.Interpolation.BezierCurve)
         });
     }
 }
예제 #7
0
 public PropertyAnimationSerializationTests()
 {
     property = new PropertyAnimation();
 }