Click or drag to resize

Animation

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.

Using 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 pre-existing product that has its own animation system.

When setTime is called, the scene manager's TimeChanged (add / remove) 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.

When render is called, the scene's Rendering (add / remove) event is raised for each scene. Scene specific data is generally updated during this event, such as the camera position and orientation.

Using the Animation Classes

If there is no pre-existing 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:

Simulation

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:

Java
SimulationAnimation animation = new SimulationAnimation();

SceneManager.setAnimation(animation);

animation.setStartTime(new JulianDate(new GregorianDate(2008, 5, 30, 14, 0, 0.0)));
animation.setEndTime(new JulianDate(new GregorianDate(2008, 5, 31, 14, 0, 0.0)));
animation.setTime(animation.getStartTime());
Java
SceneManager.getAnimation().playForward();

Animation can also be played backward. The time between each animation frame is controlled using TimeStep (get / set). 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.

Real-Time Simulation

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 (get / set) property. If the time multiplier is set to 2.0, then when the wall clock moves one second, the simulation time moves two seconds.

Java
realTimeSimulation.setTimeMultiplier(2.0);

Real-time

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 (get / set) 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.

Java
realTime.setTimeOffset(-3.0);
Frame Rate

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:

Java
SceneManager.getAnimation().setRefreshRate(RefreshRate.TARGETED_FRAMES_PER_SECOND);
SceneManager.getAnimation().setTargetedFramesPerSecond(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:

Java
SceneManager.getAnimation().setRefreshRate(RefreshRate.FASTEST);

The following code sample demonstrates how to get the current frame rate:

Java
double fps = SceneManager.getFrameRate().getFramesPerSecond();