Animation gives the illusion of movement by updating and rerendering data over time, such as the position and attitude of an aircraft. Animation is accomplished directly through the SceneManager or indirectly through one of the animation classes that communicate with the scene manager.
Used together, the scene manager's SetTime and Render methods provide animation functionality. First, call SetTime to set the time, then call Render to draw each Scene at that time. These methods are normally used when integrating Insight3D into a preexisting product that has its own animation system.
When SetTime is called, the scene manager's TimeChanged event is raised. Typically during the event, time-dependent data that is not scene-specific is updated, such as the position of a satellite. Scene data can also be updated if desired.
If there is no preexisting animation system in your application, one of the animation classes may be useful. Each of these classes manage time and drive the scene manager using the methods described above. The scene manager only allows one animation object to be active at a time.
The following animation classes are available:
SimulationAnimation is used to animate at any time. You might simulate GPS constellation at some time in the past or simulate a proposed network of satellites. The below example animates a scene:
SimulationAnimation animation = new SimulationAnimation(); SceneManager.Animation = animation; animation.StartTime = new GregorianDate(2008, 5, 30, 14, 0, 0).ToJulianDate(); animation.EndTime = new GregorianDate(2008, 5, 31, 14, 0, 0).ToJulianDate(); animation.Time = animation.StartTime;
Animation can also be played backward. The time between each animation frame is controlled using TimeStep. Because simulated time is stepped by the same amount for each frame rendered, the rate of progression of simulated time can change with the complexity of the scene. To progress simulated time at a constant rate independent of the rendering frame rate, use RealTimeSimulationAnimation.
RealTimeSimulationAnimation progresses simulated time at a constant rate independent of the rate at which frames are rendered. This is in contrast to SimulationAnimation, which progresses simulated time by a specified step per rendered frame. Otherwise, the two classes are very similar. Both allow animation to be played both forward and backward, and allow the current time to be set to any time, past, present, or future.
Often it is desired to speed up animation perhaps for similar reasons one might want to speed up a movie - to get past the boring parts. The rate at which simulated time progresses is specified by the TimeMultiplier property. If the time multiplier is set to 2.0, then when the wall clock moves one second, the simulation time moves two seconds.
realTimeSimulation.TimeMultiplier = 2.0;
RealTimeAnimation animates in step with wall clock time. Animation can only play forward in accordance with our usual sense of time.
Often objects that use this class run slightly behind real-time, because there can be a delay from when the data was generated to when the data reaches the application. For example, if an aircraft were being tracked in real-time, the telemetry defining the position of the aircraft could take a few seconds get to the application. Therefore, the latest position data that the application has is always a few seconds behind. To ensure that there is data at the current animation frame, the TimeOffset property is used to offset time from the wall clock time. In the aircraft example, the problem was solved by offsetting the time by three seconds.
realTime.TimeOffset = -3.0;
Frame rate is how many animation frames are rendered per second. Each animation class supports controlling and getting this rate.
It is desirable to control the rate, because if the application animated as quickly as possible, 100 percent of CPU processing time would be devoted to animating and to nothing else. Targeting a specific rate gives up time to other processes. Targeting a specific rate is demonstrated in the following code sample:
SceneManager.Animation.RefreshRate = RefreshRate.TargetedFramesPerSecond; SceneManager.Animation.TargetedFramesPerSecond = 30.0;
The rate is targeted, meaning Insight3D tries to run at that rate. The application will animate no faster, but may run slower if the video card is overloaded with too much to draw.
Sometimes, one may want to animate as fast as possible, for example to measure the load on a video card due to a new feature that may not otherwise be noticeable if the frame rate were targeted. Animating as fast as possible is demonstrated in the following code sample:
SceneManager.Animation.RefreshRate = RefreshRate.Fastest;
The following code sample demonstrates how to get the current frame rate:
double fps = SceneManager.FrameRate.FramesPerSecond;