Example #1
0
        public TimeEntryBlock(Toggl.TogglTimeEntryView te, int hourHeight, DateTime date)
        {
            _hourHeight  = hourHeight;
            DateCreated  = date;
            _timeEntry   = te;
            OpenEditView = ReactiveCommand.Create(() => Toggl.Edit(TimeEntryId, false, Toggl.Description));
            var startEndObservable = this.WhenAnyValue(x => x.VerticalOffset, x => x.Height, (offset, height) =>
                                                       (Started: TimelineUtils.ConvertOffsetToDateTime(offset, date, _hourHeight), Ended: TimelineUtils.ConvertOffsetToDateTime(offset + height, date, _hourHeight)));

            startEndObservable.Select(tuple => $"{tuple.Started:HH:mm tt} - {tuple.Ended:HH:mm tt}")
            .ToPropertyEx(this, x => x.StartEndCaption);
            startEndObservable.Select(tuple =>
            {
                var duration = tuple.Ended.Subtract(tuple.Started);
                return(duration.Hours + " h " + duration.Minutes + " min");
            })
            .ToPropertyEx(this, x => x.Duration);
            this.WhenAnyValue(x => x.Height)
            .Select(h => h >= TimelineConstants.MinResizableTimeEntryBlockHeight)
            .Where(_ => !IsDragged)
            .ToPropertyEx(this, x => x.IsResizable);
            this.WhenAnyValue(x => x.IsOverlapping, x => x.Height,
                              (isOverlapping, height) => !isOverlapping && height >= TimelineConstants.MinShowTEDescriptionHeight)
            .ToPropertyEx(this, x => x.ShowDescription);
        }
Example #2
0
            public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
            {
                ScriptPlayable <LegacyAnimatorTrackMixer> playable = TimelineUtils.CreateTrackMixer <LegacyAnimatorTrackMixer>(this, graph, go, inputCount);
                LegacyAnimatorTrackMixer mixer = playable.GetBehaviour();

                SetClipReferences(this);

                List <int> channels = new List <int>();

                channels.Add(_animationChannel);

                foreach (TrackAsset child in GetChildTracks())
                {
                    if (child is LegacyAnimatorTrack legacyAnimatorTrack)
                    {
                        channels.Add(legacyAnimatorTrack._animationChannel);
                        SetClipReferences(legacyAnimatorTrack);
                    }
                }

                mixer.SetChannels(channels.ToArray());


                return(playable);
            }
Example #3
0
    public static void SetDefautTimelineFunctions()
    {
        Timeline <Vector2> .TypeEncode    = EncodeVector2;
        Timeline <Vector2> .TypeDecode    = DecodeVector2;
        Timeline <Vector3> .TypeEncode    = EncodeVector3;
        Timeline <Vector3> .TypeDecode    = DecodeVector3;
        Timeline <Vector4> .TypeEncode    = EncodeVector4;
        Timeline <Vector4> .TypeDecode    = DecodeVector4;
        Timeline <Quaternion> .TypeEncode = EncodeQuaternion;
        Timeline <Quaternion> .TypeDecode = DecodeQuaternion;
        Timeline <Matrix4x4> .TypeEncode  = EncodeMatrix4x4;
        Timeline <Matrix4x4> .TypeDecode  = DecodeMatrix4x4;
        Timeline <Ray> .TypeEncode        = EncodeRay;
        Timeline <Ray> .TypeDecode        = DecodeRay;
        Timeline <Color> .TypeEncode      = EncodeColor;
        Timeline <Color> .TypeDecode      = DecodeColor;

        Timeline <Vector2> .TypeInterpolate = TimelineUtils.BuildLinearInterpolator <Vector2>(
            (x, y) => x + y, (x, y) => x * y);
        Timeline <Vector2> .TypeExtrapolate = TimelineUtils.BuildLinearExtrapolator <Vector2>(
            (x, y) => x + y, (x, y) => x * y);
        Timeline <Vector3> .TypeInterpolate = TimelineUtils.BuildLinearInterpolator <Vector3>(
            (x, y) => x + y, (x, y) => x * y);
        Timeline <Vector3> .TypeExtrapolate = TimelineUtils.BuildLinearExtrapolator <Vector3>(
            (x, y) => x + y, (x, y) => x * y);
        Timeline <Vector4> .TypeInterpolate = TimelineUtils.BuildLinearInterpolator <Vector4>(
            (x, y) => x + y, (x, y) => x * y);
        Timeline <Vector4> .TypeExtrapolate = TimelineUtils.BuildLinearExtrapolator <Vector4>(
            (x, y) => x + y, (x, y) => x * y);

        Timeline <Quaternion> .TypeInterpolate = InterpolateQuaternionSlerp;
        Timeline <Quaternion> .TypeExtrapolate = ExtrapolateQuaternionSlerp;
        Timeline <Ray> .TypeInterpolate        = InterpolateRay;
        Timeline <Ray> .TypeExtrapolate        = ExtrapolateRay;
    }
