User Interface: Animation
This section describes the Creo TOOLKIT functions that enable you to create animation frames and movies.
Introduction
Creo TOOLKIT provides the functions that enable you to animate parts and assemblies. Creo TOOLKIT handles lower-level considerations, such as hardware-dependent graphics and the user interface.
Two animation techniques are available:
•  Batch animation—You create an animation movie (ProAnimMovie object) and users control the movie using an interface similar to a VCR. Users can perform such operations as “Play”, “Fast-Forward”, “Rewind”, and so on. The following figure shows the animation dialog box.
Animation Dialog Box
Image
•  Frame-by-frame (single) animation—You create a single animation (ProSingleAnim object) and code the control loop into your application. The batch animation interface does not appear. To replay the movie, you must reexecute the control loop of your application.
For both batch and single animation, you must build the animation from two important elements. These elements are:
•  Animation object (ProAnimObj object)—Contains the object to be animated and its transformation, with respect to its immediate parent. In constructing the animation, you can show motion by creating a series of ProAnimObj objects, each with a different transformation.
•  Animation frame (ProAnimFrame object)—Captures the image of the animation objects at one instance of the animation. Your final animation is a series of animation frames shown in succession.
Animation Objects
Functions Introduced:
An animation object can be a part or an assembly. To create an animation object, call the function ProAnimobjectCreate() and pass as input the component path of the object to be animated. You must also supply the location of the animation object with respect to its immediate parent—not with respect to the top-level assembly. This distinction is important when the depth of the assembly hierarchy is greater than 1.
To delete an animation object, use the function ProAnimobjectDelete().
Animation Frames
Functions Introduced:
After you have created animation objects, you must create an animation frame in which to store the objects. To create an animation frame, call the function ProAnimframeCreate() and supply a frame view matrix. The frame view matrix is a transformation from the top model coordinate system that allows you to alter the view of the top-level model in your animation. This functionality could be used, for example, to change the view of an assembly while the assembly components (animation objects) move as specified in the call to ProAnimobjectCreate().
Note
The frame view matrix is specified as a transformation from the root assembly.
Creating an animation frame does not cause the animation objects to be contained in the frame. To add animation objects to a frame, you must call the function ProAnimframeObjAdd().
To remove an object from a frame, call the function ProAnimframeObjRemove(). To delete a frame, call ProAnimframeDelete().
The function ProAnimframeObjVisit() enables you to visit each animation object in an animation frame. The input arguments of the function specify the action and filtration functions, which are of type ProAnimObjAct.
Playing Animations
This section describes how to use your animation frames to construct and play the animation. As previously mentioned, there are two types of animation—single and batch.
Single Animation
Functions Introduced:
If you want to use single animation, your Creo TOOLKIT application must include a control loop that displays one animation frame after another. Before executing your control loop, initialize the single animation by calling ProSingleAnimationInit(). Within the loop, display each frame in turn using the function ProSingleAnimationPlay().
Note
Single animation does not involve the batch animation user interface. The control over a single animation is contained entirely within your application.
The function ProSingleAnimationClear() clears the specified single animation.
Batch Animation
Batch animation implements the user interface shown in the Introduction section. The interface enables users to control the playing of your animation movie.
Animation Movies
Functions Introduced:
The function ProAnimmovieCreate() creates an animation movie. At its creation, a movie does not contain any frames. To add frames to the animation movie, call the function ProAnimmovieFrameAdd().
To remove a frame from an animation movie, call the function ProAnimmovieFrameRemove(). Note that this action does not cause the frame to be deleted; use ProAnimmovieDelete() to release the memory of the animation frame.
The function ProAnimmovieFrameVisit() enables you to visit each of the frames in an animation movie. The input arguments to the function specify the action and filtration functions, which are of type ProAnimFrameAct.
Playing a Batch Animation
Function Introduced:
Batch animation manages the display of animation frames inside Creo Parametric. When you call ProBatchAnimationStart(), the system displays the VCR-like user interface. This interface enables users to control the speed and direction of the animation.
The function ProBatchAnimationStart() requires as input the animation movie to be started (animated). In addition, you can supply a callback function to be invoked before each animation frame is displayed. The callback function is of type ProBatchAnimAct.
Use the function ProAnimmovieSpinflagSet() to set the ProBoolean flag that allows spin in a batch animation process. If the animation includes view modifications, this flag should be set to false, otherwise it can be true.
Example 1: Creating a Batch Animation
The sample code in the file UgAnimAsmcompAnim.c located at <creo_toolkit_loadpoint>\protk_appls\pt_userguide\ptu_anim, shows how to animate an assembly component. The selected component rotates about the x-axis.