How To : Create an Interactive Image Sequence : Part 2

If you are wondering what an Image Sequence is, or why you would use one, please check out Part One here :

Create an Interactive Image Sequence: Part One

At any time while running a P3D show you can capture an image simply by pressing the "m" key, or an image sequence by pressing the "M" key and in both cases the resulting images will dropped into the same folder as the .p3d file. P3D will continue to save out images until you press "esc" to exit the show, this can rapidly take up a lot of space on your hard disk. This might be all you require and if so, you needn't read on. However, you can achieve more control by running a simple script that will allow you to specify where the files are saved, what they are called and the frame rate at which they are captured. 

For this example you will need :

1) The head_ct volume that can be found on the Downloads page here : Volume Rendering Examples 1

2) The head_ct_sequence.p3d and script both found on the Downloads page here :  Image Sequence Example 1


The Show : Slide 1

Once you have downloaded and placed the files in the appropriate places, open the head_ct_sequence.p3d file in your text editor and look at slide 1.

<key y="0.02"></key>
<bullet position="0.1 0.87 0" font="configuration/fonts/nevis.ttf" character_size="0.025">Sequence Test 1</bullet>
position="0.5 0.5 0" 
region="0.2 0.1 0.1 0.84 0.9 1" 
rotate="0 1 0 0"
rotate1="0 0 1 0"
rotate2="0 0 0 1"
rotation="10 0 0 1"



Note that in this example, the <key> tag is used twice, but in both cases will currently have no effect.

The first <key> tag is moving the mouse in "y", but as a key isn't specified, nothing will happen.

<key y="0.02"></key>

However, if we insert an "a" 

<key y="0.02">a</key>

this will now affect the alpha transfer function.

Try other values for "y" and see what difference it makes.

<key y="0.04">a</key>


The second <key> tag has been commented out, to prevent it having an effect, till required.

<!-- <key>M</key> -->

The "M" key, as stated at the beginning of this post, will result in a sequence of images being dropped into the same folder as the .p3d show file and does the same as pressing the "M" key while running a show. Therefore, it is best to keep this part commented out, or to leave the "<key></key>" tag empty, till you are ready to do the actual capture, as you will be filling your hard disk with images otherwise.


Understanding The Script : 

( Note, this section assumes you are using the OSX App and not the command line version. )

To control the capture speed, the name of the resulting images and where they are saved, we use a simple script. Open the example file "" in your text editor

${OSG_BINARY_PATH}/present3D head_ct_sequence.p3d --targetFrameRate 2.0 --screenshot head_test/head_test.jpg
echo make sequence complete
exit 0


The line we need to edit is the second one, the others do not change :

${OSG_BINARY_PATH}/present3D head_ct_sequence.p3d --targetFrameRate 2.0 --screenshot head_test/head_test.jpg


This can be broken down as follows :


This part should automatically set the path to the Present3D application and run present3D. If you are using the recommended location and file structure you shouldn't need to change this.



This is the name of the .p3d that you want to run. Edit as required.


--targetFrameRate 2.0

This is the frame rate that you want the show to run at while capturing. To get an idea of how to set this, run the show and press the "s" key, in the top LH corner of the screen you will see the frame rate that your content is running at, if it varies over time, take a note of the slowest rate and set your speed lower than this, to ensure that captured files will playback smoothly.


--screenshot head_test/head_test.jpg

This is the name of the folder and the name and type of file to be used when saving the images. You will need to create the folder, either in the same location as the .p3d file, or include the path from the .p3d file as follows :

--screenshot path/to/folder/image_sequence.jpg

if you want to save as .png's,  or another supported format, then just change the extension as required

--screenshot path/to/folder/image_sequence.png

Please note, if you specify to save in a folder that doesn't exist, or the name is misspelt, the capture will fail.


Running Present3D with the Capture Script :

run script screen grab

Once you have your modified script, you will want to run the head_ct_sequence.p3d show to check that the timings look ok before you start the capture, so leave the "M" commented out at present. Then open Present3D app and go to File/Run Script, this will open a finder browser window.. find your "" script, select it and click open.. and if if everything goes to plan, your show should run.

Some points to consider before starting Capture :

Before you start capture, make sure that you are using the correct screen config, screen resolution and stereo setup that you will require for final playback.

It doesn't matter if the Present3D window doesn't fill, or extends beyond your desktop, it is the Present3D window that is being captured.

You can't capture with an alpha channel, so the background you use is what you will have to work with later. So either use the final background, or use a background you can easily key out.


Capture :

Make sure you are happy with the timings and when you are ready, activate the capture by enabling or inserting the <key>"M"</key>...  using the "esc" key as usual, when you want to stop and exit. I usually do test run of just a few seconds to check that everything is going as expected, that my images are being saved into the correct folder and that they are the right format before going on and doing the final capture.


After Capture :

You should now have a folder full of images. If you are working in mono, that's it, you can move on to incorporating your interactive image sequence into your show, or create a movie, or take into Motion, or After Effects to combine with other captures. There are many options, these are just a few.

However, if you are working in stereo, there is one thing to do before you can move on. Open the first image, Preview will do fine, and you will see that only the left eye has been captured, open the second image and both will be there.. you will need to remove every other image, leaving only the odd numbered ones. There are many ways that you can do this, but I find it easy to just do it in finder by changing the finder view to images, squashing the window so only two columns will fit, select sort by name by using the sort button, (circled in blue in the image below) and then dragging over the  first column and pressing delete..  but you could create an automater, or shell script to do the same thing.
finder window


Incorporating an Interactive Image Sequence in Present3D

Using an image sequence is very similar to including a movie, except we use the imagesequence tag and have a couple of properties to include, see the example below :

<stereo_pair hud="on" scale_x="1.2" scale_y="2.4" paging_mode="LOAD_AND_DISCARD_IN_UPDATE_TRAVERSAL" interaction_mode="USE_MOUSE_X_POSITION">
            <imagesequence_left region="0.0 0.5 1.0 1.0">sequence/head_test</imagesequence_left>
            <imagesequence_right region="0.0 0.0 1.0 0.5">sequence/head_test</imagesequence_right>

This particular sequence was captured as an over/under stereo sequence where the left and right eye have been squashed in "y" to fit into a single 1920 x 1080 frame for use on a 3D TV and so the scale and region settings need to be modified to suit your desired format, just as with stereo movies. You must include the "paging_mode" and "interaction_mode" and for the latter you can choose either "USE_MOUSE_X_POSITION", or "USE_MOUSE_Y_POSITION" depending which way you want the user to swipe/move the Mouse. I prefer to always use the "X" direction unless there is a very good reason to use "Y", as it normally feels more natural.


Beyond The Basics

This is a very simple example, but you can create very complicated sequences that incorporate animated clipping planes and multiple sequences combined in Motion or After Effects with added effects, or text. You might find the following pages will help get you started :

Clipping Plane Animation For Volumes

Combine Image Sequences



No votes yet