Get Morphyre Free


This is a page from the Morphyre Pro Online Manual. You can return to the Contents Page, or go to the Morphyre Pro Homepage.

 

interface.h
const
float
PI;
The constant of PI - 3.14159265
const
int
true;
const
int
false;
const
int
OFFSCREEN_RES;
const
int
VB_V3;
Vertex Buffer types, these go with the structures below
const
int
VB_T2_V3;
Vertex Buffer types, these go with the structures below
const
int
VB_N3_V3;
Vertex Buffer types, these go with the structures below
const
int
VB_T2_N3_V3;
Vertex Buffer types, these go with the structures below
const
int
VB_T2_C4_N3_V3;
Vertex Buffer types, these go with the structures below
const
int
VB_T3_T3_T3_N3_V3;
Vertex Buffer types, these go with the structures below
const
int
VB_POINTS;
Rendering styles for vertex buffers - as OpenGL
const
int
VB_LINES;
Rendering styles for vertex buffers - as OpenGL
const
int
VB_LINE_STRIP;
Rendering styles for vertex buffers - as OpenGL
const
int
VB_TRIS;
Rendering styles for vertex buffers - as OpenGL
const
int
VB_QUADS;
Rendering styles for vertex buffers - as OpenGL
const
int
MAT_MODEL;
Matrix mode for getMatrix/setMatrix
const
int
MAT_PROJECT;
Matrix mode for getMatrix/setMatrix
const
int
MAT_TEXTURE;
Matrix mode for getMatrix/setMatrix
class
Colour4
{
float
r;
float
g;
float
b;
float
a;
}
class
Vector3
{
float
x;
float
y;
float
z;
}
class
Vector2
{
float
x;
float
y;
}
class
T2V3
{
tex;
pos;
}
class
N3V3
{
normal;
pos;
}
class
T2N3V3
{
tex;
normal;
pos;
}
class
T2C4N3V3
{
tex;
col;
normal;
pos;
}
3 Texture coordinates. Used mainly for Bump/Parallax mapping
tex;
tex1;
tex2;
normal;
pos;
}
void
assert(
int
isOk);
void
print(
*int
string,
float
val);
Prints out the given string and float value to the console
void
printv(
*int
string, val);
Prints out the given string and vector value to the console
int
xmlInt(
*int
path,
int
defaultValue);
Get an integer point value from the current scene's Data area in XML
float
xmlFloat(
*int
path,
float
defaultValue);
Get a floating point value from the current scene's Data area in XML
void
xmlString(
*int
dst,
int
dst_size,
*int
path,
*int
defaultValue);
Get a string value from the current scene's Data area in XML.
Dst is a pointer to an array that will get the string, dst_size is the
number of elements in it, so it won't be overrun.
int
xmlExists(
*int
path);
Returns true if the given key exists
int
jsInt(
*int
jScript);
Evaluate the given bit of javascript and return the result as an integer
float
jsFloat(
*int
jScript);
Evaluate the given bit of javascript and return the result as a float
void
jsString(
*int
dst,
int
dst_size,
*int
jScript);
Evaluate the given bit of javascript and return the result as a string
Dst is a pointer to an array that will get the string, dst_size is the
number of elements in it, so it won't be overrun.
void
jsExec(
*int
jScript);
Execute the given bit of javascript - doesn't return anything...
float
sin(
float
x);
sine wave. in radians so a full range is 0 -> 2*PI
float
cos(
float
x);
cosine wave. in radians so a full range is 0 -> 2*PI
float
tan(
float
x);
tangent. in radians so a full range is 0 -> 2*PI
float
atan(
float
x);
arc tangent. in radians so a full range is 0 -> 2*PI
float
atan2(
float
y,
float
x);
360 degree arc tangent using x and y. in radians so a full range is 0 -> 2*PI
float
pow(
float
x,
float
y);
x to the power y
float
rand();
random range 0..1
int
randint(
int
min,
int
max);
random integer between the two values INCLUSIVE
*void
malloc(
int
intSize);
allocate memory. intsize is the size in basic allocation units (ints)
void
free(
*void
ptr);
free memory got with malloc
int
fileSize(
*int
fileName);
return the size (in allocation units) of the given file. Paths are relative to the data directory
Paths are relative to the 'data' directory, but can use various accessors too. See the data at the head of this file
void
fileRead(
*int
fileName,
*void
data,
int
start,
int
count);
Read up to dataSize from the given file
Paths are relative to the 'data' directory, but can use various accessors too. See the data at the head of this file.
start and count are in basic allocation units (32 bit ints), NOT BYTES. Don't specify a count that is too great for
the array that you have given or R5 will crash.

start = where in the FILE to load from. Data is always copied starting at data[0]
result = a + b
result = a - b
vMul( a,
float
amt);
result = a * amt
result = a x b
float
vDot3( a, b);
a.b
float
vMag( vec);
magnitude = sqrt(a.a)
float
vDist( a, b);
Distance between a and b
vTransform( a,
*float[16]
mat);
vTransformNormal( a,
*float[16]
mat);
float
fInterp(
float
a,
float
b,
float
amt);
interplolate between a and b
float
fInterp(
float
a,
float
b,
float
c,
float
d,
float
amt);
hermite interplolate between b and c
vInterp( a, b,
float
amt);
interplolate between a and b
vInterp( a, b, c, d,
float
amt);
hermite interplolate between b and c
vInterp( a, b,
float
amt);
interplolate between a and b
vInterp( a, b, c, d,
float
amt);
hermite interplolate between b and c
void
matMul(
*float[16]
result,
*float[16]
a,
*float[16]
b);
result = a x b
void
matTranslate(
*float[16]
result,
*float[16]
a,
float
x,
float
y,
float
z);
void
matTranslatev(
*float[16]
result,
*float[16]
a, v);
void
matScale(
*float[16]
result,
*float[16]
a,
float
x,
float
y,
float
z);
void
matRotate(
*float[16]
result,
*float[16]
a,
float
angle,
float
x,
float
y,
float
z);
angle in radians
void
matIdentity(
*float[16]
result);
void
matLookAt(
*float[16]
result,
*float[16]
a, eye, obj, up);
void
matBillboard(
*float[16]
result,
*float[16]
a,
float
scale);
create a billboarding matrix + scale it by the given amount
int
texLoad(
*int
filename);
Load a texture from the given filename
Paths are relative to the 'tex' directory, but can use various accessors too. See the data at the head of this file
int
texFromArray(
int
width,
int
height,
*int
data);
Load a texture from an area of memory
It is read as an RGBA bitmap, with all 4 channels packed into an int as 0xAABBGGRR - so you will need width*height ints
int
texFromFloatArray(
int
width,
int
height,
*float
data);
Load a texture from an area of memory
It is read as an RGBA bitmap, with all 4 channels as separate floats - so you will need width*height*4 floats
int
texFromFloatArray(
int
width,
int
height,
int
depth,
*float
data);
Load a 3D texture from an area of memory
void
texBind(
int
unit,
int
id);
Bind a texture to the given unit. unit 0 is the default, and id 0 disables texturing
void
texUnBind(
int
unit);
Disables texturing for a certain texture unit
void
texDestroy(
int
id);
destroy the given texture
void
texRenderBegin(
int
width,
int
height);
begin rendering a texture of the given width and height - call texRenderEnd to get the texture number
void
texRenderBegin(
int
width,
int
height,
int
floatingPoint);
begin rendering a texture of the given width and height (and ask whether it should be floating point or not) - call texRenderEnd to get the texture number
Stop rendering to a texture, and return the texture's ID
texRenderFinished must then be called when it is not required any more
void
texRenderFinished(
int
texId);
signals that we're finished with this renderable texture
int
vbCreate(
int
format,
int
size);
Create a vertex buffer of the given VB_ format, and with size elements
An element is a structure like T2V3, so you only need size 3 for a triangle, whatever element type
void
vbDestroy(
int
vb);
free the memory used by a vertex buffer
*float
vbLock(
int
vb);
Lock a vertex buffer and return a pointer to the data in it
You must unlock before locking again or rendering
void
vbUnLock(
int
vb);
Unlock a vertex buffer so it can be rendered
void
vbRender(
int
vb,
int
type,
int
offset,
int
pts);
Render a vertex buffer
Vertex buffer ID vb, with a type (VB_ constant), starting at offset, and
rendering 'pts' items
void
getMatrix(
int
type,
*float[16]
mat);
Get the 4x4 matrix, use this with one of the MAT_ constants
void
setMatrix(
int
type,
*float[16]
mat);
Set the 4x4 matrix, use this with one of the MAT_ constants
int
shaderLoad(
*int
vtx_filename,
*int
frag_filename);
Load the given GLSL vertex and fragment shader
Returns an ID that should be used in later calls
void
shaderBind(
int
id);
Bind the given shader ID to the GPU
You can only have one vertex shader and one fragment shader active at a time,
specifying another will just overwrite the one before
void
shaderUniform1(
*int
name,
float
x);
Set GLSL Shader uniform parameters
These must be in the vertex of fragment shader, specified like:
"uniform vec2 blur_dir;"
See the GLSL specs on uniforms, glGetUniformLocation, glUniform1f etc.
void
shaderUniform2(
*int
name,
float
x,
float
y);
void
shaderUniform3(
*int
name,
float
x,
float
y,
float
z);
void
shaderUniform4(
*int
name,
float
x,
float
y,
float
z,
float
w);
void
shaderDestroy(
int
id);
Free the vertex/fragment shader
void
sumViewport(
*float
rgb);
Takes a pointer to 3 (red, green and blue) floats, and sums every pixel
in the viewport, returning the number divided by the number of pixels...
so it should be in the range 0..1. BEWARE: this can be slow!
void
sumViewport(
*float
rgb,
int
width,
int
height);
Takes a pointer to an array of x*y*3 (red, green and blue * boxes) floats,
and sums every pixel in each box in the viewport, returning the number divided
by the number of pixels... There are width*height boxes used, equally spaced.
so it should be in the range 0..1. BEWARE: this can be slow!
const
int
SOUND_BUFFER_SIZE;
the size of the sound buffers returned by VIS_SOUND_WAVE and VIS_SOUND_SPECTRUM
const
int
WAVE_HISTORY_SIZE;
the size of the wave history buffer returned by VIS_SOUND_WAVE_HISTORY
const
int
VIS_TIME_SCENE;
float - time scene has been on in secs
const
int
VIS_TIME_DIFF;
float - time between renders of the scene
const
int
VIS_ASPECT;
float - aspect ratio of the screen...
const
int
VIS_SOUND_ENERGY;
float - std. dev. of the last SOUND_BUFFER_SIZE sound samples
const
int
VIS_SOUND_BASS;
float - instantaneous normalized bass value
const
int
VIS_SOUND_MID;
float - instantaneous normalized mid value
const
int
VIS_SOUND_TREBLE;
float - instantaneous normalized treble value
const
int
VIS_SOUND_BEAT;
float - instantaneous beat detection algorithm output
const
int
VIS_SOUND_WAVE;
float[SOUND_BUFFER_SIZE] - copy a list of floats representing the current waveform
const
int
VIS_SOUND_SPECTRUM;
float[SOUND_BUFFER_SIZE] - copy a list of floats representing the current spectrum
const
int
VIS_SOUND_WAVE_HISTORY;
float[WAVE_HISTORY_SIZE] - copy a list of floats representing the waveform *and* back in history quite a bit
const
int
VIS_SOUND_BEATAVR;
float - average of beat detection algorithm output
const
int
VIS_SOUND_SYNC;
float - runs generally from 0->1 but may overflow, distance through the bar...
const
int
VIS_SOUND_SYNCSMOOTH;
float - always runs from 0->1, smoothly moving beat sync, normally rising
const
int
VIS_SOUND_DEBUG1;
float - debug value from sound analyser - DON'T USE IN SCENES
const
int
VIS_SOUND_DEBUG2;
float - debug value from sound analyser - DON'T USE IN SCENES
const
int
VIS_FINISHED;
int - (bool) flag that is set to 1 if this scene wants to end
const
int
VIS_TWEAK_0;
float - tweak value - all the way up to 64, one after the other
const
int
VIS_TWEAK_1;
float - tweak value - all the way up to 64, one after the other
const
int
VIS_TWEAK_2;
float - tweak value - all the way up to 64, one after the other
const
int
VIS_TWEAK_3;
float - tweak value - all the way up to 64, one after the other
const
int
VIS_TWEAK_X;
xyz movement
const
int
VIS_TWEAK_Y;
xyz movement
const
int
VIS_TWEAK_Z;
xyz movement
const
int
VIS_TWEAK_XYZ_AMT;
amount to override XYZ
const
int
VIS_TWEAK_R;
red
const
int
VIS_TWEAK_G;
green
const
int
VIS_TWEAK_B;
blue
const
int
VIS_TWEAK_RGB_AMT;
amount to override RGB
const
int
VIS_TWEAK_STEREO_SEP;
stereo separation
const
int
VIS_TWEAK_CAMSHIFTX;
for stereo - used when rendering to shift the camera
const
int
VIS_TWEAK_SIZE;
change size. size = size * 2^VIS_TWEAK_SIZE
const
int
VIS_TWEAK_FOV;
change field of view. FOV *= 2^tweak
const
int
VIS_TWEAK_HUE;
for the hue overlay...
const
int
VIS_TWEAK_SPEED_OVERRIDE;
override sound-based movement speed with static speed
const
int
VIS_TWEAK_BRIGHTNESS;
for the hue overlay...
const
int
VIS_TWEAK_SATURATION;
for the hue overlay...
float
visGetFloat(
int
id);
Get a floating point value, use it with the VIS_ constants defined above
void
visGetFloatv(
int
id,
*float
floatPtr);
Get an array of floating point values, use it with the VIS_ constants defined above
The array given MUST be big enough
void
visSetFloat(
int
id,
float
value);
Set a floating point value, use it with the VIS_ constants defined above.
Currently only VIS_TWEAK* are writable
int
visGetInt(
int
id);
Get a floating point value, use it with the VIS_ constants defined above
void
visSetInt(
int
id,
int
val);
Set a floating point value, use it with the VIS_ constants defined above
void
visRenderChildToScreen(
int
childNumber,
float
timePass);
The 3 functions below are for handling rendering the scene tree.
When visRenderChildToScreen or visRenderChildToTexture is called,
execution of the current scene will stop at the current point, the
new scene will be drawn, and execution will restart from the end of
the function.

The timePass must either be 0 (not to step the scene on at all),
or another value. Usually it should be the result of visGetFloat(VIS_TIME_DIFF)
but you might use something else to do motion blur, etc.

Note that after these functions, GL state will be reverted to the
same as if you just entered the render function - so don't rely
on anything being left set up.