Example #4
0
 /// <exception cref="System.Exception"/>
 protected override void ServiceInit(Configuration conf)
 {
     asyncApiPollIntervalMillis = conf.GetLong(YarnConfiguration.YarnClientApplicationClientProtocolPollIntervalMs
                                               , YarnConfiguration.DefaultYarnClientApplicationClientProtocolPollIntervalMs);
     asyncApiPollTimeoutMillis = conf.GetLong(YarnConfiguration.YarnClientApplicationClientProtocolPollTimeoutMs
                                              , YarnConfiguration.DefaultYarnClientApplicationClientProtocolPollTimeoutMs);
     submitPollIntervalMillis = asyncApiPollIntervalMillis;
     if (conf.Get(YarnConfiguration.YarnClientAppSubmissionPollIntervalMs) != null)
     {
         submitPollIntervalMillis = conf.GetLong(YarnConfiguration.YarnClientAppSubmissionPollIntervalMs
                                                 , YarnConfiguration.DefaultYarnClientApplicationClientProtocolPollIntervalMs);
     }
     if (conf.GetBoolean(YarnConfiguration.ApplicationHistoryEnabled, YarnConfiguration
                         .DefaultApplicationHistoryEnabled))
     {
         historyServiceEnabled = true;
         historyClient         = AHSClient.CreateAHSClient();
         historyClient.Init(conf);
     }
     if (conf.GetBoolean(YarnConfiguration.TimelineServiceEnabled, YarnConfiguration.DefaultTimelineServiceEnabled
                         ))
     {
         timelineServiceEnabled = true;
         timelineClient         = CreateTimelineClient();
         timelineClient.Init(conf);
         timelineDTRenewer = GetTimelineDelegationTokenRenewer(conf);
         timelineService   = TimelineUtils.BuildTimelineTokenService(conf);
     }
     timelineServiceBestEffort = conf.GetBoolean(YarnConfiguration.TimelineServiceClientBestEffort
                                                 , YarnConfiguration.DefaultTimelineServiceClientBestEffort);
     base.ServiceInit(conf);
 }
Example #5
0
        public void SetLength()
        {
            MediaFile file = new MediaFile("transitions.wmv");

            file.LengthInUnits = TimelineUtils.ToUnits(2);
            Assert.AreEqual(2, file.Length);
        }
                public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
                {
                    ScriptPlayable <Spine3DAnimatorChannelTrackMixer> playable = TimelineUtils.CreateTrackMixer <Spine3DAnimatorChannelTrackMixer>(this, graph, go, inputCount);
                    Spine3DAnimatorTrack parentTrack = this.parent as Spine3DAnimatorTrack;

                    if (parentTrack != null)
                    {
                        Spine3DAnimatorTrackMixer parentMixer = TimelineUtils.GetTrackMixer <Spine3DAnimatorTrackMixer>(graph, parentTrack);

                        if (parentMixer != null)
                        {
                            Spine3DAnimatorChannelTrackMixer mixer = playable.GetBehaviour();
                            mixer.Init(parentMixer);

                            IEnumerable <TimelineClip> clips = GetClips();

                            foreach (TimelineClip clip in clips)
                            {
                                Spine3DAnimationClipAsset animationClip = clip.asset as Spine3DAnimationClipAsset;

                                if (animationClip != null)
                                {
                                    clip.displayName = animationClip._animationId;
                                    animationClip.SetParentTrack(parentTrack);
                                }
                            }
                        }
                    }

                    return(playable);
                }
Example #7
0
        /// <summary>
        /// Sets encoding, decoding and interpolation functions for all position timelines
        /// Must be executed before any objects of type Timeline<Position> are created
        /// </summary>
        public static void SetDefautTimelineFunctions()
        {
            Timeline <Position> .TypeEncode = EncodePosition;
            Timeline <Position> .TypeDecode = DecodePosition;

            Timeline <Position> .TypeInterpolate = TimelineUtils.BuildLinearInterpolator <Position>(
                (x, y) => Position.Add(x, y), (x, y) => Position.Multiply(x, y));
        }
            public void OnClipCreated(TimelineClip clip)
            {
#if UNITY_EDITOR
                TimelineUtils.CreateAnimationCurves(clip);
                clip.curves.ClearCurves();
                AddDefaultCurves(clip);
#endif
            }
            public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
            {
                ScriptPlayable <MaterialFloatParamTrackMixer> playable = TimelineUtils.CreateTrackMixer <MaterialFloatParamTrackMixer>(this, graph, go, inputCount);

                ParentBindableTrack.OnCreateTrackMixer(this, playable.GetBehaviour(), graph);

                return(playable);
            }
