SoMovieScripter

InventorModule
author MeVis Medical Solutions AG
package MeVisLab/Standard
dll SoMovieScripter
definition SoMovieScripter.def
see also SoExaminerViewer
keywords frames, avi

Purpose

The module SoMovieScripter facilitates the generation of movies.

The camera position can be described by predefined rotations, interactively or by a script-based language. The camera position and some variable state are defined at certain keyframes of the movie and all frames between the keyframes are interpolated linearly.

Also some variable values (integer, float, vector, rotation and plane values) can be controlled for the duration of the movie by the same keyframe/interpolation mechanism.

Usage

The SoMovieScripter module needs a SoExaminerViewer (or a subclass/equivalent of this). Connect the SoMovieScripter’s camera position (Position) and orientation (Orientation) field to the SoExaminerViewer’s camera position and orientation field and the other way round to interactively change the camera’s orientation and position and to enable the preview feature of the SoMovieScripter module.

To record a movie connect some more fields of the SoMovieScripter to the examiner viewer’s fields. These fields to be connected are not on the common user interface but only on the automatic panel of the SoMovieScripter module. They are: startRecord (connect to viewer’s Recorder:start), stopRecord (connect to viewer’s Recorder:stop), saveRecordedMovie (connect to viewer’s createAvi). The last field to be connected is on the user available panel and it is called Frames / Second. Connect this field to the viewer’s Avi framerate field.

Best to just copy the SoMovieScripter and the SoExaminerViewer from this module’s example network with all their connections.

NOTE: the SoExaminerViewer.autoRedrawWhenRecording option of the viewer (available at the viewer’s advanced tab) must be turned OFF to correctly record the movie (otherwise the number of recorded frames does not always match the number of generated frames).

NOTE: if the SoMovieScripter module is used for automatic movie generation, especially if the script string is set by scripting or simply by loading a saved MeVisLab-network, it is crucial to put the camera to a defined state first. This means that the scene to be recorded should be centered by pressing ViewAll on the according examiner viewer.

Details

The SoMovieScripter maintains a list of frames. A sequence of frames makes a movie. In each frame all camera and variable values are stored. Every value of the camera’s parameters or of the variables can be altered independently of each other. The frames itself can be classified into normal frames and key frames. A keyframe is defined by the user and the normal frames that are inbetween the keyframes are interpolated by the module.

Windows

Default Panel

../../../Modules/Inventor/SoMovieScripter/mhelp/Images/Screenshots/SoMovieScripter._default.png

Input Fields

child

name: child, type: SoNode

Output Fields

self

name: self, type: SoNode

Parameter Fields

Field Index

Angle: Float pickCulling: Enum Seconds: Float
appendNumFrames: Integer Play (Preview): Trigger setupVector: Trigger
Axis: Vector3 Position: Vector3 Show preview: Bool
boundingBoxCaching: Enum Record Movie: Trigger Snapshot: Trigger
camLookat: Vector3 renderCaching: Enum Start Frame: Integer
camUp: Vector3 renderCulling: Enum startInterpolation: Trigger
Current Frame: Integer Reset: Trigger startRecord: Trigger
End Frame: Integer Rotate XAxis CCW: Trigger Status: String
Focal Distance: Float Rotate XAxis CW: Trigger Stop: Trigger
Frames / Second: Float Rotate YAxis CCW: Trigger stopRecord: Trigger
Frustum Height: Float Rotate YAxis CW: Trigger Submit Rotation: Trigger
inverseRotation: Bool Rotate ZAxis CCW: Trigger Total: Integer
Loop preview: Bool Rotate ZAxis CW: Trigger truncateNumFrames: Integer
Orientation: Rotation saveRecordedMovie: Trigger  
Pause: Trigger Script: String  

Visible Fields

Position

name: camPos, type: Vector3, default: 0 0 -1

Sets the position of the camera.

Connect this field to a viewer’s camera field.

Orientation

name: camOrient, type: Rotation, default: 0 0 1 0

Sets the camera’s orientation.

