In this tutorial we'll show how an animation can move an object along a path over time.
This tutorial is done using the Animation sample project. Set the working directory to /base/Ex.-Morphing to run this example.
Creating the script
To create the animation script, run the command Tex/Animations/Create animation script.
On the general tab, enter the following data:
|Animation script name||animation||The name of the script file created will be animation.py|
|Duration||10||Animation will be 10 seconds long (in the AVI created - it may take more or less time to actually create the animation in the 3D window).|
|Frames per second||24||24 frames are generated for each second of video.|
|Clear graphics on run||True||The 3D window will be cleared of all geometry prior to running the animation.|
|Hide scalebar||True||The scalebar will be hidden prior to the animation and restored at the end of it.|
|Hide orientation widget||True||The XYZ orientation widget will be hidden prior to the animation and restored at the end of it.|
The next tab to edit is the Camera tab. We're going to add a single camera that is animated along a line.
|Camera type||path||Sets the camera to move along a polyline.|
|Name||CameraPath||The name of the camera and the name of the AVI file that will be created.|
|Start time||0||The time at which the camera becomes active.|
|End time||10||The time at which the camera becomes inactive.|
|Path||camera_path.mcurve||The polyline to use for the camera path.|
The next tab to edit is the Objects tab.
|Start time||0||Start time of the object movement.|
|End time||10||End time for the object movement.|
|Geometry||dino_2.msurface||The geometry to move.|
|Animation path||obj_path.mcurve||The path to move the object along.|
|Anchor||bottom||This specifies which part of the object is set to the elevation of the animation path. In this case, the bottom of the object is anchored to the animation path.|
|Object scale||1||The vertical exaggeration to use for the animation object.|
|Hide before start||False||Hide the object before its start time True.|
|Hide when done||False||Hide the object after its end time if True.|
The final tab that needs to be edited is the Static geometry tab. This is for geometry that is visible for the entire animation.
|Geometry||../grid.mgrid||The base terrain grid.|
Running the script
If you run the script, you'll get some error messages printed to the Output Window. This is because for a camera position needs to be set.
Open the animation script by right-clicking on the T-Rex.py file in the Project Explorer and selecting Edit. This will open the script in your text editor.
In Line 35, there is a variable called focal_point that is currently defined as the Python None value. The None needs to be replaced with a coordinate that represents where the camera is looking at.
To do this, load up the topography, move the mouse over the point to focus on, and tap the 'c' key. This copies the current xyz position to the clipboard. Select None and paste the coordinates into the text file. Save the script.
Once you've pasted the coordinates, make sure to delete the # critical line (line 33 in the example above). If you don't do this, then you'll still get the warning when you try and run the script.
Run the script. It's likely that the view will not be what you want to see. This is because by default the zoom scale (the keyword variable in Line 35 called parallel_scale) is 1 and its an orthographic (parallel) projection.
You could just change the parallel_scale and rerun until you get a suitable scale. Bigger numbers mean that its zoomed out further.
You can also use a command Tex/Animation/Estimate animation parallel scale to interactively get an appropriate view scale. Load the topography and the animation path. You'll be asked to select a point on the animation path, and a point to focus on.
Change the parallel scale and hit Render to update the 3D window, until you end up with a suitable zoom level. Go back to the animation script and change the value for parallel_scale to be the valued you arrived at. Save and run the script.
Run the AVI file saved in the working directory to see the animation.