Example #10
0
        public void Construct()
        {
            MediaFile file = new MediaFile("transitions.wmv");

            Assert.AreEqual("transitions.wmv", file.FileName);
            Assert.AreEqual(7.999, file.Length);
            Assert.AreEqual(TimelineUtils.ToUnits(7.999), file.LengthInUnits);
            Assert.AreEqual(-1, file.LengthInFrames); // not assigned till later
        }
Example #11
0
        public static string AddNewTimeEntry(double offset, double height, int scaleMode, DateTime date)
        {
            var started = TimelineUtils.ConvertOffsetToUnixTime(offset, date,
                                                                TimelineConstants.ScaleModes[scaleMode]);
            var ended = TimelineUtils.ConvertOffsetToUnixTime(offset + height, date,
                                                              TimelineConstants.ScaleModes[scaleMode]);
            var timeEntryId = Toggl.CreateEmptyTimeEntry(started, ended);

            return(timeEntryId);
        }
Example #12
0
            public override void ProcessFrame(Playable playable, FrameData info, object playerData)
            {
                _trackBinding = playerData as Transform;

                if (_trackBinding == null)
                    return;

                if (_firstFrame)
                {
                    _defaultPosition = _trackBinding.position;
                    _defaultRotation = _trackBinding.rotation;
                    _firstFrame = false;
                }

                Vector3 position = _defaultPosition;
                Quaternion rotation  = _defaultRotation;

                int numInputs = playable.GetInputCount();

                for (int i = 0; i < numInputs; i++)
                {
                    ScriptPlayable<PathPlayableBehaviour> scriptPlayable = (ScriptPlayable<PathPlayableBehaviour>)playable.GetInput(i);
                    PathPlayableBehaviour inputBehaviour = scriptPlayable.GetBehaviour();

                    if (inputBehaviour != null && inputBehaviour._path != null)
                    {
                        float inputWeight = playable.GetInputWeight(i);

                        if (inputWeight > 0.0f)
                        {
                            TimelineClip clip = TimelineUtils.GetClip(_trackAsset, inputBehaviour._clipAsset);

                            if (clip != null)
                            {
                                double clipStart = clip.hasPreExtrapolation ? clip.extrapolatedStart : clip.start;
                                double clipDuration = clip.hasPreExtrapolation || clip.hasPostExtrapolation ? clip.extrapolatedDuration : clip.duration;

                                if (_director.time >= clipStart && _director.time <= clipStart + clipDuration)
                                {
                                    //To do handle loops etc

                                    double t = Mathf.Clamp01((float)(_director.time - clip.start) / (float)clip.duration);
                                    PathPosition pos = inputBehaviour._path.GetPoint((float)t);

                                    position = Vector3.Lerp(position, pos._pathPosition, inputWeight);
                                    rotation = Quaternion.Slerp(rotation, Quaternion.LookRotation(pos._pathForward, pos._pathUp), inputWeight);
                                }
                            }
                        }
                    }
                }

                _trackBinding.position = position;
                _trackBinding.rotation = rotation;
            }
Example #13
0
        protected void AssertLengths(double fps, string file1, string file2)
        {
            long length1 = MediaDetUtils.GetLength(file1);
            long length2 = MediaDetUtils.GetLength(file2);

            long frameLength = TimelineUtils.ToUnits(1.0 / fps);

            long difference = Math.Abs(length1 - length2);

            Assert.IsTrue(difference <= frameLength);
        }
            public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
            {
                Transform spawnPoint = _prefabSpawnPoint.Resolve(graph.GetResolver());

                OnCreateTrackMixer(graph);

                ScriptPlayable <PrefabInstanceTrackMixer> mixer = TimelineUtils.CreateTrackMixer <PrefabInstanceTrackMixer>(this, graph, go, inputCount);

                mixer.GetBehaviour().SetSpawnPoint(spawnPoint, _makePrefabSpawnPointParent);

                return(mixer);
            }
Example #15
0
        protected void AssertLengths(double fps, double expected, string file)
        {
            long length1 = TimelineUtils.ToUnits(expected);
            long length2 = MediaDetUtils.GetLength(file);

            long frameLength = TimelineUtils.ToUnits(1.0 / fps) * 4; // allow for 4 frames difference

            long difference = Math.Abs(length1 - length2);

            Assert.IsTrue(difference <= frameLength,
                          string.Format("expected {0} +/- {1}, but was {2}", length1, frameLength, length2));
        }
            private static void DebugGizmos(PlayableDirector playableDirector)
            {
                if (playableDirector != null && playableDirector.playableGraph.IsValid())
                {
                    List <IPlayableBehaviourGizmoDrawer> debugDrawers = TimelineUtils.GetPlayableBehaviours <IPlayableBehaviourGizmoDrawer>(playableDirector.playableGraph);

                    foreach (IPlayableBehaviourGizmoDrawer debugDrawer in debugDrawers)
                    {
                        debugDrawer.DrawGizmos();
                    }
                }
            }