Render the scene directly to the screen
void
visRenderChildToTexture(
int
childNumber,
float
timePass,
int
textureX,
int
textureY);
Render the scene to a texture. the renderable texture number can
be returned with visGetRenderedTexture, and MUST be freed with texRenderFinished.
Texture size of -1,-1 uses normal screen size, -2,-2 is half size. Anything else
is what is given.
Return the texture that we rendered to with visRenderChildToTexture
float
soundSync(
float
val);
Sync a value with the vis's idea of the rhythm of the music
This assumes the value is between 0 and 1 usually, and will
cause the vis to move onwards if it is >1
float
_soundSyncInc_last;
internal var for soundSyncInc
float
soundSyncInc(
float
val);
Increment a value with the vis's idea of the rhythm of the music
This doesn't try and get the actual value correct (like soundSync does)
- instead it just increments.
const
int
GL_DEPTH_TEST;
use with glSetInt/glGetInt, bool - whether to use depth buffer info
const
int
GL_DEPTH_MASK;
use with glSetInt/glGetInt, bool - whether write to depth buffer
const
int
GL_CULL_FACE;
use with glSetInt/glGetInt, see GL_CULL_xxx consts
const
int
GL_BLEND_SRC;
use with glSetInt/glGetInt,
const
int
GL_BLEND_DST;
use with glSetInt/glGetInt,
const
int
GL_COLOR;
use with glSetInt/glGetInt, a 32 bit int specifying alpha, red, green + blue as 0xAABBGGRR
const
int
GL_TEXTURE_WRAP;
use with glSetInt/glGetInt, texture wrap mode - repeat or clamp - applies to last set texture unit
const
int
GL_SCREEN_WIDTH;
use with glGetInt, (GET ONLY) width of the screen...
const
int
GL_SCREEN_HEIGHT;
use with glGetInt, (GET ONLY) height of the screen...
const
int
GL_TEX_WIDTH;
use with glGetInt, (GET ONLY) width of the current texture
const
int
GL_TEX_HEIGHT;
use with glGetInt, (GET ONLY) height of the current texture
const
int
GL_VIEWPORT_WIDTH;
use with glGetInt, (GET ONLY) width of what we are rendering to...
const
int
GL_VIEWPORT_HEIGHT;
use with glGetInt, (GET ONLY) height of what we are rendering to...
const
int
GL_TEX_VID_UPDATE_FRAME;
use with glGetInt, (GET ONLY) how many frames have been updated so far on the video the current texture refers to (or 0).
const
int
GL_ZERO;
use with glSetInt/glGetInt, and GL_BLEND_SRC/GL_BLEND_DST
const
int
GL_ONE;
use with glSetInt/glGetInt, and GL_BLEND_SRC/GL_BLEND_DST
const
int
GL_SRC_ALPHA;
use with glSetInt/glGetInt, and GL_BLEND_SRC/GL_BLEND_DST
const
int
GL_ONE_MINUS_SRC_ALPHA;
use with glSetInt/glGetInt, and GL_BLEND_SRC/GL_BLEND_DST
const
int
GL_SRC_COLOR;
use with glSetInt/glGetInt, and GL_BLEND_SRC/GL_BLEND_DST
const
int
GL_ONE_MINUS_SRC_COLOR;
use with glSetInt/glGetInt, and GL_BLEND_SRC/GL_BLEND_DST
const
int
GL_CULL_NONE;
use with glSetInt/glGetInt, and GL_CULL_FACE - cull nothing, display all
const
int
GL_CULL_BACK;
use with glSetInt/glGetInt, and GL_CULL_FACE - cull back faces
const
int
GL_CULL_FRONT;
use with glSetInt/glGetInt, and GL_CULL_FACE - cull front faces
const
int
GL_REPEAT;
use with glSetInt/glGetInt, for use with GL_TEXTURE_WRAP
const
int
GL_CLAMP;
use with glSetInt/glGetInt, for use with GL_TEXTURE_WRAP
const
int
GL_COLOR_BUFFER_BIT;
flag for glClear
const
int
GL_DEPTH_BUFFER_BIT;
flag for glClear
void
glClear(
float
r,
float
g,
float
b,
float
a,
int
flags);
Clear the screen to the specified colour, flags is GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT ORed together
void
glClear( col,
int
flags);
Clear the screen to the specified colour, flags is GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT ORed together
int
glGetInt(
int
id);
Get a graphics-related value. See GL_* constants
void
glSetInt(
int
id,
int
val);
Set a graphics-related value. See GL_* constants
void
glBlendFunc(
int
src,
int
dst);
Set the final blend function. See GL_ZERO,GL_ONE,GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA,GL_SRC_COLOR,GL_ONE_MINUS_SRC_COLOR
Structure holding information on an area of memory used to store
a volume used for creating metaballs
int
sx;
Size in the x dimension
int
sy;
Size in the y dimension
int
sz;
Size on the z dimension
*int
volume;
size = sx*sy*sz
}
Lookup table used with MetaBallVolume to speed up adding metaballs with mbLookupBall
int
radius;
radius of the ball in this lookup table
*int
data;
Calculated data for the lookup
}
void
mbClear( volume,
int
value);
sets the contents of the volume to the given value
returns # of points needed by the mesh once triangulated
int
mbTriangulateN3V3( volume, data,
int
dataCount);
triangulate the given mesh
int
mbValue( volume, position);
get (interpolated) value at position
void
mbBall( volume, position,
float
strength,
int
border);
Add a proper 1/r*r metaball over the whole volume
\param border the number of elements border to leave in the volume
\param strength the strength of the ball - 1 = as-is
\param position where to put the ball, in volume element coordinates
void
mbLookupBall( volume, lookup, position,
float
strength,
int
border);
Add a metaball created from a lookup table - the lookup table must be 32x the size of the final ball that we want
\param border the number of elements border to leave in the volume
\param strength the strength of the ball - 1 = as-is
\param position where to put the ball, in volume element coordinates
void
mbDisc( volume, position,
int
zPos,
float
strength,
int
border);
Add a single XY slice of a ball at the given Z position
void
mbLookupCreate( lookup,
int
radius);
Create a lookup ball using the given structure, and set it up with the given radius in voxels
Free all memory used by a metaball lookup table
void
qSort(
*int
indices,
*float
values,
int
pointCount);
Given a list of float values, sets indices such that values[indices[i]] are in ascending order
float
cubicInterpFloat(
float
y0,
float
y1,
float
y2,
float
y3,
float
mu);
Cubic interpolation of a single floating point value
Get the number of tris per frame we're allowing
Get the number of objects per frame we're allowing
AnimatedPoint.pur3h
point that moves smoothly between random positions between -1,-1,-1 and 1,1,1
Used for movement
Used for movement
Used for movement
Used for movement
float
mv;
Position in movement
pos;
Actual position in 3D space
float
speed;
Speed that applies when step is given no arguments
void
create( this);
void
destroy( this);
void
update( this);
void
step( this,
float
amt);
void
step( this);
}
AnimatedTexture.pur3h
Animated texture that changes depending on sound...
int
renderTex;
vbSquare;
int
texParticle;
int
shader;
void
step( this,
float
timePass,
float
move);
move this texture on a step...
just render this as a quad between -1,-1,0 and 1,1,0
void
bind( this,
int
unit);
}
Arrows.pur3h
Data about 1 arrow
float
angle;
float
speed;
float
speedbass;
float
speedmid;
float
speedtreble;
float
size;
float
pos;
void
randomize( this);
void
step( this,
float
amt,
float
bass,
float
mid,
float
treble);
void
render( this, vb,
*float[16]
base);
}
R4-style moving arrows over a background
class
CArrows
{
int
count;
arrows;
square;
arrow;
bgOffset;
int
tex_bg;
int
tex_arrow;
int
shader;
void
create( this);
void
destroy( this);
void
step( this);
void
render( this);
}
AutomaticWarp.pur3h
Moving warp effect like R4...
warp;
void
create( this,
int
_sx,
int
_sy);
This only needs a few points for X and Y, try 5,5
void
destroy( this);
void
step( this,
float
timePass);
void
step( this);
void
render( this);
}
Background.pur3h
Super background that can do several different things based on the
ByType tag in the XML that the scene is loaded from
int
type;
skybox;
arrows;
omatic;
warpdrive;
kicker;
int
tex_mask;
int
tex_feedback;
int
tex_background;
int
tex_flowmap;
int
tex_colormap;
int
tex_staticbg;
If we had a stationary background texture we loaded, this is it.
int
shader_tex;
int
shader_mask;
int
shader_color;
int
shader_blur;
int
shader_flowmap;
int
shader_colormap;
int
shader_edge;
rect;
int
recurse_tile_x;
int
recurse_tile_y;
float
time;
float
timePass;
void
create( this);
void
destroy( this);
void
step( this);
void
maskEnd( this);
int
feedbackStart( this,
int
points);
void
feedbackPoint( this, pos,
float
size);
void
mainStart( this);
void
mainEnd( this);
}
BioTunnel.pur3h
const
int
BIOTUNNEL_SUBSECTIONS;
Number of subsections each section is divided into
A subsection of a tunnel section is just one part of the section that is calculated and stored in a vertex buffer
const
float
BIOTUNNEL_TEX_REPEAT_Y;
This class is DEPRECATED - you should use CSuperTunnel whenever possible
pos;
float
strength;
}
This class is DEPRECATED - you should use CSuperTunnel whenever possible
Previous section in model
last2;
section before last
last3;
section before last2
The position, up vector and strength of each trail
int
trailCount;
how many traiols we have
buffer;
The buffer we use to store the metaballed shape
int[8]
subSecCalculated;
Have we calculated stuff for this subsection yet?
void
create( this,
int
trail_count,
int
vb_format);
void
destroy( this);
void
render( this,
float
alpha,
float
alpha_max);
Renders the whole section, alpha value is subtracted by the fraction of the section
we're through so we can fade out nicely. alpha_max is used to fade out nicely at the back
void
clear( this);
}
This class is DEPRECATED - you should use CSuperTunnel whenever possible
int
sectionCount;
float
sectionSpacing;
int
trailCount;
The number of trails we have
*float
trailStrengths;
How much of an impact do trails make?
*float
trailRadii;
How far out do trails span?
int
clearStrength;
What do we clear the mesh to?
The volume we'll use for rendering sections
The volume we will mesh the sections too
sections;
int
frontSection;
int
backSection;
tunnel;
The tunnel we use to bend from... if we have one.
void
calculateTexCoords( this, dst_buf,
int
subSec);
void
generateSubSection( this,
int
subSec);
void
nextSection( this,
int
generate);
void
nextSection( this);
void
updateSubSections( this,
float
amt);
Call this before rendering, giving a value between 0 and 1
It will create all the buffers needed to render up as far as we are...
void
_create( this,
int
section_count,
int
mesh_size,
int
section_trails,
int
calc_tex_coords,
int
inside_tunnel);
void
create( this,
int
section_count,
int
mesh_size,
int
section_trails);
void
create_with_tex_coords( this,
int
section_count,
int
mesh_size,
int
section_trails,
int
is_inside);
void
destroy( this);
void
setTrailStrength( this,
int
trail,
float
strength);
Sets the strength of a specific trail
getTrailPos( this,
int
trail,
float
pos);
Gets the position in a trail in volume coordinates
getTrailUp( this,
int
trail,
float
pos);
Convert volume coordinates into a tunnel-relative sortof thing (-1 -> 1)
}
Boids.pur3h
A single boid with position and velocity - most of the smarts is in CBoids
class
CBoid
{
pos;
vel;
acc;
void
create( this, initial_pos);
void
destroy( this);
void
step( this,
float
timePass,
float
friction);
void
attract( this, position,
float
amount);
}
Use this by calling calculate_acceleration, then adding the other
relevant accelerations using boid->attract/repulse, then call step
to move the boids
class
CBoids
{
boids;
Pointer to each boid
int
n_boids;
Number of boids
float
spacing;
How far away boids like to be
void
create( this,
int
boid_count, initialMin, initialMax);
Create boid_count boids. they are created between initialMin and initialMax
void
destroy( this);
void
attract( this, position,
float
amount);
void
repulse( this, position,
float
amount,
float
size);
void
step( this,
float
timePass);
}
Border.pur3h
Draws a square/rectangle with texture coordinates by dividing up a texture into 3x3
and drawing the edges without stretching them. Good for drawing nice borders.
class
CBorder
{
void
create( this);
void
destroy( this);
void
render( this, a, b,
float
z,
float
cornerSize,
int
drawMiddle);
Render between a and b, at the given z value, with corners of a certain size. set drawMiddle=false for
a hole from a+cornerSize to b-cornerSize
}
ColourParticles.pur3h
Handles drawing of multiple particles with colour and a normal
Used mainly for cell-effect stuff
our buffer data
data;
Pointer to data (when locked!)
xAxis;
Axes used for drawing particles
yAxis;
Axes used for drawing particles
zAxis;
Axes used for drawing particles
int
particlesRequested;
for debug
int
particlesUsed;
for debug
int
started;
for debug
use the current matrix to get particle directions
void
start( this,
int
particles);
Call this before we start adding particles
void
start( this, particleDirection,
int
particles);
Call this before we start adding particles
void
end( this);
Call this after we stopped adding particles
void
add( this, pos, normal,
float
size, col);
add a particle!
void
addTrail( this, pos,
int
count,
float
size, col);
add a trail of points, so make sure they are all joined up
Unlike the CParticles one - this one tries pretty hard not to get
'snags' in it..
void
addLine( this, a, b,
float
size, normal, col);
add a single line, but facing the viewer
void
addRect( this, rect,
float
x1,
float
y1,
float
x2,
float
y2, normal, col);
add a rectangular particle!
void
addCharacterSlice( this,
int
character, rect, normal, col,
float
xStart,
float
xEnd);
Add a rectangle representing a font character in a normal font
void
addCharacter( this,
int
character, rect, normal, col);
Add a rectangle representing a font character in a normal font
}
ColourScheme.pur3h
const
int
RSI_SMOOTH;
smooth (so will reflect well)
const
int
RSI_FLAT;
flat sides
const
int
RSI_SLIM_Z;
Z is much slimmer than X and Y - useful for cube water
const
int
RSI_SPHERE;
A sphere, or stuff that is more or less the same if viewed from different angles
const
int
RSI_C1;
stupid low poly-count less than 4K
const
int
RSI_C2;
low poly-count 4K to 7K
const
int
RSI_C3;
medium poly-count 8K to 15K
const
int
RSI_C4;
medium poly-count 16K to 31K
const
int
RSI_C5;
high poly-count 32k to 63k
const
int
RSI_C6;
high poly-count 64K to 127K
const
int
RSI_C7;
stupid high poly-count over 128K
const
int
RSI_C8;
test poly-count. USed for testing (size, etc) when adding new polygons.
const
int
BG_NONE;
Solid background, bgColour is the colour of it
const
int
BG_SKYBOX;
Use a skybox background. Texture on skybox. Filenames without an ending refer
to 6 images in the form of a skybox. bgColour is the brightness of the skybox
const
int
BG_BASSCUBE;
Use a skybox background that twists with bass. Texture on skybox. Filenames without an ending refer
to 6 images in the form of a skybox. bgColour is the brightness of the skybox
const
int
BG_FLOW;
'Flow' the image using giess-type patterns. use texture as colour map, bgColour is the brightness
it is rendered in.
const
int
BG_RECURSE;
Recursive tilling of the image. no texture needed, bgColour is the brightness of each iteration
const
int
BG_RECURSEWARP;
Recursive warping of the image. no texture needed, bgColour is the brightness of each iteration
const
int
BG_ARROWS;
arrows moving across the screen. BgTexture is the background, BgTexture2 is the arrow texture,
second is the arrow texture, bgColour is ignored.
const
int
BG_OMATIC;
R4-style O-matic... Layers of the given texture, spiralling into the distance.
bgColour is the colour of the background
const
int
BG_WARPDRIVE;
Sparks of texture flying by, on a skybox background. BgTexture is the skybox, BgTexture2 is the spark. bgColour affects both textures.
const
int
BG_WARPING;
R4-style background warping - BgTexture contains a texture that is drastically warped in all directions
const
int
BG_FLAT;
Display a flat, static image in the background, filename is in BgTexture
const
int
BG_COUNT;
number of backgrounds
const
int
MD_NONE;
Flags for CMidLayer - no middle layer
const
int
MD_WARP;
Flags for CMidLayer - warp the background around the foreground (no texture needed)
const
int
MD_COUNT;
Flags for CMidLayer - number of mid layers
const
int
FG_ENVMAP_SOLID;
render the foreground as an environment map using FgTexture
const
int
FG_ENVMAP_TRANSPARENT;
render the foreground as an environment map using FgTexture, but make the object transparent
const
int
FG_ENVMAP_BG_SOLID;
render the foreground as an environment map using a copy of what's on the background
const
int
FG_ENVMAP_BG_COLORMAP;
render the foreground as an environment map using a copy of what's on the background,
but looking up the Red and Green components of the background in FgTexture as X and Y
const
int
FG_TEXTURED_SOLID;
Render the foreground with a texture using the foreground's texture coordinates
const
int
FG_TEXTURED_SOLID_LIT;
Render the foreground with a texture using the foreground's texture coordinates, and simple lighting
const
int
FG_TEXTURED_TRANSPARENT;
Render the foreground transparently with a texture using the foreground's texture coordinates
const
int
FG_TEXTURED_TRANSPARENT_LIT;
Render the foreground transparently with a texture using the foreground's texture coordinates, and simple lighting
const
int
FG_COUNT;
number of foregrounds
*int[11]
STR_BG_TYPE;
These are so we can look stuff up from the XML
*int[2]
STR_MD_TYPE;
*int[8]
STR_FG_TYPE;
Data for one possible combination of colours
int
bgType;
One of the BG_ enums
*int
bgTexture;
Colour map/Texture for the background
*int
bgTexture2;
2nd Texture for the background (eg, for warp)
int
mdType;
One of the MD_ enums
*int
mdTexture;
Colour map for the middle layer
int
fgType;
One of the FG_ enums
*int
fgTexture;
Environment map/Texture/ColourMap for foreground
int
bgColour;
Colour of the background
int
maskColour;
Colour of the mask layer - 0xAABBGGRR - 0 means no mask
int
flags;
Other flags - not done yet :)
}
int
colourSchemeInitialised;
this is here for testing really - to make sure I haven't forgotten to call create() in scenes
Handles what colours (and colour maps) we use, so we don't clash...
int
fromXml;
The chosen colour scheme
int[256]
xmlBgTexture;
int[256]
xmlBgTexture2;
int[256]
xmlMdTexture;
int[256]
xmlFgTexture;
void
create( this);
void
destroy( this);
Return things the random shape (if it is used) MUST be...
}
This is a bit out of the ordinary, but we'll always want this to be called scheme
so other classes can access it, so define it here
Engine.pur3h
const
float
CONROD_LENGTH;
length of the con rod
const
float
PISTON_SPACING;
spacing between pistons (or cylinders)
const
float
PISTON_RAD;
radius of piston itelf
const
float
PISTON_HEIGHT;
height of piston itself
const
int
GAS_POSITIONS;
number of positions in preset movements for gas particles
const
float
VALVE_HEIGHT;
height of valve above crank
const
float
VALVE_DIST;
distance apart of valves
Class that handles positioning of piston + con rod
class
CPiston
{
float
pistonAngle;
angle of piston (eg. in a V)
float
crankAngle;
angle of crank, updated every frame
float
crankAngleOffset;
offset of crank
float
pistonOffset;
X offset of piston (for each cylinder)
float
conrodOffset;
X offset of con rod
conrodBig;
conrodLittle;
pistonPos;
float
pistonDisplace;
the amount the piston is displaced
void
create( this,
float
_pistonAngle,
float
_crankAngleOffset,
float
_pistonOffset,
float
_conrodOffset);
void
destroy( this);
void
step( this,
float
currentCrankAngle);
void
feedback( this, background);
40 points
void
shadow( this, shadow);
40 points
void
render( this,
*float[16]
baseMatrix, enginePiston, engineConRod);
render one complete piston,
float[16]
getCylinderMatrix( this);
gets the matrix to map to this cylinder
}
Class for an engine containing pistons
class
CEngine
{
pistons;
int
pistonCount;
float[8]
crankOffsets;
offsets for each crank
int
crankCount;
items on crank (pistons or pistons/2)
float
crankAngle;
actual angle of engine - changed with 'step'
enginePiston;
engineConRod;
engineCrank;
void
createSingle( this);
create single cylinder engine
void
create( this);
create engine of random size
void
destroy( this);
void
step( this,
float
currentCrankAngle);
void
render( this,
*float[16]
baseMatrix);
void
feedback( this, background);
void
shadow( this, shadow);
}
the position, colour and size of a particle at a given time
pos;
col;
float
size;
}
a single particle, with a set of pre-recorded locations
steps;
pre-recorded locations
float
timingOffs;
offset of timing (eg. for multiple cylinders)
pos;
float
size;
col;
void
create( this,
*float[16]
cylinderOffset,
float
timing);
void
destroy( this);
void
step( this,
float
amt);
}
FeedbackBackground.pur3h
VB_FEEDBACKSQUARE;
this is a special wide texture so that when we rotate we don't end up with blank bits
const
int
FB_NO_USE_MATRIX;
stop the feedback background from twisting with the view matrix (eg. for medusa)
Class that draws geforce-style stuff in the background
int
renderTexture;
int
flowRenderTexture;
The renderable texture used when using dynamic flow maps
int
texColorMap;
int
texParticle;
int
flowMapTex;
int
texFlowParticle;
particle texture used for flow map
int
shaderColor;
int
shaderTexture;
int
shaderFlow;
int
shaderEdge;
vbSquare;
Rect used for general full-screen drawing
Cube for skybox render
exciteParticles;
The particles used to 'excite' the feedback
flowParticles;
The particles used to warp the feedback
float
feedbackZoom;
used to zoom in on feedback - it is a smoothed version of bass
float
feedbackMulitplier;
the amount of zoom we use for feedback dependant on sound
float
feedbackRotate;
used to rotate on feedback - it is a smoothed version of bass
int
useFeedbackZoom;
int
useFeedbackRotate;
int
useFeedbackTexture;
raw feedback to a texture first
int
useSkyBoxFeedback;
Draw the feedback in a skybox (NEEDS useFeedbackTexture)
int
useWarpFeedback;
Warp the feedback with particles (NEEDS useFeedbackTexture)
float
exciteStrength;
the amount of colour added to the feedback texture ( 0 -> 1)
float
warpStrength;
the amount the feedback texture is warped by particles ( 0 -> 1)
float
warpPointScale;
The amount to scake the points by for the warp
float[16]
oldViewMatrix;
old view matrix used to move the texture in the correct way
int
matrixMoveTexture;
Move texture with the view matrix?
void
create( this,
int
flags);
void
setMovementMatrix( this,
float[16]
viewMatrix);
do the per-frame twisting of stuff
void
feedbackStart( this,
int
particles);
start the rendering of the feedback
Give this the number of particles (or max no if can't be exact). ExciteStrength
lets the level of excitement be set so it doesn't all white out, warpStrength sets the amount particles warp
the flow map (if that is enabled...)
void
feedbackPoint( this, pos,
float
size);
Add a point, between feedbackStart/End. Given Position and size. Make the size just about cover the
thing that is being rendered or the warp stuff will be crap
end the rendering of the feedback
void
excite_with( this,
int
tex_mask);
render to fill the screen
}
FlowMapFunctions.pur3h
const
int
FLOW_WIDTH;
const
int
FLOW_HEIGHT;
const
float
FLOWSPEED;
Speed multiplier for flow maps
Create a full-screen geforce-style flowmap and return the texture pointer
const
int
FLOW_PARTICLE_SIZE;
Create a flow texture for a particle that distorts the flow field
FluidFlow.pur3h
const
int
N;
const
int
NL;
const
int
NN;
const
int
qx;
const
int
qy;
int
IX(
int
i,
int
j);
Fluid flow code, still under testing
float[1024]
u;
float[1024]
v;
float[1024]
u_prev;
float[1024]
v_prev;
float[1024]
dens;
float[1024]
dens_prev;
void
create( this);
void
destroy( this);
void
add_source( this,
*float
x,
*float
s,
float
dt);
void
set_bnd( this,
int
b,
*float
x);
void
lin_solve( this,
int
b,
*float
x,
*float
x0,
float
a);
void
diffuse( this,
int
b,
*float
x,
*float
x0,
float
diff,
float
dt);
void
advect( this,
int
b,
*float
d,
*float
d0,
*float
u,
*float
v,
float
dt);
void
project( this,
*float
u,
*float
v,
*float
p,
*float
div);
void
dens_step( this,
*float
x,
*float
x0,
*float
u,
*float
v,
float
diff,
float
dt);
void
vel_step( this,
*float
u,
*float
v,
*float
u0,
*float
v0,
float
visc,
float
dt);
void
step( this,
float
dt);
}
Font.pur3h
Class to render text using an 8x8 grid in a texture such as fong.png.
Here we use some special characters to change our font.
\1 = smaller
\2 = bigger
class
CFont
{
Vertex buffer containing the text
float
lineSpacing;
If the text contains newLines, what proportion of the text size should be left between lines
int
alignX;
What alignment should text be at? -1 is left, 1 is right, 0 is centre
float
textWidth;
This is set when the text is created
float
textHeight;
This is set when the text is created
float
getLineLength( this,
*int
text,
float
size);
Get the length of a line of text
void
getTextExtents( this,
*int
text,
float
size,
*float
extentX,
*float
extentY);
Get the extents of a piece of text
void
appendText( this, buf,
*int
text,
float
xOffset,
float
y,
float
size);
Append a piece of text
void
appendText( this,
*int
text,
float
xOffset,
float
y,
float
size);
Append a piece of text
void
setText( this, vb,
*int
text,
float
x,
float
y,
float
size);
Set the text in the buffer to exactly what was given, at the given offset
void
setText( this,
*int
text,
float
x,
float
y,
float
size);
Set the text to exactly what was given, at the given offset
void
setText( this,
*int
text);
Set the text to exactly what was given
void
create( this,
*int
text);
Create with normal settings - can pass in NULL for no text
void
destroy( this);
void
render( this);
void
renderTwoPass( this);
Render twice, changing blend modes. This helps reduce overlap issues
void
scale( this,
float
size);
Scale the text we've already got stored here
void
align( this,
int
horizontal,
int
vertical);
Align this text. 0=centre, -1=left/top, 1=right/bottom
}
Font12.pur3h
int[128]
FONT12_WIDTH;
int[128]
FONT12_OFFSET;
int[566]
FONT12_DATA;
Font3x5.pur3h
int[475]
FONT3X5;
FontSpacing.pur3h
float[256]
FONT_CHAR_SPACING;
Font spacings for the CFont class and general font drawing with font.png
Grapher.pur3h
const
int
GRAPHER_FPS;
const
int
GRAPHER_ELEMENTS;
const
int
GRAPHER_TRACES;
Debugging class - draws 4 different sets of values on the screen
class
CGrapher
{
float
amt;
float[4][512]
history;
int[4]
colours;
int
offset;
float
ymin;
float
ymax;
int
shader;
void
create( this);
ymin,ymax range from 0-1 (positions on the screen)
They assume the waveform is in the region 0->1
void
destroy( this);
void
step( this,
float
a,
float
b,
float
c,
float
d);
give this only values between 0 and 1...
void
render( this);
}
Grid.pur3h
A grid of points joined up by rectangles
class
CGrid
{
int
px;
Number of points in X and Y
int
py;
Number of points in X and Y
The vertex buffer containing our stuff
void
create( this,
int
width,
int
height);
Create of the given width and height. By default the
rectangles span from -1,-1,0 to 1,1,0
void
destroy( this);
void
setTex( this, tex);
Set a series of texture coordinates (must be px*py in size)
void
setTexCol( this, tex, col);
Set a series of texture+colour coordinates (must be px*py in size)
void
setColSingle( this, col);
set everything to a single colour
void
setT2V3( this, pt);
Set a series of quads up (must be px*py in size)
void
render( this);
}
JumpCamera.pur3h
const
float
CAMERA_CHANGE_BASS;
The bass value at which the camera suddenly changes direction
A camera that jumps around within the given area
float[16]
matrix;
The view matrix
eye;
Current position of the eye
target;
Current position of the target
Current up vector position
eyeMin;
borders for the available eye position
eyeMax;
borders for the available eye position
targetMin;
borders for the available target position
targetMax;
borders for the available target position
eyeA;
ABCD are interplated between using hermite
eyeB;
ABCD are interplated between using hermite
eyeC;
ABCD are interplated between using hermite
eyeD;
ABCD are interplated between using hermite
targetA;
targetB;
targetC;
targetD;
upA;
upB;
upC;
upD;
upReal;
The up vector we expect is up (gets up at least within 180 degrees)
float
amt;
float
smoothedMovement;
float
upRotation;
The amount of rotation of the 'up' vector we allow (this can be set by the caller)
float
smoothedZoom;
float
beats_per_step;
The amount of beats between steps of the camera... <0 means we just move according to time/-beats_per_step
float
zoomOnSound;
Do we zoom in when there is sound?
int
automaticJump;
Do we jump automatically with the sound?
float
lastSync;
used for suddenly changing direction on sharp sound
void
create( this, vEyeMin, vEyeMax, vTargetMin, vTargetMax, vUp);
void
create( this);
Just sets random stuff up
void
destroy( this);
void
calculate( this,
float
zoom);
Choose new direction - Assumes *C is where we're at. Makes *A = *B, *B = *C, and creates new *D
Stop our current movement and suddenly jump to new position
void
step( this);
void
jumpTo( this, eye, target,
float
eyeMovement);
Jump to a specific location and wander about there
}
Metaball.pur3h
Utility class to make it easier to use Metaballs - use with CVolume
void
create( this,
int
radius);
}
Utility class to make it easier to use Metaballs
class
CVolume
{
int
sxy;
void
create( this,
int
x,
int
y,
int
z);
void
destroy( this);
void
clear( this,
int
v);
void
random( this);
void
ball( this, pos,
float
strength,
int
margin);
void
lookupBall( this, lookup, pos,
float
strength);
void
calculate( this);
void
render( this);
float
getValueAt( this, pos);
get the value at pos - by interpolating
void
setValueAt( this, pos,
float
val);
}
MidLayer.pur3h
Handles rendering of the mid-layer of the visuals - stuff that works around
the foreground object like MD_WARP (that's all this has currently)
class
CMidLayer
{
int
tex_avr;
int
tex_flow;
int
tex_colormap;
int
shader_combine;
int
shader_flow;
int
shader_excite;
int
shader_final;
rect;
void
create( this);
void
destroy( this);
void
_render_avr( this,
int
mask_texture);
void
render( this,
int
mask_texture,
int
background_texture);
}
Mover.pur3h
A class that interpolates smoothly between stored point positions
either call getPos and shiftForwards/backwards...
or just use move to move on and return the current value
class
CMover
{
pos;
pMin;
pMax;
pDiff;
float
amt;
float
speed;
void
create( this, vMin, vMax);
void
destroy( this);
getPos( this,
float
p);
void
shiftForwards( this);
void
shiftBackwards( this);
move( this,
float
diff);
}
OMatic.pur3h
VB_OMATIC;
Data about 1 O-Matic layer
float
speed;
float
speedbass;
float
speedmid;
float
speedtreble;
float
angle;
float
pos;
float
posmax;
void
randomize( this,
float
initial_pos,
float
max_pos);
void
step( this,
float
amt,
float
bass,
float
mid,
float
treble);
void
render( this, vb,
*float[16]
base);
}
O-Matic used in Backgrounds like R4 has
class
COMatic
{
int
count;
layers;
*int
sorted;
int
tex;
int
shader;
void
create( this);
void
destroy( this);
void
step( this);
void
render( this);
}
OrientedMorph.pur3h
A single point in a COrientedMorph
pos;
actual position
dir;
direction one side of the orianted thing sits
up vector - only needs to be rough - just not to be equal to dir
col;
colour
interpolate radially (in X and Y)
void
setMatrix( this,
*float[16]
res,
*float[16]
x,
float
scale);
}
one set of points, making up a shape
const
int
OM_WAVE;
Number of a COrientedMorphPreset that animates
const
int
OM_RIPPLE;
Number of a COrientedMorphPreset that animates
const
int
ORIENTEDMORPH_PRESETS;
morphing points with directions
The current and next presets
The current and next presets
*float
sortZValues;
Z values used for sorting
*int
sortIndices;
data[sortIndices[i]] will be in order - MUST CALL SORT(DIR) FIRST
int
points;
int
n_presets;
float
amt;
blend amount
int
preFrom;
The current and next preset numbers
int
preTo;
The current and next preset numbers
int
has_presets;
Do we have our presets? These are calculated just in time with the _jit fn, without storage
int
radial_interp;
radial (in XY) interpolation?
float
animatedTime;
time used for animated stuff in updateAnimated
float
animatedSoundCounter;
sound based counter used for animated stuff in updateAnimated
int
colour_scheme;
random colour scheme - see getColour
void
_create( this,
int
mPoints,
int
mPresets,
int
use_presets);
void
create( this,
int
mPoints,
int
mPresets);
void
get_preset_jit( this, preset,
int
npreset);
void
create( this,
int
mPoints);
void
destroy( this);
void
sort( this, dir);
updates animated morphs
void
update( this);
void
step( this,
float
stepAmt);
void
step( this);
}
Oscilloscope.pur3h
const
int
OSCILLISCOPE_SAMPLES;
Oscillocope that looks at the sound data Morphyre's got and then
tries to 'trigger' at a certain point so that you can see the shape
of the sound wave.
float[512]
values;
void
create( this);
void
destroy( this);
void
step( this);
void
render( this);
}
OutlineShadow.pur3h
Class to draw a blurry outline shadow around stuff using particles
particles;
int
texParticle;
int
shader;
void
create( this);
void
destroy( this);
void
start( this,
int
particleCount);
void
add( this, pos,
float
size);
void
end( this);
}
Particles.pur3h
Handles drawing of multiple (simple) particles. You can use
CColouredParticles for slower but more comprehensive particle
drawing
our buffer data
data;
Pointer to data (when locked!)
xAxis;
Axes used for drawing particles
yAxis;
Axes used for drawing particles
zAxis;
Axes used for drawing particles
int
particlesRequested;
for debug
int
particlesUsed;
for debug
int
started;
for debug
void
create( this);
void
destroy( this);
void
render( this);
use the current matrix to get particle directions
void
_start( this,
int
particles);
Internal - set up for start of particles
void
start( this, particleDirection,
int
particles);
Call this before we start adding particles
void
start( this,
int
particles);
Call this before we start adding particles
void
end( this);
Call this after we stopped adding particles
void
add( this, pos,
float
size);
add a particle!
void
add( this, pos,
float
size, texMin, texMax);
add a particle with texture coordinates
void
add( this, pos,
float
size,
float
rotation, texMin, texMax);
add a particle with a rotation (in radians) and texture coordinates
void
addTrail( this, pos,
int
count,
float
size);
add a trail of points, so make sure they are all joined up
void
addLine( this, a, b,
float
size);
add a single line, but facing the viewer
void
addRect( this, rect,
float
x1,
float
y1,
float
x2,
float
y2);
add a rectangular particle!
}
R4.pur3h
int
finished;
float
timepass;
float
time;
float
sounda;
float
soundb;
float
soundc;
float[512]
specleft;
float[512]
specright;
float[512]
waveleft;
float[512]
waveright;
void
onInit();
void
onFrame();
void
onFrameEnd();
float
mag(
float
x,
float
y);
float
sqr(
float
x);
int
frac(
float
x);
float
pi();
int
intg(
float
x);
void
strncpy(
*int
dst,
*int
src,
int
n);
class
CR4Shader
{
int
shader;
int
bSrc;
int
bDst;
int
tex;
int
depthTest;
int
clearDepth;
int
envmap;
int
col;
int
getBlendFuncChar( this,
int
c);
float
readFloat( this,
**int
sh);
void
create( this,
*int
sh);
void
destroy( this);
void
setup( this,
int
tex1,
int
tex2,
int
tex3);
}
class
CR4Solid
{
int
col;
int
alpha;
void
create( this);
void
postinit( this);
void
render( this,
int
tex1,
int
tex2,
int
tex3);
void
destroy( this);
}
const
int
MAX_BUFFERS;
int[8]
BUFFERS;
int
BUFFERN;
int
col;
int
handle;
square;
int
shader;
void
create( this);
void
postinit( this);
void
render( this,
int
tex1,
int
tex2,
int
tex3);
int
renderTex( this,
int
tex1,
int
tex2,
int
tex3);
void
destroy( this);
}
int
handle;
square;
int
shader;
void
create( this);
void
postinit( this);
int
renderTex( this,
int
tex1,
int
tex2,
int
tex3);
void
render( this,
int
tex1,
int
tex2,
int
tex3);
void
destroy( this);
}
*int
filename;
int[256]
_filename;
int
tex;
square;
int
shader;
void
create( this);
void
postinit( this);
void
render( this,
int
tex1,
int
tex2,
int
tex3);
int
renderTex( this,
int
tex1,
int
tex2,
int
tex3);
void
destroy( this);
}
int
cachedRenderTex;
void
create( this);
void
postinit( this);
void
render( this,
int
tex1,
int
tex2,
int
tex3);
int
renderTex( this,
int
tex1,
int
tex2,
int
tex3);
void
destroy( this);
}
int
cachedRenderTex;
void
create( this);
void
postinit( this);
void
render( this,
int
tex1,
int
tex2,
int
tex3);
int
renderTex( this,
int
tex1,
int
tex2,
int
tex3);
void
destroy( this);
}
const
int
gl_one;
const
int
gl_zero;
const
int
gl_quads;
const
int
gl_triangles;
const
int
gl_lines;
const
int
gl_points;
const
int
gl_line_strip;
const
int
gl_quad_strip;
const
int
gl_polygon;
const
int
gl_modelview;
const
int
gl_projection;
const
int
gl_src_alpha;
const
int
gl_one_minus_src_alpha;
const
int
gl_src_color;
const
int
gl_one_minus_src_color;
const
int
CR4GL_BLOCKS;
const
int
CR4GL_BLOCKBUFFERSIZE;
float[16]
model;
float[16]
project;
int
blendSrc;
int
blendDst;
int
texture;
}
class
CR4GL
{
*int
shader;
int[256]
_shader;
float
aspect;
float[16][8]
matStack;
int
matStackPtr;
float[16]
currModel;
float[16]
currProject;
currCol;
currTex;
currNorm;
int
currBlendSrc;
int
currBlendDst;
int
currTexture;
*float[16]
currMatrix;
int
texWhite;
realShader;
blocks;
currBlock;
int
blockCount;
ptr;
ptrBase;
int
ptrSize;
int
ptrCount;
int
emulateRenderType;
vLast1;
vLast2;
particlex;
particley;
void
clear( this);
void
gltranslate( this,
float
x,
float
y,
float
z);
void
glscale( this,
float
x,
float
y,
float
z);
void
glrotate( this,
float
ang,
float
x,
float
y,
float
z);
void
glpushmatrix( this);
void
glpopmatrix( this);
void
glloadidentity( this);
void
glperspective( this,
float
fov,
float
aspect,
float
znear,
float
zfar);
void
glortho( this,
float
xmin,
float
xmax,
float
ymin,
float
ymax,
float
zmin,
float
zmax);
void
gllookat( this,
float
eyex,
float
eyey,
float
eyez,
float
centerx,
float
centery,
float
centerz,
float
upx,
float
upy,
float
upz);
void
glmatrixmode( this,
int
mode);
void
glbegin( this,
int
renderType);
void
glend( this);
void
glblendfunc( this,
int
s,
int
d);
void
glbindtexture( this,
int
t);
void
glcolor( this,
float
r,
float
g,
float
b,
float
a);
void
gltexcoord( this,
float
tx,
float
ty);
void
glnormal( this,
float
x,
float
y,
float
z);
void
glvertex( this,
float
x,
float
y,
float
z);
void
glcube( this,
float
ax,
float
ay,
float
az,
float
bx,
float
by,
float
bz);
void
glparticleorient( this,
float
size);
void
glparticle( this,
float
x,
float
y,
float
z,
float
s);
void
create( this);
void
postinit( this);
void
render( this,
int
tex1,
int
tex2,
int
tex3);
void
destroy( this);
}
class
CR4Warp
{
int[256]
_shader;
*int
shader;
int
subDiv;
int
relative;
float
amount;
float[6][6]
x;
float[6][6]
y;
int[6][6]
col;
realShader;
realWarp;
void
create( this);
void
postinit( this);
void
render( this,
int
tex1,
int
tex2,
int
tex3);
void
destroy( this);
}
class
CR4Map
{
int[256]
_shader;
*int
shader;
float[32][24]
x;
float[32][24]
y;
float[32][24]
r;
float[32][24]
g;
float[32][24]
b;
int
timed;
float
amt;
int
MAP_X;
int
MAP_Y;
realShader;
realGrid;
void
create( this);
void
postinit( this);
void
render( this,
int
tex1,
int
tex2,
int
tex3);
void
destroy( this);
}
int
col;
int
kick;
int
cubes;
*int[5]
shader;
int[256][5]
_shader;
float[5]
size;
float
movespeed;
float
rotspeed;
*int
filename;
int[256]
_filename;
realShader;
float
amt;
float
SPACING;
void
create( this);
void
postinit( this);
void
render( this,
int
tex1,
int
tex2,
int
tex3);
void
destroy( this);
}
const
int
MIX_ALPHA;
const
int
MIX_ADD;
const
int
MIX_MUL;
const
int
MIX_ADDOFFS;
const
int
MIX_SUBOFFS;
const
int
MIX_IMUL;
const
int
MIX_QUAD;
class
CR4Mix
{
int
type;
float
amount;
float
amt;
square;
int[7]
shader;
void
create( this);
void
postinit( this);
void
render( this,
int
tex1,
int
tex2,
int
tex3);
void
destroy( this);
}
class
CR4Tunnel
{
float
speed;
float
len;
float
twistmin;
float
twistmax;
float
rotate;
int[4]
texmodify;
float[4]
texx;
float[4]
texy;
float[4]
texox;
float[4]
texoy;
int[4]
sides;
float[4]
fog;
float[4]
radius;
*int[4]
shader;
float[4]
r;
float[4]
g;
float[4]
b;
float[4]
a;
int[256][4]
_shader;
realShader;
tunnel;
float
amt;
void
create( this);
void
postinit( this);
void
render( this,
int
tex1,
int
tex2,
int
tex3);
void
destroy( this);
}
class
CR4Invert
{
int
enabled;
square;
int[2]
shader;
void
create( this);
void
postinit( this);
void
render( this,
int
tex1,
int
tex2,
int
tex3);
void
destroy( this);
}
*int[5]
shader;
float[5]
size;
float
dist;
float
aspect;
float
kick;
int[256][5]
_shader;
realShader;
kicker;
void
create( this);
void
postinit( this);
void
render( this,
int
tex1,
int
tex2,
int
tex3);
void
destroy( this);
}
class
CR4Render
{
int
fit;
int
col;
float
scale;
float
rotz;
*int
type;
*int
shader;
int
count;
float[4096]
data;
int[256]
_shader;
int[256]
_type;
realShader;
void
pointxy( this,
float
x,
float
y);
void
create( this);
void
postinit( this);
void
render( this,
int
tex1,
int
tex2,
int
tex3);
void
destroy( this);
}
RainObjects.pur3h
Class defining how each new rain object is created
posRange;
Area new objects will be created over
sizeRange;
Range of different sizes objects are
int
stretched;
Are objects stretched?
velRange;
Range of different velocities objects created over
float
rotationMin;
Range of rotation speed
float
rotationMax;
Range of rotation speed
void
create( this);
}
A single rain object
pos;
vel;
size;
rotationNormal;
int
vbIndex;
Index of vertex buffer - note that to use this you must pass an array of VBs into CRainObjects.render()
float
rotationSpeed;
float
zValue;
used for sorting
float
rotAngle;
float
amount;
float
amountDir;
void
reset( this, data);
void
step( this, data,
float
movAmt,
float
rotAmt);
void
create( this);
void
destroy( this);
}
A bunch of objects that come raining down - these are rendered in sorted order and faded in and out
objectData;
Information about how objects are created (size ranges, etc)
int
initialised;
int
count;
objects;
*float
sortZValues;
Z values used for sorting
*int
sortIndices;
data[sortIndices[i]] will be in order - MUST CALL SORT(DIR) FIRST
viewerPos;
viewerDir;
float
soundResponse;
Amount falling objects respond to sound (0=none, 1=normal)
void
create( this,
int
numObjects);
void
destroy( this);
void
sort( this, direction);
sort everything in the given direction (for rendering)
float
getObjectAmount( this,
int
idx);
void
render( this, buf,
int
buffers);
Render - you must pass in a pointer to an array of VBs to render with (and the number of vbs). Note that you can
set CRainObject.vbIndex to point to which VB you want
void
render( this, buf);
void
step( this,
float
amount);
}
RandomRenderSolid.pur3h
const
int
RRS_TRANSPARENT;
const
int
RRS_SOLID;
Comes up with 'random' render styles for solid objects
Often it just gets the information from the scene's colour scheme
int
shader;
handle to shader
int
staticTexture;
A texture that *may* be used (that we load)
int
useBackground;
Will we use the texture we were given?
int
transparent;
void
renderStart( this,
int
textureId);
call this before rendering solid objects
If hasTextureBackground was set, we can supply a texture here
call this after rendering solid objects
}
RandomShape.pur3h
Shape info structure, used for RSI_SHAPEINFO array
*int
fileName;
object filename
int
flags;
one or more of the RSI_ constants ORed tonether
float
scale;
amount to multiple by
}
const
int
RSI_SHAPEINFO_COUNT;
RSI_SHAPEINFO;
This class creates a vertex buffer containing a random shape, OR
You can specify a 'Model' tag in the XML data to force it to use a
specific model
vertex buffer containing our shape
the current shape info structure chosen
int
findFitting( this,
int
rsiFlagAllowed,
int
rsiFlagDisallowed);
void
create( this,
int
rsiFlagAllowed,
int
rsiFlagDisallowed);
Call this constructor with mixtures of the RSI_ constants and a shape will be chosen that fits the criteria
RSI_ constants can be ORed together if more than one criteria is needed
void
create( this);
create and give us any old shape
void
create( this,
int
rsiFlagAllowed);
create and give us any old shape
void
destroy( this);
void
render( this);
}
SkyBox.pur3h
*int
filename;
}
const
float
TA;
const
float
TB;
T2N3V3[24]
VB_SKYBOX;
SKY_NAMES;
Skybox that's drawn with the current camera angle. Note that
filenames can be:
1) A standard filename (draws the same texture on each side of the cube)
2) A name with a '*' in which case 'front/back/top/bottom/left/right'
will be put into the name to try and load all 6 sides
class
CSkyBox
{
int[6]
tex;
int
full_skybox;
float[16]
m;
float[16]
mold;
int
shader;
int
loadTex( this,
*int
skyFile,
*int
skyType);
Load a texture from the skybox, skyDir is the filename with a star in (see above)
and the star will get replaced with the text in skyType (front/back/etc)
void
create( this,
*int
skyFile);
void
create( this);
void
destroy( this);
void
render( this);
}
SoundTrip.pur3h
const
float
TRIP_BASS;
Class which analyses sound and tries to pick out
strong beats which you can use to move suddenly
in time with the music
int
trip;
This is set to true if there has just been a strong beat
float
lastBass;
Bass value last time step was called
float
timeSinceTrip;
Time since we last set trip - we don't want to trip too often
void
create( this);
void
destroy( this);
int
step( this);
This analyses the sound and returns true if there
has just been a strong beat
}
SpaceObjects.pur3h
Object for CSpaceObjects
pos;
size;
float
amount;
the 'amount' of this block - should be max 1, min 0
float
fadeSpeed;
The speed we fade in... -1 to fade out
float
zValue;
Setup with position and used for sorting...
int
user;
This is any user-defined value, but is reset to 0 whenever the object it
void
create( this);
void
destroy( this);
float
getSpaceValue( this, spacePos);
Get the 'filledness' at a point - this is 1/distance
float
getSpacePull( this, spacePos);
Get the pull at a point for the camera
}
const
float
CSPACEOBJECTS_SPACEX;
const
float
CSPACEOBJECTS_SPACEY;
const
float
CSPACEOBJECTS_SPACEZ;
Class to handle a bunch of objects in space. The camera
attempts (half-heartedly) to avoid them as it flies through them
objects;
*float
sortZValues;
Z values used for sorting
*int
sortIndices;
data[sortIndices[i]] will be in order - MUST CALL SORT(DIR) FIRST
viewerPos;
viewerVel;
viewerDir;
int
count;
float
getSpaceValue( this, spacePos);
Get the 'filledness' at a point - this is 1/distance
float
getSpacePull( this, spacePos);
Get the pull at a point for the camera
get the normal vector of the space at a given point... This will point towards the place with the most pull
void
recalculate( this, currentVolume, newVolume);
void
sort( this, direction);
sort everything in the given direction (for rendering)
float
getObjectAmount( this,
int
obj);
get the 'amount' to render the object - fades out when it is close
void
step( this,
float
timePass,
float
amount);
void
create( this,
int
objectCount);
void
destroy( this);
}
Spark.pur3h
Class to handle generating a spark-like effect
class
CSpark
{
int
nControlPoints;
controlPoints;
controlPointsSound;
*int
controlPointsOrder;
amount ot respond... x,y and z correspond to bass, mid + treble
*float
controlPointsValue;
used to sort control points
float
jaggedness;
used to sort control points
float
clinginess;
Amount to randomly vary spark by
void
create( this,
int
_controlPoints);
Amount sparks 'cling' to the control point
void
destroy( this);
void
step( this);
void
getPointsRecurse( this, pFrom, pTo, points,
int
nPoints,
float
randomness);
Recursively get points to jump between - assume points at either end already set up
void
getPositions( this, pFrom, pTo, points,
int
nPoints);
Fill in a specific amount of points between the two endpoints given
}
Spider.pur3h
const
int
SPIDER_LEGS;
const
int
SPIDER_LEG_DIV;
SPIDER_LEG;
Draws a spider - code to position spider and legs.
class
CSpider
{
N3V3[8]
legPositions;
bodyPosition;
bodyDirection;
void
create( this);
void
destroy( this);
void
plot( this);
void
render( this);
void
renderDefault( this);
void
positionOnCube( this, cube);
}
Square.pur3h
A simple square
class
CSquare
{
void
create( this, texa, texb);
void
create( this);
void
createClip( this);
void
destroy( this);
void
render( this);
REnder the square. don't use this after calling renderAt, etc
void
renderAt( this,
float
x1,
float
y1,
float
x2,
float
y2,
float
z);
Note - this PERMANENTLY modifies the CSquare and makes render() pretty useless
void
renderAt( this,
float
x1,
float
y1,
float
x2,
float
y2);
Note - this PERMANENTLY modifies the CSquare and makes render() pretty useless
void
renderAspectTexture( this, pos,
float
z,
int
alignx,
int
aligny,
float
scale);
Render with the currently bound texture's aspect ratio. tries to make the biggest axis from -1 to 1
alignx and aligny are -1(left/top),0(center), or 1(right/bottom)
Note - this PERMANENTLY modifies the CSquare and makes render() pretty useless.
void
renderScaledTexture( this, pos,
float
z,
int
alignx,
int
aligny,
float
pixelsPerUnit);
Render with the currently bound texture's aspect ratio. if pixelsPerUnit==256, a 512x256 picture is at -1,-0.5->1,0.5
alignx and aligny are -1(left/top),0(center), or 1(right/bottom)
Note - this PERMANENTLY modifies the CSquare and makes render() pretty useless.
void
renderAspectTexture( this,
int
alignx,
int
aligny);
Render with the currently bound texture's aspect ratio. tries to make the biggest axis from -1 to 1
alignx and aligny are -1(left/top),0(center), or 1(right/bottom)
Note - this PERMANENTLY modifies the CSquare and makes render() pretty useless.
Render with the currently bound texture's aspect ratio. tries to make the biggest axis from -1 to 1
Note - this PERMANENTLY modifies the CSquare and makes render() pretty useless.
void
renderAt( this,
float
x1,
float
y1,
float
x2,
float
y2,
float
tx1,
float
ty1,
float
tx2,
float
ty2);
Note - this PERMANENTLY modifies the CSquare and makes render() pretty useless
void
scaleForTexture( this,
int
tex);
}
SuperTunnel.pur3h
const
float
ST_MIN_DIST;
**********************************************************************************
All-encompassing tunnel class to handle mixing different types of tunnel-based
graphics.


