Surface Variables  (Animation Script)

Surface variables refer to named surfaces from the scene
Global in scope


Operators
( . ) Invoke function


Declaration
Named and listed in Animation dialog

VERTEX Value
When used as VERTEX parameter Surface normal vector


Surface Functions

Parameter Modifiers
( - ) Use negative of normal vector value for function parameter

Notations

VERTEX - Declared VERTEX variable / object centter from named Object variable / surface normal from named Surface variable
SURFACE - Named Surface Variable
float - Scalar floating point constant or VERTEX variable component (.x/.y/.z)
MATRIX2X2 - Declared MATRIX2X2 variable

Functions Description and parameter type variations
DistToPlane Calculate distance from VERTEX to plane
Returns > 0 if VERTEX is in front of plane
Returns < 0 if VERTEX is in back of plane
Returns 0 if VERTEX is on plane

float DistToPlane(VERTEX V)

ParallelDist Distance between parallel SURFACE planes
Returns > 0 if SURFACE parameter is in front of SURFACE variable
Returns < 0 if SURFACE parameter is in back of SURFACE variable
Returns 0 if both Surfaces are coplanar

float ParallelDist(SURFACE S)
Assumes SURFACE S parameter normal vector is either 0° or 180° to SURFACE variable's normal vector
 
AlignToAxis

Aligns Surface to specified axis (normal vector)

AlignToAxis(VERTEX N)
SetUVMatrix Set texture transform matrix for Surface with pattern map or refraction map set, has no effect otherwise.
Pattern/refraction maps contains signed UV used to translate texture coordinates
Matrix used to rotate and scale texture coordinates  
Transform applies to all surfaces using matrix index set from Surface Effects dialog

SetUVMatrix(MATRIX2X2 M)

Sample UV from pattern/refraction map
U' = U * M00 + V * M10
V' = U * M01 + V * M11
































Examples


Named Objects in example, Cylinder, Rectangle
Named Surface in example, RectTop


VERTEX v
MATRIX2X2 M

//Get distance from Cylinder center vertex to RectTop surface
v.x = RectTop.DistToPlane(Cylinder)

//Use distance to plane to translate
Cylinder.TranslateV(RectTop, v.x)

v.Set(1, 0, 0)
//Align RectTop surface to X Axis
RectTop.AlignToAxis(v)

M.SetScalar(2.3, 1.5)
//Set pattern/refraction map UV transform
RectTop.SetUVMatrix(M)