Changes between Version 8 and Version 9 of Examples/ParaviewAnimating


Ignore:
Timestamp:
06/14/18 16:53:39 (6 years ago)
Author:
Herwig Zilken
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Examples/ParaviewAnimating

    v8 v9  
    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.
    1919
    20 In !ParaView-Python, different kinds (classes) of tracks/cues are available. We will try to explain four of them, which are implemented in the following Python classes:
     20In !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
    2222* paraview.simple.!CameraAnimationCue: cue to change camera parameters (e.g. position, focal point, up direction, view angle)
     
    2424* paraview.simple.!TimeAnimationCue: cue to determine what data timesteps are loaded depending on the animation clock time
    2525
    26 The (change of the) values of the properties in the timeline are defined by one or more keyframes included in each track. 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. Some types of keyframes also 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.
     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 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. Some types of keyframes also 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.
    2727
    28 In the next paragraphs we are going to explain the basic mechanisms of the relevat Python classes and we give some examples of typical use cases.
     28In the next paragraphs we are going to explain the basic mechanisms of the relevat Python classes and we give examples of typical use cases.
    2929
    30 == Class !AnimationScene ==
    31 The !AnimationScene is responsible for steering the animation clock time.
    32 For this purpose, the !AnimationScene has a !StartTime, an !EndTime, and a mechanism to determine the discrete time steps it will generate between !StartTime and !EndTime. The descrete timesteps are determined by the Mode (called !PlayMode in Python) of the !AnimationScene. Three different Modes are avilable:
     30== !AnimationScene ==
     31The !AnimationScene is responsible to steer the animation clock time.
     32For this purpose, the !AnimationScene has a !StartTime, an !EndTime, and a mechanism to determine the discrete points in time it will generate between !StartTime and !EndTime. These descrete timesteps are determined by the Mode (called !PlayMode in Python) of the !AnimationScene. Three different PlayModes are avilable:
    3333* 'Sequence': the timesteps are defined by the property !NumberOfFrames
    34 * 'Snap To !TimeSteps': the descrete timesteps are defined by the timesteps available in the (time dependend) data. The !AnimationScene has knowledge about the available data timesteps by the help of a seperate object, the !TimeKeeper.
    35 * '!RealTime': the timesteps are calculated on the fly (while rendering) to achieve a certain duration of the rendering. This mode is not useful for typical Python scripting, though.
     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.
    3636
    3737Important properties of !AnimationScene:
     
    7272}}}
    7373
    74 Get the animation scene and play all available timesteps of the time dependent data:
     74Get the animation scene and play all available timesteps of time dependent data:
    7575{{{
    7676#!python
     
    8888
    8989== Key Frames ==
    90 Before 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 has at a give point in time.
     90Before 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.
    9191Without 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.
    9292
     
    9696These two keyframes have only two intersting properties: !KeyTime and !KeyValues (which is a Python-list of values).
    9797
    98 The keyframes used to interpolate values are:
     98Keyframes used to interpolate values are:
    9999* paraview.simple.!RampKeyFrame: linear interpolation
    100100* paraview.simple.!SinusoidKeyFrame: sinusoidal interpolation
     
    108108As already mentioned, a !KeyFrameAnimationCue connects the property of a pipeline object to the cue.
    109109This 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 default anyhow.
     110Similar 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.
    111111
    112112=== !KeyFrameAnimationCue Use Case ===
     
    120120track2 = GetAnimationTrack("Center", 0, sphere)
    121121track3 = GetAnimationTrack(sphere.GetProperty("Radius"))
     122# set keyframes, in this example only for track1:
     123kf0 = CompositeKeyFrame()
     124kf0.Interpolation = 'Ramp'
     125# At time = 0, value = 0
     126kf0.KeyTime = 0
     127kf0.KeyValues = [0]
     128kf1 = CompositeKeyFrame()
     129# At time = 1.0, value = 200
     130kf1.KeyTime = 1.0
     131kf1.KeyValues = [200]
     132# attach keyframes to track1
     133track1.KeyFrames = [kf0, kf1]
    122134}}}
    123135
    124136
    125137== !TimeAnimationCue ==
    126 This type of cue is a very special one: while all other kind of cues are absolutely useless without attached keyframes, this one can fullfill a special task without having any: it can directly hand over the animation clock time (coming from !AnimationScene) to the property of a connected object. The typical use case within !ParaView is as follows: the !AnimationScene sets the value of the !TimeAnimationCue directly to its clock time. The !TimeAnimationCue is connected to the Time property of the !TimeKeeper object, which in turn requests all data objects to load the correct time step of the data. This way the clock time of the animation scene can be kept in sync with the data timsteps.
    127 But one can override this behaviour by attaching keyframes to this cue and setting "!UseAnimationTime" to 0. This way one can control what data timesteps are loaded/rendered at what animation clock time.
     138This type of cue is very special somehow: while all other kind of cues are absolutely useless without attached keyframes, this one can fullfill a special task without any: it can directly hand over the animation clock time (coming from !AnimationScene) to the property of a connected object. The typical use case within !ParaView is as follows: the !AnimationScene sets the value of the !TimeAnimationCue directly to its clock time. The !TimeAnimationCue is connected to the Time property of the !TimeKeeper object, which in turn requests all data objects to load just this time step of the data. This way the clock time of the animation scene can be kept in sync with the data timsteps.
     139Nevertheless you can override this behaviour by attaching keyframes to this cue and setting "!UseAnimationTime=0". This way you can control what data timesteps are loaded/rendered independent from the animation clock time.
    128140
    129141=== !TimeAnimationCue Use Cases ===
    130 Whatever the AnimationScene clock time is, set the time of the timetrack to 100.
     142Whatever the !AnimationScene clock time is, set the time of the timetrack to 100.
    131143This setup can be useful e.g. to generate an animated camera flight from one single data timestep (100 in this example).
    132144{{{
     
    151163
    152164== !CameraAnimationCue ==
    153 To be done
     165The !CameraAnimationCue controls severals parameters of the camera, like position, focal point, up vector and view angle.
     166It's main purpose is to generate camera flights by controlling the position and focal point of the camera depending on the animation time.
     167The behaviour of the camera can be set to three different modes by the property Mode:
     168
     169Mode:
     170* 'Interpolate Camera': each keyframe of the !CameraAnimationCue stores one camera position. These positions are interpolated in the animation.
     171* 'Path-based': the first keyframe of the !CameraAnimationCue stores a list of camera positions (!PositionPathPoints) and focal points (!FocalPathPoints). These values are interpolated in the animation. The pathes may be closed to generate seamless camera rides (!ClosedPositionPath, !ClosedFocalPath).
     172* 'Follow-data': The !CameraAnimationCue is connected to a visible pipeline object and the focal point of the camera is adjusted to point at the center of this (potentially moving) object.
     173
     174=== !CameraAnimationCue Use Cases ===
     175{{{
     176#!python
     177renderView = GetActiveView()
     178cameraTrack = GetCameraAnimationCue(view=renderView)
     179cameraTrack.Mode = 'Interpolate Camera'
     180}}}
    154181
    155182== !PythonAnimationCue ==