Example #17
0
        public virtual void TestEntities()
        {
            TimelineEntities entities = new TimelineEntities();

            for (int j = 0; j < 2; ++j)
            {
                TimelineEntity entity = new TimelineEntity();
                entity.SetEntityId("entity id " + j);
                entity.SetEntityType("entity type " + j);
                entity.SetStartTime(Runtime.CurrentTimeMillis());
                for (int i = 0; i < 2; ++i)
                {
                    TimelineEvent @event = new TimelineEvent();
                    @event.SetTimestamp(Runtime.CurrentTimeMillis());
                    @event.SetEventType("event type " + i);
                    @event.AddEventInfo("key1", "val1");
                    @event.AddEventInfo("key2", "val2");
                    entity.AddEvent(@event);
                }
                entity.AddRelatedEntity("test ref type 1", "test ref id 1");
                entity.AddRelatedEntity("test ref type 2", "test ref id 2");
                entity.AddPrimaryFilter("pkey1", "pval1");
                entity.AddPrimaryFilter("pkey2", "pval2");
                entity.AddOtherInfo("okey1", "oval1");
                entity.AddOtherInfo("okey2", "oval2");
                entity.SetDomainId("domain id " + j);
                entities.AddEntity(entity);
            }
            Log.Info("Entities in JSON:");
            Log.Info(TimelineUtils.DumpTimelineRecordtoJSON(entities, true));
            NUnit.Framework.Assert.AreEqual(2, entities.GetEntities().Count);
            TimelineEntity entity1 = entities.GetEntities()[0];

            NUnit.Framework.Assert.AreEqual("entity id 0", entity1.GetEntityId());
            NUnit.Framework.Assert.AreEqual("entity type 0", entity1.GetEntityType());
            NUnit.Framework.Assert.AreEqual(2, entity1.GetRelatedEntities().Count);
            NUnit.Framework.Assert.AreEqual(2, entity1.GetEvents().Count);
            NUnit.Framework.Assert.AreEqual(2, entity1.GetPrimaryFilters().Count);
            NUnit.Framework.Assert.AreEqual(2, entity1.GetOtherInfo().Count);
            NUnit.Framework.Assert.AreEqual("domain id 0", entity1.GetDomainId());
            TimelineEntity entity2 = entities.GetEntities()[1];

            NUnit.Framework.Assert.AreEqual("entity id 1", entity2.GetEntityId());
            NUnit.Framework.Assert.AreEqual("entity type 1", entity2.GetEntityType());
            NUnit.Framework.Assert.AreEqual(2, entity2.GetRelatedEntities().Count);
            NUnit.Framework.Assert.AreEqual(2, entity2.GetEvents().Count);
            NUnit.Framework.Assert.AreEqual(2, entity2.GetPrimaryFilters().Count);
            NUnit.Framework.Assert.AreEqual(2, entity2.GetOtherInfo().Count);
            NUnit.Framework.Assert.AreEqual("domain id 1", entity2.GetDomainId());
        }
Example #18
0
            public override void PrepareFrame(Playable playable, FrameData info)
            {
                ClearChannelData();

                int numInputs = playable.GetInputCount();

                for (int i = 0; i < numInputs; i++)
                {
                    float inputWeight = playable.GetInputWeight(i);

                    if (inputWeight > 0f && TimelineUtils.IsScriptPlayable(playable.GetInput(i), out LegacyAnimatorPlayableBehaviour inputBehaviour) && inputBehaviour._animation != null)
                    {
                        TimelineClip clip = inputBehaviour._clipAsset.GetTimelineClip();

                        if (clip != null)
                        {
                            double clipStart    = clip.hasPreExtrapolation ? clip.extrapolatedStart : clip.start;
                            double clipDuration = clip.hasPreExtrapolation || clip.hasPostExtrapolation ? clip.extrapolatedDuration : clip.duration;

                            if (_director.time >= clipStart && _director.time <= clipStart + clipDuration)
                            {
                                int ch = GetChannelIndex(inputBehaviour._clipAsset.GetChannel());

                                bool  isPrimaryClip = TimelineUtils.IsPrimaryClip(clip, _director);
                                float trackTime     = TimelineUtils.GetExtrapolatedTrackTime(clip, _director.time, inputBehaviour._animation.length);

                                if (isPrimaryClip)
                                {
                                    _channelData[ch]._primaryAnimation._animation = inputBehaviour._animation;
                                    _channelData[ch]._primaryAnimation._time      = trackTime;
                                    _channelData[ch]._primaryAnimation._weight    = inputWeight;
                                    _channelData[ch]._primaryAnimation._speed     = 0f;
                                }
                                else
                                {
                                    LegacyAnimator.AnimationParams backroundAnimation = new LegacyAnimator.AnimationParams
                                    {
                                        _animation = inputBehaviour._animation,
                                        _time      = trackTime,
                                        _weight    = 1.0f,
                                        _speed     = 0f,
                                    };
                                    _channelData[ch]._backgroundAnimations.Add(backroundAnimation);
                                }
                            }
                        }
                    }
                }
            }
