Exemplo n.º 1
0
 /// <summary>
 /// Runs one step of simulation. This is called by the Thread Timer
 /// </summary>
 /// <param name="state">Needed to conform to timercall back delegate, not used</param>
 private void DoSimulation(object state)
 {
     if (Monitor.TryEnter(lockObject, targetDeltaTime / 2))
     {
         try
         {
             // Do work
             if (scene != null)
             {
                 IList <Entity> rootEntity = scene.RootEntities;
                 simTime.FrameStart();
                 //Do keyframing
                 KeyframeEngine.Step();
                 //Update behaviours
                 PreUpdateScenegraphChildren(rootEntity);
                 UpdateScenegraphChildren(rootEntity);
                 PostUpdateScenegraphChildren(rootEntity);
                 simTime.FrameEnd();
                 //Calculate timing
                 //Debug.WriteLine("DeltaTime:" + simTime.DeltaTime);
                 //Notify about a finished simulation step
                 TriggerStepFinished();
             }
         }
         finally
         {
             Monitor.Exit(lockObject);
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructs a new engine instance
 /// </summary>
 /// <param name="scene">Scenegraph to use for simulations</param>
 public SimulationEngine(SceneGraph scene)
 {
     this.scene             = scene;
     this.simTime           = new SimulationTime();
     this.simulateStepTimer = new Timer(new TimerCallback(DoSimulation), null, Timeout.Infinite, targetDeltaTime);
     updatesPerSecond       = 30;
     targetDeltaTime        = 1000 / updatesPerSecond;
     lastDeltaTime          = targetDeltaTime;
     this.keyframeExecutor  = new KeyframeEngine();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Instantiates a new timeline viewmodel
 /// </summary>
 public TimelineViewModel(ITinyMessengerHub messenger, KeyframeEngine engine)
 {
     NotifyPropertyUpdateRate = 50;
     TimelineStart            = 0;
     TimelineEnd = 100;
     Messenger   = messenger;
     //Set up engine
     Engine = engine;
     Engine.CurrentTimeChanged += Engine_CurrentTimeChanged;
     //SetTimeLine(Engine.Keyframes);
     //MessengerInstance.Register<SelectedNodeChanged>(this, ActiveNodeChanged);
     //MessengerInstance.Register<ActiveTimelineChanged>(this, TimelineChanged);
     Messenger.Subscribe <SelectedEntityChanged>(ActiveEntityChanged);
     Messenger.Subscribe <InvalidateEntity>(OnInvalidateEntitiesMessage);
     AddKeyframeCommand = new RelayCommand(CaptureKeyframes, CanCaptureKeyframes);
     Keyframes          = new ObservableCollection <KeyframeViewModel>();
     playPauseCommand   = new RelayCommand(TogglePlayPauseState);
 }
Exemplo n.º 4
0
 public static void Send(KeyframeTimeline timeline, KeyframeEngine engine)
 {
     Messenger.Default.Send <ActiveTimelineChanged>(new ActiveTimelineChanged(timeline, engine));
 }
Exemplo n.º 5
0
 private ActiveTimelineChanged(KeyframeTimeline timeline, KeyframeEngine engine)
 {
     this.Timeline = timeline;
     Engine        = engine;
 }