TOC PREV NEXT INDEX

Visualization Concepts



6 Using the Animator and
Image Capture Modules


This chapter describes how to create a keyframe animation from an AVS/Express viewer, and how to generate a movie of the animation.

This chapter discusses:

6.1 Keyframe Animation in AVS/Express

A keyframe animation is created by interpolating images between a series of captured views, the keyframes.

AVS/Express supports keyframe animation through the following features:

Understanding Keyframe Animation

To create a keyframe animation, you create a series of views, the "keyframes," that define known points in the animation you want to produce. The animator then adds frames between the keyframes to produce an animated sequence. These new frames are created by interpolating parameters of the view, such as size, position, or color, from one keyframe to the next. You control the number of frames that are created by specifying the number of frames per second for the animation. The following illustration shows the relationship between keyframes and interpolated frames.



The keyframes are visualizations you create in the AVS/Express viewer window. You use the animator module to capture these images and assign them to a time step in your animation. The keyframes record a "snapshot" of the parameter values in your application. The keyframes do not need to be evenly spaced. When you run the animation, the animator creates frames between the keyframes by interpolating parameter values to produce the number of frames per second you specify for the animation. The interpolated frames provide a smooth animation between the fixed points in the animation sequence defined by the keyframes.

For more information on how the interpolated frames are generated, see Controlling what is Animated6-11.

6.2 Defining a Keyframe Animation

To create a keyframe animation in AVS/Express, you

1. Instance the animator module into the application that will generate the views you want to animate. You do not need to prepare the application to be animated in any special way.
2. Capture the views you want to animate as keyframes.
3. Run the animation to generate interpolated frames and view the animation.

You can refine the animation by adding, deleting, or moving keyframes.

Instancing the animator Module
Adding the animator to your application

You instance the animator object from the DataIO sublibrary on the Main library page into the application you want to animate. Place the animator module at the same level in your application as the view you want to animate. AVS/Express automatically establishes a connection from the animator object to the viewer; you do not need to make a visible connection between the animator and your application. For example, the following diagram shows the animator module added to the network for the Isovolume example found in the Examples.Visualization sublibrary:



When you instance the animator module, it creates a database of the parameters in the current application that can be animated. The parameters that can be animated have the animate property set to 1. The set of animatable parameters defines the aspects of the view that can appear in the animation when you create your keyframes. By default, most of the scalar, matrix, or array parameters in the Data Visualization and Graphic Display objects have the animate property set. You cannot animate string, or enumerated values.

If you make changes to your application by adding or deleting objects, or by changing the animate property on any object's parameters in order to include or remove the parameters from the animation, you must click the Rescan button on the animator's control panel:    This causes the animator to rebuild its table of animatable parameters just as it did when it was instanced.

For more information about how the animation is built and how you can control it, see Controlling what is Animated6-11.
The animator controls

When you instance the animator, its controls are also added automatically to the application's module panel. The following is the animator user interface as it appears in the Data Viewer module panel:

Figure F-1


You can select the Separate Window checkbox to display the animator controls in their own window outside the DataViewer panel. This allows you to use the DataViewer editors and other module's controls to create your keyframes while you are building the animation, without having to switch the editor panel back and forth between the DataViewer and animator controls.

Creating the Animation Keyframes

You use the Keyframe Controls on the animator interface to define the series of keyframes on which your animation will be based:

Figure F-2


Before adding keyframes

In most cases, after you complete your application, but before you begin adding keyframes to your animation, you should do the following things

Reset, Normalize, Center, and Turn Auto-normalize off

In order to avoid unexpected behavior in you animation, set the view as follows:

Making these changes avoids unexpected shifts in the position of the objects in the view as your animation runs. For example, if you change a parameter that affects the extents of the data or the position of the camera, the camera automatically performs a reset-normalize-center operation. This means that if you set keyframes that change one of these parameters, and you have Auto Normalize on, the objects in the view may appear to jump when you run the animation.

Playback in the same Auto-normalize mode used to create the animation

However, if you choose to leave the auto-normalize option on, you should also playback the animation with auto-normalize on. Once you create an animation, you must play it back using the same auto-normalize mode that you used to create it. If you use a different mode during playback, the transformations applied to the view objects change, and the objects may appear in unexpected locations, or they may not be visible at all.