Example #19
0
        public virtual void TestEvents()
        {
            TimelineEvents events = new TimelineEvents();

            for (int j = 0; j < 2; ++j)
            {
                TimelineEvents.EventsOfOneEntity partEvents = new TimelineEvents.EventsOfOneEntity
                                                                  ();
                partEvents.SetEntityId("entity id " + j);
                partEvents.SetEntityType("entity type " + j);
                for (int i = 0; i < 2; ++i)
                {
                    TimelineEvent @event = new TimelineEvent();
                    @event.SetTimestamp(Runtime.CurrentTimeMillis());
                    @event.SetEventType("event type " + i);
                    @event.AddEventInfo("key1", "val1");
                    @event.AddEventInfo("key2", "val2");
                    partEvents.AddEvent(@event);
                }
                events.AddEvent(partEvents);
            }
            Log.Info("Events in JSON:");
            Log.Info(TimelineUtils.DumpTimelineRecordtoJSON(events, true));
            NUnit.Framework.Assert.AreEqual(2, events.GetAllEvents().Count);
            TimelineEvents.EventsOfOneEntity partEvents1 = events.GetAllEvents()[0];
            NUnit.Framework.Assert.AreEqual("entity id 0", partEvents1.GetEntityId());
            NUnit.Framework.Assert.AreEqual("entity type 0", partEvents1.GetEntityType());
            NUnit.Framework.Assert.AreEqual(2, partEvents1.GetEvents().Count);
            TimelineEvent event11 = partEvents1.GetEvents()[0];

            NUnit.Framework.Assert.AreEqual("event type 0", event11.GetEventType());
            NUnit.Framework.Assert.AreEqual(2, event11.GetEventInfo().Count);
            TimelineEvent event12 = partEvents1.GetEvents()[1];

            NUnit.Framework.Assert.AreEqual("event type 1", event12.GetEventType());
            NUnit.Framework.Assert.AreEqual(2, event12.GetEventInfo().Count);
            TimelineEvents.EventsOfOneEntity partEvents2 = events.GetAllEvents()[1];
            NUnit.Framework.Assert.AreEqual("entity id 1", partEvents2.GetEntityId());
            NUnit.Framework.Assert.AreEqual("entity type 1", partEvents2.GetEntityType());
            NUnit.Framework.Assert.AreEqual(2, partEvents2.GetEvents().Count);
            TimelineEvent event21 = partEvents2.GetEvents()[0];

            NUnit.Framework.Assert.AreEqual("event type 0", event21.GetEventType());
            NUnit.Framework.Assert.AreEqual(2, event21.GetEventInfo().Count);
            TimelineEvent event22 = partEvents2.GetEvents()[1];

            NUnit.Framework.Assert.AreEqual("event type 1", event22.GetEventType());
            NUnit.Framework.Assert.AreEqual(2, event22.GetEventInfo().Count);
        }
Example #20
0
 private void PutEntity(TimelineEntity entity)
 {
     try
     {
         if (Log.IsDebugEnabled())
         {
             Log.Debug("Publishing the entity " + entity.GetEntityId() + ", JSON-style content: "
                       + TimelineUtils.DumpTimelineRecordtoJSON(entity));
         }
         client.PutEntities(entity);
     }
     catch (Exception e)
     {
         Log.Error("Error when publishing entity [" + entity.GetEntityType() + "," + entity
                   .GetEntityId() + "]", e);
     }
 }
Example #21
0
    void ConstructTimeline()
    {
        m_director = m_directorList[m_retIdx];

        Undo.RecordObject(m_director.playableAsset, "Import Animation Clip");

        var timeline_asset = m_director.playableAsset as TimelineAsset;

        double         marker    = 0.0;
        AnimationTrack animTrack = null;

        if (m_trackIdx == 0 && animTrack == null)
        {
            animTrack = timeline_asset.CreateTrack <AnimationTrack>(null, selected.name);
        }
        else
        {
            animTrack = m_animTracks[m_trackIdx - 1] as AnimationTrack;
        }

        foreach (var i in m_TreeView.m_itemList)
        {
            var animClip = i.animclip;

            var newClip = animTrack.CreateClip(animClip);
            m_director.SetGenericBinding(animTrack, selected);
            newClip.displayName = animClip.name;
            newClip.start       = marker;
            marker = newClip.end;

            // set exptrapolation to none
            TimelineUtils.SetClipExtrapolationMode(newClip, "preExtrapolationMode", TimelineClip.ClipExtrapolation.None);
            TimelineUtils.SetClipExtrapolationMode(newClip, "postExtrapolationMode", TimelineClip.ClipExtrapolation.None);
        }


        // update timeline window
        TimelineUtils.ToggleLockWindow();
        TimelineUtils.SetTimeline(timeline_asset, m_director);
        Selection.activeObject = m_director.gameObject;
        TimelineUtils.ToggleLockWindow();

        // persist changes
        EditorSceneManager.SaveScene(selected.scene);
    }
