Escolar Documentos
Profissional Documentos
Cultura Documentos
Overview
Sizzle is a scripting language enabling SynthEyes users to modify the scene files
exported for different 3-D animation packages, create their own exporters for new software
packages, create or modify importers, and create or modify scene tools. It is derived from a loose
amalgam of C++, Javascript, Visual Basic, AWK, etc. User’s familiar with any of these scripting
languages, or scripting languages for 3-D packages such as 3ds max or MEL should recognize
enough to get started. A complete guide to programming can not be provided here. The features
described here are for the SynthEyes 2008 build in the title; features may be available in earlier or
later builds as well.
Warning: if you start changing things in the scene, you can potentially create an
unreadable scene.
If you use the VIM text editor (http://www.vim.org), you can obtain a syntax file that will
color-code the Sizzle scripts as you edit them by e-mailing support@ssontech.com.
A First Example
A simple Sizzle exporter script is listed below. The first line must contain “//SIZZLEX ”,
starting in the first column. After that follows a file extension, and a human-readable name for the
exporter. This information appears on SynthEyes File/Exports menu. SynthEyes picks up its list
of scripts from reading the SynthEyes program folder (and also a user-specific folder), looking
for files with a .szl extension and the proper header.
shot = ob.shot
f0 = shot.start
f1 = shot.stop
for (frame = f0; frame <= f1; frame++)
printf("Frame %d: %.3lf %.3lf %.3lf %.3lf %.3lf %.3lf\n",
frame, ob.x, ob.y, ob.z, ob.rx, ob.ry, ob.rz)
end
The @[ sequence on the second line switches Sizzle into script mode. The Sizzle script is
embedded in the file, the same as Javascript is embedded in an HTML web page.
At the beginning of a file, Sizzle reads the input, copying it to the output. When it
encounters a @[ sequence, that denotes the beginning of some Sizzle script, which continues until
the next ]@. Sizzle interprets everything between the ]@ and the @[ as if it was in “quotes” If
you want the file to include the value of ten plus eleven, you could just write @[10+11]@ and it
would appear as 21 in the output file. Of course, in a real Sizzle script, much more interesting
expressions can be used, accessing shot, object, and tracker information.
This makes a different style possible:
//SIZZLEX .tsx Another test
This stuff just goes right into the file.
There are @[#Trk]@ trackers in the scene,
And @[Shot[1].length]@ frames.
I’d like to emphasize the following remark,
@[for (I = 1; I <= 10; I++)]@by repeating it 10 times…
@[end]@. That should be enough.
This style of scripting can be easier to read, especially when an output file format
requires a lot of “boilerplate”. You can embed the Sizzle script into the file, or vice versa.
Types of Scripts
Sizzle supports three different script types: importers, tools, and exporters. The importers
read an input file, typically to add a new object or tracker path to the scene. An exporter examines
the scene, producing an output file that will later be read by a computer-graphics or compositing
package. Sizzle tools examine the scene and optionally make changes.
Since any script can read or write files, the distinction between types is somewhat
arbitrary, but SynthEyes provides specialized amenities for the varieties, such as sticky export file
names for exporters.
Import scripts appear on the File/Import menu, export scripts on the File/Export menu,
and tools on the Script menu.
The scripts are placed in the scripts folder, usually located in “C:\Program
Files\Andersson Technologies LLC\SynthEyes” or “/Library/Application Support/SynthEyes,” or
in a user-specific folder. You can quickly get to either folder with the two menu items at the top
of the Script menu.
SynthEyes mirrors the folder structure into the menus, so you can create subfolders of
related scripts and have them turn up inside a submenu. This can help reduce clutter and let you
keep straight different versions of scripts, or distinguish standard scripts from your custom ones.
To tell which type of script is which, the header lines are different:
//SIZZLEI .ext Human-readable importer name [An importer for .ext files]
//SIZZLET Human-readable tool name [A tool]
//SIZZLEX .ext Human-readable exporter name [An exporter for .ext files]
SynthEyes will prompt for the file name for importers and exporters. Any script can read
or write additional files if it needs to, by calling the appropriate I/O functions within Sizzle.
After running any script, you can undo its effect if desired.
Note that the assignment operators do not produce output to the file, as in the
concatenation example above. The mini-script @[x=”Hi” “there”]@ writes “there” (without the
quotes) to the output file, assigning “Hi” to the variable x. This is because concatenation is lower
in the precedence table than assignment, so the assignment “=” binds only to “Hi”. If you wanted
x to be “Hi There”, you would write [@x=(“Hi” “There”)]@, which would output nothing.
Though this means you need parentheses for this example, the precedence above eliminates the
need to end each line with a semicolon or end of line.
Object Lists
Cam List of cameras
Curve List of 2-D Curve objects in the scene. New supported.
Extra List of “extra” points. New supported.
Flex List of 3-D Flex objects in the scene. New supported.
Lite List of lights. New supported.
Mesh List of mesh objects (boxes, waving man, imports).
New meshes added here.
Obj List of cameras and moving objects
Output Object containing output-specific attributes
Scene Object containing scene-specific attributes
Shot List of shots
Trk List of all trackers, solved or not. Use new object.trk
Extra Points
.inFront Point is in front of, not behind, the active camera (read
only)
.inFront(cam) Point is in front of, not behind, the specific camera
(read only)
.nm Extra point name
.pu Predicted u position from active camera (read only)
.pv Predicted v position from active camera (read only)
.pu(cam) Predicted u position seen from specific camera (read
only)
.puv(cam) Predicted v position seen from specific camera (read
only)
.pv(cam) Predicted v position seen from specific camera (read
only)
.u Predicted u position from active camera (read only)
.u(cam) Predicted u position seen from specific camera (read
only)
.uv(cam) Predicted v position seen from specific camera (read
only)
.v Predicted v position from active camera (read only)
.v(cam) Predicted v position seen from specific camera (read
only)
.vec Position vector (writeable)
.willDelete 1 if the object will be deleted after the script completes.
Can be changed to control what will happen.
.x,.y,.z Extra point position on the current frame (read only)
Flex
.curve List of curves attached to this flex (read only)
.end 3-D position of the end point constraining the ending
end of the flex.
.endMode If 0, the flex ends perpendicular to the point, if 1, ends
exactly at the point.
Curve
.cp List of Curve Control Points (see below). New
supported.
.flex The flex to which the curve is attached, if any.
.isEnabled Animated control marking whether or not the curve is
valid on any frame.
.isVisible Show the curve in the viewports or hide it.
.nm Curve’s name
.obj The object (camera) to which the curve refers. (read
only)
.Pt(frac) Function returning the 2-D position along the curve at
the given frac (0..1) from start to end.
Curve Control Point
.curve The hosting curve for this control point (read only)
.isKeyed The control point is keyed on the current frame.
.pt The 2-D position of the control point on the current
frame.
Scene
These are read only except as noted.
.activeObj Object that is “active” within the scene.
.build SynthEyes build number, integer such as 1005
.clipboard Operating system’s clipboard, read/write
.exportFile Export file name
.exportType Export file type
.exportUnits Export units: “in”, “ft”, “yd”, “mi”, “mm”, “cm”, “m”,
“km”
.FolderPref(i) Returns the folder preference setting for the given
index: 1:BatchIn, 2:BatchOut, 3:Images, 4:Scene,
5:Imports, 6:Exports, 7:Previews
.info Access to the user’s Description of the scene file on the
File/File Info dialog, read/write.
.OSbits 32 on 32-bit operating systems, 64 on Windows XP-64
or Vista-64. Note that 64-bit operation requires a 64-bit
processor, a 64-bit Operating System, and a 64-bit
license and installation of SynthEyes.
.platform The machine, either “PC”, “MAC”, or “MACTEL”
.scriptFile The file name of the running script
.selected The (single) thing selected in the user interface. Use
typeof to determine what it is: SynMesh, SynObj,
SynTrk, SynLite, SynExtraPt
.Save(filename) Saves the .sni file to this name, intended for setting up
batch operations. Return value is 1 for success, 0
failure.
.SetFolderPref(i, foldername) Set the preference for the given index (see FolderPref)
to the given foldername.
.sourceFile Source .sni file name
.startFrame Starting frame number preference
.version SynthEyes version, something like 2005.1.1002
Output
.binary Set file to binary (value != 0) or text (value==0) Write
only.
.chars Number of characters written. Read only.
Transforms
The transform matrices are 4 rows by 3 columns, so that new vectors are multiplied in
from the left, as in OpenGL. Transforms are offered as attributes of various SynthEyes objects or
may be manipulated directly.
Transform(row1, row2, row3, row4) creates a transform object. Transform(diag_vector)
creates a transform with the specified vector constituting the diagonal. Transform(value) creates a
transform with the value repeated three times along the diagonal (good for zero and identity
transforms). RotX(angle), RotY(angle), and RotZ(angle) create transforms that rotate about the
specified axis by the given angle. Offset(vector) creates a transform with an identity rotation and
the given position offset. Mangle(axisMode) is a transform that mangles transforms from the
internal Zup to the given axis mode. Demangle(axisMode) is the inverse of Mangle.
A variety of different attributes may be accessed from a transform:
.x, .y, and .z are the positions.
.rx, .ry, and .rz are three rotation angles. The rotations are read-only. The rotation angles
are controlled by a rotation angle ordering value, the global rotOrder value, and a global
axisMode value. These are initialized to the SynthEyes Maya axis ordering and scene’s
coordinate axis mode settings: Z Up(0), Y Up(1), and Y Up Left(2).
.rowA, .ax, .ay, .az are the first row, and the three components of it.
.rowB, .bx, .by .bz are the second row, and the three components of it.
.rowC, .cx, .cy, .cz are the third row, and the three components of it.
.rowP, .px, .py, .pz are the fourth (position) row, and the three components of it (same as
.x, .y, and .z).
.angXYZ is a vector of the rotation angles, interpreted in the XYZ order, read-only.
.angZXY is the vector of rotation angles in ZXY order, read-only.
.angZYX is the vector of rotation angles in XYX order, read-only.
.inv is the inverse transform. (read-only)
.rot is a transform consisting only of the rotation portion. (read-only)
.trans returns an object that is the entire transform, when it is offered as an attribute. You
can pass it to a function, say, and then extract any of the attributes from it at that time.
If an object offers multiple transforms, each transform’s attribute names will have an
additional prefix, such as .wx or .wrz.
Operators: you can multiply transforms together, for example, posnew = oldpos *
wldtoobj * objtoref.
Vectors
A vector offers .x, .y, and .z attributes, or an offered vector can be taken whole with .vec.
Vectors can be created outright with Vector(x,y,z).
.length is the length of the vector (square root of the sum of x, y, and z, each squared).
(read-only).
.norm is the vector with the length normalized to one. (read-only)
.Dot(vector2) returns the dot product of this vector with vector2.
.Cross(vector2) returns the cross product of this vector with vector2.
When an object offers multiple vectors, each vector’s attribute names have a different
prefix, resulting in .wx, .wy, .wz or .ox, .oy, or .oz, for example.
Operators: +, -, *(scalar), *(transform), /(scalar)
Points
A vector offers .u, and .v attributes, or an offered vector can be taken whole with .pnt.
Points can be created outright with Point(u,v).
.length is the length of the vector (square root of the sum of u and v, each squared). (read-
only).
.norm is the vector with the length normalized to one. (read-only)
.Dot(vector2) returns the dot product of this vector with vector2.
When an object offers multiple vectors, each point’s attribute names have a different
prefix, resulting in .wu, .wv or .pu or .pv, for example.
Operators: +, -, *(scalar), /(scalar).
Generic Lists
You can create generic indexed lists of objects
Mylist = [1, 2, “buckle my shoe”]
and subsequently change or retrieve the components with Mylist[2], for example. You can tack
on additional items to the last slot, with Mylist[4] = 3, Mylist[5]=4, etc. It is an error to perform
Mylist[10] = “why?” because that would leave a hole.
You can create a new empty list to add items to
MyNewEmptyList = [ ]
You can also create associative lists with
Color[“apple”] = “red”
Color[“pear”] = “green”
You can access Color[2] as well, at this point.
#Color is the number of elements, 2 in this example
Color.keys is the list [“apple”, “pear”]. Note that there may be fewer keys than elements
in the list, if some elements have been added without keys, using numeric subscripts.
Color.index(“pear”) = 2, ie the index of a key in the list, or 0 if it cannot be found.
Function Calls
Sizzle has subroutine calls with parameters. Parameters are passed by value, meaning that
from within a subroutine, you can’t change any of the arguments of the caller. The order of
functions and calls within the file does not matter.
Simon(“right”)
function Simon(val)
“Simon says jump “ val “\n”
end
Simon(“up”)
Include Files
You can include libraries of code within SynthEyes scripts using the INCLUDE
operation, with the following syntax:
INCLUDE(“filename”)
There should be no whitespace between any of these elements. The INCLUDE does not
have to fall in column 1. Although it looks like a function call, it must be executed directly during
syntax parsing (like a C++ preprocessor), so the filename can not be an expression.
The filename can be absolute or relative. Absolute files names start with either kind of
slash, or with a drive specification such as C:. Relative file names can be plain filenames such as
mylib.szl, or may contain a relative path specification such as ../shared/mylib.szl or
./includes/mylib.szl. Any file extension can be used, though .szl is probably a good idea.
The included file does not have to include a standard Sizzle header such as //SIZZLET,
though it may. Any header line will be ignored, because it looks like a comment. Note that you
should not include //SIZZLEX export scripts, because they default as inline content, and will be
misinterpreted.
Includes can be nested as desired. There is an arbitrary maximum depth of 20 levels, to
catch runaway recursive includes.
Builtin Functions
printf(format, arguments….) Formatted Unix-style print to output or string. Supports
%c, %d, %x, %f, %g, %e, %s formats.
substr(string, start [, count]) If start is negative, measure from the end
index(look_in_here, for_this) Find first 2nd string in 1st, return zero if not found
rindex(look_in_here, for_this) Find last 2nd string in 1st, return zero if not found
length(string)
translate(string, from_chars, to_chars) Translate string, replacing each character in
from_chars to the corresponding character of to_chars
openout(filename) Start outputting to this file instead. WARNING: you
can clobber any file on your computer!
closeout() Close redirection, output to previous file instead
getline() Read a line from the current input file, returning a new-
line terminated string or an empty string on end-of-file.
scanf(format, arguments…) Read data from current input file. The arguments
should be variables or attributes that you might find on
the left hand side of an assignment (no & required).
Supports %s, %c, %d, %x, %f, %lf, %g, %lg, %[..] and
the ‘*’ assignment suppression. Returns the number of
variables assigned to.
sscanf(string, format, arguments…) Read data from a string, see scanf for details.
openinp(filename) Start reading this file (save read point in current file).
Returns 1/0 if OK/not.
closeinp() Stop reading current file, resume reading earlier file
DateTime(fmt) The current time and date in a user-selected format, see
the strftime function on the Microsoft site:
http://msdn.microsoft.com/library/default.asp?url=/libr
ary/en-
us/vccore98/HTML/_crt_strftime.2c_.wcsftime.asp For
example, "%a, %b %d, %Y %I:%M:%S %p" produces
“Tue, Feb 25, 2003 10:19:22 PM”
Message(msg) Pops up an informational dialog box
YesNoCancel(question) Asks the question, click buttons for “yes”, “no”or
“cancel”, which is returned from the function.
abs(x) or fabs(x) absolute value
sqrt(x) square root
sin(x) sine function
cos(x) cosine function
tan(x) tangent function
atan(x) arc-tangent function
atan(y, x) arc-tangent of y/x
log(x) logarithm function
exp(x) exponent function
pow(x,y) x to the y’th power
floor(x) largest integer less than x
ceil(x) smallest integer greater than x
round(x) nearest integer
typeof(x) A string giving x’s type: Double, String, etc
isNull(x) Returns 1 if x is a null (non-existant) object, 0 if it an
actual object
system(cmd [,dir]) Run the command cmd in a “DOS” command shell
using “cmd.exe /c”. If present, start in the directory dir,
which must include a drive name and full path if
present. Use double-backslashes as appropriate:
“C:\\temp”. WARNING: erroneous system
commands can damage or destroy any file in your
computer!
User Interfaces
You can use the Dialog object to display a user interface for your exporter, importer, or
tool. The user interface can consist of the usual checkboxes, buttons, data entry fields, etc. After
creating a dialog, you populate it with fields, show it, then access the data entered as attributes of
the dialog object. If the user cancels the displayed dialog, then entire script will be cancelled.
So that the user doesn’t have to keep on re-entering the same settings, each dialog’s final
entries are stored away and then restored when that dialog box is shown again. If the operation is
Export Again, the dialog box is not shown; the saved data is used instead. The script can cause
this data to be reset, potentially when the user hits a button, or always cause the dialog box to be
shown.
Most of the data-field-creating member function calls require an attribute name, which
can be used to access the value of the field after the dialog is shown, and a prompt string, which is
displayed in the user interface to explain what must be entered in the field. The attribute name
must be a valid SynthEyes identifier name, with no embedded spaces or special characters.
dlg = NewDialog(“uniqid”) Create a new dialog object. The uniqid must be unique
across ALL DIALOGS of ALL SCRIPTS on the user’s
system: it is used to identify the identify the settings of
this dialog for when it is re-opened later. It should be a
simple alphanumeric string related to the script name.
dlg.OpenFile(“attr”, “prompt”, “extn”) Create a data-entry field for a file name, presumably to
be read by the script (the file must exist). There will be
a browse button as well as a text field. The extn is the
default file-name extension to use. Note that it is up to
the script to actually read the file.
dlg.SaveFile(“attr”, “prompt”, “extn”) Create a data-entry field for a file name, presumably to
be written (the user must approve the over-write if the
file already exists).
dlg.Path(“attr”, “prompt”) Create a data-entry field for a path name.
dlg.String(“attr”, “prompt”, “defstr”) Create a text input field. The defstr value is its default
value when the dialog is first displayed, or after a reset
operation.
dlg.Info(“attr”, “prompt”, “info”) Create an unchangeable text input field. This can be
used to provide additional explanatory text to the user,
perhaps to show other information such as the number
of frames or image resolution.
dlg.Int(“attr”, “prompt”, minv, defv, maxv) Create an integer input field. The input will have
an initial value of defv, and must fall within the range
of minv to maxv.
dlg.Float(“attr”, “prompt”, minv, defv, maxv) Create a floating-point input field. The input will
have an initial value of defv, and must fall within the
range of minv to maxv.
dlg.Check(“attr”, “prompt”, defv) Create a checkbox. The defv controls its initial state,
and must be 0 or 1.
dlg.StartRadio(“overall_name”, “overall_prompt”) Start a group of radio buttons. The
overall_name attribute will be set to the name of the
attribute that is selected.
dlg.Radio(“attr”, “prompt”, defv) Create a radio button. Only one radio button must have
defv of 1, the rest should have defv of 0.
dlg.Button(“funcname”, “prompt”, “btn”) Create a push button. The button will be labeled
btn, and have a description of prompt. The funcname
will be called when the button is pushed.
dlg.Show() Display the assembled dialog and wait for user action.
If this is an Export Again, the dialog will not be
shown, but will have the saved settings. (See the
Always function.)
dlg.Reset() The dialog values are reset to the default values set by
the script, overriding previously-stored values. Can be
called during a pushbutton function evaluation.
dlg.Always() Causes the dialog to be shown even during Export
Again operations, when called before Show.
Here’s an example of a small settings panel.
dlg = NewDialog(“MyFavorite”)
dlg.String(“f1st”, “Start Frame”, 0, 0, shot.length)
dlg.Check(“abs”, “Use Absolute Coordinates”, 0)
dlg.StartRadio(“which”, “Trackers to Output”)
dlg.Radio(“all”, “All”, 1)
dlg.Radio(“sel”, “Only selected”, 0)
dlg.Button(“reset_dlg”, “Reset to defaults”, “Reset”)
dlg.Show()
only_sel = dlg.sel
bias = dlg.f1st
function reset_dlg()
dlg.Reset()
end
You can use several dialogs (and dialog objects) simultaneously within a single script, if
necessary.
Builtin Variables
frame // current frame number
rotOrder // rotation order, 1=xyz, 0=zxy
axisMode // Zup=0, Yup=1, Yupleft=2
Pi // 3.14159…
Sizzle Grammar Reference
prog → stmtlist
stmtlist → stmtlist stmt
stmtlist → stmt
stmt → for ( [expr] ; [expr] ; [expr] ) stmtlist end (expressions are optional)
stmt → while ( expr ) stmtlist end
stmt → for ( lhs in expr ) stmtlist end (each object in an object list)
stmt → break
stmt → continue
stmt → return
stmt → return expr
stmt → function ident ( idlist ) stmtlist end (function definition)
stmt → function ident ( ) stmtlist end
idlist → idlist , ident
idlist → ident
stmt → if ( expr ) stmtlist end
stmt → if ( expr ) stmtlist else stmtlist end
stmt → if ( expr ) stmtlist elseifs else stmtlist end
stmt → if ( expr ) stmtlist elseifs end
elseifs → elseifs elseif
elseifs → elseif
elseif → elsif ( expr ) stmtlist
elseif → elseif ( expr ) stmtlist
stmt → assop
stmt → boolor // Generating output...
stmt → ;
stmt → delete lhs
expr → expr assop
expr → expr boolor
expr → assop
expr → boolor
assop → lhs = boolor
assop → lhs += boolor
assop → lhs -= boolor
assop → lhs *= boolor
assop → lhs /= boolor
assop → lhs &= boolor
assop → lhs |= boolor
assop → lhs ^= boolor
boolor → boolor || booland
boolor → booland
booland → booland && boolnot
booland → boolnot
boolnot → ! relop
boolnot → relop
relop → addop < addop
relop → addop > addop
relop → addop == addop
relop → addop <= addop
relop → addop >= addop
relop → addop != addop
relop → addop
addop → addop + mulop (addition)
addop → addop - mulop (subtraction)
addop → addop | mulop (bitwise or)
addop → mulop
mulop → mulop * negop (multiplication)
mulop → mulop / negop (division)
mulop → mulop % negop (modulo)
mulop → mulop & negop (bitwise and)
mulop → mulop ^ negop (bitwise exclusive or)
mulop → mulop << negop (left binary shift)
mulop → mulop >> negop (right binary shift)
mulop → negop
negop → ~ powop (bitwise complement)
negop → - powop (negative)
negop → + powop (nothing, except strings converted to numbers)
negop → powop
powop → powop ** term (powerop to the auto power)
powop → term
auto → ++ lhs
auto → -- lhs
auto → lhs ++
auto → lhs --
term → ident ( arglist ) (function call)
term → ident ( ) (function call)
term → ( boolor ? expr : expr ) (select the 1st or 2nd expression, based on boolean)
term → string
term → number
term → lhs
lhs → ident (ident is an identifier, an alphanumeric starting with alpha)
lhs → lhs [ expr ] (select I’th element from an object list)
lhs → lhs . ident (select an attribute from an object)
lhs → lhs . $ ident
term → lhs . ident ( arglist ) (member function call)
term → lhs . ident ( ) (member function call)
term → ( expr )
term → [ arglist ] (create a list object from the expressions)
term → [ ] (create an empty list)
term → # term (number of objects in a list)
term → $ term (the object with the name given by term)
arglist → arglist , expr
arglist → expr