Changes between Version 10 and Version 11 of Examples/ParaviewAnimating
- Timestamp:
- 06/15/18 10:34:58 (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Examples/ParaviewAnimating
v10 v11 14 14 15 15 == 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.16 The 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. 17 17 Within the time interval defined in the timeline, properties of the scene can be changed. 18 18 In 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. … … 20 20 In !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: 21 21 * 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) 23 23 * paraview.simple.!PythonAnimationCue: cue to execute a Python script at a certain point in time 24 24 * paraview.simple.!TimeAnimationCue: cue to determine what data timesteps are loaded depending on the animation clock time 25 25 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 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 (se below). 28 27 In the next paragraphs we are going to explain the basic mechanisms of the relevat Python classes and we give examples of typical use cases. 29 28 30 29 == !AnimationScene == 31 30 The !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:31 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 available: 33 32 * '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 bythe 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. 36 35 37 36 Important properties of !AnimationScene: … … 58 57 #!python 59 58 from paraview.simple import * 59 renderView = GetActiveViewOrCreate('RenderView') 60 60 animationScene = GetAnimationScene() 61 61 animationScene.StartTime = 0 … … 64 64 animationScene.PlayMode = 'Sequence' 65 65 animationScene.GoToFirst() 66 i = 0 66 67 while 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]) 69 72 if animationScene.AnimationTime == animationScene.EndTime: 70 73 break … … 76 79 #!python 77 80 from paraview.simple import * 81 renderView = GetActiveViewOrCreate('RenderView') 78 82 animationScene = GetAnimationScene() 79 83 animationScene.PlayMode = 'Snap To TimeSteps' 80 84 animationScene.GoToFirst() 85 i = 0 81 86 while 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]) 84 91 if animationScene.AnimationTime == animationScene.EndTime: 85 92 break … … 89 96 == Key Frames == 90 97 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 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.98 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. 92 99 93 100 The two basic keyframe classes are: … … 108 115 As already mentioned, a !KeyFrameAnimationCue connects the property of a pipeline object to the cue. 109 116 This 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 t he 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.117 Similar 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. 111 118 112 119 === !KeyFrameAnimationCue Use Case ===