Animation & View Capture
Met.3D can automatically step through a sequence of times or camera positions and export the result as a series of images or a video. This can be used to render an animation of a forecast’s evolution over its full lead time. The animation system is implemented as animation controllers and view captures.
Animation controllers
MAnimationController is the abstract base class for all animation controllers.
It implements the common animation loop, frame timing (setFrameTime()) and state management.
A list of MViewCapture instances, capture all animated views.
Derived animation controllers must implement the following abstract methods:
startAnimation()– Initializes the animation and prepares the first frame.advanceAnimation()– Advances the animation by one step and prepares the next frame.stopAnimation()– Cleans up temporary resources allocated duringstartAnimation().
Preparing a frame may require waiting for asynchronous work to complete.
For example, the MTimeAnimationController advances the synchronized time, which requires waiting until synchronization is completed.
To suspend the animation until asynchronous work completes, call MAnimationController::waitForAsync().
Once the operation has finished, call MAnimationController::stopWaiting() to resume the animation.
After a frame has been prepared by the derived controller, the base class captures the view.
It invokes all registered MViewCapture instances and waits for each capture() future to complete before advancing to the next step.
Two concrete controllers are built on this base, one on top of the other:
MTimeAnimationControlleradvances anMTimeControlby one time step per animation frame, using the same time-stepping andMTimeSyncEventmechanism described in Synchronization.MCameraAnimationControllerderives fromMTimeAnimationControllerand additionally moves the camera along a predefinedMCameraSequenceeach frame, so that camera movement and time-stepping can be combined in a single animation.
MAnimationControlSettings holds the configuration for the animation dock widget
(which time control and/or camera sequence to use, frame timing, etc.), separate
from the controllers themselves.
View captures
MAnimationController is responsible for controlling the animation, but it does not write image or video files directly.
Instead, it owns a list of MViewCapture instances (MAnimationController::addViewCapture()).
Each converts the rendered output of a single view into a specific output format.
Multiple captures can be attached to the same animation controller and capture the same view.
The available view capture implementations are:
MViewImageCapture– Saves each rendered frame as an image.MViewVideoCapture– Encodes rendered frames into a video file.MViewGeometryCapture– Exports the geometry visible in the view as.objfiles (one per time step). This is an experimental feature and currently only supports outputting jetcores, isosurface intersection lines, and trajectories.
MViewCapture::capture() implements the capture process.
It requests a newly rendered frame from the captured view, which returns a QFuture that completes once the rendering has finished.
Multiple view captures can request a frame from the same view independently, but only a single redraw of the view is performed.
After the view has finished rendering, MViewCapture::processResult(const QImage&) is called.
Derived classes implement this method to process the captured result.
Depending on the implementation, this mayinvolve writing the rendered image to disk, encoding it into a video, or exporting geometry data.
The supplied QImage contains the final rendered image of the view.