Example #22
0
                public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
                {
                    ScriptPlayable <SpineAnimatorPlayableBehaviour> playable = ScriptPlayable <SpineAnimatorPlayableBehaviour> .Create(graph, new SpineAnimatorPlayableBehaviour());

                    SpineAnimatorPlayableBehaviour clone = playable.GetBehaviour();

                    SpineAnimatorTrackMixer trackMixer = TimelineUtils.GetTrackMixer <SpineAnimatorTrackMixer>(graph, _parentAnimatorTrack);

                    clone._clipAsset = this;

                    if (trackMixer != null && trackMixer.GetTrackBinding() != null && !string.IsNullOrEmpty(_animationId))
                    {
                        SkeletonAnimation skeletonAnimation = trackMixer.GetTrackBinding();
                        clone._animation      = skeletonAnimation.skeletonDataAsset.GetAnimationStateData().SkeletonData.FindAnimation(_animationId);
                        clone._animationSpeed = _animationSpeed;
                    }

                    return(playable);
                }
Example #23
0
                public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
                {
                    var playable = ScriptPlayable <Spine3DAnimatorPlayableBehaviour> .Create(graph, new Spine3DAnimatorPlayableBehaviour());

                    Spine3DAnimatorPlayableBehaviour clone = playable.GetBehaviour();

                    Spine3DAnimatorTrackMixer trackMixer = TimelineUtils.GetTrackMixer <Spine3DAnimatorTrackMixer>(graph, _parentAnimatorTrack);

                    clone._clipAsset = this;

                    if (trackMixer != null && trackMixer.GetTrackBinding() != null && !string.IsNullOrEmpty(_animationId))
                    {
                        clone._animationId                = _animationId;
                        clone._animationDuration          = trackMixer.GetTrackBinding().GetAnimationLength(_animationId);
                        clone._animationSpeed             = _animationSpeed;
                        clone._proxyAnimationOrientations = (eSpine3DOrientation)int.MaxValue;
                    }

                    return(playable);
                }