SubTunnel -> List of positions for one 'trail' in the tunnel
Section -> one 'slice' of some part of tunnel
Element -> An entire tunnel of a certain type

Minimum distance between CSuperTunnelSubTunnel = maximum force which can be applied
const
float
ST_DIFF;
'time' increment
Position of something in the tunnel
section;
section in tunnel-local coordinates
worldSection;
section in *world* coordinates
int
sectionCount;
length of section and worldSection arrays
int
sectionCurrent;
index in section+worldSection or current section
int
sectionLast;
index in section+worldSection or last section
currentPos;
The current position of this point
repulsePos;
When repulsing other things, we use this position
targetPos;
The position the point is aiming for (in tunnel coords)
int
sectionsForTarget;
Number of sections left before we change target
currentX;
current X - used for maintaining upness
velocity;
the current velocity in tunnel-local coordinates
int
colour;
positions with different colours should avoid each other
float
moveability;
How fast this particular element moves. bigger=faster. 0=not at all. Basically it's 1/mass
float
repulsiveness;
Now much this pushes away other subtunnels of different colours
float
colour_repulsiveness;
Now much this pushes away other subtunnels of the same colour ( / R^2)
float
colour_attract;
How much this attracts like a spring ( * R)
float
friction;
amount we 'damp' the movements by
int
targetSections;
Number of sections after which target changes. 0=never
float
targetAttraction;
Amount we are pulled towards our target
void
create( this,
int
_sectionCount);
void
calculateSection( this, others,
int
otherCount,
*float[16]
orientation);
Create a new section, but look at the others so we know what we can avoid
Advance to next section - calculateSection should be called after
}
const
int
STET_NONE;
display nothing
const
int
STET_CUBES;
'divisions' cubes per section, spread out by 'spread'
const
int
STET_CUBESANGLED;
'divisions' cubes per section, spread out by 'spread' and randomly angled
const
int
STET_SQUARETUBE;
a tube with 4 sections
const
int
STET_ROUNDTUBE;
a tube with 8 sections
const
int
STET_SPIRALTUBE;
a tube that rotates around spiralLength sections, 'spread' away from the centre. 'divisions' is the divisions per section
const
int
STET_RANDOM_END;
end of randomly-selected stuff
const
int
STET_BIOTUNNEL_N3V3;
A biotunnel surrounding the given elements (N3V3 - no tex coords)
const
int
STET_BIOTUNNEL_T2N3V3;
A biotunnel surrounding the given elements (T2N3V3 - containing texture coords)
const
int
STET_BIOTUNNEL_T3T3T3N3V3;
A biotunnel surrounding the given elements (T3T3T3N3V3 - containing texture coords and vectors for Dot3 calculations)
const
int
STE_MAX_SUBTUNNELS;
How many subtunnels we allow in each CSuperTunnelElement
The volume we'll use for rendering sections
meshBuffer;
The buffer we'll mesh into
float[16]
currentOrientation;
Helpful data when calculating sections
float[16]
lastOrientation;
void
create( this,
int
mesh_size);
}
Each 'element' of the tunnel (eg. biotunnel, main tunnel, etc)
int[16]
subtunnel;
subtunnels this is based on (STE_MAX_SUBTUNNELS/16 is just the max I think we ever need...)
we use only 0..subtunnelCount-1 of these, they reference CSuperTunnelSubTunnels...
int
subtunnelCount;
section;
int
sectionCount;
int
sectionCurrent;
int
type;
render type
float
size;
size of the main element
spread;
if the element is spread out (eg, randomcube, spiral), the amount it spreads in each direction
geoPtr;
pointer to source geometry
int
geoCount;
number of vertices in source geometry
int
geoType;
source geometry render type (eg VB_QUADS)
int
geoPtrOwned;
internal. Do we own the geoPtr (do we have to free it?)
colour;
colour of what we render
float[16]
subtunnelSize;
when using biotunnels, this is the multiplier
int
divisions;
for RANDOMCUBES, how many cubes, for spirals - how many divisions per section, default 4
int
spiralLength;
how many sections the spiral spreads over, default 4
int
spiralSection;
render temp var: when rendering STET_SPIRALTUBE, which portion are we on?
void
create( this,
int
_sectionCount);
void
render( this,
float
lastAlpha);
set the geometry from a vertex buffer. This MUST be T2N3V3
}
Super tunnel that can contain many different types of tunnel. All the CSuperTunnelSubTunnel
elements are 'bent' around a CTunnel - so there are more 'sections' in the CSuperTunnelSubTunnels
than there are in the CTunnel
int
sectionCount;
number of sections we divide into depthwise
Subtunnels - store position information for each 'trail'
int
subtunnelCount;
Elements - create and store geometry created from trails
int
elementCount;
tunnel;
The main tunnel that controls where all these trails really go
int
sectionsPerTunnel;
Numbers of sections depthwise per tunnel section
int
tunnelSection;
Which section are we at relative to the tunnel? 0..sectionsPerTunnel-1
Helper stuff for CSuperTunnelElement which we can't put in here
because the compiler can't look upwards at the moment
float
getTunnelAmt( this,
float
pos);
Get position along 'tunnel'
void
create( this,
int
_subtunnelCount,
int
_elementCount,
int
_sectionCount,
int
_sectionsPerTunnel,
int
_meshSize);
Call create followed by prepare. See up top for subtunnel/element/section explanations.
_subtunnelCount = data for elements to render (~8?)
_elementCount = a type of rendering such as cubes/tube/biotunnel
_sectionCount = how many sections we have in total (~48)
_sectionsPerTunnel = subsections per tunnel's section (~16)
_meshSize = size of metaball mesh (0 for none) (~24)
void
prepare( this);
This pre-calculates anything that is needed after we
have been created and the user has set their stuff.
void
destroy( this);
void
render( this,
int
first,
int
last,
float
lastAlpha);
Render just a range of elements
void
render( this,
float
lastAlpha);
render all elements
getPos( this,
int
subtunnelIdx,
float
pos);
Get the position of the given subtunnel index and the position given
}
TVTestUtils.pur3h
int
textureHLinear(
float
r,
float
g,
float
b);
Create a texture with a horizontal gradient from black to the colour
int
textureHStriped(
float
r,
float
g,
float
b);
Create a texture with a horizontal stripe of black and the colour
int
textureVStriped(
float
r,
float
g,
float
b);
Create a texture with a vertical stripe of black and the colour
int
textureChequer(
float
r,
float
g,
float
b);
Create a texture with a chequer pattern of black and the colour
Timeline.pur3h
Timeline class that interpolates between a series of values after being
supplied an array of floats. The array contains a series of 'steps'. Each step
starts with one float for the to spend interpolating between that step and the next.
class
CTimeline
{
*float
data;
The data we have
int
dataSize;
The number of floats in the data array
int
stepSize;
The number of floats in each timeline step. INCLUDING the time.
int
currentStep;
The index in data of the start of the current step
*float
values;
The values as calculated for this time period. entry 0 is the % of this step we're through.
float
stepTime;
Current time in this step
int
smoothInterpolate;
Do we do smooth interpolation or not?
void
reset( this);
Reset the animation
void
step( this,
float
timePass);
Step on by the given amount
void
create( this,
*float
data,
int
dataSize,
int
stepSize);
void
destroy( this);
int
isFinished( this);
void
setSmooth( this);
void
setTime( this,
float
time);
}
TrailTexture.pur3h
const
int
FLOWX;
const
int
FLOWY;
float[65536]
flowtex;
Random texture for trails - can be animated
int
isAnimated;
int
texture;
int
texColorMap;
Colour mao texture if we are feedback-based
int
flowTexture;
int
mapTexture;
int
shaderFlowPixel;
int
shaderPixel;
int
shaderColorMap;
int
shaderTex;
vbSquare;
void
create( this);
void
destroy( this);
void
step( this);
void
render( this);
just render this as a quad between -1,-1,0 and 1,1,0
}
Trees.pur3h
const
int
TREE_RECURSE;
const
int
TREE_BRANCHES;
const
int
TREE_PARTICLES;
leaves per tree
Values used when creating a tree
float
twist;
twist at each joint
float
scale_a;
scale of branch a (trunk)
float
scale_b;
scale of branch b
float
sway;
amount tree sways to the side
float
split;
amount branches split off
void
create( this);
Create with random values
}
A tree element that can be created in any shape
pos;
The centre of this tree when it was last created with construct
Buffer containing the tree shape
particles;
Buffer containing the positions of particles for leaves
int
particle_count;
Number of particles in particles
float
alpha;
Utility variable for rendering
void
createBranch( this, branch,
*float[16]
matrix,
int
depth, tweak);
void
create( this);
Create a tree structure, use construct to fill it with a tree
void
destroy( this);
void
render( this);
void
construct( this, branch, pos,
float
size, tweak);
Create a tree at the given location using the given vertex buffer as
a model for a branch, and using the given set of tweaks
void
construct( this, branch, pos,
float
size);
Create a tree at the given location using the given vertex buffer as
a model for a branch
}
Tunnel.pur3h
pos;
position
normal up vector
dir;
normal for direction
side;
normal sizeways (x)
void
create( this, vpos, vup, vdir, vside);
standard initialiser
void
createFrom( this, previous,
float
distance,
float
directionX,
float
directionY,
float
rotate);
Create this section from a previous section given a distance to advance the frame
and the amount to move left/right and up/down
void
createFromPos( this, previous, newPos);
Create this section from a previous section given a distance to advance the frame
and the amount to move left/right and up/down
}
Code for a classic-style tunnel...
class
CTunnel
{
int
sectionCount;
sections;
int
backSection;
The index of the section right at the back
int
frontSection;
The index of the section right at the front
float
sectionSpacing;
The distance between sections
int
justGoStraight;
whether to just go totally straight in z direction with up as y and side as x
float
twistAmount;
Normally 1 - multiplier for side-side movement
int
effect_type;
These are for specific effects, for instance the tunnel may do a loop
int
effect_progress;
int
effect_dir;
void
nextSection( this);
create a new section going in a random direction
void
nextSectionAt( this, newPos);
create a new section ending up in the direction given
void
create( this,
int
section_count,
float
section_spacing);
void
destroy( this);
Set that this tunnel should just go totally straight (in +z)
getSection( this,
int
index);
getPos( this,
float
pos);
Get the position vector, pos is 0 at the start of the tunnel, and increments by 1 for each tunnel section
getUp( this,
float
pos);
Get the up vector, pos is 0 at the start of the tunnel, and increments by 1 for each tunnel section
getSide( this,
float
pos);
Get the side vector, pos is 0 at the start of the tunnel, and increments by 1 for each tunnel section
getDir( this,
float
pos);
Get the direction vector, pos is 0 at the start of the tunnel, and increments by 1 for each tunnel section
Convert a vector from tunnel coords to world coords
pos.x/y are -1 to 1, and pos.z increments by 1 for each tunnel
section forwards from the back
float[16]
getMatrix( this,
float
pos);
Return a matrix to convert from tunnel coords to world coords
pos.x/y are -1 to 1, and pos.z increments by 1 for each tunnel
section forwards from the back
float[16]
getMatrixCorrected( this,
float
pos);
Return a matrix to convert from tunnel coords to world coords directions corrected
pos.x/y are -1 to 1, and pos.z increments by 1 for each tunnel
section forwards from the back. The directions come from a previous tunnel section
which helps make thing point in the correct direction
void
calculateSlice( this, points,
float
radius,
int
radialDivisions, sa, sb, sc, sd,
float
amt);
calculates a single slice of the tunnel
amt is distance along the tunnel
void
calculateSection( this, buffer,
float
radius,
int
radialDivision,
int
lengthDivision,
int
sectionFromFront);
Write the quads for a new tunnel section into a vertex buffer. sectionFromFront==0 will render the foremost tunnel section
}
TurbulenceField.pur3h
const
int
TURBULENCE_X;
const
int
TURBULENCE_Y;
const
int
TURBULENCE_XY;
const
int
TURBULENCE_Z;
A field of points that move around - this can be used for smoke-type
effects with particles
points;
float[64]
speeds;
void
step( this,
float
amt);
}
VertexBuffer.pur3h
Wrapper around vertex buffer code
int
type;
The type of this buffer, one of the VB_... consts, like VB_V3
int
defaultRenderType;
The default mode of rendering, for renderDefault - eg. VB_TRIS/VB_QUADS
int
buffer;
ID of the buffer - used with vbCreate/etc.
int
size;
how much of this buffer is allocated? If size is >0 there is a buffer allocated
int
used;
how many vertices are used?
void
create( this,
int
vertexType,
int
initialSize);
Create this buffer, type is one of the VB_... consts, like VB_V3.
if initialSize is 0, no buffer will be allocated yet
Get the size of the type for this VB
void
setDefaultRenderType( this,
int
renderType);
set the type, like VB_TRIS/VB_QUADS
void
createFrom( this, data,
int
size);
create from the given data - use like createFrom(&VB_SQUARE, sizeof(VB_SQUARE))
void
createFromT2C4N3V3( this, data,
int
size);
create from the given data - use like createFrom(&VB_SQUARE, sizeof(VB_SQUARE))
void
createFromFile( this,
*int
filename,
int
vbType,
int
vbElSize);
create by loading a file with the given name from the data directory
vbType = VB_N3V3/etc
vbElSize = sizeof(VB_N3V3)/etc
void
createFromFile( this,
*int
filename);
Load the buffer from a file. This knows about .t2n3v3, .n3v3 and .t2c4n3v3 extensions. If it's not one of
them then it assumes .t2n3v3
void
createT2N3V3File( this,
*int
filename);
create by loading a file with the given name from the data directory
void
createN3T3( this, data,
int
size);
create from the given data - use like createN3T3(&VB_SQUARE, sizeof(VB_SQUARE))
void
destroy( this);
Free this vertex buffer
void
reallocate( this,
int
newSize);
Make sure the buffer is at least the size given AND KEEP THE DATA IN IT
void
allocate( this,
int
newSize);
Make sure the buffer is at least the size given
lockV3( this,
int
requiredSize);
Allocate and return a pointer to a buffer with the given number of elements. Must be unlocked after use.
lockN3V3( this,
int
requiredSize);
Allocate and return a pointer to a buffer with the given number of elements. Must be unlocked after use.
lockT2N3V3( this,
int
requiredSize);
Allocate and return a pointer to a buffer with the given number of elements. Must be unlocked after use.
lockT2C4N3V3( this,
int
requiredSize);
Allocate and return a pointer to a buffer with the given number of elements. Must be unlocked after use.
lockT2V3( this,
int
requiredSize);
Allocate and return a pointer to a buffer with the given number of elements. Must be unlocked after use.
lockT3T3T3N3V3( this,
int
requiredSize);
Allocate and return a pointer to a buffer with the given number of elements. Must be unlocked after use.
lockPos( this,
int
requiredSize,
*int
stride);
Allocate and return a pointer to this buffer's position elements. Must be unlocked after use.
This returns a stride, it *must* be used as follows:
int stride=0;
Vector3 *pos = lockPos(used, &stride);
for (...) {
...
pos = (Vector3*)(((float*)pos)+stride);
}
unlock();
void
unlock( this);
Unlock teh buffer after lock* has been used.
void
setUsed( this,
int
actualUsed);
set the amount that was *actually* used (we may have locked more)
void
mesh( this, vol);
triangulate the given volume into this buffer
void
scale( this,
float
x,
float
y,
float
z);
scale all positions by the values given
void
translate( this, amt);
translate all positions by the vector given
void
multiply( this,
*float[16]
m);
multiply all positions by the matrix given
void
rotate( this,
float
angle,
float
x,
float
y,
float
z);
translate all positions by the vector given
get the centre of the given buffer
get the extents of the given buffer
void
explode( this,
float
amt);
scale all positions on triangles by their normals (MUST BE TRIANGLE BASED)
void
render( this,
int
renderType);
Render this buffer, renderType is how the vertices will be used, like VB_QUADS or VB_LINES
Render this buffer with the default rendering type (defined with setDefaultRenderType)
void
calculateTangentsTri( this, verts,
int
nverts);
For Triangles: Calculate a set of Tangent vectors in tex1 and tex2 based on the texture coordinates and positions.
void
calculateTangentsQuad( this, verts,
int
nverts);
For Quads: Calculate a set of Tangent vectors in tex1 and tex2 based on the texture coordinates and positions.
void
calculateTangents( this, verts,
int
nverts,
int
type);
Calculate a set of Tangent vectors in tex1 and tex2 based on the texture coordinates and positions.
defaultRenderType must be set correctly
Calculate a set of Tangent vectors in tex1 and tex2 based on the texture coordinates and positions.
defaultRenderType must be set correctly. This works directly from the buffer.
Calculate tangent vectors from the T2N3V3 buffer supplied, and
write them into this buffer
void
append( this, buffer,
*float[16]
matrix);
Append a vertex buffer to this one after multiplying it with the given matrix. Only works for N3V3 T2N3V3 T2C4N3V3 at the moment
Copy the given N3V3 buffer into this T2N3V3 buffer
void
setRect( this, a, b, ta, tb);
Set the contents of this T2N3V3 buffer to a Rectangle with the given position and texture coordinates
void
printScreenExtents( this,
*int
name);
Print how far this vertex buffer extends on the screen
}
Warp.pur3h
const
int
WARP_INTERP;
After setting coords, this interpolated between them smoothly
and renders a mesh with those texture coordinates between -1,-1,0 and 1,1,0
class
CWarp
{
int
sx;
int
sy;
coords;
_interpx;
_interpxy;
grid;
void
create( this,
int
_sx,
int
_sy);
void
destroy( this);
void
step( this);
void
render( this);
}
WarpDrive.pur3h
Single spark in warp-drive effect
float
ang;
float
rad;
float
size;
float
pos;
float
speed;
void
random( this);
void
step( this,
float
timePass);
void
render( this, zAxis, particles);
}
R4 warp-drive effect
int
sparks;
particles;
int
tex;
int
shader;
void
create( this);
void
destroy( this);
void
step( this);
void
render( this);
}
WarpMapFunctions.pur3h
const
int
WARP_MAP_SIZE;
Create a random texture to warp things by - warping
uses absolute coordinates whereas flow uses relative ones
Water1D.pur3h
1D water simulation
We still use 3D points though...
class
CWater1D
{
int
count;
pos;
vel;
float
frictionHalfLife;
void
create( this,
int
pointCount);
void
destroy( this);
void
step( this,
float
timePass);
}
docs.html
geomutils.pur3h
void
createTube16( v, a, ax, ay, b, bx, by,
float
tya,
float
tyb);
Creates a tube between a and b with the given offsets for x and y. USES 16 VERTS (QUAD-BASED)
The X coordinate varies smoothly around the circumference, and the texture coordinates vary between tya and tyb
void
createTube32( v, a, ax, ay, b, bx, by,
float
tya,
float
tyb);
Creates a tube between a and b with the given offsets for x and y. USES 32 VERTS (QUAD-BASED)
The X coordinate varies smoothly around the circumference, and the texture coordinates vary between tya and tyb
void
createTubeExt16( v,
int
divisions,
float
dia, ea, pa, ax, ay, pb, bx, by, eb);
Creates an interpolated tube with divisions*16 Verts (QUAD-BASED)
It lies betwen ea -> pa -> pb-> eb
Create a cube between a and b - 24 Verts (QUAD-BASED)
interface.h
const
float
PI;
The constant of PI - 3.14159265
const
int
true;
const
int
false;
const
int
OFFSCREEN_RES;
const
int
VB_V3;
Vertex Buffer types, these go with the structures below
const
int
VB_T2_V3;
Vertex Buffer types, these go with the structures below
const
int
VB_N3_V3;
Vertex Buffer types, these go with the structures below
const
int
VB_T2_N3_V3;
Vertex Buffer types, these go with the structures below
const
int
VB_T2_C4_N3_V3;
Vertex Buffer types, these go with the structures below
const
int
VB_T3_T3_T3_N3_V3;
Vertex Buffer types, these go with the structures below
const
int
VB_POINTS;
Rendering styles for vertex buffers - as OpenGL
const
int
VB_LINES;
Rendering styles for vertex buffers - as OpenGL
const
int
VB_LINE_STRIP;
Rendering styles for vertex buffers - as OpenGL
const
int
VB_TRIS;
Rendering styles for vertex buffers - as OpenGL
const
int
VB_QUADS;
Rendering styles for vertex buffers - as OpenGL
const
int
MAT_MODEL;
Matrix mode for getMatrix/setMatrix
const
int
MAT_PROJECT;
Matrix mode for getMatrix/setMatrix
const
int
MAT_TEXTURE;
Matrix mode for getMatrix/setMatrix
class
Colour4
{
float
r;
float
g;
float
b;
float
a;
}
class
Vector3
{
float
x;
float
y;
float
z;
}
class
Vector2
{
float
x;
float
y;
}
class
T2V3
{
tex;
pos;
}
class
N3V3
{
normal;
pos;
}
class
T2N3V3
{
tex;
normal;
pos;
}
class
T2C4N3V3
{
tex;
col;
normal;
pos;
}
3 Texture coordinates. Used mainly for Bump/Parallax mapping
tex;
tex1;
tex2;
normal;
pos;
}
void
assert(
int
isOk);
void
print(
*int
string,
float
val);
Prints out the given string and float value to the console
void
printv(
*int
string, val);
Prints out the given string and vector value to the console
int
xmlInt(
*int
path,
int
defaultValue);
Get an integer point value from the current scene's Data area in XML
float
xmlFloat(
*int
path,
float
defaultValue);
Get a floating point value from the current scene's Data area in XML
void
xmlString(
*int
dst,
int
dst_size,
*int
path,
*int
defaultValue);
Get a string value from the current scene's Data area in XML.
Dst is a pointer to an array that will get the string, dst_size is the
number of elements in it, so it won't be overrun.
int
xmlExists(
*int
path);
Returns true if the given key exists
int
jsInt(
*int
jScript);
Evaluate the given bit of javascript and return the result as an integer
float
jsFloat(
*int
jScript);
Evaluate the given bit of javascript and return the result as a float
void
jsString(
*int
dst,
int
dst_size,
*int
jScript);
Evaluate the given bit of javascript and return the result as a string
Dst is a pointer to an array that will get the string, dst_size is the
number of elements in it, so it won't be overrun.
void
jsExec(
*int
jScript);
Execute the given bit of javascript - doesn't return anything...
float
sin(
float
x);
sine wave. in radians so a full range is 0 -> 2*PI
float
cos(
float
x);
cosine wave. in radians so a full range is 0 -> 2*PI
float
tan(
float
x);
tangent. in radians so a full range is 0 -> 2*PI
float
atan(
float
x);
arc tangent. in radians so a full range is 0 -> 2*PI
float
atan2(
float
y,
float
x);
360 degree arc tangent using x and y. in radians so a full range is 0 -> 2*PI
float
pow(
float
x,
float
y);
x to the power y
float
rand();
random range 0..1
int
randint(
int
min,
int
max);
random integer between the two values INCLUSIVE
*void
malloc(
int
intSize);
allocate memory. intsize is the size in basic allocation units (ints)
void
free(
*void
ptr);
free memory got with malloc
int
fileSize(
*int
fileName);
return the size (in allocation units) of the given file. Paths are relative to the data directory
Paths are relative to the 'data' directory, but can use various accessors too. See the data at the head of this file
void
fileRead(
*int
fileName,
*void
data,
int
start,
int
count);
Read up to dataSize from the given file
Paths are relative to the 'data' directory, but can use various accessors too. See the data at the head of this file.
start and count are in basic allocation units (32 bit ints), NOT BYTES. Don't specify a count that is too great for
the array that you have given or R5 will crash.

