Changes between Version 10 and Version 11 of Examples/ParaviewAnimating


Ignore:
Timestamp:
06/15/18 10:34:58 (6 years ago)
Author:
Herwig Zilken
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Examples/ParaviewAnimating

    v10 v11  
    1414
    1515== Basic Concept ==
    16 The basic concept of how to animate "something", in this case the rendered !ParaView scene, is quite easy to understand. The central element of any animation is a timeline with a start and end time and a mechanism to determine a number of descrete timesteps (frames). All this is implemented in the Python class paraview.simple.!AnimationScene.
     16The basic concept of how to animate "something", in this case parameters (so called properties) of the !ParaView scene, is quite easy to understand. The central element of any animation is a timeline with a start and end time and a mechanism to determine a number of descrete timesteps (frames). in ParaView all this is implemented in the Python class paraview.simple.!AnimationScene.
    1717Within the time interval defined in the timeline, properties of the scene can be changed.
    1818In the !ParaView GUI this concept is reflected by so called "tracks" (or "cues") in the Animation View. Basically, each track defines the temporal change of one (or more) properties of the scene.
     
    2020In !ParaView-Python, different kinds (classes) of tracks/cues are available. We will deal with four of them, which are implemented in the following Python classes:
    2121* paraview.simple.!KeyFrameAnimationCue: basic cue to animate general properties of objects (readers, sources, filters) in the render pipeline
    22 * paraview.simple.!CameraAnimationCue: cue to change camera parameters (e.g. position, focal point, up direction, view angle)
     22* paraview.simple.!CameraAnimationCue: cue to change camera parameters (e.g. position, focal point, up direction, view angle, parallel scale)
    2323* paraview.simple.!PythonAnimationCue: cue to execute a Python script at a certain point in time
    2424* paraview.simple.!TimeAnimationCue: cue to determine what data timesteps are loaded depending on the animation clock time
    2525
    26 In general, each cue is connected to one or more properties of a ParaView object and has a number of keyframes attached to it, each defining certain values valid for a specific point in time. Therefore the key elements :) of a keyframe are keytime and keyvalues. The value(s) of the referred property is set to the keyvalues at the specified keytime. The most types of keyframes have the ability to interpolate keyvalues from one keyframe to the next. Specifically these are paraview.simple.!CameraKeyFrame, paraview.simple.!CompositeKeyFrame, paraview.simple.!ExponentialKeyFrame, paraview.simple.!RampKeyFrame and paraview.simple.!SinusoidKeyFrame.
    27 
     26In general, each cue is connected to one or more properties of a !ParaView object and has a number of keyframes attached to it, each defining certain values valid for a specific point in time. Therefore the key elements :) of a keyframe are !KeyTime and !KeyValues. The value(s) of the referred property is set to the keyvalues at the specified keytime. The most types of keyframes have the ability to interpolate keyvalues from one keyframe to the next (se below).
    2827In the next paragraphs we are going to explain the basic mechanisms of the relevat Python classes and we give examples of typical use cases.
    2928
    3029== !AnimationScene ==
    3130The !AnimationScene is responsible to steer the animation clock time.
    32 For this purpose, the !AnimationScene has a !StartTime, an !EndTime, and a mechanism to calculate the discrete points in time between !StartTime and !EndTime. These descrete timesteps are determined by the Mode (called !PlayMode in Python) of the !AnimationScene. Three different PlayModes are avilable:
     31For this purpose, the !AnimationScene has a !StartTime, an !EndTime, and a mechanism to calculate the discrete points in time between !StartTime and !EndTime. These descrete timesteps are determined by the Mode (called !PlayMode in Python) of the !AnimationScene. Three different !PlayModes are available:
    3332* 'Sequence': the timesteps are defined by the property !NumberOfFrames
    34 * 'Snap To !TimeSteps': only useful if you have time dependent data. The descrete timesteps are determind by the timesteps of the data. The !AnimationScene has knowledge about the available data timesteps by the help of a seperate object, the !TimeKeeper.
    35 * '!RealTime': given a specified duration, the timesteps are calculated on the fly (while rendering) in order to achieve that the animated sequence will take this duration. This mode is not useful for typical Python scripting, though.
     33* 'Snap To !TimeSteps': only useful if you have time dependent data. The descrete timesteps are identical to the timesteps of the data. The !AnimationScene has knowledge about the available data timesteps by the help of a seperate object, the !TimeKeeper.
     34* '!RealTime': given a specified duration, the timesteps are calculated on the fly (while rendering) in order to guarantee that the animated sequence will take this duration. This mode is not useful for typical Python scripting, though.
    3635
    3736Important properties of !AnimationScene:
     
    5857#!python
    5958from paraview.simple import *
     59renderView = GetActiveViewOrCreate('RenderView')
    6060animationScene = GetAnimationScene()
    6161animationScene.StartTime = 0
     
    6464animationScene.PlayMode = 'Sequence'
    6565animationScene.GoToFirst()
     66i = 0
    6667while True:
    67    # render scene
    68    # safe image
     68   imageName = "image_%04d.jpg" % (i)
     69   i = i + 1
     70   renderView.Update()
     71   SaveScreenshot(imageName, renderView, ImageResolution=[1920, 1080])
    6972   if animationScene.AnimationTime == animationScene.EndTime:
    7073      break
     
    7679#!python
    7780from paraview.simple import *
     81renderView = GetActiveViewOrCreate('RenderView')
    7882animationScene = GetAnimationScene()
    7983animationScene.PlayMode = 'Snap To TimeSteps'
    8084animationScene.GoToFirst()
     85i = 0
    8186while True:
    82    # render scene
    83    # safe image
     87   imageName = "image_%04d.jpg" % (i)
     88   i = i + 1
     89   renderView.Update()
     90   SaveScreenshot(imageName, renderView, ImageResolution=[1920, 1080])
    8491   if animationScene.AnimationTime == animationScene.EndTime:
    8592      break
     
    8996== Key Frames ==
    9097Before we start our explantion of cues, we give an overview about keyframes, as keyframes are an integral part of cues. Keyframes define what value(s) a cue passes to the property of the connected pipeline object at a give point in time.
    91 Without keyframes, a cue is more or less useless (with the exception of the !TimeAnimationCue, see below). A cue stores the list of attached keyframes in its KeyFrame property.
     98Without keyframes, a cue is more or less useless (with the exception of the !TimeAnimationCue, see below). A cue stores the list of attached keyframes in its !KeyFrame property.
    9299
    93100The two basic keyframe classes are:
     
    108115As already mentioned, a !KeyFrameAnimationCue connects the property of a pipeline object to the cue.
    109116This connection is defined via the attributes !AnimatedProxy (proxy of the pipeline object) and !AnimatedPropertyName (name of the connected property), though typically you do not have to set these attributes on your own. Instead they are set when constructing a !KeyFrameAnimationCue by calling !GetAnimationTrack(...) (see use case below).
    110 Similar to the !AnimationScene, every cue also has the properties !StartTime and !EndTime. Typically these properties do not have the identical values as the corresponding ones of !AnimationScene. When !TimeMode is set to 'Normalize', the start and end time of the animation scene is linearly interpolated to the interval ![0,1]. But don't care, these values are the defaults anyhow.
     117Similar to the !AnimationScene, every cue also has the properties !StartTime and !EndTime. Typically these properties do not have to be identical to the corresponding ones of !AnimationScene. When !TimeMode is set to 'Normalize' (which is the default), the start and end time of the animation scene is linearly interpolated to the interval ![StartTime, EndTime]. Default values are StartTime=0 and EndTime=1.
    111118
    112119=== !KeyFrameAnimationCue Use Case ===