Example #24
0
        private void PrepareTimelineDomain()
        {
            TimelineClient timelineClient = null;

            if (conf.GetBoolean(YarnConfiguration.TimelineServiceEnabled, YarnConfiguration.DefaultTimelineServiceEnabled
                                ))
            {
                timelineClient = TimelineClient.CreateTimelineClient();
                timelineClient.Init(conf);
                timelineClient.Start();
            }
            else
            {
                Log.Warn("Cannot put the domain " + domainId + " because the timeline service is not enabled"
                         );
                return;
            }
            try
            {
                //TODO: we need to check and combine the existing timeline domain ACLs,
                //but let's do it once we have client java library to query domains.
                TimelineDomain domain = new TimelineDomain();
                domain.SetId(domainId);
                domain.SetReaders(viewACLs != null && viewACLs.Length > 0 ? viewACLs : " ");
                domain.SetWriters(modifyACLs != null && modifyACLs.Length > 0 ? modifyACLs : " ");
                timelineClient.PutDomain(domain);
                Log.Info("Put the timeline domain: " + TimelineUtils.DumpTimelineRecordtoJSON(domain
                                                                                              ));
            }
            catch (Exception e)
            {
                Log.Error("Error when putting the timeline domain", e);
            }
            finally
            {
                timelineClient.Stop();
            }
        }
                public override void OnInspectorGUI()
                {
                    DrawDefaultInspector();

                    EditorGUILayout.Separator();

                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.LabelField(GUIContent.none, GUILayout.Width(EditorUtils.GetLabelWidth()));

                        if (GUILayout.Button("Match Curves To Clip", GUILayout.ExpandWidth(false)))
                        {
                            BaseAnimatedClip Clip = target as BaseAnimatedClip;

                            if (Clip != null && TimelineEditor.inspectedAsset != null)
                            {
                                TimelineClip clip = TimelineUtils.GetClip(TimelineEditor.inspectedAsset, Clip);
                                MatchCurvesToClipDuration(clip);
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                public override void OnInspectorGUI()
                {
                    DrawDefaultInspector();

                    EditorGUILayout.Separator();

                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.LabelField(GUIContent.none, GUILayout.Width(EditorUtils.GetLabelWidth()));

                        if (GUILayout.Button("Set Duration From Child Tracks", GUILayout.ExpandWidth(false)))
                        {
                            ParentBindingMasterClip Clip = target as ParentBindingMasterClip;

                            if (Clip != null && TimelineEditor.inspectedAsset != null)
                            {
                                TimelineClip clip = TimelineUtils.GetClip(TimelineEditor.inspectedAsset, Clip);
                                ClampMasterClipToChildClips(clip);
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
Example #27
0
        public virtual void TestTimelinePutErrors()
        {
            TimelinePutResponse TimelinePutErrors = new TimelinePutResponse();

            TimelinePutResponse.TimelinePutError error1 = new TimelinePutResponse.TimelinePutError
                                                              ();
            error1.SetEntityId("entity id 1");
            error1.SetEntityId("entity type 1");
            error1.SetErrorCode(TimelinePutResponse.TimelinePutError.NoStartTime);
            TimelinePutErrors.AddError(error1);
            IList <TimelinePutResponse.TimelinePutError> response = new AList <TimelinePutResponse.TimelinePutError
                                                                               >();

            response.AddItem(error1);
            TimelinePutResponse.TimelinePutError error2 = new TimelinePutResponse.TimelinePutError
                                                              ();
            error2.SetEntityId("entity id 2");
            error2.SetEntityId("entity type 2");
            error2.SetErrorCode(TimelinePutResponse.TimelinePutError.IoException);
            response.AddItem(error2);
            TimelinePutErrors.AddErrors(response);
            Log.Info("Errors in JSON:");
            Log.Info(TimelineUtils.DumpTimelineRecordtoJSON(TimelinePutErrors, true));
            NUnit.Framework.Assert.AreEqual(3, TimelinePutErrors.GetErrors().Count);
            TimelinePutResponse.TimelinePutError e = TimelinePutErrors.GetErrors()[0];
            NUnit.Framework.Assert.AreEqual(error1.GetEntityId(), e.GetEntityId());
            NUnit.Framework.Assert.AreEqual(error1.GetEntityType(), e.GetEntityType());
            NUnit.Framework.Assert.AreEqual(error1.GetErrorCode(), e.GetErrorCode());
            e = TimelinePutErrors.GetErrors()[1];
            NUnit.Framework.Assert.AreEqual(error1.GetEntityId(), e.GetEntityId());
            NUnit.Framework.Assert.AreEqual(error1.GetEntityType(), e.GetEntityType());
            NUnit.Framework.Assert.AreEqual(error1.GetErrorCode(), e.GetErrorCode());
            e = TimelinePutErrors.GetErrors()[2];
            NUnit.Framework.Assert.AreEqual(error2.GetEntityId(), e.GetEntityId());
            NUnit.Framework.Assert.AreEqual(error2.GetEntityType(), e.GetEntityType());
            NUnit.Framework.Assert.AreEqual(error2.GetErrorCode(), e.GetErrorCode());
        }
Example #28
0
        public virtual void TestTimelineDomain()
        {
            TimelineDomains domains = new TimelineDomains();
            TimelineDomain  domain  = null;

            for (int i = 0; i < 2; ++i)
            {
                domain = new TimelineDomain();
                domain.SetId("test id " + (i + 1));
                domain.SetDescription("test description " + (i + 1));
                domain.SetOwner("test owner " + (i + 1));
                domain.SetReaders("test_reader_user_" + (i + 1) + " test_reader_group+" + (i + 1)
                                  );
                domain.SetWriters("test_writer_user_" + (i + 1) + " test_writer_group+" + (i + 1)
                                  );
                domain.SetCreatedTime(0L);
                domain.SetModifiedTime(1L);
                domains.AddDomain(domain);
            }
            Log.Info("Domain in JSON:");
            Log.Info(TimelineUtils.DumpTimelineRecordtoJSON(domains, true));
            NUnit.Framework.Assert.AreEqual(2, domains.GetDomains().Count);
            for (int i_1 = 0; i_1 < domains.GetDomains().Count; ++i_1)
            {
                domain = domains.GetDomains()[i_1];
                NUnit.Framework.Assert.AreEqual("test id " + (i_1 + 1), domain.GetId());
                NUnit.Framework.Assert.AreEqual("test description " + (i_1 + 1), domain.GetDescription
                                                    ());
                NUnit.Framework.Assert.AreEqual("test owner " + (i_1 + 1), domain.GetOwner());
                NUnit.Framework.Assert.AreEqual("test_reader_user_" + (i_1 + 1) + " test_reader_group+"
                                                + (i_1 + 1), domain.GetReaders());
                NUnit.Framework.Assert.AreEqual("test_writer_user_" + (i_1 + 1) + " test_writer_group+"
                                                + (i_1 + 1), domain.GetWriters());
                NUnit.Framework.Assert.AreEqual(0L, domain.GetCreatedTime());
                NUnit.Framework.Assert.AreEqual(1L, domain.GetModifiedTime());
            }
        }
                public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
                {
                    ScriptPlayable <Spine3DAnimatorPlayableBehaviour> playable = ScriptPlayable <Spine3DAnimatorPlayableBehaviour> .Create(graph, new Spine3DAnimatorPlayableBehaviour());

                    Spine3DAnimatorPlayableBehaviour clone = playable.GetBehaviour();

                    Spine3DAnimatorTrackMixer trackMixer = TimelineUtils.GetTrackMixer <Spine3DAnimatorTrackMixer>(graph, _parentAnimatorTrack);

                    clone._clipAsset = this;

                    if (_animationSource != null && !string.IsNullOrEmpty(_animationId))
                    {
                        SkeletonData skeletonData = _animationSource.GetSkeletonData(false);
                        Animation    animation    = skeletonData.FindAnimation(_animationId);

                        clone._animationDuration = animation != null ? animation.Duration : (float)PlayableBinding.DefaultDuration;
                        clone._animationSpeed    = _animationSpeed;

                        clone._proxyAnimation             = animation;
                        clone._proxyAnimationOrientations = _validOrientations;
                    }

                    return(playable);
                }
                protected override void PrepareChannelFrame(Playable playable)
                {
                    int numInputs = playable.GetInputCount();

                    Spine3DAnimatorTrackMixer.ChannelAnimationData        primaryAnimation     = new Spine3DAnimatorTrackMixer.ChannelAnimationData();
                    List <Spine3DAnimatorTrackMixer.ChannelAnimationData> backgroundAnimations = new List <Spine3DAnimatorTrackMixer.ChannelAnimationData>();

                    for (int i = 0; i < numInputs; i++)
                    {
                        ScriptPlayable <Spine3DAnimatorPlayableBehaviour> scriptPlayable = (ScriptPlayable <Spine3DAnimatorPlayableBehaviour>)playable.GetInput(i);
                        Spine3DAnimatorPlayableBehaviour inputBehaviour = scriptPlayable.GetBehaviour();

                        if (inputBehaviour != null && (!string.IsNullOrEmpty(inputBehaviour._animationId) || inputBehaviour._proxyAnimation != null))
                        {
                            float inputWeight = playable.GetInputWeight(i);

                            if (inputWeight > 0.0f)
                            {
                                TimelineClip clip = TimelineUtils.GetClip(_trackAsset, inputBehaviour._clipAsset);

                                if (clip != null)
                                {
                                    double clipStart    = clip.hasPreExtrapolation ? clip.extrapolatedStart : clip.start;
                                    double clipDuration = clip.hasPreExtrapolation || clip.hasPostExtrapolation ? clip.extrapolatedDuration : clip.duration;

                                    if (_director.time >= clipStart && _director.time <= clipStart + clipDuration)
                                    {
                                        bool isPrimaryClip = IsPrimaryClip(clip);

                                        //Work out track time
                                        float animationDuration = inputBehaviour._animationDuration;
                                        float trackTime         = GetExtrapolatedTrackTime(clip, _director.time, animationDuration);

                                        if (isPrimaryClip)
                                        {
                                            primaryAnimation._animationId                = inputBehaviour._animationId;
                                            primaryAnimation._animationTime              = trackTime;
                                            primaryAnimation._animationWeight            = inputWeight;
                                            primaryAnimation._animationSpeed             = inputBehaviour._animationSpeed;
                                            primaryAnimation._proxyAnimation             = inputBehaviour._proxyAnimation;
                                            primaryAnimation._proxyAnimationOrientations = inputBehaviour._proxyAnimationOrientations;
                                        }
                                        else
                                        {
                                            Spine3DAnimatorTrackMixer.ChannelAnimationData backroundAnimation = new Spine3DAnimatorTrackMixer.ChannelAnimationData
                                            {
                                                _animationId                = inputBehaviour._animationId,
                                                _animationTime              = trackTime,
                                                _animationWeight            = 1.0f,
                                                _animationSpeed             = inputBehaviour._animationSpeed,
                                                _proxyAnimation             = inputBehaviour._proxyAnimation,
                                                _proxyAnimationOrientations = inputBehaviour._proxyAnimationOrientations,
                                            };
                                            backgroundAnimations.Add(backroundAnimation);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    Spine3DAnimatorTrackMixer   parentMixer = (Spine3DAnimatorTrackMixer)_parentMixer;
                    Spine3DAnimatorChannelTrack track       = (Spine3DAnimatorChannelTrack)_trackAsset;

                    parentMixer.SetChannelData(track._animationChannel, primaryAnimation, backgroundAnimations.ToArray());
                }