Reinitialize the animation parameters

If you have made any changes to the view or in your application network that you do not want to include in the animation, click the reinitialize button, , before adding any keyframes.

The reinitalize button resets the values of animatable parameters in your network to the current values of the parameters in the view. This allows you to capture a predictable first keyframe.

Note: You can only use the reinitialize button before you begin to add keyframes.
Adding the first keyframe
n To make the currently displayed view a keyframe, click the Add keyframe button:

The first keyframe is added at the 0 time step and a 0 appears in the list of Frame Times in the Keyframe Controls panel.

Note: The animator only adds a frame if it finds changes in the view. If no changes have been made in the view, attempting to add another frame causes an error message to be displayed and the frame is not added. To add the first keyframe, you may need to make a small change in the view. For example, you might use a control for one of the parameters in your application to change a value and return it to its original value before adding the keyframe.
Adding additional keyframes

To add additional keyframes, make the changes needed in the view to define the new image, and then click the Add Keyframe button again. The keyframe is added to the sequence at the time step specified by the Current Time control, and Current Time is automatically incremented by the amount specified by the Frame Delta. The new Current Time becomes the time step for the next keyframe you add. By default the Frame Delta is one second. You can change the time at which keyframes are added by typing a new value into the Frame Delta control on the Keyframe Controls panel.

As you add keyframes, the times at which keyframes are defined is displayed in the Frame Times listing. You can display the frame associated with a time by clicking on it in this list. When you select a time from the Frame Times list, the Interpolators listing is also updated to show the interpolators that are active for the corresponding time frame. This tells you which parameters are included in the Viewer animation.

You can also view the animation at any time in the sequence by directly setting the Current Time dial or by typing in the time below it. When you specify a time, the view is updated to display the animation at that moment.

Using the Current Time control to insert frames

You can also use the Current Time control to specify the time at which the next frame should be added. To add a new keyframe between existing frames:

The animator adds the next frame at the time you specify, and the animator updates the Current Time to the time you specified plus the Frame Delta. When you next add a keyframe, the animator attempts to add the new keyframe at the updated Current Time. However, if a keyframe is already set for that time, AVS/Express displays an error message and the frame is not added. You must adjust either the Current Time or the Frame Delta so that the keyframe you are adding falls between or after the keyframes you have already defined.

Adding a frame to complete an animated cycle

If you are creating an cyclic animation, that is one that ends with the same image with which it begins, you can use the Complete button, .

When you click Complete, the animator adds a keyframe that is a copy of the first keyframe at the end of the animation sequence. The time step of the keyframe added by the Complete button is the current time of the last keyframe in the animation plus the frame delta. The Current Time is then updated to the time of the ending keyframe.

Modifying the Keyframes

As you develop the animation you may want to adjust the keyframes you have added. You can change the series of keyframes by deleting or moving frames.

Deleting keyframes

To delete individual keyframes, select the time of the frame in the Frame Times list and click the Delete Keyframe button:   

To delete all the currently defined keyframes, click the Clear button: 

Moving a frame in the animation

Perform the following steps to change the time at which a keyframe is located in the animation sequence:

The animator moves the frame to the time you have specified in the New Time typein, and New Time is updated to the new time you specified for the frame plus the Frame Delta value. However, if a keyframe is already set for that time, AVS/Express displays an error message and the frame is not added. You must specify a New Time or Frame Delta so that the keyframe you are adding falls between or after the keyframes you have already defined.

When you run the animation again, the animator creates the animation using the modified keyframes.

6.3 Controlling what is Animated

As described above, the keyframes you create become the fixed points in the animation sequence. AVS/Express creates interpolated frames to create a smooth animation between keyframes. This section explains in more detail how the animation is created and how you can control the animation.

When you Run the animation, AVS/Express creates an interpolator object of the appropriate type for each animatable parameter that changes between keyframes. Then, for each time step, as determined by the number of frames per second you have specified, the interpolator outputs a value for the parameter. The combined output of the interpolators into the application create the images that are displayed as the animation is run.