start = where in the FILE to load from. Data is always copied starting at data[0]
result = a + b
result = a - b
vMul( a,
float
amt);
result = a * amt
result = a x b
float
vDot3( a, b);
a.b
float
vMag( vec);
magnitude = sqrt(a.a)
float
vDist( a, b);
Distance between a and b
vTransform( a,
*float[16]
mat);
vTransformNormal( a,
*float[16]
mat);
float
fInterp(
float
a,
float
b,
float
amt);
interplolate between a and b
float
fInterp(
float
a,
float
b,
float
c,
float
d,
float
amt);
hermite interplolate between b and c
vInterp( a, b,
float
amt);
interplolate between a and b
vInterp( a, b, c, d,
float
amt);
hermite interplolate between b and c
vInterp( a, b,
float
amt);
interplolate between a and b
vInterp( a, b, c, d,
float
amt);
hermite interplolate between b and c
void
matMul(
*float[16]
result,
*float[16]
a,
*float[16]
b);
result = a x b
void
matTranslate(
*float[16]
result,
*float[16]
a,
float
x,
float
y,
float
z);
void
matTranslatev(
*float[16]
result,
*float[16]
a, v);
void
matScale(
*float[16]
result,
*float[16]
a,
float
x,
float
y,
float
z);
void
matRotate(
*float[16]
result,
*float[16]
a,
float
angle,
float
x,
float
y,
float
z);
angle in radians
void
matIdentity(
*float[16]
result);
void
matLookAt(
*float[16]
result,
*float[16]
a, eye, obj, up);
void
matBillboard(
*float[16]
result,
*float[16]
a,
float
scale);
create a billboarding matrix + scale it by the given amount
int
texLoad(
*int
filename);
Load a texture from the given filename
Paths are relative to the 'tex' directory, but can use various accessors too. See the data at the head of this file
int
texFromArray(
int
width,
int
height,
*int
data);
Load a texture from an area of memory
It is read as an RGBA bitmap, with all 4 channels packed into an int as 0xAABBGGRR - so you will need width*height ints
int
texFromFloatArray(
int
width,
int
height,
*float
data);
Load a texture from an area of memory
It is read as an RGBA bitmap, with all 4 channels as separate floats - so you will need width*height*4 floats
int
texFromFloatArray(
int
width,
int
height,
int
depth,
*float
data);
Load a 3D texture from an area of memory
void
texBind(
int
unit,
int
id);
Bind a texture to the given unit. unit 0 is the default, and id 0 disables texturing
void
texUnBind(
int
unit);
Disables texturing for a certain texture unit
void
texDestroy(
int
id);
destroy the given texture
void
texRenderBegin(
int
width,
int
height);
begin rendering a texture of the given width and height - call texRenderEnd to get the texture number
void
texRenderBegin(
int
width,
int
height,
int
floatingPoint);
begin rendering a texture of the given width and height (and ask whether it should be floating point or not) - call texRenderEnd to get the texture number
Stop rendering to a texture, and return the texture's ID
texRenderFinished must then be called when it is not required any more
void
texRenderFinished(
int
texId);
signals that we're finished with this renderable texture
int
vbCreate(
int
format,
int
size);
Create a vertex buffer of the given VB_ format, and with size elements
An element is a structure like T2V3, so you only need size 3 for a triangle, whatever element type
void
vbDestroy(
int
vb);
free the memory used by a vertex buffer
*float
vbLock(
int
vb);
Lock a vertex buffer and return a pointer to the data in it
You must unlock before locking again or rendering
void
vbUnLock(
int
vb);
Unlock a vertex buffer so it can be rendered
void
vbRender(
int
vb,
int
type,
int
offset,
int
pts);
Render a vertex buffer
Vertex buffer ID vb, with a type (VB_ constant), starting at offset, and
rendering 'pts' items
void
getMatrix(
int
type,
*float[16]
mat);
Get the 4x4 matrix, use this with one of the MAT_ constants
void
setMatrix(
int
type,
*float[16]
mat);
Set the 4x4 matrix, use this with one of the MAT_ constants
int
shaderLoad(
*int
vtx_filename,
*int
frag_filename);
Load the given GLSL vertex and fragment shader
Returns an ID that should be used in later calls
void
shaderBind(
int
id);
Bind the given shader ID to the GPU
You can only have one vertex shader and one fragment shader active at a time,
specifying another will just overwrite the one before
void
shaderUniform1(
*int
name,
float
x);
Set GLSL Shader uniform parameters
These must be in the vertex of fragment shader, specified like:
"uniform vec2 blur_dir;"
See the GLSL specs on uniforms, glGetUniformLocation, glUniform1f etc.
void
shaderUniform2(
*int
name,
float
x,
float
y);
void
shaderUniform3(
*int
name,
float
x,
float
y,
float
z);
void
shaderUniform4(
*int
name,
float
x,
float
y,
float
z,
float
w);
void
shaderDestroy(
int
id);
Free the vertex/fragment shader
void
sumViewport(
*float
rgb);
Takes a pointer to 3 (red, green and blue) floats, and sums every pixel
in the viewport, returning the number divided by the number of pixels...
so it should be in the range 0..1. BEWARE: this can be slow!
void
sumViewport(
*float
rgb,
int
width,
int
height);
Takes a pointer to an array of x*y*3 (red, green and blue * boxes) floats,
and sums every pixel in each box in the viewport, returning the number divided
by the number of pixels... There are width*height boxes used, equally spaced.
so it should be in the range 0..1. BEWARE: this can be slow!
const
int
SOUND_BUFFER_SIZE;
the size of the sound buffers returned by VIS_SOUND_WAVE and VIS_SOUND_SPECTRUM
const
int
WAVE_HISTORY_SIZE;
the size of the wave history buffer returned by VIS_SOUND_WAVE_HISTORY
const
int
VIS_TIME_SCENE;
float - time scene has been on in secs
const
int
VIS_TIME_DIFF;
float - time between renders of the scene
const
int
VIS_ASPECT;
float - aspect ratio of the screen...
const
int
VIS_SOUND_ENERGY;
float - std. dev. of the last SOUND_BUFFER_SIZE sound samples
const
int
VIS_SOUND_BASS;
float - instantaneous normalized bass value
const
int
VIS_SOUND_MID;
float - instantaneous normalized mid value
const
int
VIS_SOUND_TREBLE;
float - instantaneous normalized treble value
const
int
VIS_SOUND_BEAT;
float - instantaneous beat detection algorithm output
const
int
VIS_SOUND_WAVE;
float[SOUND_BUFFER_SIZE] - copy a list of floats representing the current waveform
const
int
VIS_SOUND_SPECTRUM;
float[SOUND_BUFFER_SIZE] - copy a list of floats representing the current spectrum
const
int
VIS_SOUND_WAVE_HISTORY;
float[WAVE_HISTORY_SIZE] - copy a list of floats representing the waveform *and* back in history quite a bit
const
int
VIS_SOUND_BEATAVR;
float - average of beat detection algorithm output
const
int
VIS_SOUND_SYNC;
float - runs generally from 0->1 but may overflow, distance through the bar...
const
int
VIS_SOUND_SYNCSMOOTH;
float - always runs from 0->1, smoothly moving beat sync, normally rising
const
int
VIS_SOUND_DEBUG1;
float - debug value from sound analyser - DON'T USE IN SCENES
const
int
VIS_SOUND_DEBUG2;
float - debug value from sound analyser - DON'T USE IN SCENES
const
int
VIS_FINISHED;
int - (bool) flag that is set to 1 if this scene wants to end
const
int
VIS_TWEAK_0;
float - tweak value - all the way up to 64, one after the other
const
int
VIS_TWEAK_1;
float - tweak value - all the way up to 64, one after the other
const
int
VIS_TWEAK_2;
float - tweak value - all the way up to 64, one after the other
const
int
VIS_TWEAK_3;
float - tweak value - all the way up to 64, one after the other
const
int
VIS_TWEAK_X;
xyz movement
const
int
VIS_TWEAK_Y;
xyz movement
const
int
VIS_TWEAK_Z;
xyz movement
const
int
VIS_TWEAK_XYZ_AMT;
amount to override XYZ
const
int
VIS_TWEAK_R;
red
const
int
VIS_TWEAK_G;
green
const
int
VIS_TWEAK_B;
blue
const
int
VIS_TWEAK_RGB_AMT;
amount to override RGB
const
int
VIS_TWEAK_STEREO_SEP;
stereo separation
const
int
VIS_TWEAK_CAMSHIFTX;
for stereo - used when rendering to shift the camera
const
int
VIS_TWEAK_SIZE;
change size. size = size * 2^VIS_TWEAK_SIZE
const
int
VIS_TWEAK_FOV;
change field of view. FOV *= 2^tweak
const
int
VIS_TWEAK_HUE;
for the hue overlay...
const
int
VIS_TWEAK_SPEED_OVERRIDE;
override sound-based movement speed with static speed
const
int
VIS_TWEAK_BRIGHTNESS;
for the hue overlay...
const
int
VIS_TWEAK_SATURATION;
for the hue overlay...
float
visGetFloat(
int
id);
Get a floating point value, use it with the VIS_ constants defined above
void
visGetFloatv(
int
id,
*float
floatPtr);
Get an array of floating point values, use it with the VIS_ constants defined above
The array given MUST be big enough
void
visSetFloat(
int
id,
float
value);
Set a floating point value, use it with the VIS_ constants defined above.
Currently only VIS_TWEAK* are writable
int
visGetInt(
int
id);
Get a floating point value, use it with the VIS_ constants defined above
void
visSetInt(
int
id,
int
val);
Set a floating point value, use it with the VIS_ constants defined above
void
visRenderChildToScreen(
int
childNumber,
float
timePass);
The 3 functions below are for handling rendering the scene tree.
When visRenderChildToScreen or visRenderChildToTexture is called,
execution of the current scene will stop at the current point, the
new scene will be drawn, and execution will restart from the end of
the function.

