Actor Definition Scripts
All geometric actors are created in the first place using Mathscript scripts. Such scripts may be typed directly in the actor definition window when defining a named actor, may be attached to a Mathscript gadget (pushbutton, slider, checkbox, textfield, etc.), or may be created as part of a stand-alone program in a TextBox or Mathscript Script Window.
See Actor Script for more details. At any time, you may change the definition of a named actor. For now we mention that these programs are saved (as text) as .msp files, or are compiled and saved (as executables) in .lsp files. All such files define Mathscript objects (functions, programs, vectors, matrices, etc.) which may in turn create geometry and control animations of various sorts. The graphics files themselves (the actors) are saved as .sce files that are associated with graph3D objects.
Mathscript presently contains 57 OpenGL functions, all 47 OpenGL constants, and 10 animation commands . The functions themselves are not case-sensitive, but the constants (such as GL_LINES) must be capitalized, and, except for the fact that they are missing the ubiquitous "gl" or "aux" the functions have precisely the same number of arguments, with the same interpretation, as in the C version of OpenGL. There are two important exceptions:
Quaternion() and vertex()
Vertex() may take a 3-vector as its single argument, or it may take a triple of numbers as arguments. The arguments may contain variables which can be supplied at run time. Similarly for Quaternion() which of course takes a 4-vector. For example, one might define 3 points: P, Q and R as vectors and execute something like the following.
glDraw {
Begin(GL_TRIANGLES);
Vertex(P);
Vertex(Q);
Vertex(R);
Vertex(P+R);
Vertex(Q+R);
Vertex(2*R);
End();
}
To understand what these functions do, you might like to look at an OpenGL reference such as the OpenGL Programming Guide.
OpenGL Programming Guide, Second Edition
The OpenGL Architecture Review Board
Mason Woo, Jackie Neider, Tom Davis
Addison-Wesley Developers Press, 1997
A special actor is created for you, called: Setup. Setup creates a Coordinate Frame that may be useful for orienting yourself. Setup may be edited; for example, you may remove or replace this reference system. We describe the script for the setup actor to give an idea how to use these functions.
We give an example below to illustrate an actor script. You may examine the scripts of any actors in our projects for other examples. Once you choose an actor to edit, you may view or edit its script by selecting: Actors, Edit an Actor.
Notice that the glDraw{} protocol should not be used in an actor script. It is called automatically there.
Setup Actor (slightly rotated)

Script for the default Setup Actor:
disable(GL_LIGHTING);
'Eliminate reflection'
linewidth(2);
'set the line width to
2'
Begin(GL_LINES);
'begin
to draw lines connecting pairs of vertices'
glcolor(255,0,0,255);
'set color to red'
vertex3(-10,0,0);
'start
x axis'
vertex3(10,0,0);
'end
x axis'
glcolor(255,255,255,255);
'set color to white'
vertex3(0,-10,0);
'start
y axis'
vertex3(0,10,0);
'end
y axis'
glcolor(0,0,255,255);
'set color to blue'
vertex3(0,0,-10);
'start
z axis'
vertex3(0,0,10);
'end
z axis'
End();
'end line sequence
Begin(GL_TRIANGLES);
'begin
to draw triangles connecting triples of vertices'
glcolor(255,0,0,255);
'set
color to red for tip of red arrow (x axis)'
vertex3(9,-1,-1);
'first
vertex of red arrow tip'
vertex3(10,0,0);
'second
vertex of red arrow tip'
vertex3(9,1,1);
'third
vertex of red arrow tip'
glcolor(255,255,255,255);
'set
color to white for tip of y axis'
vertex3(-1,9,-1);
'first
vertex of white arrow tip'
vertex3(0,10,0);
'second
vertex of white arrow tip'
vertex3(1,9,1);
'third
vertex of white arrow tip'
glcolor(0,0,255,255);
'set
color to blue for tip of z axis'
vertex3(-1,-1,9);
'first
vertex of blue arrow tip'
vertex3(0,0,10);
'second
vertex of blue arrow tip'
vertex3(1,1,9);
'third
vertex of blue arrow tip'
End();
'finish triangle
sequence'
enable(GL_LIGHTING);
'Restore
reflection'
If you are familiar with OpenGL, you know that, except for the "gl" that starts each command, and except for case, this is a typical drawing script. MathScript does not care about case except for the constants such as GL_LINES and within strings ("This is a string").
If the idea is to work in 2-dimensions while in 3D mode, then authors may arrange for that simply by placing in the Setup Actor Script the following:
matrixmode(GL_PROJECTION);
loadidentity();
ortho(-10,10,-10,10,20,
-1000);
matrixmode(GL_MODELVIEW);
loadidentity();
To work in 2-dimensions in 3D mode, then change ViewPort Setting to 2D by selecting: Scene, Toggle Perspective View.