Note: The keyframes do not capture the view as an image. Rather, they record the state of the parameters in your application. When you playback the animation, AVS/Express executes the application using the interpolated parameter values. Because of this, animating one parameter can cause other parameters to change as well. For example, changing the scale of an object changes the extent of the object's data which, in turn, may cause the view to re-normalize and the view's Top transformation to also change.
For cautions about the use of auto-normalize in automations, see Reset, Normalize, Center, and Turn Auto-normalize off6-7.
The animate property

By default, most of the parameters of the DVkit and GDkit macros that are used to create a visualization have the animate property. The animate property is not set by default on any of the Image Processing (IP) library object parameters.

Changes in perspective, and front and back clipping cannot be animated. In addition, string parameters cannot be interpolated and so are not animatable.

If you want to limit the attributes of the view that are animated, you can remove the animate property from the parameters that control them.

If you want to animate the results of visualization macros you write yourself, you must assign the animate property to the appropriate parameters. You can assign the property by adding animate=1 to the v code definition of the object or by using the Properties editor in the Network Editor.

To see how the animate property is used, review the v files dv_macro.v, gd.v, and gdif.v, or check an object with the Properties Editor.

Rescanning the application for changes in the animatable parameters

If you change the animate property on a parameter after you instance the animator module, you can force the animator to re-build its database of animatable parameters by clicking the Rescan button:   

When you click Rescan, the animator object walks the current network to build a database of animatable parameters just as it did when it was instanced. If you have added the animate property to a parameter, it is added to the animator's database. If you have removed the animate property from a parameter, it will be removed from the animator database.

Understanding the interpolation

When you Run the animation, AVS/Express creates an interpolator object of the appropriate type for each parameter that changes between keyframes. Interpolators are of three types: scalar, matrix, or array.

The Interpolators list on the Keyframe Controls lists the interpolators that have been created for the currently selected keyframe:

Figure F-1


This list lets you know which parameters in the application are being animated for each step of the animation. Each listing gives the object path in the current application to the parameter.

How Keyframes Set Parameters

In order to get the results you expect, it is important to understand how the interpolators work. There are three things to consider when creating keyframes:

For example, the following diagram illustrates a series of keyframes you might create to animate the iso_level parameter in an Iso Surface visualization. In the first three keyframes you perform other operations and leave the iso_level parameter unchanged from its initial value. In the fourth and following keyframes, you change the iso_level.



The following diagram illustrates the values of the iso_level parameter in the interpolated frames when you run the animation.



When a parameter value first changes, the animator creates an interpolator for that parameter. If there is no initial value for the parameter, keyframes that were created before the change do not have a value for the parameter. The animator automatically supplies the earlier keyframes with the value of the parameter before it was changed.

6.4 Generating and Viewing the Animation

You use the Playback Controls to generate and display your animation:

Figure F-1


As shown in the illustration above, you can use the buttons on the Playback Controls panel to run or step through the animation in either direction, or to go directly to the beginning or end of the sequence.

Each time you run the animation, AVS/Express generates the interpolated frames between the keyframes to create the animation. Changes you make to the animator settings or keyframes appear automatically the next time you run the animation. If you save an AVS/Express application containing the animator module, the current set of interpolated frames is also saved. You can also save the animation as an AVI or MPEG movie using the image capture module.

For more information on the image capture module, see Capturing Viewer Images6-16.

You can use the Frames Per Second setting to control the number of interpolated frames that are created between keyframes. By default AVS/Express creates 30 frames per second. You can set Frames Per Second to any value between 1 and 60. Specifying a higher number creates a more fine-grained animation.

You can use the Run option menu to specify three different ways of running the animation:

6.5 Capturing Viewer Images

You can use the image capture module to record images from an AVS/Express view or framebuffer. You can save the image frames to memory or to disk, play them back to any AVS/Express view or framebuffer, and generate AVI or MPEG 1 movies of them.

To capture images, instance the image capture module from the Main.DataIO sublibrary into the application workspace in the Network Editor and connect the appropriate image capture input port to either a view, the view port of a Uviewer object or a "framebuffer," the field output port of a filter or other object that produces a 2D image field. For example, the following diagram shows the image capture routine added to the network for the Isovolume example found in the Examples.Visualization sublibrary:

Figure F-1


When you instance image capture, its interface is added to the DataViewer's module editor panels:

Figure F-2


You use the Capture Controls to enable capture and to control how the images are recorded. You can specify whether the module stores the images in your computer's memory or in temporary files on your disk.

When you have captured a sequence of images, you can use the Playback Controls to display them. You can use the Mode option menu in the Capture Controls panel to choose whether to playback the images to a view or a framebuffer.

You can use the Movie Controls to save the stored images in AVI or MPEG 1 format files.

Details on each of these sets of control are given in the following sections.

Using the Capture Controls

You use the Capture Controls to control when and how the images are captured:

Figure F-3


Capturing images

To begin capturing images, Set the Mode option menu to one of the capture options:

As soon as you set Mode to one of the capture options, image capture begins to record an image each time the view or framebuffer field is re-rendered. Any change in the application that causes the view or framebuffer to be rendered causes image capture to add a frame. If you run an animation using the animator module while the image capture module is in the Capture from view or Capture from framebuffer mode, image capture records each of the frames as they are displayed.

Note: If you save and restore an application in which the image capture mode is set to Capture from view or Capture from framebuffer, the mode will be reset to inactive. This is to avoid unintentionally capturing images as the application loads and you begin to use it.

You can also force a frame to be added by clicking the Record button. When you push Record, the current view is recorded in a frame at the end of the current series of captured frames. You can delete the current image by clicking the Delete button, or delete all the saved images by clicking the Clear button. Total Frames displays the number of images currently saved.

Note: If any part of the view is obscured by a window or because it has been moved offscreen, the image cannot be captured. If you attempt to capture the image from an obscured view, Image Capture generates an error message and the image is not captured.
Controlling how the images are saved

You can set the Capture Mode option menu to specify how the images are saved:

When you have captured a set of images, you can use the Capture Mode option to convert the storage between memory and disk. For example, if you have captured a set of images in memory, setting the Capture Mode to Disk moves the images from memory to disk files. Similarly, setting the Capture Mode to Memory will move images you have saved to disk into your computer's memory.

Using the Playback Controls

You can use the Playback Controls to view the saved images:

Figure F-4


To playback the image you have recorded:

1. Use the Capture Mode option menu in the Capture Controls panel to choose one of the playback options:
You do not have to playback to the same view or framebuffer from which the images were recorded.
Note: Playing back the animation into the same view you are using to capture the animation can display some confusing images. When you play the movie back into the same view, the movie replaces the current view in the view window. However, when you cause the view to be re-rendered by interacting with the view window or exposing it, the objects in the application will be displayed in place of the movie frames. If you are viewing a movie of the current application, the change of images can make it appear as if the movie has captured incorrect frames.
2. Use the Playback Controls to run or step through the images.
See Generating and Viewing the Animation6-14 for more information about using these controls.
Creating a Movie

You can use the Movie Controls to create a movie of the images you have recorded:

Figure F-5


To create a movie of currently recorded images, perform the following steps:

1. Use the Mode option menu to select one of the following file formats:
2. Use the Movie Name typein or the Browse button to specify the directory and filename in which to store the movie files.
3. Click Generate Movie.

When you click Generate Movie, image capture creates a movie of the currently recorded frames in the format and directory specified. You do not need to playback the images to create the movie.

The status bar at the bottom of the Display Editor window displays image capture's progress as the movie is created. Depending on the number of frames you are converting to a movie file and the type of machine you are using, it can take some minutes to generate the movie. You can cancel creation of the movie by clicking the left oval in the execution interrupt toggle at the bottom of the Display Editor window:



The movies are generated in two stages, each of which will be reflected in the status bar. In the first stage, a temporary file is created for each frame in the movie. This stage is labeled Prepare MPEG or AVI and the status bar reflects its progress. When the first stage is complete, the status bar resets. In the second stage, the temporary files are processed to create the actual movie. This stage is labeled Generate MPEG or AVI and, again, the status bar displays the progress through this stage.

Once the movie generation is done, the status bar returns to idle.


TOC PREV NEXT INDEX