The timePass must either be 0 (not to step the scene on at all),
or another value. Usually it should be the result of visGetFloat(VIS_TIME_DIFF)
but you might use something else to do motion blur, etc.

Note that after these functions, GL state will be reverted to the
same as if you just entered the render function - so don't rely
on anything being left set up.

Render the scene directly to the screen
void
visRenderChildToTexture(
int
childNumber,
float
timePass,
int
textureX,
int
textureY);
Render the scene to a texture. the renderable texture number can
be returned with visGetRenderedTexture, and MUST be freed with texRenderFinished.
Texture size of -1,-1 uses normal screen size, -2,-2 is half size. Anything else
is what is given.
Return the texture that we rendered to with visRenderChildToTexture
float
soundSync(
float
val);
Sync a value with the vis's idea of the rhythm of the music
This assumes the value is between 0 and 1 usually, and will
cause the vis to move onwards if it is >1
float
_soundSyncInc_last;
internal var for soundSyncInc
float
soundSyncInc(
float
val);
Increment a value with the vis's idea of the rhythm of the music
This doesn't try and get the actual value correct (like soundSync does)
- instead it just increments.
const
int
GL_DEPTH_TEST;
use with glSetInt/glGetInt, bool - whether to use depth buffer info
const
int
GL_DEPTH_MASK;
use with glSetInt/glGetInt, bool - whether write to depth buffer
const
int
GL_CULL_FACE;
use with glSetInt/glGetInt, see GL_CULL_xxx consts
const
int
GL_BLEND_SRC;
use with glSetInt/glGetInt,
const
int
GL_BLEND_DST;
use with glSetInt/glGetInt,
const
int
GL_COLOR;
use with glSetInt/glGetInt, a 32 bit int specifying alpha, red, green + blue as 0xAABBGGRR
const
int
GL_TEXTURE_WRAP;
use with glSetInt/glGetInt, texture wrap mode - repeat or clamp - applies to last set texture unit
const
int
GL_SCREEN_WIDTH;
use with glGetInt, (GET ONLY) width of the screen...
const
int
GL_SCREEN_HEIGHT;
use with glGetInt, (GET ONLY) height of the screen...
const
int
GL_TEX_WIDTH;
use with glGetInt, (GET ONLY) width of the current texture
const
int
GL_TEX_HEIGHT;
use with glGetInt, (GET ONLY) height of the current texture
const
int
GL_VIEWPORT_WIDTH;
use with glGetInt, (GET ONLY) width of what we are rendering to...
const
int
GL_VIEWPORT_HEIGHT;
use with glGetInt, (GET ONLY) height of what we are rendering to...
const
int
GL_TEX_VID_UPDATE_FRAME;
use with glGetInt, (GET ONLY) how many frames have been updated so far on the video the current texture refers to (or 0).
const
int
GL_ZERO;
use with glSetInt/glGetInt, and GL_BLEND_SRC/GL_BLEND_DST
const
int
GL_ONE;
use with glSetInt/glGetInt, and GL_BLEND_SRC/GL_BLEND_DST
const
int
GL_SRC_ALPHA;
use with glSetInt/glGetInt, and GL_BLEND_SRC/GL_BLEND_DST
const
int
GL_ONE_MINUS_SRC_ALPHA;
use with glSetInt/glGetInt, and GL_BLEND_SRC/GL_BLEND_DST
const
int
GL_SRC_COLOR;
use with glSetInt/glGetInt, and GL_BLEND_SRC/GL_BLEND_DST
const
int
GL_ONE_MINUS_SRC_COLOR;
use with glSetInt/glGetInt, and GL_BLEND_SRC/GL_BLEND_DST
const
int
GL_CULL_NONE;
use with glSetInt/glGetInt, and GL_CULL_FACE - cull nothing, display all
const
int
GL_CULL_BACK;
use with glSetInt/glGetInt, and GL_CULL_FACE - cull back faces
const
int
GL_CULL_FRONT;
use with glSetInt/glGetInt, and GL_CULL_FACE - cull front faces
const
int
GL_REPEAT;
use with glSetInt/glGetInt, for use with GL_TEXTURE_WRAP
const
int
GL_CLAMP;
use with glSetInt/glGetInt, for use with GL_TEXTURE_WRAP
const
int
GL_COLOR_BUFFER_BIT;
flag for glClear
const
int
GL_DEPTH_BUFFER_BIT;
flag for glClear
void
glClear(
float
r,
float
g,
float
b,
float
a,
int
flags);
Clear the screen to the specified colour, flags is GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT ORed together
void
glClear( col,
int
flags);
Clear the screen to the specified colour, flags is GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT ORed together
int
glGetInt(
int
id);
Get a graphics-related value. See GL_* constants
void
glSetInt(
int
id,
int
val);
Set a graphics-related value. See GL_* constants
void
glBlendFunc(
int
src,
int
dst);
Set the final blend function. See GL_ZERO,GL_ONE,GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA,GL_SRC_COLOR,GL_ONE_MINUS_SRC_COLOR
Structure holding information on an area of memory used to store
a volume used for creating metaballs
int
sx;
Size in the x dimension
int
sy;
Size in the y dimension
int
sz;
Size on the z dimension
*int
volume;
size = sx*sy*sz
}
Lookup table used with MetaBallVolume to speed up adding metaballs with mbLookupBall
int
radius;
radius of the ball in this lookup table
*int
data;
Calculated data for the lookup
}
void
mbClear( volume,
int
value);
sets the contents of the volume to the given value
returns # of points needed by the mesh once triangulated
int
mbTriangulateN3V3( volume, data,
int
dataCount);
triangulate the given mesh
int
mbValue( volume, position);
get (interpolated) value at position
void
mbBall( volume, position,
float
strength,
int
border);
Add a proper 1/r*r metaball over the whole volume
\param border the number of elements border to leave in the volume
\param strength the strength of the ball - 1 = as-is
\param position where to put the ball, in volume element coordinates
void
mbLookupBall( volume, lookup, position,
float
strength,
int
border);
Add a metaball created from a lookup table - the lookup table must be 32x the size of the final ball that we want
\param border the number of elements border to leave in the volume
\param strength the strength of the ball - 1 = as-is
\param position where to put the ball, in volume element coordinates
void
mbDisc( volume, position,
int
zPos,
float
strength,
int
border);
Add a single XY slice of a ball at the given Z position
void
mbLookupCreate( lookup,
int
radius);
Create a lookup ball using the given structure, and set it up with the given radius in voxels
Free all memory used by a metaball lookup table
void
qSort(
*int
indices,
*float
values,
int
pointCount);
Given a list of float values, sets indices such that values[indices[i]] are in ascending order
float
cubicInterpFloat(
float
y0,
float
y1,
float
y2,
float
y3,
float
mu);
Cubic interpolation of a single floating point value
Get the number of tris per frame we're allowing
Get the number of objects per frame we're allowing
kicker.pur3h
Kicker like R4 - use 'matrix' and kick it by a value like bass, and
it will swing the object around in time to the beats
class
CKicker
{
float
kickAmount;
float
friction;
float
lastValue;
kickAngle;
inertia;
float[16]
velocityMatrix;
The speed of twisting
float[16]
matrix;
The actual 'absolute' twisting that should be used directly...
void
create( this);
void
destroy( this);
void
step( this,
float
timePass,
float
value);
void
pullback( this,
float
timePass,
float
speed);
pull the matrix back to the identity matrix (speed is roughly number to secs to go back to normal)
This does create a non-ortho matrix. Needs Work!!
}
mathutils.pur3h
float
halfLife(
float
timePass,
float
halflife);
return the amount you multiply each frame to get half the size after 'halfLife' time
float
clip(
float
val,
float
min,
float
max);
float
min(
float
a,
float
b);
Minimum of A and B
float
max(
float
a,
float
b);
Maximum of A and B
float
avr(
float
a,
float
b);
Average
int
randintsqr(
int
min,
int
max);
Random integer, but using random value squared so values
are more evenly spread out
float
sqrt(
float
x);
float
trwv(
float
x);
float
flip(
float
x);
float
wrap(
float
x);
float
floor(
float
x);
float
sign(
float
x);
float
abs(
float
x);
float
magXY( v);
Magnitude in X and Y
toColour4(
int
packedCol);
Given a vector, return a random normal which is at a right angle to the argument
getXVec(
*float[16]
mat);
Given a matrix, return the X vector - eg, the one that points left/right
getYVec(
*float[16]
mat);
Given a matrix, return the Y vector - eg, the one that points up/down
getZVec(
*float[16]
mat);
Given a matrix, return the Z vector - eg, the one that points at the camera
A Cuboid, with useful functions
class
CCuboid
{
min;
max;
void
create( this, boundsMin, boundsMax);
void
createNull( this);
create a cuboid that can never contain any points
void
destroy( this);
int
contains( this, pt);
return true if the point is inside
void
extendTo( this, pt);
Extend this to cover the given point
}
cLinear( a, b,
float
amt);
void
setOrtho(
float
xmin,
float
xmax,
float
ymin,
float
ymax);
void
setPerspective(
float
fovy,
float
aspect,
float
zNear,
float
zFar);
float
saw(
float
x);
Sawtooth - /|/|/|/|
float
smoothsaw(
float
x);
\/\/\/\/\/\/ thing between 0 and 2 - 0..1 -> 0..1, 1..2 -> 1..0
float
smooth(
float
x);
turns 0->1 into a smooth 0->1 using a sine wave
int
rgba( col);
int
rgba(
float
r,
float
g,
float
b,
float
a);
int
rgb(
float
r,
float
g,
float
b);
float
det3x3(
*float[16]
m);
Return determinant of top 3x3 matrix in matrix m
float[16]
orient( x, y, z, pos,
float
scale);
void
orient(
*float[16]
res,
*float[16]
old, x, y, z, pos,
float
scale);
Class containing position and orientation information. Basically a matrix
class
COrient
{
pos;
float[16]
getMatrix( this,
float
scale);
void
randomlyRotate( this);
Randomly rotate us
}
void
matGetRotation(
*float[16]
res,
*float[16]
mat,
float
scale);
Strip out all but the rotation from this matrix and return the result - used for SkyBoxes
Scale is the amount to multiply by. Sometimes the setPerspective sets a largish
minimum clip plane, which clips what we'd draw so we need to scale up bigger
void
matTranspose(
*float[16]
res,
*float[16]
m);
transpose a matrix
void
setIdentity(
int
matrix);
Set the given matrix type to the identity matrix
float
hermiteInterpFloat(
float
y0,
float
y1,
float
y2,
float
y3,
float
mu,
float
tension,
float
bias);
int
HSBtoRGB(
float
hue,
float
sat,
float
bri);
float
distanceToLine( pos, lineStart, lineEnd);
Distance from a point to a line
int
isInRect( pos, rectMin, rectMax);
float[16]
_PUSHPOP_ORTHO_MODEL;
float[16]
_PUSHPOP_ORTHO_PROJ;
void
setMatrixTranslateScale(
*float[16]
orig,
float
tx,
float
ty,
float
tz,
float
sx,
float
sy,
float
sz);
Set the modelview matrix to a translate matrix followed by a scale matrix (based on the argument)
void
setMatrixTranslateScale(
float
tx,
float
ty,
float
tz,
float
sx,
float
sy,
float
sz);
Set the modelview matrix to a translate matrix followed by a scale matrix
void
setMatrix2DTransform(
*float[16]
orig,
float
tx,
float
ty,
float
scale,
float
rotation);
Set the modelview matrix to a translate matrix followed by a scale matrix and a rotate. Onlyc include what we need for 2D
void
pushOrtho(
float
xa,
float
xb,
float
ya,
float
yb);
Push an orthographic modelview matrix, and set depth test+mask off
void
pushOrtho();
Push an orthographic modelview matrix, and set depth test+mask off
void
popOrtho();
Restore to previous state after pushOrtho
medusa.pur3h
R4-style medusa class - can be used for bigfoots and other stuff too
class
CMedusa
{
int
tails;
number of tails
int
tailElements;
How many elements in a tail
float
tailSpacing;
how far apart are elements
float
tailHalfLife;
How fast does each tail respond?
normals;
direction each tail sticks out in, size=tails
ups;
'up' vector of each tail. Needed to keep tails straight, size=tails
transformedUps;
'up' vector of each tail, transformed by the last matrix
positions;
size=tails*tailElements
*float
sizes;
sizes of each tail Element (same for each tail!)
void
calculateTails( this);
getPosition( this,
int
tailNo,
int
elementIdx);
getTail( this,
int
tailNo);
void
create( this,
int
_tails,
int
_tailElements,
float
_tailSpacing,
float
_tailHalfLife);
void
destroy( this);
void
step( this,
*float[16]
matrix,
float
timePass);
Move on the animation
If matrix==NULL then we assume that the first 2 elements of the tails
have already been set up
int
calculateSolidMedusa( this, medusaData,
int
segments);
Calculate the quads for a medusa
Returns the offset of the element after the last elemnt written
\param medusaData The data to be written tails * SEGMENTS * medusa.tailElements * 4 elements required
void
renderModel( this, model,
float
size);
Render the given model at each point on the medusa for each
tail - like R4's BigFoot
}
modelCube.pur3h
T2N3V3[24]
VB_CUBE;
Simple cube
modelSquare.pur3h
VB_SQUARE;
model_Shatter.pur3h
T2N3V3[24]
SHATTER0;
T2N3V3[24]
SHATTER1;
T2N3V3[24]
SHATTER2;
T2N3V3[36]
SHATTER3;
T2N3V3[24]
SHATTER4;
T2N3V3[24]
SHATTER5;
T2N3V3[24]
SHATTER6;
T2N3V3[24]
SHATTER7;
T2N3V3[24]
SHATTER8;
T2N3V3[36]
SHATTER9;
T2N3V3[24]
SHATTER10;
T2N3V3[24]
SHATTER11;
T2N3V3[24]
SHATTER12;
T2N3V3[24]
SHATTER13;
T2N3V3[24]
SHATTER14;
T2N3V3[24]
SHATTER15;
T2N3V3[24]
SHATTER16;
T2N3V3[24]
SHATTER17;
T2N3V3[24]
SHATTER18;
T2N3V3[24]
SHATTER19;
morph.pur3h
const
int
MORPH_SIZE;
const
int
MORPH_DIVX;
const
int
MORPH_DIVY;
const
int
MORPH_SHAPES;
Simple fixed size shape morph class
class
CMorph
{
class { float x <0> ;
float y <1> ;
float z <2> ;
}[256][7]
shapes;
the shapes we morph between
Vector3[256]
points;
the current points calculated by calculate
int[256]
sortedIndices;
the sorted offsets to morphed points
float[256]
sortZValues;
the z values used for sorting
int
morphFrom;
shape index morphing from
int
morphTo;
shape index morphing too
float
morphAmt;
the amount of morph - between 0 and 1
void
step( this,
float
amt);
void
create( this);
void
calculate( this,
*float[16]
matrix);
}
string.pur3h
int
strlen(
*int
s);
Length of string (returns 0 for null-pointers too)
void
strcpy(
*int
dst,
*int
src);
Copy string src over string dst
*int
strdup(
*int
src);
Allocate a new string and copy this into it
void
strcat(
*int
dst,
*int
src);
Append string src to string dst
void
strcatnum(
*int
dst,
int
num);
Append decimal number num to string dst
int
strcontains(
*int
str,
int
character);
returns true if string contains character
int
str_find_first(
*int
str,
int
character);
returns the index if string contains character, or -1
void
strsplit(
*int
dsta,
*int
dstb,
*int
src,
int
sep);
split a string in two by the first instance of sep
int
strequal(
*int
a,
*int
b);
returns true if 2 strings are equal
int
endswith(
*int
str,
*int
strend);
returns true if string str ends with string strend
int
endswithi(
*int
str,
*int
strend);
returns true if string str ends with string strend IGNORING CASE
int
strfind(
**int
list,
int
list_size,
*int
str);
Try and find the string in a list, and return its index, or 0.
float
atof(
*int
str);
Convert the given float to a string
int
readfloatarray(
*float
out,
int
outcount,
*int
str);
Read the given string as an array of floats
textureutils.pur3h
int
texCreateRadialAlpha(
int
width,
int
height);
Create a texture that is just a radial gradient of alpha (that's white)
Radial alpha - like texCreateRadialAlpha, but better suited to vignettes
Radial colour
int
texCreateRoundedBox(
int
width,
int
height,
int
radius);
Create box with rounded corners
int
texCreateBlendedBox(
int
width,
int
height,
int
radius);
Create box with smooth rounded corners - for shadows
int
texCreateFabric(
int
r,
int
g,
int
b);
create jeans-like fabric texture (try 96,128,192)