Connect this field to a viewer’s orientation field.

Focal Distance

name: focalDistance, type: Float, default: 0

Sets the focal distance.

The focal distance is the distance from the camera to the center of rotation.

This value is computed by the module.

Frustum Height

name: frustumHeight, type: Float, default: 0

Sets the height of the viewing frustum (or the aspect ratio).

Rotate XAxis CW

name: rotateXAxisCW, type: Trigger

If pressed, the movie script is set to perform a rotation around the x-axis clockwise.

Rotate YAxis CW

name: rotateYAxisCW, type: Trigger

If pressed, the movie script is set to perform a rotation around the y-axis clockwise.

Rotate ZAxis CW

name: rotateZAxisCW, type: Trigger

If pressed, the movie script is set to perform a rotation around the z-axis clockwise.

Rotate XAxis CCW

name: rotateXAxisCCW, type: Trigger

If pressed, the movie script is set to perform a rotation around the x-axis counter-clockwise.

Rotate YAxis CCW

name: rotateYAxisCCW, type: Trigger

If pressed, the movie script is set to perform a rotation around the y-axis counter-clockwise.

Rotate ZAxis CCW

name: rotateZAxisCCW, type: Trigger

If pressed, the movie script is set to perform a rotation around the z-axis counter-clockwise.

Axis

name: userDefAxis, type: Vector3, default: 0 1 0

Sets a user defined axis for rotation.

Angle

name: userDefAngle, type: Float, default: 1, minimum: -360, maximum: 360

Sets a user defined angle for a rotation over the whole movie.

Start Frame

name: userDefStartFrame, type: Integer, default: 0

Sets a start keyframe to start the user defined rotation.

End Frame

name: userDefEndFrame, type: Integer, default: 79

Sets an ending frame for the user defined rotation.

Submit Rotation

name: userDefSubmit, type: Trigger

If pressed, the user defined rotation is computed between the set start and ending frame.

Script

name: scriptString, type: String

Sets the user script for controlling the camera and variable interpolation.

Syntax

All expressions must be enclosed in $(<expression>). To comment a statement, simply delete the dollar sign. Only statements with a leading dollar followed by a opening round bracket will be recognized, and the dollar sign does not have to be the first character in a row.

After that a range statement must be provided. This may have three different forms:

  • absolute in frames
  • absolute in seconds
  • relative in percent.

Each range statement consists of a starting frame (time, percent), a minus sign, an ending frame (time, percent) and a range qualifier that can be empty (frames), the letter ‘s’ (seconds, timebased) or a percent sign ‘%’ (percent based range).

Note: when a frame value or a time value exceeds the minimum or the maximum value of available frames or time, it will be automatically clamped: when less then zero it will be set to zero, when greater then the maximum it will be set to the maximum.

Examples of Range Statement Syntax

Absolute in frames: $(0-29 <command>) or $(2-3 <command>)

Absolute in seconds: $(0-29 s <command>) or $(1.3-2.7s <command>)

Relative in percent: $(0-29 % <command>) or $(3.1-4% <command>)

Commands

The commands available at the time alter the camera (rotation) or some variables.

The angle parameter is always between -360 and 360 (so we measure in degree).

Every variable has eight variations (i.e. for integer variables: int0, int1, int2, int3, int4, int5, int6, int7) and each of them can be used in the script language, but we describe here only the first variation (int0 for integers, flt0 for floats, vec0 for vectors and so on).

Command Description
rotateAxis [[x, y, z], angle] Rotates the camera around an axis defined by x, y, z with the specified angle. A full rotation around the Y-axis over the whole movie may be noted as $(0-100% rotateAxis [[0,1,0],360])
rotateXAndBack angle Rotates the camera around the X-axis in the first half of the stated time (or frames..) with the angle and in the other half back.
rotateYAndBack angle Same as above, only rotate around another axis (Y)
rotateZAndBack angle

Same as above, only rotate around another axis (Z)

To conveniently produce a movie which shows a scene from some different angles, try this:

$(0-25% rotateYAndBack 60) $(25-50% rotateYAndBack -60) $(50-75% rotateXAndBack 60) $(75-100% rotateXAndBack -60)

rotateX angle Rotates camera around X-axis with angle degrees.
rotateY angle Same as above, only different axis (Y-axis)
rotateZ angle Same as above, only different axis (Z-axis)
int0 s t

Interpolates the int0 variable (integer) from s to t (which must be integers).

Raising this variable from 10 to 95 in the second half of the movie can be expressed like this:

$(51-100% int0 10 95)

Note that the variable int0 has a value of 10 in the first half of the movie when providing only this statement regarding int0.

flt0 s t Interpolates the flt0 variable(float) from s to t (which may be float values).
vec0 [ xs, ys, zs][xt, y t, zt] Interpolates the vec0 variable (vector) from a start vector value to a target vector.
rot0 [[ xs, ys, zs], as] [[xt, yt, zt], at] Interpolates the rot0 variable (rotation) from a start rotation value to a target value. The rotation is described by an axis (x,y,z) and an angle (a) around this axis.
pla0 [[ xs, ys, zs], ds] [[xt, yt, zt], dt] Interpolates the pla0 variable (plane) from a start plane value to a target value. The plane is described by a normal vector (x,y,z ) and a distance (d) from the origin to the plane in normal direction.

Total

name: numFrames, type: Integer, default: 80

Shows the total number of frames.

Frames / Second

name: numFramesPerSecond, type: Float, default: 8

Sets the number of frames per second.

Seconds

name: numSeconds, type: Float, default: 10

Sets the duration of the movie in seconds.

Current Frame

name: currentFrame, type: Integer, default: 0, minimum: 0, maximum: :field:`numFrames`

Shows and sets the current frame.

Snapshot

name: snapshot, type: Trigger

If pressed, the current state of the camera is saved into the current frame as a keyframe configuration.

Show preview

name: previewOn, type: Bool, default: TRUE

If checked, the camera fields are updated as the user steps through the current frames.

Play (Preview)

name: playMovie, type: Trigger

If pressed, the frames are activated consecutively with their camera/variables settings.

Stop

name: stopMovie, type: Trigger

If pressed, the movie stops and the current frame is set to the first one.

Pause

name: pauseMovie, type: Trigger

If pressed, the running movie is paused at the current frame.

A second pressing of the Pause button resumes the movie.

Record Movie

name: recordMovie, type: Trigger

If pressed, the whole movie is run and the viewer is recording the sequence of images as a movie.

Reset

name: setAllBack, type: Trigger

If pressed, all keyframes and normal frames are set back to their initial empty state.

Loop preview

name: loopPlayback, type: Bool, default: TRUE

If checked, the preview movie is run in a loop.

Status

name: status, type: String, persistent: no

Shows status information.

Hidden Fields

renderCaching

name: renderCaching, type: Enum, default: AUTO

Values:

Title Name
On ON
Off OFF
Auto AUTO

boundingBoxCaching

name: boundingBoxCaching, type: Enum, default: AUTO

Values:

Title Name
On ON
Off OFF
Auto AUTO

renderCulling

name: renderCulling, type: Enum, default: AUTO

Values:

Title Name
On ON
Off OFF
Auto AUTO

pickCulling

name: pickCulling, type: Enum, default: AUTO

Values:

Title Name
On ON
Off OFF
Auto AUTO

camLookat

name: camLookat, type: Vector3, default: 0 0 0

camUp

name: camUp, type: Vector3, default: 0 1 0

inverseRotation

name: inverseRotation, type: Bool, default: FALSE

appendNumFrames

name: appendNumFrames, type: Integer, default: 0

truncateNumFrames

name: truncateNumFrames, type: Integer, default: 0

setupVector

name: setupVector, type: Trigger

startRecord

name: startRecord, type: Trigger

stopRecord

name: stopRecord, type: Trigger

saveRecordedMovie

name: saveRecordedMovie, type: Trigger

startInterpolation

name: startInterpolation, type: Trigger