In this tutorial we'll show how an animation can be created with a camera moving along a path.
This tutorial is done using the Animation sample project. Set the working directory to /base/Ex.3-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:
Field | Value | Description |
---|---|---|
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 populate the Morph tab.
Field | Value | Description |
---|---|---|
Start time (row 1) | 0 | The time to start the morph. |
End time (row 1) | 10 | The time for the morph to be complete. |
Start grid (row 1) | ../grid.mgrid | The starting point for the morph. In this example, this is the bare earth grid. |
End grid (row 1) | ../grid+dam.mgrid | The end point for the morph. In this example this is the grid+dam |
Morph type (row 1) | uniform | There are two types of morphing between grids: uniform & interpolation. This is explained below. |
Hide before start (row 1) | False | Hide the object before its start time True. |
Hide when done (row 1) | False | Hide the object after its end time if True. |
![]() |
To add new rows in the table, right click the header row and click Add rows from the popup menu. |
The final tab that needs to be edited is the Camera tab. We're going to add a single camera that is animated along a line.
Field | Value | Description |
---|---|---|
Camera type | path | Sets the camera to move along a polyline. |
Name | PathCamera | 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. |
Hit OK to create the script.
Morph types
There are 2 types of morphs that can be done: uniform and interpolation.
Uniform morphs
This morph method will take the final surface, drop it by the maximum elevation difference between the start and final surfaces, and then gradually load the final surface over time, The resulting grid at each time step is the maximum of the start & end grids.
Interpolation morphs
The interpolation morph will look at the difference in elevation at each point on the grid and at each time step the final grid elevation will be the starting surface elevation + (elevation difference/timesteps) * current timestep.
Running the script
If you run the script, you'll get some errror messages printed to the Output Window. This is because for a camera that follows a path, a focal point for the camera needs to be defined.
Open the animation script by right-clicking on the CameraPath.py file in the Project Explorer and selecting Edit. This will open the script in your text editor.
In Line 34, 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 will look as its following the camera path.
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.