MojoWorld SDK
Documentation
(Version 0.1)

Craig McNaughton
Copyright 2000,2001,2002
Pandromeda Inc.


 
CONTENTS

A Novice's Introduction

Development Environment
Library Layout
Class Hierarchy
Overview of Base Classes
Additional Classes (not in the hierarchy)
Basic Types
    Plugin Types
    Parameter Types
Plugin File Basics
   Loading and Saving
Steps in Creating a Plugin
Class Descriptions
   Atmosphere
   Backdrop
   BBox2d
   BBox3d
   Camera
   CloudLayer
   Color
   ColorA
   Core
   Curve
   CurveHolder
   FunContext
   Function
   HelperObject
   ImageFileHandler
   Light
   Material
   Matrix
   Noise
   Object
   Param
   ParamObj
   Plugged
   Plugin
   PreviewObject
   Quaternion
   Renderer
   RenderObject
   Satellite
   SParam
   SubPrimitive
   Vec2d
   Vec3d
   Vec4d
 

Development Environment

The MojoWorld SDK is designed to allow plugin development on Windows and Macintosh. While it may be possible to develop plugins under different environments, the following are the recommended:

  • Windows : Microsoft Visual C/C++ 6.0
  • Macintosh : CodeWarrior 7.1

 

Library Layout

MojoWorld is spread across a number of shared libraries. These are:

  • MojoOhNo.dll: An error handling library. Contains functions to check for and report errors, and a number of utility methods that are used in many places.
  • MojoUI.dll: User interface library for creating the MojoWorld and MojoVox user interface. As all user interface elements for plugins are created procedurally, plugins will not need to link with this.
  • MojoUtil.dll: Utility and base type library. Contains classes for all the basic MojoWorld types (Vectors, matrices, etc), and common classes for handling bitmaps, file streams and other utilities.
  • wxMojo.dll: A modified version of wxWindows, a cross platform user interface library (http://www.wxwindows.org). Although not providing direct user interface support, plugins can link with this to utilize any of the wxWindows utility methods.
  • Mojo.dll: The core MojoWorld shared library. Contains all the base class definitions for the MojoWorld, the planet and ocean implementations, memory allocation methods and various other things.

 

Class Hierarchy

Most of the base classes for MojoWorld fit into the class hierarchy laid out below. See the next section for a brief description of each class.

    Plugged
        Renderer 
        ParamObj
            Function
            Atmosphere
            Noise
            Material
            Backdrop
            CloudLayer
            ImageFileHandler
            Object
                PreviewObject
                    RenderObject
                    Camera
                    Light
                    HelperObject
                    Satellite

 

Overview of Base Classes

Plugged
This is the base class from which all plugins are derived. It provides basic identification routines for the plugin manager.

Renderer
All renderers derive from this. Provides methods for preparing to render, rendering to a bitmap and tidying up. Adding additional plugin renderers is currently beyond the scope of the SDK.

ParamObj
The base class for any plugin that has user controls. It provides control over parameters, dependency on other ParamObjs, sub-object control, curve control and gradients. It also handle dependency information, UI callbacks, loading and saving, and state information.

Function
The basis of the texture graph. Provides evaluation methods for a standard set of data types, for both a single instance and an array of instances.

Material
All shading is controlled by materials. Provides shading routines for the real time and photorealistic renderers.

Atmosphere
Provides global volumetric effects for a planetary atmosphere. Has methods to integrate the atmosphere along a line segment and to provide approximations to the real time renderer.

Backdrop
Provides a simple background texturing routine. Used for fast simple skies, star fields, etc. Has a shading routine for given view direction.

Object
The base class for anything that has a three dimensional position in space. Provides methods for object transformations.

PreviewObject
Base class for anything that wishes to draw a representation of itself in the real time renderer. Provides methods for creation, preparing and drawing, and selection in the real time renderer.

Camera
Base for any viewing method. Provides methods for setting viewing direction and other vectors, generating rays for pixels on the screen, and transforming to/from camera space. Currently the SDK does not support creation of new plugin cameras.

Light
All lights derive from this. Provides methods for getting the color and direction on incoming light for points in space and for controlling shadow casting.

RenderObject
Base class for anything that needs to be rendered as final geometry. Provides methods for splitting/dicing into micropolygons, and setting shadow and material information.

Noise
A simple noise basis function. Provides methods to evaluate single value and vector value results at a given point in multiple dimensions. Also provides methods for returning frequency information and average value.

CloudLayer
A single layer of cloud in the atmosphere. Provides methods to control the layer altitude and to shade the clouds.

Satellite
Provides control and real time rendering methods for anything that orbits the planet. Used for both Sun and Moons. The rendering methods are used for real time only and the final render uses geometry from the RenderObject that a Satellite will be controlling.

HelperObject
Base class for objects which define a local space on the planet (otherwise known as Parameter Bombs). Provides methods for converting from/to local helper space and terrain export.

ImageFileHandler
Base class for loading and saving images. Provides methods to specify image extensions and handling single images and image sequences.

 

Additional Classes (not in the hierarchy)

Param
Base class for animatable parameters. Provides get/set methods at specific times and overriding functions.

SParam
Templated class for the varying parameter types. Provides access to interpolated data at arbitrary times.

FunContext
A class that gets passed around anytime any evaluation of parameters needs to be done. Contains all the relevant information for the current task at hand. E.g. height functions will get time, point in space, size of sample. Shading functions will also get things like altitude, slope, viewing direction, lights, etc.

Plugin
Support class for each plugin type. Describes the plugin to the internal plugin manager.

SubPrimitive
Support class for the standard renderer. Each RenderObject must provide a SubPrimitive class if it wishes to be renderable with the standard renderer. Provides methods for splitting itself into multiple smaller SubPrimitives and dicing itself into a rectangular grid of Micropolygons.

Curve
Provides support for a single parameteric cubic curve.

CurveHolder
A wrapper class to handle either a single curve or a triple of curves for RGB colors.

Core
A global class holding pretty much all the useful information about the current scene.

 

Basic Types

In order to maintain platform independence, the following basic types are defined and should be used in place of standard C++ types. This ensures that sizeof() returns consistent values across all platforms.

int8, int16, int32 : signed 8, 16, and 32 bit integers
uint8, uint16, uint32 : unsigned 8, 16, 32 bit integers
real, real64 : single and double precision floating point numbers
flag : Boolean value

The following classes are also available for more complex types

Vec2d, Vec3d, Vec4d : double precision floating point vectors
Quaternion : double precision orientation class
Matrix : 4x4 transformation matrix, double precision floating point
Color, ColorA : RGB triple, and RGB triple with alpha
BBox3d, BBox2d : 2 and 3 dimensional bounding boxes

To reduce memory use, the following single precision floating point types are also available.

fVec2d, fVec3d, fColor, fBBox2d

 

Plugin Types

The following constants are used to define what task a plugin performs and hence what class it is being derived from.

    enum OTYPE { 
        objFunction,
        objMaterial,
        objPrimitive,
        …,   
        objLight,
        objCamera,         
        objHelper,          
        objAtmosphere,
        objBackdrop,
        …,  
        objRenderer,
        …,
        objImageFormat,
        objNoise,
        objSatellite,
        …, 
        objCloudLayer,
        objMarker,
        objUndefined = 9999999
    };
Other values in the OTYPE are reserved for either internal or future use.

objFunction : A plugin that derives from Function and provides a node in the function graph. E.g. MonoFractal, Add, Blend.

objMaterial : A plugin that derives from Material and provides surface shading capabilities. E.g. Displacement Material, Blend Material.

objPrimitive : A plugin that derives from RenderObject and provides a solid primitive to the renderer. E.g. Planet, sphere, polygon mesh.

objLight : A plugin that derives from Light and provides an implementation of a light source. E.g. sunlight, Spot light.

objCamera : A plugin that derives from Camera and provides an implementation of a viewing geometry.

objHelper : A plugin that derives from PreviewObject and provides a tool for placement of other things. E.g. Parameter Bomb helper.

objAtmosphere : A plugin that derives from Atmosphere and provides a global atmospheric effect. E.g. Cloudy Atmosphere.

objBackdrop : A plugin that derives from Backdrop and provides a background texture behnd all geometry, atmosphere and volumes.

objRenderer : A plugin that derives from Renderer and provides a photorealistic render of the scene.

objImageFormat : Load/save for various image formats E.g. TIFF, PNG, JPEG.

objNoise : A plugin that derives from Noise and provides a basis function for fractals. E.g. Gradient Noise, Voronoi.

objSatellite : A plugin deriving from Satellite, providing control over an object and light source as a satellite of the planet.

objCloudLayer : A plugin providing a simple layered cloud at a defined altitude. Note that the renderer does not handle cloud layers natively, but relies on the atmosphere to incorporate any cloud layers into its calculations.

objMarker : Anything deriving from PreviewObject that just provides a simple visual indicator in the real time renderer. E.g. Marker Flags.

 

Parameter Types

A ParamObj can have multiple parameters (each represented by a Param class), which will have a user interface for them procedurally built from the parameter definition.

The following types currently supported by the Param class:

    enum PTYPE { 
        typeInt,
        typeDouble,
        typeVec2d,
        typeVec3d,
        typeVec4d,
        typeQuaternion,      
        typeColor,
        typeColorA,
        typeString,
        typeUndef=9999999
    };
typeInt : A signed 32 bit integer
typeDouble : A double precision floating point number
typeVec2d : A 2D vector of double precision floating point
typeVec3d : A 3D vector of double precision floating point
typeVec4d : A 4D vector of double precision floating point
typeQuaternion : A 4D vector representing a rotation as a quaternion, double precision floating point.
typeColor : RGB color triple, stored as double precision floating point
typeColorA : RGB and Alpha color value, stored as double precision floating point
typeString : A variable length character string.
typeUndef : In some cases, parameter types are not defined until the return value is defined. This type is used to indicate a currently undefined parameter type.

 

Plugin File Basics

Each plugin must provide two functions to allow the plugin objects to be registered by the system.

int32 NumPlugs()
Returns the number of plugins that are defined in this DLL file.

Plugin *Plugin(int32 i)
Returns a pointer to a Plugin class that describes the particular numbered plugin.

 

Loading and Saving

Each plugin is responsible for loading and saving any local data that needs to persist across differing invocations of the file. In order to maintain the hierarchy of the scene graph, each plugin in the scene is given a unique ID prior to saving and that ID is written to the file as part of the save data for each plugin. A plugin that requires a pointer to another object to persist should find the ID of that object at save time and write it to the file as part of its data. Loading is then a 2 pass process. First, each plugin's object ID is read from the file, an instance is created and that instance's Load() method is called to get all the data from the file. This data will include the unique ID of the object whose pointer you require. The second pass will call the PostLoad() method, which can find the objects based on the ID's that were saved.

In general, any plugin's Load/Save/PostLoad methods will also call the relevant method of its class parent to make sure that everything relevant to the parent is also loaded/saved properly. If plugins stick to this, then all the parameters, curves, dependencies and everything else that is managed by its class parents will be loaded and saved automatically.

As an example, here are code chunks from the RenderObject Load and Save methods. The only pointer it needs to maintain is the material pointer.

flag RenderObject::Save(FileStream *out)
{
    PreviewObject::Save(out);
    // make sure everything in classes below us gets saved
    …
    if (mtl)
        fwrite(&mtl->saveID, sizeof(uint32), 1, out);
        // write the ID of the material to the file
        // if there is one
    else
    {
        uint32 dd = 0;
        fwrite(&dd, sizeof(uint32), 1, out);
        // write a zero to the file, indicating a NULL pointer.
    }
    …
}

flag RenderObject::Load(FileStream *in)
{
    PreviewObject::Load(in);
    // make sure everything in classes below us is loaded.
    …

    fread(&mtlID, sizeof(uint32), 1, in);
    // read the ID of the material
    // The pointer will be found in PostLoad()

    …
}

flag RenderObject::PostLoad(TList *list)
{
    PreviewObject::PostLoad(list);
    // make sure everything in classes below us gets
    // linked up properly.
    …

    // Find the pointer of the node with the ID we loaded.
    // If that ID doesn't exist, or the ID is zero,
    // NULL will be returned.
    mtl = (Material *)FindNodeWithID(list, mtlID);
    …
}
 
Steps in Creating a Plugin

Having decided what the new plugin will do and which plugin type it best fits under, there are a few standard things that need to be done to provide the framework in which it will perform its function.

We'll look at the Distance function node as an example of how this process works. The Distance node is a very simple node with two 3D vector parameters that simply returns the distance between the two points specified by the parameters.

The first two things that need to be defined are the class definition for the main plugin class (derived from class Function in this case) and the description class to tell the plugin manager what this plugin does (derived from class Plugin).

Here's the header file for the FDistance plugin, showing these.

#define FDISTANCE_OBJ_ID      0x00000003
Each plugin gets a unique 32 bit numerical ID. All internal Pandromeda plugins will have the high bit of the ID set to zero (E.g. 0x00000000 to 0x7fffffff). Third party developers should make sure the high bit is set to 1 to avoid ID clashes (E.g. 0x80000000 to 0xffffffff).

This is the class that defines the functionality of our new plugin. It overrides virtual functions from Plugged, ParamObj and Function to do its work.

class FDistance : public Function
{
public:

    // constructor/destructor
    FDistance();
    ~FDistance();

    // Things needed by ParamObj
    void Update(int32 which, FunContext *fc);
    MojoString ClassName();
    ID UniqueID();
    OTYPE ObjectType();

    // Things needed by Function
    void Eval(int32 &v, FunContext *fc);
    void Eval(real64 &v, FunContext *fc);
    void Eval(Vec2d &v, FunContext *fc);
    void Eval(Vec3d &v, FunContext *fc);
    void Eval(Vec4d &v, FunContext *fc);
    void Eval(Quaternion &v, FunContext *fc);
    void Eval(Color &v, FunContext *fc);
    void Eval(ColorA &v, FunContext *fc);
    void Eval(MojoString &v, FunContext *fc);
    // Typed Vector evals, this time taking a vector of
    // FunContext's and doing everything at once
    void SIMDEval(int32 *v, FunContext *fc, int32 xs, int32 ys);
    void SIMDEval(real64 *v, FunContext *fc, int32 xs, int32 ys);
    void SIMDEval(Vec2d *d, FunContext *fc, int32 xs, int32 ys);
    void SIMDEval(Vec3d *d, FunContext *fc, int32 xs, int32 ys);
    void SIMDEval(Vec4d *d, FunContext *fc, int32 xs, int32 ys);
    void SIMDEval(Quaternion *d, FunContext *fc, int32 xs, int32 ys);
    void SIMDEval(Color *d, FunContext *fc, int32 xs, int32 ys);
    void SIMDEval(ColorA *d, FunContext *fc, int32 xs, int32 ys);
    void SIMDEval(MojoString *v, FunContext *fc, int32 xs, int32 ys);
    MojoString Category() { return MojoString("Math Nodes"); };
};
This is the descriptor class that the plugin manager uses to know what this plugin does and what it's called.
class FDistancePlug : public Plugin
{
public:
    ID UniqueID() { return FDISTANCE_OBJ_ID; };
    OTYPE Type() { return objFunction;  };
    MojoString Description() { return MojoString("Distance"); };
    Plugged *Create() { return new FDistance; };
};
Once we've defined the main class, we can start filling in the methods that we need to override the standard methods in the base classes. The first (and easiest) to tackle are the methods from class Plugged.

UniqueID() identifies the plugin. It must return the same value as the plugin descriptor FDistancePlug.

ID FDistance::UniqueID()
{
    return FDISTANCE_OBJ_ID;
}
ObjectType() tells the system what kind of thing we are. In this case, we're a function node. This must return the same type as the FDistancePlug::Type() method.
OTYPE FDistance::ObjectType()
{
    return objFunction;
}
ClassName() is a simple descriptive name for what this plugin does. (Currently, MojoString is defined as std::string, but plugins should always use MojoString to ensure future compatibility.)
MojoString FDistance::ClassName()
{
    return MojoString("Distance");
}
Next, we should look at the constructor and destructor. The constructor of anything that derives from ParamObj is where the parameters are created and initial values set up.
FDistance::FDistance() : Function()
{
    // initialize the params
    numParams = 2;
    params = new ParamPtr[numParams];
    // param 0 : position 1
    params[0] = new SParam<Vec3d>(this, Vec3d(0.0, 0.0, 0.0));
    params[0]->canFunction = TRUE;
    params[0]->name = MojoString("Distance position1");
    // param 1 : position 2
    params[1] = new SParam<Vec3d>(this, Vec3d(0.0, 0.0, 0.0));
    params[1]->canFunction = TRUE;
    params[1]->name = MojoString("Distance position2");
    name = ClassName();
}
We allocate the array of parameter pointers and create a parameter for everything that will have a user control. The canFunction flag lets us control whether or not another function node can be used to drive the value of this parameter. For the Distance node we do want to be able to drive these with functions (as its main use is generally finding distance from the current world position to a known object), but for parameters on other nodes, it might not make sense (E.g. it makes no sense to drive the filename for a bitmap node from another function).
FDistance::~FDistance()
{
}
The ParamObj destructor will take care of deleting any parameters, gradients, curves or sub-plugins that we allocate in our constructor. Anything else that is for our own internal use should be deleted here.

Now we can look at the methods of ParamObj that we need to override. The main method that will generally be needed is the Update() method.

void FDistance::Update(int32 which, FunContext *fc)
{
    Function::Update(which, fc);
}
The Update() method will be called with the number of the parameter that has changed, or -1 if something other than a parameter has changed. For our Distance node, we don't need to do anything special when a parameter changes, so we technically don't need the Update() method, but it is included as a matter of consistency. The main use for the Update() method is to update any cached values of parameters that can't have a function connected and any internal information based on these parameters. For example, the Planet radius can't have a function connected, but when its value changes, the Planet primitive needs to regenerate preview information for the real time renderer.

The last thing we need are the methods to actually evaluate the distance value. For functions, it's quite common for there to be a "native" type that they work in and to use the converter to provide results in different types. In this case, we have a "native" double precision version and all the other versions just use the converter.

// The native real64 version that does all the work
void FDistance::Eval(real64 &v, FunContext *fc)
{
     Vec3d pos1, pos2;

     pos1 = params[0]->GetVec3d(fc);
     pos2 = params[1]->GetVec3d(fc);

     pos1 -= pos2;

     v = pos1.Length();
}
This version evaluates the result as a double precision floating point (real64) number. It gets the two 3D vectors from the parameters and finds the distance between them. The FunContext that gets passed in provides all the necessary base information that the renderer can provide (e.g. World Position, surface normal, slope, etc). A node can either access this information directly (e.g. the World Position node just returns the position value directly from the context), or pass this context onto the parameters so they (and their connection functions) can use that information.
void FDistance::Eval(int32 &v, FunContext *fc)
{
    real64 d;
    Eval(d, fc);
    param->conv->convert(d, v);
}
The integer version just evaluates the result as a real64 and then uses the converter that the parameter provides to convert that to an integer. Doing this is a simple convenience when the behavior isn't dependant on the type. When the result is dependant on the required type, or maximum efficiency is required, all the different type versions of the Eval methods can be different. For example, the noise node only needs to evaluate a single noise value for the real64 version, but requires 3 noise evaluations for the Vec3d and Color versions.
void FDistance::SIMDEval(real64 *v, FunContext *fc, int32 xs, int32 ys)
{
    Vec3d *pos1, *pos2;
    pos1 = (Vec3d *)GlobalCore()->simdStack.Push(xs*ys*sizeof(Vec3d));
    pos2 = (Vec3d *)GlobalCore()->simdStack.Push(xs*ys*sizeof(Vec3d));

    params[0]->SIMDGetVec3d(pos1, fc, xs, ys);
    params[1]->SIMDGetVec3d(pos2, fc, xs, ys);

    for (int32 i = 0; i<xs*ys; i++)
    {
        pos1[i] -= pos2[i];

        v[i] = pos1[i].Length();
    }
    GlobalCore()->simdStack.Pop();
    GlobalCore()->simdStack.Pop();
}
The SIMDEval methods are used by the renderer to provide much better filtering of the final value. They are passed a 2D array of contexts and evaluate the result at all points in the array, returning a 2D array of results. For a simple node like Distance, whose behavior isn't dependant on sample sizes, this can be implemented as a simple loop over all the points in the array. More complex nodes like the fractals (who calculate the number of octaves of noise to evaluate based on the distance between sample points) can examine the neighbors of each point in the array to get a reasonably accurate measure of the size of the required sample area. The simdStack.Push() and Pop() methods provide more efficient memory handling than calling new and delete for the temporary storage required.

Note that for function nodes, some of the required return types don't make much "sense" in terms of getting a useful value. Asking for the distance between two points as a quaternion doesn't have any useful meaning. In these cases, always use the Convert() method to convert from a sensible type. While this doesn't provide any more meaningful information, it guarantees a consistent value, and one that is at least numerically sensible.

The final step is to set up the DLL functions that the core actually calls to get information about the plugins in a particular plugin file.

extern "C" __declspec(dllexport) int32 NumPlugs() 
{ 
    return 1; 
}
A plugin file can have any number of plugins of any type in it. Every time you add a new plugin to a plugin file, just increment this number.
extern "C" __declspec(dllexport) Plugin *Plugin(int32 i)
{
     case 0:
          return new FDistancePlug;
     default:
          return NULL;
     }
}
The Plugin() function just returns a pointer to the plugin descriptor for the numbered plugin. Remember to add a new case to this each time you add a new plugin to the plugin file, or the core code won't see your new plugin!

(The __declspec(dllexport) syntax above is for Win32 plugins under Visual C++. Other platforms may use differing compiler directives. Check the sample code for your particular platform.)

We have included sample code for most of the plugin types that can be added to MojoWorld. In most cases, this is the actual code that we use to ship MojoWorld. We strongly recommend using this code and projects as a starting point for any plugin development, as there are many platform specific compiler and project settings that can cause headaches if not set correctly.

 

Class Descriptions

This is an alphabetical list of all relevant classes for plugin creation and documentation on each method and member.

 

Atmosphere

class Atmosphere : public ParamObj
This class provides for global atmospheric effects.

Methods:

Atmosphere() : ParamObj()
Constructor. Should create any parameters required.

virtual ~Atmosphere()
Destructor. Frees any local data. Parameters are freed by the ParamObj destructor and don't need to be done here.

virtual void Fog(FunContext *fc, ColorA &col) = 0
Main shading routine. Given the color and the point defined in the shading context, modify the color to include the effects of the atmosphere between the camera location and context point. This method is obsolete and should generally be implemented as a call to the more general purpose Fog() method below.

virtual void Fog(FunContext *fc, ColorA &col, const Vec3d &start, const Vec3d &end, flag isDir = false) = 0
Main shading routine. Given the input color, modify the color to include the effects of the atmosphere between the start and end points given. If the isDir flag is true, then the end point is assumed to be a direction vector rather than a point in space and the atmosphere should be applied from the start point out to an infinite distance, in the direction given by the end parameter.

virtual void GLSetup(FunContext *fc) = 0
Called by the real time renderer to set up an approximation to the fog using OpenGL calls. The Atmosphere should make whatever calls to the glFog*() routines to set up the best approximation it can. No assumptions should be made about the current state of OpenGL.

virtual flag BackgroundColor(FunContext *fc, Vec3d *directions, int numDirs, Color *colors) { return false; }
Evaluates an array of colors to be used as the backdrop for the real time renderer. Each evaluation should start at the camera eye point (the camera is available in the FunContext) and evaluate to infinity in the direction given by the directions array. This method should return true if the array of colors has been properly set, or false if this is unsupported for a particular atmosphere. (E.g. if your atmosphere is very slow, RTR performance may suffer.)

 

Backdrop

class Backdrop : public ParamObj
A class to provide simple background textures. Backdrops are considered as a texture or color at infinity, beyond all atmospheric effects and geometry.

Methods:

Backdrop() : ParamObj()
Constructor. Create any parameters, curves or subobjects required.

virtual ~Backdrop()
Destructor. Frees up any local data.

virtual Color Shade(FunContext *fc) = 0
Main shade routine. Takes the view direction vector in the FunContext and returns a color visible in that direction.

 

BBox2d

class BBox2d
Provides a 2 dimensional axis aligned bounding box. If the minimum values are greater than the max, then the box is considered empty.

Data:

Vec2d min, max;
The corners of the bounding box.

Methods:

inline BBox2d(Vec2d mn, Vec2d mx)
Constructor. Initialises the corners to the passed values.

inline BBox2d()
Constructor. The corners are not initialized.

real64 MaxDimension()
Returns the maximum side length of the box.

BBox2d Intersection(BBox2d bb)
Returns a box which represents the area of intersection of this box and box bb.

flag Empty()
Returns TRUE if this box has no area.

void Include(Vec2d p)
Updates the box corners to include the passed point.

inline flag Inside(Vec2d v)
Returns TRUE if the given point is inside the box.

inline flag FudgeInside(Vec2d v, real64 ff = 0.0)
Returns TRUE if the point is inside the enlarged box obtained by extending the box by ff in each axis.

[The analogous class fBBox2D provides identical functionality with single precision floating point vectors.]

 

BBox3d

class BBox3d
Provide a 3 dimensional axis aligned bounding box.

Data:

Vec3d min, max;
Corners of the box.

Methods:

inline BBox3d(Vec3d mn, Vec3d mx)
Constructor. Initializes the corners to the passed vectors.

inline BBox3d()
Constructor. The corners are not initialized.

real64 MaxDimension()
Returns the length of the longest side of the box.

BBox3d Intersection(BBox3d bb)
Returns a 3D box representing the area of intersection of this box and the passed argument.

flag Empty()
Returns TRUE if the box has no volume.

void Include(Vec3d p)
Updates the box corners to include the passed point.

BBox3d operator*(const Matrix &m)
Transforms the box by the given matrix and returns the new bounding box of the transformed corners. Because each box must remain axis aligned, successive transformations will reduce the tightness of a box around a given set of points.

void GetCorners(Vec3d *corners)
Passed an array of 8 vectors, this method enumerates all the corner locations of the box.

 

Camera

class Camera : public PreviewObject
Provides a base class for representation of a viewing geometry. How to store the actual viewing parameters is up to the plugin. Most often they'll be done via parameters.

Data:

flag changed
(protected) Flag to say whether the viewing parameters have changed since this was last reset. If they haven't changed, then preview objects that adapt to the view (ie planets) can use their last cached representation and don't need to update.

real64 wxs, wys
Size of the image plane in world coordinates, at a unit distance from the eye. Directly calculated off the field of view and the aspect ratio.

real64 aspect
Aspect ratio of the image, width divided by height.

real64 pixelAspect
The aspect ratio of the pixels in the image. Most often 1.0, but PAL and NTSC video have differing values. (In MojoWorld 1.0, all cameras will have a pixel aspect of 1.0)

flag ortho
Is this camera orthographic or perspective? (Note : orthographic cameras are only used internally for shadow map calculations. Creating a new orthographic camera for general use will almost certainly flummox MojoWorld.)

int32 ixs, iys
Size of the current image plane in pixels.

real64 closeClip, farClip
Current near and far clipping planes for the real time renderer. The photorealistic renderers will be much more generous than these, if clipping at all.

Methods:

Camera()
Constructor. Initializes the data members to sensible defaults. A plugin should also create whatever parameters it needs to store the eye point etc, and initialize those to sensible defaults as well.

virtual ~Camera()
Destructor.

virtual void SetEyePoint(Vec3d eye, FunContext *fc) = 0
Sets the eye point of the camera (in world space) at the time given in the FunContext.

virtual Vec3d GetEyePoint(FunContext *fc) = 0
Gets the eye point (in world space) at the given time.

virtual Vec3d GetUpVec(FunContext *fc) = 0
Gets the up vector (in world space) at the given time.

virtual Vec3d GetDirVec(FunContext *fc) = 0
Gets the direction vector (in world space).

virtual Vec3d GetRightVec(FunContext *fc) = 0
Gets the right hand vector of the camera at the given time.

virtual void SetFOV(real64 fov, FunContext *fc) = 0
Sets the horizontal field of view (in radians) at the given time. This is the field of view used by the real time renderer and may not represent the actual camera field of view if the image aspect of the RTR and the current render setting do not match. Use SetUIFOV() to set the actual FOV that the renderer will use.

virtual real64 GetFOV(FunContext *fc) = 0
Gets the horizontal field of view (in radians) at the given time for the RTR. (See SetFOV() for comments.)

virtual void SetUIFOV(real64 fov, FunContext *fc) = 0
Sets the horizontal field of view (in radians) that will be used by the renderer. Use this method rather than SetFOV() to exactly define the horizontal FOV that will be rendered.

virtual real64 GetUIFOV(FunContext *fc) = 0
Gets the horizontal field of view (in radians) at the given time. (See SetUIFov().)

virtual void SetOrientation(const Quaternion &orient, FunContext *fc) = 0
Sets the global orientation of the camera to the given quaternion.

virtual void SetOrientation(const Vec3d &dir, const Vec3d &up, FunContext *fc) = 0
Sets the global direction vector and up vector for the camera to the given values. The right vector is calculated at right angles to both of these.

virtual void UpdateOrientation(const Quaternion &orient, FunContext *fc) = 0
Update the camera's orientation by multiplying its current orientation by the passed quaternion.

virtual void GetOrientation(Quaternion &orient, FunContext *fc) = 0
Gets the current global orientation of the camera as a quaternion.

virtual void GetOrientation(Matrix &orient, FunContext *fc) = 0
Gets the current global orientation of the camera as a 4x4 matrix. Note that the matrix will only represent the orientation and will not include the translation component to the current eye point.

virtual real64 FindCurrentHeading();
Finds the current heading of the camera in the range 0.0 to 1.0. Both 0.0 and 1.0 represent North in terms of the planet, 0.5 is South.

virtual void TurnToHeading(real64 ang)
Sets the current heading of the camera, given as 0.0 to 1.0.

virtual void GetLatLong(real64 &longitude, real64 &latitude)
Returns the current latitude and longitude of the camera in radians.

virtual void SetLatLong(real64 longitude, real64 latitude)
Sets the current latitude and longitude of the camera to the passed values (in radians). Maintains the current heading, roll and pitch of the camera.

virtual real64 GetCurrentPitch()
Returns the current pitch of the camera, where -1.0 is looking directly down, 0.0 is level and 1.0 is looking directly up.

virtual real64 GetCurrentRoll()
Returns the current roll of the camera, 1.0 is rolled upside down to the right, 0.0 is level and -1.0 is rolled upside down to the left.

virtual void SetCurrentPitch(real64 pitch)
Sets the current pitch value of the camera. See GetCurrentPitch().

virtual void SetCurrentRoll(real64 roll)
Sets the current roll value of the camera. See GetCurrentRoll().

virtual void SetPitchAndRoll(real64 pitch, real64 roll)
Sets both the pitch and roll in a single calculation. Much more efficient than separate SetCurrentPitch() and SetCurrentRoll() calls.

virtual real64 PixelSize(Vec3d point) = 0
Returns an estimate of the size of a pixel in world space at the given point. This can be used where no information is available about adjacent shading points (as in the Function::SIMDEval() methods) and where the FunContext::dP value has not been correctly calculated.

virtual void SetAspect(real64 aspect, FunContext *fc)
Sets the aspect ratio of the camera and updates the image plane world size based on the current field of view and the new aspect ratio.

virtual void GenerateRay(Vec2d screen, Vec3d &from, Vec3d &dir) = 0
Generates a start point and a direction vector for the given pixel on the screen. Pixel coordinates are passed as 0.0..1.0 in both x and y.

virtual flag WorldToScreen(Vec3d p, Vec2d &pp) = 0
Maps a point in world space to a pixel coordinate. Pixel coordinates are in the range 0.0..1.0 for both x and y. Returns TRUE if the point is on screen, false otherwise. It's possible to get pixel coordinates with in the range of 0.0..1.0 and still have a point off screen if the point is behind the eye, so use the return value rather than relying on checking the bounds of the pixel value.

virtual void WorldToEye(Vec3d p, Vec3d &ep, Matrix *tw = NULL) = 0
Converts a point in world space to a point in camera space. Camera space is defined as point located at the origin, looking down the negative Z axis. If the point starts in the primitive space of an object, you can pass the object's primitive to world transform in tw and it'll be taken into account.

virtual flag EyeToScreen(Vec3d p, Vec2d &sp) = 0
Converts a point in camera space to a pixel coordinate. Pixel coordinates are in the range 0.0..1.0 for both x and y. Also see notes for WorldToScreen().

virtual Vec3d ScreenToWorld(Vec2d p, real64 depth = 1.0) = 0
Converts a point in pixel coordinates (0.0..1.0 in x and y) to a point in world coordinates, a distance depth away from the eye point.

virtual void EyeToWorld(Vec3d eyeP, Vec3d &wp) = 0
Converts a point in camera "eye" space to world space. See WorldToEye().

virtual void FindCamBounds(BBox3d pb, BBox3d &cb, Matrix *tw = NULL) = 0
Converts the primitive space bounding box pb to a camera space bounding box cb. If the matrix pointer is NULL, it's assumed that pb is currently in world space.

virtual void FindScreenBox(BBox3d cb, BBox2d &sb) = 0
Converts a 3 dimensional camera space bounding box to a 2 dimensional screen space bounding box. Screen coordinates are 0.0..1.0 for both x and y.

virtual flag Load(FileStream *in)
Loads information from the file stream for the camera geometry.

virtual flag Save(FileStream *out)
Saves information about the camera geometry to the current file stream.

virtual flag PostLoad(TList *list)
Finds the nodes in the list with ID's which match those returned from Load() and reconnects the nodes. See the initial notes on Loading and Saving for more information.

virtual Plugged *Clone(flag func = true, flag subP = true)
Creates and returns a duplicate of the camera. See ParamObj::Clone() for more information.

 

CloudLayer

class CloudLayer : public ParamObj
A spherical cloud shell. It is the responsibility of the atmosphere to interpret the effect of cloud layers, they are not handled by the renderer natively.

Data:

flag excludeMe
(protected) A flag specifying whether the cloud layer should be taken into account by the atmosphere when rendered.

Methods:

CloudLayer() : ParamObj()
Constructor. Sets the excludeMe flag to false.

virtual ~CloudLayer()
Destructor.

virtual real64 GetHeight() = 0
Returns the height of the cloud layer.

virtual void SetHeight(real64 height) = 0
Sets the height of the cloud layer.

virtual void Shade(FunContext *fc, ColorA *col, real64 *atten = NULL) = 0
The main shading method. Modifies the color to include the effect of the cloud and returns the amount of light attenuated throught the cloud. Both the col and atten parameters may be NULL, indicating that particular result isn't required.

flag Excluded()
Returns the value of the excludeMe flag.

 

Color

class Color

A 3 component RGB color class.

Data:

real64 r, g, b
The red, green and blue color values. Generally they'll be in the range 0.0..1.0, but not necessarily.

Methods:

inline Color(real64 pr, real64 pg, real64 pb)
Constructor. Initializes the red, green and blue values.

inline Color(int32 ir, int32 ig, int32 ib)
Constructor. Initializes the color values. Assumes the arguments are in the range 0..255 and divides appropriately.

inline Color()
Constructor. Color values are undefined.

inline Color(const Color &c)
Constructor. Copies color values from the passed color.

inline Color(const Vec3d &v)
Constructor. Assumes the x, y, z values of the vector correspond to r, g, b.

inline real64 &operator[] (const int32 i)
Indexes the color as an array in the order red = 0, green = 1, blue = 2.

inline Color operator+(const Color &v)
inline Color &operator+=(const Color &v)
Adds two colors together, component by component.

inline Color operator-(const Color &v)
inline Color &operator-=(const Color &v)
Subtracts the passed argument from the color.

inline Color operator*(const Color &v)
inline Color &operator*=(const Color &v)
Multiplies by the passed argument.

inline Color operator/(const Color &v)
inline Color &operator/=(const Color &v)
Divides the color by the components of the passed argument.

inline Color operator+(const real64 &v)
inline Color &operator+=(const real64 &v)
Adds the passed constant to each component of the color.

inline Color operator-(const real64 &v)
inline Color &operator-=(const real64 &v)
Subtracts the passed constant from each component.

inline Color operator*(const real64 &v)
inline Color &operator*=(const real64 &v)
Scales each component by the passed constant.

inline Color operator/(const real64 &v)
inline Color &operator/=(const real64 &v)
Divides each component by the passed constant.

inline Color& operator=(const Color& v )
Color assignment.

inline int32 operator ==(const Color amp;&v)
Test for equality between two colors. Doesn't do any epsilon check, so is not very robust.

inline int32 operator !=(const Color &v)
Inequality check between two colors.

inline void Clamp()
Clamps the values of each component to be in the range 0.0..1.0. This is a nasty way of doing this and can introduce hue and saturation shifts.

inline void ClampPositive()
Ensures that all components of the color are greater than or equal to zero.

Inline bool IsBlack()
Returns TRUE if all three color components are less than a very small epsilon.

void RGBtoHSV()
Converts the internal representation from RGB to HSV. HSV values are (typically) in the range 0.0 to 1.0.

void HSVtoRGB()
Converts the internal representation from HSV to RGB.

[There is also the analogous class fColor, which stores the colors as single precision floating point internally.]

 

ColorA

class ColorA
A 4 component red, green, blue, alpha color class.

Data:

real64 r, g, b, a
Red, green, blue and alpha color components.

Methods:

inline ColorA(real64 pr, real64 pg, real64 pb, real64 pa)
Constructor. Initializes the four components.

inline ColorA(int32 ir, int32 ig, int32 ib, int32 ia)
Constructor. Initializes the components. Assumes the integer arguments are in the range 0..255 and divides accordingly.

inline ColorA()
Constructor. Color components are left undefined.

inline real64 &operator[] (const int32 i)
Indexes the color as an array in the order red = 0, green = 1, blue = 2, alpha = 3.

inline ColorA(const ColorA &c)
Constructor. Copies the components from the arguments.

inline ColorA(const Color &c)
Constructor. Copies red, green, blue from the argument and sets alpha to 1.0

inline ColorA(const Vec4d &v)
Constructor. Assumes that x, y, z, w of the vector correspond to r, g, b, a.

inline ColorA operator+(const ColorA &v)
inline ColorA &operator+=(const ColorA &v)
Adds to ColorA, component by component.

inline ColorA operator-(const ColorA &v)
inline ColorA &operator-=(const ColorA &v)
Subtracts the argument, component by component.

inline ColorA operator*(const ColorA &v)
inline ColorA &operator*=(const ColorA &v)
Multiplies by the argument, component by component.

inline ColorA operator/(const ColorA &v)
inline ColorA &operator/=(const ColorA &v)
Divide by the argument, component by component.

inline ColorA operator+(const real64 &v)
inline ColorA &operator+=(const real64 &v)
Adds the constant to all components.

inline ColorA operator-(const real64 &v)
inline ColorA &operator-=(const real64 &v)
Subtracts the constant from all components.

inline ColorA operator*(const real64 &v)
inline ColorA &operator*=(const real64 &v)
Scales all components by the constant.

inline ColorA operator/(const real64 &v)
inline ColorA &operator/=(const real64 &v)
Divides all components by the constant. No error checking is done to avoid divide by zero errors.

inline int32 operator ==(const ColorA &v)
Equality check. No epsilon check is done on the values, so it may not be robust in some cases.

inline int32 operator !=(const ColorA &v)
Inequality check.

inline void Clamp()
Clamps all components to be in the range 0.0..1.0. This can introduce hue and saturation shifts and is a nasty way to do this (better ways coming).

inline void ClampPositive()
Ensures that all components are greater than or equal to zero.

void RGBtoHSV()
Converts the internal representation from RGB to HSV. HSV values are (typically) in the range 0.0 to 1.0. The alpha value is unchanged.

void HSVtoRGB() Converts the internal representation from HSV to RGB. The alpha value is unchanged.

 

Core

class Core
The Core class keeps track of every object in the scene. The lists of objects can be read by any plugin to determine what's in the scene, but shouldn't be modified. Everything that needs to be added to the scene should be done via the Create() method.

Data:

TList<PreviewObject *> *objList
A list of all the objects in the scene.

TList<Material *> *matList
A list of all the materials we've created.

TList<Light *> *lightList
A list of all the lights we know about.

TList<Camera *> *cameraList
A list of all the cameras we've created.

TList<Satellite *> *satellites
A list of all the suns'n'moons'n'stuff that orbit around us.

TList<CloudLayer *> *cloudList
A list of all the cloud layers.

Atmosphere *atmos
The current atmosphere. Can be NULL if there is no atmosphere assigned.

Backdrop *backdrop
The current backdrop. Can be NULL.

Material *defaultMaterial
Obsolete. Don't use this.

Electrician electrician
The plugin manager.

CentralExchange theExchange
The Undo/Redo handler.

bool currentlyLoading
Are we in the middle of a load, and if so, don't create any default sub-plugs.

FunContext *globFC
This is a Function Context that anything can grab.

RayEngine *rayEngine
A ray trace engine anyone can use. (Currently unimplemented.)

MemStack simdStack
A memory stack for the simd methods to use while evaluating functions. This is used for faster memory allocation of the stacks required for SIMD style evaluation of function nodes.

real64 fixedDP
When we need to fix the sample size of a function (like for distortion fractals) this is the size to use. Also used as the sample size in the OpenGL view.

PQaeb *planet
What planet are we currently on?

POcean *ocean
What ocean (if any) currently rules on our planet?

int TextUpdateRefCount
flag m_InStableState
int StableStateRefCount
For internal use.

real64 stepSize
The size of a movement step (also the height above the planet).

TList<SceneState *> states
The list of current Transporter states. Plugins shouldn't modify this.

TList<MUITextureLeaf *> *texLeaf
A list of all the texture leaf nodes the Generator texture editor should know about.

TList<Plugged *> *nodeList
(private) A list of everything that's been created so far.

Camera *currentCam
(private) The camera we're using the view the scene.

flag doTextureUpdate
(private) A flag indicating whether the world needs a texture update.

flag frozen
(private) A flag indicating whether the RTR is paused or not.

TList<Plugged *> libraryList
(private) A list of plugins. Used only for loading/saving of libraries.

flag doingLibrary
(private) A flag indicating whether a library save is in progress or not.

flag sceneChanged
(private) A flag indicating whether the scene has changed.

std::list<MessageStruct> messageList
(private) A list of messages. Obsolete. Use the MojoOhNo UIServices and error message methods.

std::list<MessageStruct> ErrorList
(private) A list of errors. Obsolete. Use the MojoOhNo UIServices and error message methods.

flag m_CleaningUp
(private) This is true if we're doing a huge delete of all nodes in system.

bool m_bMachineValid
(private) A flag indicating whether the machine is valid.

bool m_bOpenGLAbove1_2
(private) A flag indicating whether the OpenGL installation is above version 1.2 or not.

MojoString m_glVendor, m_glVersion, m_glExtensions, m_glRenderer
(private) Strings to show information about the OpenGL installation in the File->Info dialog.

MojoString m_machineInfo
(private) A string to show machine info in the File->Info dialog.

float m_glVersionMajMin
(private) The GL version.

float m_SunPosition
(private) The global sun position as set in the Time editor.

float m_YearPosition
(private) The global year position as set in the Time editor.

Methods:

Core()
Constructor. Initializes all the lists. The app is responsible for creation and deletion of the Core.

virtual ~Core()
Destructor.

flag Initialize(CoreCallback *cb)
Handles all the initialization.

void Add(Plugged *node)
Adds the node to the main nodelist and to appropriate other lists.

flag Delete(Plugged *node)
Deletes the node from the appropriate lists. Only delete things created with the Core::Create() method.

int32 NumNodes()
How many things are in the master nodelist.

Plugged *Get(int32 i)
Gets a thing from the master nodelist.

Plugged *Create(ID id)
Creates a new node of the given ID and adds it to the lists. This is the main method for creation of new nodes to ensure proper deletion.

void SetCurrentCamera(Camera *cam)
Sets the current camera.

Camera *GetCurrentCamera()
Gets the current camera.

flag LoadTheFile(MojoInputStream &in)
flag SaveTheFile(MojoOutputStream &out)
Load and save. The file should be open for current operation. Plugins cannot currently load and save the entire scene file.

FileChunk BeginFileChunk(MojoOutputStream &out, Plugged *plug)
void EndFileChunk(MojoOutputStream &out, FileChunk chunk)
FileChunk LoadChunkHeader(MojoInputStream &in)
Files are saved in chunks. These methods handle the chunking.

ImageFileHandler *GetImageHandler(const MojoString &ext)
Gets an new image file handler for the given extension. The pointer will be NULL if the extension doesn't match.

void CleanUp()
Deletes everything we know about.

flag CurrentlyCleaning()
A flag to indicate whether a cleanup is in progress.

real64 PlanetHeight(Vec3d p, real64 dP = 1.0)
Returns the height of the planet at the given point.

real64 PlanetHeight(FunContext *fc, flag doNormal = FALSE)
Returns the height of the planet at the given point and sets fc->altitude. If doNormal is TRUE, then the FunContext normal and slope information is also calculated. Note that finding the normal and slope is approximately 3 times slower than finding just the altitude.

Matrix PlanetSpace(Vec3d p)
Returns a local 3x3 space at the given point on the planet, where the three axes correspond to north, east and up on the planet. Note that there are discontinuities in this space at the poles of the planet.

real64 PlanetSlope(Vec3d p, real64 dP = 1.0)
Returns the slope of the planet at the given point.

Vec3d PlanetNormal(Vec3d p, real64 dP = 1.0)
Returns the normal of the planet at the given point.

real64 PlanetRadius()
Returns the base radius of the planet.

void EnableTextureUpdate(flag b)
flag DoTextureUpdate()
Internal use only.

void SetStableState(flag state)
flag InStableState()
Internal use only.

void SetFrozen(flag b)
flag GetFrozen()
When the OpenGL is paused, set the frozen flag so the planet knows it doesn't need to do a PreparePreview().

real64 SeaLevel()
Returns the "sea level" height above or below the planet base radius. (Returns 0.0 if there is no ocean on the planet.)

void SetSeaLevel(real64 seaLevel)
Sets the sea level if there's an ocean.

void SetSceneStateValues(std::vector<SceneState> &MySceneValues)
void GetSceneStateValues(std::vector<SceneState> &MySceneValues)
Internal use only.

MUITextureLeaf *CreateTextureLeaf(ID id = 0, bool col = true)
Used by the Generator texture editor. Shouldn't be called from plugin code.

void StartLibrarySave()
void EndLibrarySave()
flag DoingLibrary()
Call these to flag the start/end of a library save block.

flag SaveToLibrary(Plugged *obj, MojoOutputStream &out)
flag SaveToLibrary(TList<Plugged *> &objList, MojoOutputStream &out)
Plugged *LoadFromLibrary(MojoInputStream &in)
flag LoadFromLibrary(TList<Plugged *&gt; &objList, MojoInputStream &in)
Routines for the actual work of saving and loading to and from libraries.

OTYPE LibraryType(MojoInputStream &in)
Returns the type of the thing stored in the library.

void SetChanged()
Flag the scene as changed since the file load.

flag HasChanged()
A flag indicating that the scene has been changed.

void ResetChanged()
The core is the only thing that can set the scene state to not changed.

void InitMachineInfo()
Initializes the machine info strings.

float GetOpenGLVersion() const
Gets the OpenGL version.

MojoString GetMachineInfo() const
Gets the machine info string.

flag IsOpenGLAbove1_2() const
A flag indicating whether the OpenGL installation is higher than 1.2.

void SetOpenGLAbove1_2(flag val)
Set the m_bOpenGLAbove1_2 flag.

void UpdateForLightSourceChanges()
Forces a recalculation on the planet to regenerate textures for the new light source position.

void SetRelativeRotationPosition(float value, bool ignoretimefix = false)
float GetRelativeRotationPosition()
These set the 'relative' time position with regard to camera position. Time will depend on where we are on the planet with regard to Longitude. Setting this incorrectly will result in the time editors getting out of sync with the actual sun position.

void SetBUISunPosition(float value)
Sets the sun position but doesn't actually change the shading on the terrain.

void SetBUIYearTime(float val)
Sets the time of year for all the satellites.

float GetSunPosition()
Gets the sun position. (Returned value ranges from 0.0 to 1.0)

float GetYearPosition()
Gets the year position.

float GetMoonPosition()
Gets the moon position.

Core *MojoInitialize()
Initializes the core. Should never be called except at application startup.

void MojoUninitialize( Core*& pCore )
The last thing that happens is that the global core gets freed.

void MinimalLifeSupport()
(private) A method that sets up the minimal set of objects needed for the application to start.

Curve

class Curve
A user-definable curve, used anywhere we want to remap a value across a range. All points are stored internally as 0 to 1 and remapped at Eval().

Data:

flag unchanged
(private) A flag tracking whether or not the curve has been changed.

enum RangeClampType { rangeNoChange = 0, rangeClamp, rangeReflect }
Types of clamping for output range.

enum ClampType { curveClamp = 0, curveContinue, curveMirror, curveRepeat }
Types of clamping for input.

TList<CurvePoint *> *points
The list of CurvePoint structs defining the curve.

real64 lowInput, highInput
The domain of input values.

real64 lowOutput, highOutput
The range of output values.

ClampType clamp
How to handle input values that are out of the domain.

RangeClampType rClamp
How to handle output values that go off the top or bottom of the curve.

real64 invertSize
(private) Stores the value of 1.0 / (highInput - lowInput) in order to speed up the Eval() calls.

Support Struct:

The Curve class makes use of the following CurvePoint data structure:

struct CurvePoint
{
    Vec2d p;            // x stores the value, y stores the time
    Vec2c dprev, dnext; // tangent values previous and next

    flag broken;
    // are we enforcing tangent continuity through this point?

    flag IsIdentical(CurvePoint *cp);
}

Methods:

Curve()
Constructor.

Curve(const Curve& val)
Constructor. Copies the passed in curve.

~Curve()
Destructor.

inline real64 Eval(real64 v)
Evaluate the curve at the context.

real64 UnitEval(real64 v, flag differential = false)
Evaluate the curve at the given point, where the point v ranges from 0.0 to 1.0. If the differential flag is TRUE, the value returned will be the derivative of the curve. Values of v outside 0.0 to 1.0 will be constrained according to the input ClampType.

void SetInputRange(real64 lo, real64 hi)
Sets the input range.

void SetOutputRange(real64 lo, real64 hi)
Sets the output range.

void GetInputRange(real64 &lo, real64 &hi)
Gets the input range.

void GetOutputRange(real64 &lo, real64 &hi)
Gets the output range.

void InvertHorizontal()
Flips the curve on the horizontal axis.

void InvertVertical()
Flips the curve on the vertical axis.

int32 GetNumPoints()
Returns the number of CurvePoints in the curve.

CurvePoint *GetPoint(int32 i)
Gets the i-th point on the curve.

void AddPoint(CurvePoint *cp)
Adds a point. The curve gains ownership of point memory (cp must be allocated on heap).

void AddPoint(Vec2d position)
Adds a point at position. Sets the slope through the new point to ensure that the resulting curve is unchanged.

void Reorder()
Must be called after any point has its y value changed.

void DeletePoint(real64 t)
Deletes the point at time t.

flag IsIdentical(Curve *cc)
Compares the curve to the passed in curve.

void StartAccumulate()
void Accumulate(Curve *c, real64 weight)
These two methods are used in the Hyperspace Mixer state system for calculating the actual curve values for any given set of state weights. These should not be called from plugin code.

void AddSpuriousPoint(real64 v)
void CreateNecessaryPoints(Curve *c)
Used in the Hyperspace Mixer state system for creating transitional curves between any given set of state weights. These should not be called from plugin code.

void SetChanged()
Sets the unchanged flag.

inline flag IsUnchanged()
Is this an unchanged identity curve? If so, we don't need to do any calculation.

void CheckForChange()
(private) Called after a load to ensure that this is an unchanged curve.

Curve& operator=(const Curve &c)
Curve assignment.

flag Load(MojoInputStream &in)
Loads the data from the file stream.

flag Save(MojoOutputStream &out)
Saves the data to the file stream.

 

CurveHolder

class CurveHolder
Holds curves in a logical bundle, one for grey values, three for RGB values. Use the Get/Set Range methods on this class for getting and setting the range. The Get/Set Range methods on each individual curve should not be used directly in order to keep the CurveHolder object in a consistant state.

Data:

Curve* Curve1, Curve2, Curve3
(private) For grey, Curve1 will have a curve, Curve2 and Curve3 will be NULL. For RGB, all curve pointers will have curves.

int NumCurves
(private) Number of curves in the CurveHolder.

std::string Name
(private) Name of a curve, used for UI display purposes.

bool Curve1Enabled, Curve2Enabled, Curve3Enabled
(private) Whether or not a curve is enabled. If not enabled, a straight line y=x evaluation is used.

bool Curve1Visible, Curve2Visible, Curve3Visible
(private) Whether or not a curve is visible in the UI.

Methods:

CurveHolder()
Constructor. Leaves curve memory set to NULL.

CurveHolder(int curvenum, std::string theName)
Constructor. Allocates curves and sets NumCurves and Name.

CurveHolder(const CurveHolder& val)
Constructor. Copies the curve from the passed value.

~CurveHolder()
Destructor.

CurveHolder& operator=(const CurveHolder& val)
Curve assignment.

void Reset(int curvenum, std::string theName)
Clears and allocates new curves and sets NumCurves, Name. Use a curvenum of 1 for a grey curve, 3 for an RGB curve.

std::string GetName()
Gets the curve name.

void SetName(std::string theName)
Sets the curve name.

int GetNumCurves()
Returns the number of curves. A value of 1 means this is a grey / value curve. A value of 3 means this is an RGB curve. A value of 0 means it is not initialized.

Curve* GetCurve(int num)
Returns a pointer to the curve specified by num.

bool GetEnabled(int curvenum)
Returns the value of the appropriate enabled flag.

void SetEnabled(int curvenum, bool val)
Sets the value of the appropriate enabled flag.

bool GetVisible(int curvenum)
Returns the value of the appropriate visible flag.

void SetVisible(int curvenum, bool val)
Sets the value of the appropriate visible flag.

void SetInputRange(real64 lo, real64 hi)
Sets the input range for all curves in the holder.

void SetOutputRange(real64 lo, real64 hi)
Sets the output range for all curves in the holder.

void GetInputRange(real64 &lo, real64 &hi)
Gets the input range for all curves in the holder.

void GetOutputRange(real64 &lo, real64 &hi)
Gets the output range for all curves in the holder.

Curve::ClampType GetClampValue()
Gets the clamp type for the input clamping on all curves in the holder.

void SetClampValue(Curve::ClampType val)
Sets the clamp type for input clamping on all curves in the holder.

Curve::RangeClampType GetRangeClampValue()
Gets the clamp type for output range clamping on all curves in the holder.

void SetRangeClampValue(Curve::RangeClampType val)
Sets the clamp type for output range clamping on all curves in the holder.

real64 EvalGrey(real64 v)
real64 EvalRed(real64 v)
real64 EvalGreen(real64 v)
real64 EvalBlue(real64 v)
Return the y value of the curve given the passed in x value.

flag IsIdentical(CurveHolder *cc)
Returns TRUE if the curve holder is equal to the passed in curve holder.

void StartAccumulate()
void Accumulate(CurveHolder *ch, real64 weight)
These two methods are used in the Hyperspace Mixer state system for calculating the actual curve values for any given set of state weights. These should not be called from plugin code.

void AddSpuriousPoint(real64 v)
void CreateNecessaryPoints(CurveHolder *ch);
Used in the Hyperspace Mixer state system for creating transitional curves between any given set of state weights. These should not be called from plugin code.

flag Load(MojoInputStream &in)
Loads the curve holder data from the file stream.

flag Save(MojoOutputStream &out)
Saves the curve holder data to the file stream.

 

FunContext

class FunContext
The FunContext provides all the information that function nodes and parameters need to evaluate themselves. At the very least, it will contain the current time, the current camera and the list of lights in the scene. The other fields will be valid if the data is relevant to the current evaluation. The data members are shown as either In, Out or In/Out depending on whether a node should treat them as input values, output values or dependant on context. The "time" member of the FunContext is there in anticipation of animation support in future versions. For MojoWorld 1.x, this is initialized to 0.0 and should be left at this value.

There is a global FunContext available for any use. A pointer to this can be obtained by GlobalCore()->globFC. The time, cam, and lights fields of this context should not be changed.

Data:

real64 time
(In) The current time value. All parameters will use this in conjunction with their interpolators to do animation. (For MojoWorld 1.x, this should remain set to 0.0.)

Vec3d point
(In/Out) The point in world space at which we're evaluating this function. Height functions will take this point and change it to point at the correct altitude. Other functions will use this as input as to where to evaluate themselves.

Vec3d normal
(In/Out) The surface normal in world space at the point of evaluation. Height functions will set this based on the height value calculations. Other functions will use this for shading or any thing else.

Vec3d viewDir
(In) The direction vector from the eye point to the current point being shaded.

uint32 signature
(In) Currently unused.

Material *mtl
(In) A pointer to the material that's being shaded/textured.

int32 matIndex
(In) Polygon meshes with multiple materials will set this to the index of the material to be evaluated.

RenderObject *obj
(In) A pointer to the object that's being rendered/shaded/textured.

Camera *cam
(In) A pointer to the current camera.

TList<Light *> *lights
(In) A pointer to a list of the current lights in the scene.

real64 altitude
(In/Out) The altitude above a nominal planet surface of the current point. This is set by height functions and can be used by material and texture functions.

real64 slope
(In/Out) The slope of the surface at the current point. 1.0 is a horizontal surface, 0.0 is a vertical surface. Set by height functions and used by anything else. This is the dot product of the normal and a local up vector.

Vec3d unitD
(In) The direction vector from the eye to the current point being shaded.

Vec3d dPV
(In) A vector representing the size of world space fragment being sampled. Currently unused. Use dP instead.

real64 dP
(In) A single value representing the size of the world space fragment being sampled.

Vec3d fractalPoint
(In/Out) A world space point generated by the fractal loop of a function with an internal function node. The basis function for a function fractal can use this to access the actual point to be evaluated by this fractal.

flag doShadows
(In) A flag to determine if any shading calls should be calculating shadows or not.

Vec2d UV
(In/Out) UV texture coordinates at the current point. SubPrimitive::Dice() methods will set this and it can be used by texturing and shading nodes.

Vec2d helperPos
(In/Out) The current point, represented in Helper Space. Helper space is -1.0 to 1.0 in both x and y, and fits the region defined by a parameter bomb.

Vec2d screenPos
(In) The 2D pixel coordinate of the current world space point. Pixel coordinates are expressed as 0.0 to 1.0 in x and y.

flag doingSliderChange
(In) This will be true if an update is happening as a result of a change in the Transporter sliders. This can result in a lot of Update() calls and if the Update() will be very expensive (for example, the planet), then it can be skipped (and dependants not notified) until the slider changes are complete. Most nodes will not need to use this.

real64 v1Time
(In) A simple time value, used by the Time and SpaceTime nodes in the Pro UI. Simply returns the time (in seconds) at the current point in an animation.

flag worthMyWhile
(In) A flag indicating that results from this context are not going to be used, so no calculations need to be done. Used for the Function::SIMDEval() methods so parts of the array can be ignored by expensive functions like fractals if prior functions (such as blends) won't be using the result from some elements of a SIMD calculation. If TRUE, then calculations need to be done, if FALSE, then no calculations are needed and any return value will be ignored.

Vec3d objectPoint
(In) The current point, expressed in object coordinates of the current object. The same point can be found from the current point multiplied by the current object's worldToLocal matrix.

flag heightTexture
(In) A flag indicating if this is a height calculation or not. During height calculations the normal, slope and altitude values will be indeterminate until the height calculation is finished and should not be used.

uint32 hackflags
(In/Out) A general purpose set of flags that can be used to for any purpose required. Generally used to communicate state information that isn't included in any of the other members.

Methods:

static real64 FindBestdP(int x, int xs, int y, int ys, Vec4d *points, FunContext *fc);
static real64 FindBestdP(int x, int xs, int y, int ys, Vec3d *points, FunContext *fc);
static real64 FindBestdP(int x, int xs, int y, int ys, Vec2d *points, FunContext *fc);
These methods take an 2D array (whose size is given by xs and ys) of points and contexts, and finds an estimate of the sample size at the given array index (x, y). The sample size estimate takes the distance between adjacent samples in the array and the projected screen area into account.

 

Function

class Function : public ParamObj
The function class forms the basis of the function graph hierarchy. Any parameter on a ParamObj can have its value overridden by a function. If that function has any parameters, they in turn can be overridden, building the tree structure of the function graph. A single function may override as many parameters on as many other ParamObj's as necessary.

A function should be able to evaluate its result as any type. As a fallback, a function can use the Converter class available from the parameter that it's overriding. In many cases the conversion won't have any meaning, but will at least produce a sensible default value that won't cause math problems for the renderers.

Data:

Tlist<Param *> *paramList
(protected) The list of parameters that this function overrides.

Param *param
(protected) A "representative" parameter that is overridden. This will generally be the first parameter that this function got connected to. Use this when you don't care which specific parameter you are connected to, you just need any old one. This will probably be the first parameter in the paramList.

int32 xpos, ypos
(protected) The screen position of this node in a Pro UI Function graph editor.

flag collapsed
(protected) Is this node currently collapsed in the Pro UI?

flag active
(protected) Is this node currently active? (Inactive function nodes are never evaluated and any parameters with inactive nodes will just return their currently set value.)

flag useFixedDP
(protected) Should this node use the default system sample size, or should it calculate the sample size from the context or neighbors. Certain functions (e.g. domain distortion fractals) need to avoid changing their behavior as the camera moves to get consistent results. Set this to true to obtain this behavior.

uint32 useFlags
(protected) A set of flags indicating how this function node can be used. Nodes may be used at any point in the Pro UI Function graph, but the Generator Texture editor makes certain assumptions about how nodes will behave and these flags indicate to the Editor which assumptions will be true. See the Remarks section below for the flags and their meanings.

Param *minder
(public) If this node appears in a Pro UI Function graph, but is not connected to any parameter of that graph, the base parameter will be a "minder" for this node so that when the graph editor is re-opened, we can show all the nodes that were visible previously. This is handled by the Pro UI and should not be changed.

Methods:

Function() : ParamObj()
Constructor. Default values are set.

~Function()
Destructor.

virtual void SetOverriddenParam(Param *p)
Adds this parameter to the list of things that we're overriding. Many functions have their own parameters whose types are dependant on the type of the parameter they're overriding. If that's the case, then they can use this routine to get the type of the parameter and create their own parameters of the same type.

Param *GetOverriddenParam(int i)
Returns a pointer to the i-th parameter we're currently overriding.

int GetNumOverriddenParams()
Returns the number of parameters that this node is currently connected to.

void RemoveOverriddenParam(Param *p)
Removes the passed parameter from the list of overridden params and breaks any dependencies between them. (See ParamObj for more information on dependencies.)

virtual void Update(int32 which, FunContext *fc)
Updates all the nodes with parameters that this node overrides.

flag Active()
Returns the state of the active flag.

virtual void SetActive(flag a)
Sets the state of the active flag.

flag UsingFixedDP()
Returns the state of the fixedDP flag.

void SetFixedDP(flag a)
Sets the state of the fixedDP flag.

virtual MojoString Category()
Returns a string indicating which category this node should be listed under in the Pro UI Function Graph Editor.

The following Eval methods all return a single value, the result of the function based on its parameters at the context given by the passed FunContext.

virtual void Eval(int32 &v, FunContext *fc) = 0
Evaluates the function at the given FunContext and returns the result as an integer.

virtual void Eval(real64 &v, FunContext *fc) = 0
Evaluates the function at the given FunContext and returns the result as a double precision float.

virtual void Eval(Vec2d &d, FunContext *fc) = 0
Evaluates the function at the given FunContext and returns the result as a 2 dimensional vector.

virtual void Eval(Vec3d &d, FunContext *fc) = 0
Evaluates the function at the given FunContext and returns the result as a 3 dimensional vector.

virtual void Eval(Vec4d &d, FunContext *fc) = 0
Evaluates the function at the given FunContext and returns the result as a 4 dimensional vector.

virtual void Eval(Quaternion &d, FunContext *fc) = 0
Evaluates the function at the given FunContext and returns the result as a quaternion representation of an orientation.

virtual void Eval(Color &d, FunContext *fc) = 0
Evaluates the function at the given FunContext and returns the result as a 3 component RGB color.

virtual void Eval(ColorA &d, FunContext *fc) = 0
Evaluates the function at the given FunContext and returns the result as a 4 component RGB and alpha color.

virtual void Eval(MojoString &d, FunContext *fc) = 0
Evaluates the function at the given FunContext and returns the result as a character string.

The following SIMDEval methods all evaluate a 2D array of values, based on the parameters and the array of passed in contexts. Nodes may use the neighbor information available from the context array to calculate accurate sample sizes. (see FunContext::FindBestDP()). Function nodes which are either leaf nodes (nodes with no parameters) or whose parameters cannot be overridden by functions may use the default implementation. All other nodes should provide SIMD style evaluation routines to ensure that any nodes higher up the tree get the required information. (See the Function node sample code.)

virtual void SIMDEval(int32 *v, FunContext *fc, int32 xs, int32 ys)
Evaluates a the function at a number of FunContexts and fills in the array of integer values.

virtual void SIMDEval(real64 *v, FunContext *fc, int32 xs, int32 ys)
Evaluates a the function at a number of FunContexts and fills in the array of double precision floating point values.

virtual void SIMDEval(Vec2d *d, FunContext *fc, int32 xs, int32 ys)
Evaluates a the function at a number of FunContexts and fills in the array of 2D vectors.

virtual void SIMDEval(Vec3d *d, FunContext *fc, int32 xs, int32 ys)
Evaluates a the function at a number of FunContexts and fills in the array of 3D vectors.

virtual void SIMDEval(Vec4d *d, FunContext *fc, int32 xs, int32 ys)
Evaluates a the function at a number of FunContexts and fills in the array of 4D vectors.

virtual void SIMDEval(Quaternion *d, FunContext *fc, int32 xs, int32 ys)
Evaluates a the function at a number of FunContexts and fills in the array of quaternions.

virtual void SIMDEval(Color *d, FunContext *fc, int32 xs, int32 ys)
Evaluates a the function at a number of FunContexts and fills in the array of Colors.

virtual void SIMDEval(ColorA *d, FunContext *fc, int32 xs, int32 ys)
Evaluates a the function at a number of FunContexts and fills in the array of 4 component colors.

virtual void SIMDEval(String *d, FunContext *fc, int32 xs, int32 ys)
Evaluates a the function at a number of FunContexts and fills in the array of character string values.

virtual flag Load(FileStream *in)
Loads the data from the file stream.

virtual flag Save(FileStream *out)
Saves the data to the file stream.

virtual flag PostLoad(TList<Plugged *> *list)
Ensures that all the parameter pointers are connected up properly after a load.

virtual Plugged *Clone(flag func = true, flag subP = true)
Clones this current function node, and optionally any other functions and sub-plugins from parts of the tree above this. See ParamObj::Clone() for more information.

void SetPosition(int32 xp, int32 yp)
Sets the screen position of the node in the editor.

void GetPosition(int32 &xp, int32 &yp)
Gets the current screen position of the node in the editor.

void Collapse(flag c)
Sets the current state of the collapse flag (which causes this node and any part of the tree above it to be hidden in the editor).

flag IsCollapsed()
Returns the state of the collapsed flag.

virtual flag IsValidGenerator()
virtual flag IsValidSpace()
These two methods are obsolete. See UsageFlags() for replacement functionality.

virtual uint32 UsageFlags()
Returns the value of the useFlags member. (See remarks below.)

void DeleteIfUnconnected()
Deletes this node if it overrides no parameters and has nothing connected to any of its parameters. Should only be called by the system.

Remarks:

The Generator Texture Editor (and Material Editor) make certain assumptions about the organization of function nodes so that they fit the "template" required by the editors. Nodes should set the following flags in the useFlags member only if they meet the requirements listed. If the flag is set, then the node will show up as an option in the editors. See ParamObj for more information about parameters and sub-plugins.

GlobalSpace: Indicates that this node can be used as a space for global textures (i.e. not inside parameter bombs). No assumptions are made about parameters or sub-plugs. Example: World Space

PBSpace: Indicates that this node can be used as a space inside a parameter bomb. Example: Helper Space. (See HasHelper)

IsGenerator: Indicates that this node can be used as a fractal/generator node in the texture editor. Assumes that the first parameter is the point to evaluate the node at. Example: MonoFractal. (See HasDimension, HasBasis, ReturnsColor.)

IsDistortion: Indicates that the node can be used as a distortion in the editor. Assumes the first parameter is the point to evaluate at. Example: MonoFractal.

HasDimension: Indicates the last parameter is an integer used to control the dimensionality of the Generator/Distortion. For example, when using the Altitude space, fractals and noises only need to be 1-dimensional. When using World Space, they need to be 3 dimensional. If this flag is set, the editor can change the dimension from 1 to 4 by setting the last parameter and the node will behave accordingly. Example: MonoFractal.

HeightSpace: Indicates that this space can be used when calculating height textures. Certain spaces (e.g. Altitude, Slope, Normal) are not defined until a height calculation is complete. Set this flag if the node is not one of these spaces. Example: WorldSpace.

HasBasis: Indicates that the first sub-plugin of a generator or distortion is a basis function. Some nodes (e.g. Bitmap) use something other than a basis function and should not set this flag. Example: MonoFractal.

HasHelper: Indicates that the first sub-plugin is a helper object. Generally used when the PBSpace flag is also set. Example: HelperSpace.

ReturnsColor: Indicates that a generator node returns a color value rather than a single grey scale value. This causes the editor to provide a single set of color mapping curves in the output section rather than the usual input curve, gradient, output curves selection. No assumptions are made. Example: Bitmap Node.

 

HelperObject

class HelperObject : public PreviewObject
A preview object that defines a mapping from 3D world space to a 2D local space and a blend value based on position within that local space. Helper space is defined as a square centered on the axis of the helper, with values ranging from -1.0 to 1.0 in x and y.

Data:

flag constrain
(protected) Do we limit the effect to within the helper object?

HelperObject *replacement
(protected) Used for cloning to avoid duplication of helper objects.

Methods:

HelperObject() : PreviewObject()
Constructor. Sets the constrain flag to TRUE and the replacement pointer to NULL.

virtual flag WorldToLocal(const Vec3d &worldPoint, Vec2d &localPoint, real64 *blend = NULL) = 0
Converts a point in world space to a 2D point in helper space (and optionally returns the blend value as well).

virtual void LocalToWorld(const Vec2d &localPoint, Vec3d &worldPoint) = 0
Converts a point in local 2D helper space to a 3D point in world space.

virtual real64 BlendVal(const Vec3d &worldPoint) = 0
virtual real64 BlendVal(const Vec2d &localPoint) = 0
Calculate the blending/distance value for a point in world or local space.

inline void SetConstrain(flag c)
Sets the constrain flag. If a helper is constrained, then the blend value will be 0.0 for any helper space point outside the -1.0 to 1.0 square. An unconstrained helper will return the blend value directly from the curve, allowing for cyclic helpers.

inline flag Constrained()
Returns the value of the constrain flag.

OTYPE ObjectType()
Returns an OTYPE of objHelper.

virtual Plugged *Clone(flag func = true, flag subP = true)
Creates and returns a duplicate of the helper object. See ParamObj::Clone() for more information.

static CurveHolder MakePBHeavyCurve()
Generates a single curve CurveHolder to be used as the response curve. The curve rises smoothly to a value of 1.0 at in input value of 0.05 and is flat at 1.0 for the remainder. This is generally a much more useful blend curve for Parameter Bombs than the standard linear x=y default curve.

bool ExportTerrain(TerrainData &data, int xres, int yres)
bool GetTerrainTextMap(Bitmap &bmp, int xres, int yres)
Internal methods used for the import and export of bitmap terrains.

virtual double GetAspectRatio()
If the helper object isn't square (or circular), this should return the aspect ratio (y size / x size). Used by the export routines to ensure square pixels in exported terrain bitmaps.

 

ImageFileHandler

class ImageFileHandler : public ParamObj
Handles reading and writing images from the renderer. It should be able to handle single images as well as image sequences, movies, QTVR panoramas and anything else we may need.

Data:

MojoString baseFileName
(protected) The file name.

int32 extIndex
The index for which extension to use from the vector returned by GetExtension() and GetUIExtension().

Methods:

virtual MojoString &GetBaseName()
Returns the file name.

virtual void SetBaseName(MojoString &str)
Sets the file name.

virtual std::vector <MojoString> &GetExtension() = 0
Returns a vector containing the possible extensions for types this plugin can write in a format to be used on the filename itself. For example: bmp

virtual std::vector <MojoString> &GetUIExtension() = 0
Returns a vector containing the possible extensions for types this plugin can write in a format to be displayed in the user interface. For example: *.bmp

virtual flag HandleImage(Bitmap *bm, int32 frameNum) = 0
Processes / saves a single image in a multiple frame sequence. For animations and QTVRs, this will be called multiple times between the StartImageSequence() and EndImageSequence() calls.

virtual flag StartImageSequence(int32 numFrames)
Prepares to render an animation of numFrames frames.

virtual flag EndImageSequence(flag error = FALSE)
Tidy up after rendering an animation. If error is TRUE, something went wrong during the render/saving of frames and the handler should tidy up and delete anything created so far.

virtual flag HandleSingleImage(Bitmap *bm) = 0
Handle a single frame render.

virtual Bitmap *LoadImage(MojoString &name)
Try to load the image specified by the file name.

virtual flag CanLoadImage(MojoString &name)
Can this file name / image file be loaded? Returns TRUE if the file can be loaded, FALSE otherwise.

OTYPE ObjectType()
All plugins must return the proper object type.

virtual flag IsCubicVR() = 0
A flag to specify whether this file format can be used to save Quicktime VR files. This doesn't necessarily mean that a Quicktime ".mov" file will be created, just that the file format handler is capable of taking six consecutive images and doing something sensible with them. For example, the PNG file handler just writes them as 6 individual PNG files.

virtual flag IsMovie() = 0
A flag to specify whether this file format can handle multiple image sequences. These may be written to disk as individual frames or as a compressed movie file depending on the particular file format.

virtual flag IsStill() = 0
A flag to specify whether this file format can handle a single image file.

virtual flag DoRunTimeCheck()
Verifies that the QuickTime install is the right version.

virtual void SetFPS(int val)
Sets the Frames Per Second for an animation render.

 

Light

class Light : public PreviewObject
Provides a base class from which all light sources are derived.

enum LIGHTTYPE { LT_ERROR = 0, LT_POINT, LT_DIRECTIONAL, LT_AMBIENT, LT_SPOT }
These light types are obsolete and not used.

Data:

LIGHTTYPE lighttype
(protected) Indicates the type of light. Obsolete.

flag castShadows
(protected) Flag to turn on/off shadow casting from this light.

Methods:

Light( LIGHTTYPE t) : PreviewObject()
Constructor. A plugin light should create any parameters or other data it requires. The light type is currently ignored. (Differing light types just implement differing Lighting() methods.)

~Light()
Destructor.

virtual Color Lighting(FunContext *fc, Vec3d &dir, flag realTime = FALSE) = 0
The main lighting method. This is called by the materials for each light in the scene to perform shading. This method returns the color of the light falling on the point given by the FunContext and the direction the light is coming from. If the realTime flag is TRUE, then the lighting should not include any shadow or other effects as those will be either too expensive to compute in real time or will change with the view position.

virtual Vec4d GlLightPos() = 0
Lighting controls for the real time renderer. This returns a 4D vector that OpenGL can use to set up lights. The first three components give either the light source position, or in the case of a infinite light source, the direction the light is coming from. The fourth component should be 1.0 for a local light source and 0.0 for an infinite one.

virtual Vec4d GlLightCol() = 0
Returns a 4D vector with the color of the light for use by OpenGL lighting routines. In most cases, the fourth component should be 1.0.

virtual flag ShadowPrepare(FunContext *fc, RenderCallback *rcb = NULL)
This method will be called once per rendered frame, prior to any actual rendering. Any information (such as shadow maps) that the light source needs can be calculated here.

virtual void ShadowClose()
Called once at the end of each frame to allow for tidying up of any shadow information.

virtual real64 InShadow(FunContext *fc)
Returns the amount of shadow from this light source at the point given in the context. 0.0 (the default value) indicates no shadow, 1.0 indicates full shadow and no contribution from this light.

virtual LIGHTTYPE GetType() const
Returns the type passed to the constructor. Obsolete.

virtual void SetCastShadows(flag f)
Sets the state of the castShadows flag.

virtual flag GetCastShadows()
Gets the state of the castShadows flag.

virtual flag CanCastShadows()
Indicates if the light is capable of casting shadows. If not, all UI relating to shadows will be disabled for this light. NB: the default return value is TRUE, so be sure to override this if any new light cannot cast shadows.

virtual void SetLocation(const Vec3d &point)
Used by the Satellite controllers to set the position of a light source that's attached to a satellite.

virtual void SetDirection(const Vec3d &dir)
Again, used by Satellites to control the direction in which a light source attached to the satellite will point.

virtual void SetType(const LIGHTTYPE type)
Obsolete.

 

Material

class Material : public ParamObj
Provides the base class from which all material definitions derive. Has methods for shading for both the real time renderer and the photorealistic renderer, and for displacing surfaces.

Data:

flag active
(protected) Is this material active? Non-active materials should return a flat known color (but will probably never be called).

Methods:

Material() : ParamObj()
Constructor.

~Material()
Destructor.

virtual Color Shade(FunContext *fc, Color *transp = NULL) = 0
The main shading routine used by renderers. All fields of the FunContext can be considered valid. Should evaluate any texture functions and perform whatever shading calculations are required, and return the color and transparency of the surface at that point. If the transp parameter is NULL, no transparency information is required.

virtual void SIMDShade(Color *res, FunContext *fc, int32 xs, int32 ys, Color *transp = NULL)
Evaluates the shading routine at all points in a 2D array of contexts. The size of the array is given by the xs and ys parameters. Should call the SIMD methods on any parameters. If transp is NULL, no transparency information is required.

virtual Color PreviewColor() = 0
Returns a color to be used in any preview or wireframe rendering. This can be an approximation to the actual surface color, or another arbitrary color as required.

virtual Color Diffuse() = 0
Returns a single representitive color for OpenGL diffuse shading.

virtual Color Specular() = 0
Returns a single representitive color for OpenGL specular highlights.

virtual real64 Shininess() = 0
Returns an appropriate value for OpenGL shininess.

virtual Color Transparency()
Returns an appropriate color for OpenGL transparency. (Currently unused.)

virtual Color UnlitShade(FunContext *fc) = 0
Returns a color suitable for use by the OpenGL diffuse shading routines. Obsolete.

virtual Color glShade(FunContext *fc) = 0
Returns a shaded color suitable for OpenGL rendering. This is primarily used for the planet terrains, which use prelit textures. The shading method here should differ from the main Shade() routine in the no view direction dependant effects should be included (as these can't be changed in the texture). This includes effects such as specular highlights, reflection and refraction, or anything else that will change based on the position of the eye point or the surface point. In most cases, this will be a simple diffuse lighting calculation.

virtual real64 Displacement(FunContext *fc)
Returns an amount to displace the surface along the surface normal, in world space units. Negative values push the surface in, positive values will pull the surface out. The default implementation returns 0.0.

virtual void SIMDDisplacement(real64 *res, FunContext *fc, int32 xs, int32 ys)
Evaluates the displacement at all points in a 2D array of contexts. See SIMDShade().

virtual flag DoDisplacement(FunContext *fc)
Returns TRUE if the renderer needs to perform displacement calculations for this material.

virtual bool IsLeafNode()
Returns true if the material can appear as an option in the Material Editor types. Generally, any material that isn't dependant on other materials should be a leaf node.

void SetActive(bool a)
Sets the state of the active flag.

flag Active()
Returns the state of the active flag.

virtual flag Load(FileStream *in)
Loads the data from the file stream.

virtual flag Save(FileStream *out)
Saves the data to the file stream.

virtual flag PostLoad(TList<Plugged *> *list)
Ensures that all the parameter pointers are connected up properly after a load.

 

Matrix

class Matrix
Provides a simple 4x4 transformation matrix.

Data:

real64 m[4][4]
The 16 data elements of the matrix.

Methods:

inline Matrix()
Constructor. The data is left uninitialized.

inline Matrix(const Matrix &v)
Constructor. The data is copied from the passed argument.

void SetIdentity()
Sets the matrix data to the 4x4 identity matrix.

inline Matrix operator-()
Negates all components of the matrix.

inline Matrix operator+(const Matrix &v)
inline Matrix operator+=(const Matrix &v)
Adds two matrices, component by component.

inline Matrix operator-(const Matrix &v)
inline Matrix operator-=(const Matrix &v)
Subtracts the argument from the matrix, component by component.

inline Matrix operator*(const Matrix &v)
inline Matrix operator*=(const Matrix &v)
Post multiplies the matrix by the argument.

inline Vec3d operator*(const Vec3d &v)
Transforms the 3D vector by the given matrix. Does not include any perspective transform.

inline Vec4d operator*(const Vec4d &v)
Does a full multiple of the 4x4 matrix by a 4D vector.

inline int32 operator ==(const Matrix &v)
Equality check. Doesn't do any epsilon checks, so will not be robust in some circumstances.

inline int32 operator !=(const Matrix &v)
Inequality check.

Matrix Invert()
Returns the inverse of the 4x4 matrix. If the matrix is not invertable, the unit matrix is returned. This is an expensive operation and should be avoided where speed is vital.

Matrix Invert(int32 &fail, real64 epsilon = 1.0e-10)
Returns the inverse of the 4x4 matrix. If the matrix is not invertable, sets the fail flag to TRUE and returns the unit matrix. Uses the optional epsilon value to determine of the matrix can be inverted. This is an expensive operation and should be avoided where speed is vital.

Matrix Transpose()
Returns the transpose of the matrix. Can use this instead of the much slower Invert() if we know the matrix is orthonormal.

real64 Determinant()
Returns the determinant of the 4x4 matrix. Used by the Invert() method.

real64 Cofactor(int32 x, int32 y)
Returns the cofactor of the given matrix element. Used by the Invert() method.

Quaternion ToQuaternion()
Returns the quaternion representation of the upper 3x3 corner of the matrix.

void SetRotateX(real64 ang)
Sets the matrix to correspond to a rotation about the X axis by the given angle (in radians).

void SetRotateY(real64 ang)
Sets the matrix to correspond to a rotation about the Y axis by the given angle (in radians).

void SetRotateZ(real64 ang)
Sets the matrix to correspond to a rotation about the Z axis by the given angle (in radians).

Vec3d Right()
Returns the "right" vector of the view space defined by this matrix.

Vec3d Up()
Returns the "Up" vector of the viewing space defined by this matrix.

Vec3d Direction()
Returns the view direction of the space defined by this matrix.

void SetAxisAngle( real64 theta, real64 x, real64 y, real64 z)
void SetAxisAngle(real64 theta, const Vec3d& v)
Sets the matrix to represent a rotation by the given angle about the given axis.

 

Noise

class Noise : public ParamObj
The base class from which all noise basis functions are derived. Provides methods for evaluating the scalar and vector valued noise at points in various dimensions.

Data:

flag compat102
(protected) Internal use only.

Methods:

Noise() : ParamObj()
Constructor. A plugin noise should create any data that's required to evaluate its noise function (e.g. random number tables).

~Noise()
Destructor. A plugin should free up any data created.

virtual real64 Eval(real64 v) = 0
The actual noise basis function. Returns the value at the given point in 1D space.

virtual real64 Eval(Vec2d &v) = 0
Returns the value at the given point in 2D space.

virtual real64 Eval(Vec3d &v) = 0
Returns the value at the given point in 3D space.

virtual real64 Eval(Vec4d &v) = 0
Returns the value at the given point in 4D space.

virtual void VEval(real64 v, real64 &dv) = 0
Returns the a 1D vector valued noise at the given point. (Yep, this is the same as Eval(real64 v).)

virtual void VEval(Vec2d &v, Vec2d &dv) = 0
Returns a 2D vector valued noise.

virtual void VEval(Vec3d &v, Vec3d &dv) = 0
Returns a 3D vector value noise.

virtual void VEval(Vec4d &v, Vec4d &dv) = 0
Returns a 4D vector value noise.

virtual real64 DCValue()
Returns the average value of the noise function over all space. Used by fractals as a "representative" value of this noise when there frequency of the noise approaches (or is smaller than) a pixel.

virtual real64 OctaveCorrect()
Returns an indication of the frequency components of the noise. Noises which contain known frequencies higher than unit frequency can return the number of octaves that a fractal should reduce itself by in order to get those frequencies back to pixel size. For example, the ridged basis functions generate frequencies approximately twice the unit frequency, so return 1.0 here to reduce the fractal octaves by 1 (assuming a lacunarity of 2.0). If in doubt, return 0.0 here.

flag Load(MojoInputStream &in)
flag Save(MojoOutputStream &out)
Loads and saves the state of the compat102 flag (internal use only).

 

Object

class Object : public ParamObj
The Object class provides the base class for anything that will have an actual position in space and be part of the scene. This includes renderable primitives like the planets, spheres, polygon meshes, and things that don't get rendered, like cameras, lights, helper objects.

The Object class contains information regarding hierarchies, pivots and groups (not documented below). All this is currently unimplemented.

Data:

Matrix toWorld, fromWorld
(public) The transformations to and from world space.

flag renderable
(public) Should a renderer attempt to render geometry for this object?

flag previewable
(public) Should the real time renderer ask this object to draw a representation?

Methods:

Object()
Constructor. All transforms are set to the identity.

~Object()
Destructor.

virtual void Translate(Vec3d d, Matrix *space = NULL, Matrix *iSpace = NULL)
Applies a translation of the passed vector to the world space position of the object. If the space matrices are NULL, this transformation takes place in world space. If the spaces are defined, then the transforms takes places in the space defined. iSpace should always be the inverse of space.

virtual void Scale(Vec3d s, Matrix *space = NULL, Matrix *iSpace = NULL)
Scales the object by the given scale vector. See Translate().

virtual void Rotate(Vec3d a, real64 ang, Matrix *space = NULL, Matrix *iSpace = NULL)
Rotates the object by the given angle (in radians) about the given axis. See Translate().

virtual void SetUnitScale()
Resets the scale of the object to (1.0, 1.0, 1.0) while leaving translation and rotation unchanged.

virtual void TransformEnd()
Called whenever a series of transformations has ended. Objects with previews that depend on transformations can override this to update that transformation when required, rather at each transformation call.

virtual void ConformMatrices()
Ensures that the toWorld and fromWorld matrices are valid inverses. Used to get rid of drift and numerical instability resulting from very large numbers of small transforms.

virtual Vec3d FindTransformCentre()
If an object wishes to transform around a point other then the origin in object space, it can return the "center" point here.

virtual flag Load(FileStream *in)
Loads transformations and rendering/preview state from the file.

virtual flag Save(FileStream *out)
Saves the transforms and flag state to the file.

virtual flag PostLoad(TList<Plugged *> *list)
Rebuilds the pointers from the save ID's loaded from the file.

 

Param

class Param
The Param class is the basis of all the controls a ParamObj will provide. It also provides for function overrides, allowing the creation of function graphs. This base class is "typeless" and provides some common things for the SParam class, which derives from this and is templated to provide support for specific types. Regardless of the "native" type of any parameter, the Converter class allows it to return its value as any other type. This conversion will always produce a sensible value (in that it won't crash the app), but this value may not be meaningful in any way depending on the types involved.

The Param class is designed with support for key frame animation, but this is currently unsupported in MojoWorld 1.x. It's assumed that parameters will contain a single value at time 0.0 and that the time field of the FunContext will be 0.0.

See Also:class SParam

Data:

Function *func
(protected) A pointer to the function that overrides this parameter (if any).

Tlist<Function *> minders;
(protected) A list of the function nodes that aren't connected to us in any way, but that we wish to show in the Function graph editor which is based on this parameter.

ParamObj *object
(public) The object that we are a parameter of.

flag canFunction
Can this parameter be overridden with a function? There are situations where it doesn't make sense to override a parameter with a function. Setting this to false will stop the function calls from happening and will not let the user connect functions to this parameter.

void *vEntries
A typeless pointer to the array of data values (defined in class SParam). (Obsolete.)

int32 numEntries
The current number of value/time pairs in the parameter arrays.

int32 maxEntries
The maximum size the arrays can be.

real64 *times
An array of time values, one corresponding to each data value in the entries array.

Converter *conv
A pointer to a converter class that can be used to convert between various parameter types.

uint32 overrideID
The save ID of the function that overrides this parameter. Loaded from the file during Load() and used in PostLoad() to find the actual function pointer.

MojoString name
The name of the parameter.

MojoString tooltip
A short help line to pop up to give more information about this parameter. (Currently unused)

MojoString longhelp
A much longer help message for this parameter. (Currently unused).

flag hidden
Should the interface hide this parameter? Either use this for "internal" parameters that aren't meant to be under user control, or for advanced parameters that most users will not need. Hidden parameters are shown in the Pro UI Graph Editor and when the "Advanced" flag is set in the preferences.txt file.

flag live
Should the object gets updates as this parameter changes? As a user drags a UI control to change this parameter, "live" parameters will cause the underlying object to get an Update() call whenever the value changes, whereas "non-live" params will only Update() the object when the user releases the control. Live parameters can be used for anything that should update in real time, but this update must be fast enough to ensure reasonable interaction with the interface.

flag noStates
Flag to exclude this parameter from the state mechanism. This stops the parameter being changed when the "Hyperspace Mixer" sliders are changed and the jump button is pressed. Some things (e.g. camera position) shouldn't change regardless of the state of the states. Use this flag to enable this behavior.

int32 group
Parameters can be grouped in the interface to provide a nested structure. By default, all parameters are group -1 which places their controls at the top level of the interface. The ParamObj contains the information about the actual groups.

WidgetType widgetType
Which widget will the UI use to present this parameter? Available widgets are?:

  • WidgetSlider: a linear slider with set minimum and maximum values.
  • WidgetThumbwheel: a thumb-wheel control with optional minimum and maximum values.
  • WidgetColorSwatch: a color swatch control to launch the color picker.
  • WidgetCheckBox: a simple Boolean check box.
  • WidgetAngleClipper: a "field of view" control for selecting angles ranges.
  • WidgetAngleSelect: a rotational angle control for selecting a single angular value.
  • WidgetTextEdit: an editable text field.
  • WidgetReadOnlyTextEdit: read only text field, used to simple return info to the user.
  • WidgetEnumListBox: a list of strings in a list box that can be converted to an integer selection.
  • WidgetFileLoad: an editable text field with a button to launch a file load dialog.
  • WidgetExpandTextEdit: a text edit for vectors that can show a single editable field (which places the same value in all vector elements) or can be switched to show multiple editable text fields, one per vector component.
  • WidgetDefaultWidget: Each parameter type has default widgets. Use this to get the default choice.

uint32 *minderID
Used internally for load/save.

int32 numMinders
Used internally for load/save. Use minders.Num() for a count of the current minder list.

Methods:

Param()
Constructor. No data is allocated and all pointers are set to NULL.

~Param()
Destructor.

virtual PTYPE Type() = 0
Returns the native type of this parameter. See Parameter Types in the Introduction.

virtual WidgetType GeneratorWidget() = 0
Returns the default widget type to use in the Generator Editors.

virtual WidgetType ProWidget() = 0
Returns the default widget type to use in the Pro UI.

virtual int32 GetInt(FunContext *fc) = 0
Gets the parameter value as an integer at the FunContext. If the parameter is overridden by a function, ignores the parameter values and calls the function to get the result.

virtual real64 GetDouble(FunContext *fc) = 0;
Gets the parameter value as a double precision float at the FunContext. If the parameter is overridden by a function, ignores the parameter values and calls the function to get the result.

virtual Vec2d GetVec2d(FunContext *fc) = 0;
Gets the parameter value as a 2D vector at the FunContext. If the parameter is overridden by a function, ignores the parameter values and calls the function to get the result.

virtual Vec3d GetVec3d(FunContext *fc) = 0;
Gets the parameter value as a 3D vector at the FunContext. If the parameter is overridden by a function, ignores the parameter values and calls the function to get the result.

virtual Vec4d GetVec4d(FunContext *fc) = 0;
Gets the parameter value as a 4D vector at FunContext. If the parameter is overridden by a function, ignores the parameter values and calls the function to get the result.

virtual Quaternion GetQuaternion(FunContext *fce) = 0;
Gets the parameter value as a quaternion orientation at the FunContext. If the parameter is overridden by a function, ignores the parameter values and calls the function to get the result.

virtual Color GetColor(FunContext *fc) = 0;
Gets the parameter value as an RGB color triple at the FunContext. If the parameter is overridden by a function, ignores the parameter values and calls the function to get the result.

virtual ColorA GetColorA(FunContext *fc) = 0;
Gets the parameter value as a 4 channel color at the FunContext. If the parameter is overridden by a function, ignores the parameter values and calls the function to get the result.

virtual MojoString GetString(FunContext *fc) = 0;
Gets the parameter value as a character string at the time defined in the FunContext. If the parameter is overridden by a function, ignores the parameter values and calls the function to get the result.

void Get(int32& val, FunContext *fc)
void Get(real64& val, FunContext *fc)
void Get(Vec2d& val, FunContext *fc)
void Get(Vec3d& val, FunContext *fc)
void Get(Vec4d& val, FunContext *fc)
void Get(Quaternion& val, FunContext *fc)
void Get(Color& val, FunContext *fc)
void Get(ColorA& val, FunContext *fc)
void Get(MojoString& val, FunContext *fc)
These methods provide an alternate way to access the parameter value. The current implementation just calls the appropriate GetInt(), GetDouble(), etc methods.

virtual int32 GetBaseInt() = 0
virtual real64 GetBaseDouble() = 0
virtual Vec2d GetBaseVec2d() = 0
virtual Vec3d GetBaseVec3d() = 0
virtual Vec4d GetBaseVec4d() = 0
virtual Quaternion GetBaseQuaternion() = 0
virtual Color GetBaseColor() = 0
virtual ColorA GetBaseColorA() = 0
virtual MojoString GetBaseString() = 0
Methods to get the base value of the parameter. These methods ignore any functions that may be overriding the parameter and just return the base value that has been set.

virtual void SIMDGetInt(int32 *v, FunContext *fc, int32 xs, int32 ys) = 0
virtual void SIMDGetDouble(real64 *v, FunContext *fc, int32 xs, int32 ys)= 0
virtual void SIMDGetVec2d(Vec2d *v, FunContext *fc, int32 xs, int32 ys)= 0
virtual void SIMDGetVec3d(Vec3d *v, FunContext *fc, int32 xs, int32 ys)= 0
virtual void SIMDGetVec4d(Vec4d *v, FunContext *fc, int32 xs, int32 ys)= 0
virtual void SIMDGetQuaternion(Quaternion *v, FunContext *fc, int32 xs, int32 ys)= 0
virtual void SIMDGetColor(Color *v, FunContext *fc, int32 xs, int32 ys)= 0
virtual void SIMDGetColorA(ColorA *v, FunContext *fc, int32 xs, int32 ys)= 0
virtual void SIMDGetString(MojoString *v, FunContext *fc, int32 xs, int32 ys)= 0
These methods will evaluate the parameter value at every point in a 2D array of contexts. If the parameter has a function overriding it, then that function's SIMDEval() method should be called to find the return values.

virtual void Set(int32 v, FunContext *fc) = 0
virtual void Set(real64 v, FunContext *fc) = 0
virtual void Set(Vec2d v, FunContext *fc) = 0
virtual void Set(Vec3d v, FunContext *fc) = 0
virtual void Set(Vec4d v, FunContext *fc) = 0
virtual void Set(Quaternion v, FunContext *fc) = 0
virtual void Set(Color v, FunContext *fc) = 0
virtual void Set(ColorA v, FunContext *fc) = 0
virtual void Set(MojoString v, FunContext *fc) = 0
Sets the value of the parameter. If the type is not the same as the type of the parameter, the value will be converted to the actual parameter type via the Converter.

void SetFromParam(Param* otherparam, PTYPE ptype, FunContext *fc)
Sets the value of this parameter to be the same as the passed otherparam, using the type specified in ptype as an intermediate representation.

virtual void GetRange(int32& low, int32& high) = 0
virtual void GetRange(real64& low, real64& high) = 0
virtual void GetRange(Vec2d& low, Vec2d& high) = 0
virtual void GetRange(Vec3d& low, Vec3d& high) = 0
virtual void GetRange(Vec4d& low, Vec4d& high) = 0
virtual void GetRange(Quaternion& low, Quaternion& high) = 0
virtual void GetRange(Color& low, Color& high) = 0
virtual void GetRange(ColorA& low, ColorA& high) = 0
virtual void GetRange(MojoString& low, MojoString& high) = 0
If a parameter's value is restricted in range, these methods will return the allowable range of parameter values. Note that the UI is responsible for ensuring that values set onto a parameter are in the allowable range.

virtual void SetRange(const int32 &low, const int32 &high) = 0
virtual void SetRange(const real64 &low, const real64 &high) = 0
virtual void SetRange(const Vec2d &low, const Vec2d &high) = 0
virtual void SetRange(const Vec3d &low, const Vec3d &high) = 0
virtual void SetRange(const Vec4d &low, const Vec4d &high) = 0
virtual void SetRange(const Quaternion &low, const Quaternion &high) = 0
virtual void SetRange(const Color &low, const Color &high) = 0
virtual void SetRange(const ColorA &low, const ColorA &high) = 0
virtual void SetRange(const MojoString &low, const MojoString &high) = 0
If the parameter should report a range to the UI, the low and high values of that range can be specified using these methods.

void SetFunction(Function *fn)
Sets the function that is used instead of the parameter values. Setting this to NULL will remove any function currently applied. This will cause an update on everything that is affected by this parameter.

void RemoveFunction()
Sets the current function to NULL, but does not cause an update on affected things.

Function *GetFunction()
Returns a pointer to the function currently overriding this parameter.

void SetConverter(Converter *conv)
Sets the converter used to convert between various parameter types (obsolete, as there is now one global converter).

Converter *GetConverter()
Returns a pointer to the current converter. (Obsolete.)

virtual flag Load(FileStream *in) = 0
Classes derived from this will load all their data/time pairs from the file along with the ID of the overriding function.

virtual flag Save(FileStream *out) = 0
Derived classes should save all their data/time pairs to the file along with the ID of the overriding function.

virtual flag PostLoad(TList<Plugged *> *list) = 0
Derived classes should use the overriding function ID to get the actual function pointer.

virtual flag IsIdentical(Param *p) = 0
Returns TRUE if both the type and the base value of this parameter are equal to the passed parameter.

virtual Param *Clone(ParamObj *newObj = NULL) = 0
Allocates a new parameter and fills it with copies of the data from this parameter. The new parameter will have no overriding function. If the newObj is NULL, the new parameter will point to the same object as this parameter, otherwise it'll point to the passed object.

virtual void Copy(Param *p) = 0
Copies all the values from passed in parameter into this parameter. This only copies that actual parameter value data, not the entire parameter information. If the parameters are not the same type, no data is copied.

virtual void StartAccumulate() = 0
virtual void Accumulate(Param *p, real64 weight) = 0
These two methods are used in the Hyperspace Mixer state system for calculating the actual parameter values for any given set of state weights. These should not be called from plugin code.

void AddToMinders(Function *fn)
void ClearMinders()
void RemoveMinder(Function *fn)
TList<Function *> *GetMinders()
These methods maintain the list of function nodes that, although not connected, should appear in the Pro UI Function Graph Editor for this parameter. These should not be called from plugin code.

 

ParamObj

class ParamObj : public Plugged
The ParamObj is the base class for all plugin types that need to present an interface of any sort to the user. They're also the base for all objects that can change and have dependencies on other objects.

The ParamObj class provides the following:

  • An array of parameters. This is used to procedurally build the interface for the object.
  • An array of Curves. These curves can be used for any remapping purpose that object needs. The curves will appear in the UI, giving access to the curve editor.
  • An array of Gradients. These allow mapping from a single value onto a color value through the Gradient Editor.
  • An array of sub-plugins. These can be used for anything the ParamObj needs to do its work. Examples include Noises for use by fractal routines, Materials for use by a blending material. The ParamObj can define which types of objects each sub-plug can be. The sub-plugins will appear in the UI, enabling users to pick specific things.
  • Dependency connections to all other ParamObj's that both depend on us and are depended on by us. Maintaining these dependencies means that when some object is changed, all the other things in the scene whose behavior depends on that object will get notified.
  • Base and Named state information. This is used by the Hyperspace Mixer states and is used to find intermediate values for the parameters, curves and gradients for a given set of state weights.

Types:

enum PARAMOBJ_ITEM {NAME, PARAM, CURVE, GRADIENT, SUBPLUG, SEPERATOR}
typedef std::pair< PARAMOBJ_ITEM, int32 > POBJ_ITEMPAIR
The default UI behavior for ParamObjs is to show the parameters, curves, then gradients in their default order from the appropriate arrays. To change the order that things are shown in the UI, set the StackDisplayList (see below) to reflect the appropriate order.

Data:

Param **params
(protected) The array or pointers to parameters. Should be allocated and all the parameters created in the plugin constructor. A parameter can be set to NULL if the type of the parameter isn't known when the ParamObj is constructed. If this is the case, then the plugin must provide an implementation of CreateDefaultParameter() to allow these parameters to be created later.

int32 numParams
(protected) The number of parameters this object has. This may be zero if the plugin has no user controls.

TList<ParamObj *> *dependsOn
(protected) A list of all the objects that this ParamObj depends on. When one of these changes, we'll get notified and can update ourselves accordingly.

TList<ParamObj *> *dependedOnBy
(protected) A list of objects that are depended on by us. When we change, we need to tell all these objects about it.

Curve **curves
(protected) An array of pointers to curves. Allocated in the plugin's constructor.

int32 numCurves
(protected) The number of curves the plugin uses. This may be zero.

Gradient **gradients
(protected) An array of pointers to gradients. Allocated in the plugin's constructor.

int32 numGradients
(protected) The number of gradients that the plugin uses. This may be zero.

Plugged **subPlugs
(protected) An array of pointers to sub-plugins that this ParamObj needs to use.

int32 numSubPlugs
(protected) The number of sub-plugins this ParamObj needs to use. May be zero.

MojoString *subPlugNames
(protected) An array of names that the UI will present for the sub-plugin slots.

uint32 *subPlugID
(protected) An array of save ID's used for loading and reconnecting the sub-plugins in Load() and PostLoad().

uint32 *depended
int32 numD
(protected) Used for loading and saving the dependency information.

BaseBUIState *baseState
TList<NamedBUIState *> namedStates
(protected) The object's base state and the list of named states that are applicable.

flag dirty
(protected) Internal use only.

int32 numGroups
MojoString *groupNames
(protected) Parameters can be collected into groups, which will be shown as expandable sub-trees in the UI. Parameters are in group -1 by default, which is the top level. If any parameter has a group set to something other than -1, then the array of group names must be allocated and initialized.

int m_UICallbackIDCounter
std::vector<ParamObjUICallback*> m_CallbackObjs
int ignorememberid
(protected) For internal use to ensure that the interface remains in sync with the actual ParamObj representation.

std::vector < POBJ_ITEMPAIR > StackDisplayList
If you want to present the parameters, curves, sub-plugins and gradients in an order different from the default layout, initialize this vector with the appropriate ordering of the objects (see Types above).

flag NameVisible
(public) Flag to turn on/off display of the name of this object in the user interface.

Methods:

ParamObj()
Constructor. Sets all arrays and counts to be zero and initializes all the lists to be empty.

~ParamObj()
Destructor. Notifies all dependents that we're being deleted, deletes all parameters, curves and gradients, and frees up all the arrays and lists.

int32 NumParams()
Returns the number of parameters this object has.

Param *GetParam(int32 i)
Gets a pointer to the i-th parameter. The index must be in the range 0..numParams-1.

virtual void Update(int32 which, FunContext *fc)
Called to tell the ParamObj that something has changed and it needs to reload any cached values of its parameters. The which value is either the index of the parameter which changed, or -1 if a global change has taken place, and all parameters need to be updated.

flag CheckForCycles(ParamObj *new_obj)
Checks through all the parameters to see if connecting this object to us in any way would create a cycle and throw MojoWorld into an infinite loop. Returns TRUE if a cycle is detected.

int32 FindParamIndex(MojoString &name)
Given the name of a parameter, find its index in the parameter array.

int32 FindParamFromPtr(Param *p)
Returns the index of the passed parameter, or -1 if the parameter doesn't belong to this object.

Param *GetParamFromName(MojoString &name)
Given the name of a parameter, return a pointer to the Param class.

virtual void CreateDefaultParameter(int32 i, PTYPE type)
Utility routine to create a new parameter of the given type at the given parameter index. The default implemtation calls assert(), a plugin should override this to create its own parameters if this is needed. In general, plugins whose parameter types are dependant on other things will use this to create parameters when the type is known, rather than creating them in the constructor.

int32 NumCurves()
Returns the number of curves this ParamObj uses.

Curve *GetCurve(int32 i)
Returns a pointer to the i-th curve. The index must be in the range 0..numCurves-1.

int32 NumGradients()
Returns the number of gradients this ParamObj uses.

Gradient *GetGradient(int32 i)
Returns a pointer to the i-th gradient. The index must be in the range 0..numGradients-1.

int32 NumSubPlugs()
Returns the number of sub-plugins this ParamObj uses.

Plugged *GetSubPlug(int32 i)
Returns a pointer to the i-th sub-plugin. The index must be in the range 0..numSubPlugs-1.

virtual flag SetSubPlug(int32 i, Plugged *plug)
Sets the i-th sub-plugin to the passed argument. The index must be in the range 0..numSubPlugs-1. Returns TRUE if the sub-plug was successfully set, FALSE if a cycle was detected and the sub-plug wasn't set.

virtual void SubPlugType(int32 i, std::vector<OTYPEFamilyPair> &list)
The plugin should use this to specifiy what types of plugin are relevant for the i-th sub-plugin. The list will be passed empty and the plugin should add as many types as are relevant to the list. This will control what the user interface allows users to choose when selecting sub-plugins. See Plugin Types in the Introduction for more information on types.

virtual SPWidgetType SubPlugWidgetType(int32 i)
Returns the style of widget that the i-th sub-plug should use for UI display. Should be one of the following:

  • spwidgetEditButton: has a single button that launches the appropriate editor for the sub-plugin. The user cannot change the actual sub-plug.
  • spwidgetLBEditButton: has a button to launch the appropriate editor and a list box to select a sub-plugin.
  • spwidgetBranch: open the sub-plugin controls as a nested branch off the current controls. The user cannot change the actual sub-plug.
  • spwidgetLBBranch: open the sub-plugin controls as a nested branch off the current controls and include a list box to select a sub-plug.

virtual flag SubPlugCreate(int32 i)
Return TRUE if you want the user to be able to create a new object to use as a sub-plugin. Return FALSE if you only want the user to be able to select currently existing objects from the scene.

MojoString GetSubPlugName(int32 i)
Returns the UI display name for the i-th sub-plug.

flag CheckForSubPlugCycles(Plugged *plug)
Similar to CheckForCycles(), this returns TRUE if adding this as a sub-plug would create a cycle or infinite loop.

void SetDirty()
Obsolete.

int32 GetNumGroups()
Returns the number of parameter groups for this object.

MojoString &GetGroupName(int32 i)
Returns the name of the i-th parameter group.

bool GetParamsInGroup(int32 i, std::vector<Param*> &list)
Clears the vector and puts all parameters in group i into vector. Ordering is same as in main parameter list. Asserts and returns FALSE if the group ID is invalid.

int32 NumDependsOn()
Returns the number of objects that we depend on.

void AddDependsOn(ParamObj *obj)
Add this object to the list of things we depend on.

flag RemoveDependsOn(ParamObj *obj)
Removes this object from the list of things we depend on. Returns FALSE if there was no dependency on the object, TRUE otherwise.

ParamObj *GetDependsOn(int32 i)
Gets the i-th object that we depend on.

flag ReplaceDependsOn(ParamObj *obj, int32 i)
Replace the i-th object we depend on with this new object. Returns TRUE on success.

flag ReplaceDependsOn(ParamObj *obj, ParamObj *old)
Replace the "old" object we depend on with the new object. Returns FALSE if the old object wasn't in the dependsOn list, TRUE otherwise.

flag DependsOn(ParamObj *obj)
Returns TRUE if we depend on this object.

void TellDependsOn(DependMessage mess, void *param, FunContext *fc = NULL)
Loops over all the things we depend on and send them a message telling them we're being changed/added/deleted.

int32 NumDependedOnBy()
Returns the number of ParamObjs that depend on us.

void AddDependedOnBy(ParamObj *obj)
Add this object to the list of things that depend on us.

flag RemoveDependedOnBy(ParamObj *obj)
Remove this object from the list of things that depend on us. Returns TRUE on success, FALSE if the object was not in our dependency list to start with.

ParamObj *GetDependedOnBy(int32 i)
Returns a pointer to the i-th object that depends on us. The index must be in the range 0..numDependedOnBy-1.

flag ReplaceDependedOnBy(ParamObj *obj, int32 i)
Replaces the i-th object that depends on us by this one. The index must be in the range 0..numDependedOnBy-1.

flag ReplaceDependedOnBy(ParamObj *obj, ParamObj *old)
Search for the old object in the list of things that depend on us, and if found, replace it with the new. Returns TRUE if found, FALSE if the object wasn't in the list.

flag DependedOnBy(ParamObj *obj)
Returns TRUE if we are depended on by this object.

void TellDependedOnBy(DependMessage mess, void *param, FunContext *fc = NULL)
Tells all the objects that we are depended on by that we're being changed/added/deleted. Does this by calling each depedent's HandleDependedOnByMessage() method.

virtual void HandleDependsOnMessage(DependMessage mess, void *param, FunContext *fc = NULL)
Called by TellDependsOn() of something that depends on us. The message parameters tells whether the object is being changed, added or deleted. If it's a change, the parameter that was changed is also passed. (NB: this needs further work to get all the dependency stuff going properly.)

virtual void HandleDependedOnByMessage(DependMessage mess, void *param, FunContext *fc = NULL)
Similar to HandleDependsOnMessage(), but called by the TellDependedOnBy() method of something that we depend on.

virtual flag Load(FileStream *in)
Loads everything important from the file stream. This is currently all the parameters, curves, sub-plugin ID's and dependency ID information.

virtual flag Save(FileStream *out)
Saves all relevant data to the file stream. Currently does all parameters, curves, sub-plugin ID's and the ID's of everything in the dependency lists.

virtual flag PostLoad(TList<Plugged *> *list)
Called after Load() and reconnects everything whose ID was loaded with the proper pointer.

 

Plugged

class Plugged
The Plugged class is the base class from which all plugins must derive. It has methods for identifying this plugin, defining what type of plugin it is and a generic expansion method.

Data:

uint32 saveID
A unique ID for this object, used for loading and saving. Just prior to saving, each plugin instance is assigned a unique ID. A plugin can save the ID of anything it wants to retain a pointer to and use this ID to regain that pointer in its PostLoad() method. These ID's are only valid for a single Save/Load cycle and should not be used for anything else. No assumption should be made about the contents of this variable except in the Save() method.

Methods:

virtual ID UniqueID() = 0
Returns a unique ID for this class of plugin. Each different type of plugin must have a unique ID associated with it. This is used for creation of instances of plugins inside the core app. The ID is an unsigned 32 bit integer. Under the current scheme, all values with the high bit not set are reserved for standard MW plugins. All values with the high bit set are available to third party developers.

virtual OTYPE ObjectType() = 0
Returns the type of the plugin that this is. See the Plugin Types section in the Introduction.

virtual char *Name() = 0
Returns a generic name for this plugin type.

virtual void *Execute(void *p1, void *p2, void *p3, void *p4)
A generic expansion method. Any plugin can do anything it wants with this method. This can be used for communication between two plugins, or for extending the API at a later date without breaking the current standard.

virtual flag Load(FileStream *in)
Loads the plugins saveID from the file stream.

virtual flag Save(FileStream *out)
Saves the plugins Unique ID and save ID to the file stream.

virtual flag PostLoad(TList<Plugged *> *list)
Currently just a placeholder.

 

Plugin

class Plugin
The Plugin class provides a description of a plugin and a method to create an instance of a plugin. Each plugin in a plugin file requires a class derived from Plugin to tell the plugin manager what it does and let the plugin manager create instances of the plugin. It is this derived class that is returned from the DLL's Plugin() call. See the Plugin File Basics section in the Introduction.

Methods:

virtual ID UniqueID() = 0
Tells the plugin manager the unique ID of the plugin. This must be the same value as the UniqueID() method of the actual plugin instance this creates.

virtual OTYPE Type() = 0
Tells the plugin manager what type of plugin this creates. Must be the same as the value returned by the plugin instance's ObjectType() method.

virtual Plugged *Create() = 0
Returns a pointer to a newly created instance of this plugin.

virtual char *Description() = 0
Returns a pointer to a character string with a short name/description of what this plugin does.

 

PreviewObject

class PreviewObject : public Object
The PreviewObject class provides methods for anything that will require something to be drawn in the real time renderer. It provides methods for preparing and updating the preview represenation and drawing the preview in a variety of styles. It also has support for object selection.

Data:

Color preColor
Provides a preview color for rendering the object when it's not selected.

Color selColor
A selected color. Used for rendering the object when it's the currently selected one.

Methods:

PreviewObject() : Object()
Constructor. Sets the preview and selection colors to default values. Flags this object as not renderable, but previewable (see class Object for those flags).

~PreviewObject()
Destructor.

virtual void PreparePreview(Camera *cam, FunContext *fc)
Given the camera and any other information from the FunContext (eg time), prepare any initial preview representation of the object.

virtual void UpdatePreview(Camera *cam, FunContext *fc)
Update any previously prepared preview, based on the new camera position or time value.

virtual void SetPreviewQuality(real64 pq)
Sets the quality of the preview, 0.0 = bad and fast, 1.0 = good and slow (NB: not currently used).

virtual void WireDraw(DrawingContext *dc)
Draw the preview representation using wire frame only.

virtual void ShadeDraw(DrawingContext *dc)
Draw the preview representation using shaded polygons, but no textures.

virtual void TextureDraw(DrawingContext *dc)
Draw the full preview representation, textures and all. (NB: for all drawing routines, the DrawingContext is not currently used and will probably go.)

virtual flag HitTest(Camera *cam, Vec2d pixel, HitInfo &hinfo) = 0
Does the ray through the pixel hit the object? Used for quick'n'dirty selection in the real time renderer, so only needs to be as accurate as required to select the object.

virtual flag Load(FileStream *in)
Loads the preview and selected colors from the file stream.

virtual flag Save(FileStream *out)
Saves the preview and selected colors to the file stream.

virtual flag PostLoad(TList<Plugged *> *list)
Currently just calls Object::PostLoad().

 

Quaternion

class Quaternion
Provides for a quaternion representation of object orientation. Used in the Quaternion parameter type.

A quaternion defines an angle of rotation and an axis about which to rotate. The x, y, z components of the quaternion are the unit axis, multiplied by the sine of half the angle. Then w component is the cosine of half the angle.

E.g.: (where ang is the angle of rotation in radians, and axis is a unit vector to rotate about)

     real64 sa = sin(ang*0.5);
     real64 ca = cos(ang*0.5);
     q.x = axis.x*sa;
     q.y = axis.y*sa;
     q.z = axis.z*sa;
     q.w = ca;

In general, quaternions should be unit, where x2 + y2 + z2 + w2 == 1.0

Data:

real64 x, y, z, w
The four components of the quaternion. See above for the component meanings.

Methods:

inline Quaternion(real64 pw, real64 px, real64 py, real64 pz)
Constructor, initializes the four components.

inline Quaternion()
Constructor. No initialization is done.

inline Quaternion(const Quaternion &v)
Constructor, copies the information from the argument.

inline real64 &operator[] (const int32 i)
Array indexing operator. Indexes the components in the order x = 0, y = 1, z = 2, w = 3.

inline Quaternion operator+(const real64 &v)
inline Quaternion operator+=(const real64 &v)
Adds a constant to all terms in the quaternion.

inline Quaternion operator-(const real64 &v)
inline Quaternion operator-=(const real64 &v)
Subtracts a constant from all terms of the quaternion.

inline Quaternion operator*(const real64 &v)
inline Quaternion operator*=(const real64 &v)
Multiplies all terms of the quaternion by a constant.

inline Quaternion operator/(const real64 &v)
inline Quaternion operator/=(const real64 &v)
Divides all terms of the quaternion by a constant.

inline Quaternion operator-()
Quaternion negation. Negates the axis components, leaves the angle (w) component unchanged. The new quaternion represents the reverse rotation about the same axis.

inline Quaternion operator+(const Quaternion &v)
inline Quaternion operator+=(const Quaternion &v)
Adds two quaternions, term by term.

inline Quaternion operator-(const Quaternion &v)
inline Quaternion operator-=(const Quaternion &v)
Subtracts the argument from this quaternion, term by term.

inline Quaternion operator*(const Quaternion &v)
inline Quaternion operator*=(const Quaternion &v)
Multiplies the two quaternions.

inline Quaternion operator/(const Quaternion &v)
inline Quaternion operator/=(const Quaternion &v)
Divides the quaternion by the argument.

inline int32 operator ==(const Quaternion &v)
Quaternion equality check. Does no epsilon check, so may not be robust under some circumstances.

inline int32 operator !=(const Quaternion &v)
Inequality check.

inline real64 Length() const
Returns the length of the quaternion. √(x2 + y2 + z2 + w2)

inline real64 Length2()
Returns the length of the quaternion squared. Much quicker than Length() as it doesn't require the square root.

inline void Normalize()
Ensures the the quaternion is a unit quaternion, length == 1.0. Does no error checking for a zero length quaternion.

Matrix ToMatrix()
Converts the quaternion to a matrix representation. The matrix will be a pure rotation (i.e. no shift, scale or perspective components).

 

Renderer

class Renderer : public Plugged
The base class from which all photorealistic renderers will derive. A simple interface with methods for preparing to render and rendering a frame to a bitmap.

Methods:

Renderer() : Plugged()
Constructor. Currently just blank.

~Renderer()
Destructor.

virtual flag PrepareToRender(TList<PreviewObject *> *scene, Camera *cam, real64 time) = 0
Method to let the renderer prepare anything it will need to perform the actual render. This defines the camera that the rendering will use (NB: this may not be the current camera that the real time renderer is using).

virtual flag Render(Bitmap *result, RenderCallback *rcb)
Method to actually render the image. The camera should be the one defined in PrepareToRender(). The image resolution is defined by the bitmap (see below). The RenderCallback provides for image updates as the render proceeds and can let renders be cancelled (see below).

Support Classes:

The renderer also makes use of two support classes, defined here for the time being. These classes will probably change, as the goblin bitmap class comes available, and the actual UI requirements for the renderers become clearer.

class Bitmap
{
public:
    uint8 *data;  // pointer to the image data
    int32 wid, hgt, channels; // resolution and number of channels

    Bitmap();
    Bitmap(int32 wid, int32 hgt, int32 channels);
    ~Bitmap();
};

class RenderCallback
{
public:
    virtual flag UpdateImageBlock(int32 lx, int32 ly, int32 hx, int32 hy) = 0;
    // return TRUE to continue render, false to cancel.
};

 

RenderObject

class RenderObject : public PreviewObject
The render object class is the base class for any object who wants to have geometry rendered by the photorealistic renderers. The main render methods are the ray intersection method for any ray tracers and the SubPrimitive generation methods for scan line renderers.

Data:

uint32 mtlID
(private) The save ID of the material, used for loading/saving only.

Material *mtl
The current material that's applied to this object.

Methods:

RenderObject() : PreviewObject()
Constructor. Sets the material to NULL and the renderable flag to TRUE (see class Object for the rendering flags).

~RenderObject()
Destructor. Currently empty.

virtual flag Intersect(Ray &ray, Intersection &inter, FunContext *fc)
Perform a ray intersection with the primitive. See below for current definitions of the Ray and Intersection classes. Returns TRUE if the ray hit and the intersection data is valid, FALSE otherwise.

virtual int32 NumSubPrims()
Returns the initial number of sub-primitives this object will supply to a scan line/Reyes renderer. How the RenderObject chooses to split itself is entirely arbitrary.

virtual SubPrimitive *GetSubPrim(int32 i)
Gets a pointer to the i-th SubPrimitive of this RenderObject. NULL can be returned to make the renderer just skip that sub-primitive.

virtual void RenderPrepare(FunContext *fc)
Called once on each object before rendering starts. Objects should ensure all their parameters are up to date and any representations needed for internal rendering calculations can be performed.

virtual flag Load(FileStream *in)
Loads the save ID of the object's material.

virtual flag Save(FileStream *out)
Saves the save ID of the object's current material to the file.

virtual flag PostLoad(TList<Plugged *> *list)
Uses the just loaded ID of the material to get the actual material pointer.

Support Classes:

These two classes are used by the ray trace interface to perform ray intersections with objects. These will evolve as the shipping ray tracer gets solidified.

class Ray
{
public:
    Vec3d from; 
    // ray start and direction (direction is unit)
    Vec3d dir;
    real64 startT, endT;
    // t parameters of the segment we're interested in
    int32 level;
    // how many bounces has this done?
};

class Intersection
{
public:
    Vec3d hit;          // hit point
    Vec3d norm;         // UNIT normal at hit
    real64 rayT;        // the ray parameter
    RenderObject *ob;   // what we actually hit
    Ray ray;            // the ray that was fired to create this hit.
};

 

Satellite

class Satellite : public PreviewObject
The main function of the Satellite class is to ensure that transforms on the associated render object and light source are correct for the renderers. It also ensures that the drawing order is correct for the OpenGL renderer.

Data:

RenderObject *obj
(protected) What object does the Reyes renderer use for rendering? May be NULL if no object is associated with this satellite.

Light *light
(protected) The light source that we're responsible for. May be NULL if this satellite does not cast light.

Methods:

Satellite() : PreviewObject()
Constructor. Sets the render object and light to NULL.

~Satellite()
Destructor.

OTYPE ObjectType()
Returns type objSatellite.

virtual void SetOrbitalPosition(float val)
Sets the orbital position, in the range 0.0 to 1.0.

virtual void SetOrbitalRadius(float val)
Sets the orbit's radius.

virtual real64 GetOrbitalRadius()
Returns the orbit's radius.

virtual void SetTimeOfYear(float val)
Lets a satellite change its orbit and/or other parameters dependant on time of year. (val ranges from 0.0 to 1.0.) The standard Sun and Moon satellites use this to simulate the eccentricity of the planetary axis.

virtual real64 GetOrbitalPosition()
Returns the orbital position.

virtual void RotateOrbitalPlane(const Vec3d &axis, real64 ang, const Vec3d &mainAxis)
In MojoWorld 1.x, the time of year is simulated by rotating the entire orbital plane about the planet's axis.

 

SParam

template < class T > class SParam : public Param
The SParam class provides type specific implementations of the base Param class and provides access to the Interpolator for animation. In general, plugins will create their parameters as Sparams, which can then be treated as a typeless Param by other parts of the system.

Data:

Interpolator<T> *interp
(private) Pointer to the current interpolator used by this parameter.

T *entries
A pointer to the array of data values. (This is the typed version of the vEntries pointer in the Param class.)

Methods:

SParam(T v) : Param()
Constructor. The entries and times arrays are allocated and an initial value (the argument) is set at time 0.0. The interpolator is set to NULL.

~SParam()
Destructor. Deletes the entries and times arrays.

void LocalSet(T v, FunContext *fc)
Sets the value of the parameter at the time given in the FunContext. This method is generally only called by the typed Set() methods below, once any type conversions have been done. It will only take an argument of the native type of the parameter.

void Get(T &t, FunContext *fc)
Gets the value at the time given by the FunContext. If there is an overriding function, this is called to get the value. If there is an interpolator, that is used to get values at times other than the key frames. This method is generally only called from the typed Get*() methods below, which perform any type conversions. This method only returns a value of the native type of the parameter.

PTYPE Type()
Returns the native type of this parameter. See Parameter Types in the Introduction.

inline int32 GetInt(FunContext *fc)
Gets the value of this parameter at the time given by the FunContext, converted to an integer.

inline real64 GetDouble(FunContext *fc)
Gets the value of this parameter at the time given by the FunContext, converted to a double precision floating point value.

inline Vec2d GetVec2d(FunContext *fc)
Gets the value of this parameter at the time given by the FunContext, converted to a 2D vector.

inline Vec3d GetVec3d(FunContext *fc)
Gets the value of this parameter at the time given by the FunContext, converted to a 3D vector.

inline Vec4d GetVec4d(FunContext *fc)
Gets the value of this parameter at the time given by the FunContext, converted to a 4D vector.

inline Quaternion GetQuaternion(FunContext *fc)
Gets the value of this parameter at the time given by the FunContext, converted to a quaternion orientation.

inline Color GetColor(FunContext *fc)
Gets the value of this parameter at the time given by the FunContext, converted to a 3 component RGB color.

inline ColorA GetColorA(FunContext *fc)
Gets the value of this parameter at the time given by the FunContext, converted to a 4 component RGBA color.

inline String GetString(FunContext *fc)
Gets the value of this parameter at the time given by the FunContext, converted to a character string.

void VectorGetInt(int32 *v, FunContext *fc, int32 num)
Gets an array of values from the parameter, converted to integers.

void VectorGetDouble(real64 *v, FunContext *fc, int32 num)
Gets an array of values from the parameter, converted to double precision floating point values.

void VectorGetVec2d(Vec2d *v, FunContext *fc, int32 num)
Gets an array of values from the parameter, converted to 2D vectors.

void VectorGetVec3d(Vec3d *v, FunContext *fc, int32 num)
Gets an array of values from the parameter, converted to 3D vectors.

void VectorGetVec4d(Vec4d *v, FunContext *fc, int32 num)
Gets an array of values from the parameter, converted to 4D vectors.

void VectorGetQuaternion(Quaternion *v, FunContext *fc, int32 num)
Gets an array of values from the parameter, converted to quaternion orientations.

void VectorGetColor(Color *v, FunContext *fc, int32 num)
Gets an array of values from the parameter, converted to 3 component RGB colors.

void VectorGetColorA(ColorA *v, FunContext *fc, int32 num)
Gets an array of values from the parameter, converted to 4 component RGBA colors.

void VectorGetString(String *v, FunContext *fc, int32 num)
Gets an array of values from the parameter, converted to character strings.

inline void Set(int32 v, FunContext *fc)
Converts the integer to the native parameter type and sets a keyframe at the time given by the FunContext.

inline void Set(real64 v, FunContext *fc)
Converts the double precision float to the native parameter type and sets a keyframe at the time given by the FunContext.

inline void Set(Vec2d v, FunContext *fc)
Converts the 2D vector to the native parameter type and sets a keyframe at the time given by the FunContext.

inline void Set(Vec3d v, FunContext *fc)
Converts the 3D vector to the native parameter type and sets a keyframe at the time given by the FunContext.

inline void Set(Vec4d v, FunContext *fc)
Converts the 4D vector to the native parameter type and sets a keyframe at the time given by the FunContext.

inline void Set(Quaternion v, FunContext *fc)
Converts the quaternion orientation to the native parameter type and sets a keyframe at the time given by the FunContext.

inline void Set(Color v, FunContext *fc)
Converts the RGB Color to the native parameter type and sets a keyframe at the time given by the FunContext.

inline void Set(ColorA v, FunContext *fc)
Converts the 4 component RGBA color to the native parameter type and sets a keyframe at the time given by the FunContext.

inline void Set(String v, FunContext *fc)
Converts the character string to the native parameter type and sets a keyframe at the time given by the FunContext.

flag Load(FileStream *in)
Loads all the value/data pairs from the file and the ID of the overriding function. (NB: we will have to include interpolator as well at some point.)

flag Save(FileStream *out)
Saves all the value/data pairs to the file and the ID of the overriding function (if any).

flag PostLoad(TList<Plugged *> *list)
Restores the pointer to any overriding function.

void SetInterpolator(Interpolator<T> *interp)
Sets the current interpolator used to generate values for times that are not exactly on key frames.

Interpolator<T> *GetInterpolator()
Returns the current interpolator.

 

SubPrimitive

class SubPrimitive
If a RenderObject wants to be renderable by the Reyes renderer, it needs to be able to describe itself in terms of one or more sub-primitives. These sub-primitives in turn need to be able to split themselves into smaller sub-primitives, or dice themselves into a mesh of micropolygons.

Data:

RenderObject *object
The RenderObject that we represent a section of.

MicroGrid *grid
The grid of micropolygons that we've diced ourselves into (may be NULL if this sub-primitive hasn't been diced yet).

int32 bucketCount
How many screen buckets we're currently in. Maintained by the renderer.

BBox2d screenBox
A screen space bounding box of the sub-primitive. Used to decide between splitting into more sub-primitives or dicing into polygons.

real64 closeDist
The closest distance that any geometry comes to the eye point. This can be a conservative guess, as long as any guess is closer than the actual value. This is used to prune geometry before dicing into micropolygons.

virtual void PrimBounds(BBox3d &box, FunContext *fc) = 0
Defines the bounding box of this sub-primitive in world space.

virtual flag Split(TList<SubPrimitive *> *list, FunContext *fc) = 0
Split this sub-primitive into any number of smaller ones. The passed list is the current list of sub-primitives from the renderer. This sub-primitive should make as many smaller sub-primitives as it wants and add them to the list (e.g. list->Add(newSubPrim). Any other modification to the list than a simple add will cause major grief in the renderer.

virtual void Dice(int32 &xs, int32 &ys, FunContext *fc) = 0
Dices this sub-primitive into an xs by ys mesh of micropolygons. In the current state of the renderer, this methods also needs to call the material Shade() method for each micropolygon. This is efficient in some ways (we don't need to store all the contexts from generating the geometry to call the Shade() method later) and inefficient in others (everything gets shaded regardless of whether it's visible). This is one of the areas under scrutiny as the Reyes renderer progresses.

virtual ~SubPrimitive()
Destructor. A plugin should delete the microgrid data if it has been created.

Support Classes:

The sub-primitives need to dice themselves into grids of micropolygons. This is the current definition of the MicroGrid class.

class MicroGrid
{
public:
    MicroGrid(RenderObject *ro, int32 xs, int32 ys);
    ~MicroGrid();
    int32 xSize, ySize;
    // The dimensions of the grid.
    // There are size+1 points, making size quads.
    int32 displaced;           // are the vertices displaced?
    RenderObject *object;

    int32 screenDone;          // have we calculated the screen points yet?
    Vec3d *points;             // the original world space points
    Vec3d *eyePoints;
    // and the points transformed into eye space
    Vec2d *screenPoints;       // cache of the points in screen space
    Vec3d *normals;            // world space normals
    Color *colors; 
    // _preshaded_ colors returned from the material.
    // (why do we need normals?)

    flag ScreenPointInside(int32 x, int32 y, Vec2d p, real64 &z);
    // is the screen point inside the given poly?
    // (and find the z if it is...)
    BBox2d FindScreenBounds(int32 x, int32 y);
    // find the screen bounds of the given poly

    void Shade(FunContext *fc); // calls the material Shade() on all points
};

 

Vec2d

class Vec2d
A two dimensional vector class. Components are stored as double precision floating point. A corresponding fVec2d class which stores its data as single precision floating point is also available.

Data:

real64 x, y
The components of the vector.

Methods:

inline Vec2d(real64 px, real64 py)
Constructor. Initializes the components.

inline Vec2d()
Constructor. No initialization is done.

inline Vec2d(const Vec2d &v)
Constructor. Copies the data from the argument.

inline real64 &operator[] (const uint32 i)
Indexes the vector as an array, x = 0, y = 1.

inline Vec2d operator+(const Vec2d &v)
inline Vec2d &operator+=(const Vec2d &v)
Adds two vectors together.

inline Vec2d operator-(const Vec2d &v)
inline Vec2d &operator-=(const Vec2d &v)
Subtracts the argument from this vector.

inline Vec2d operator*(const Vec2d &v)
inline Vec2d &operator*=(const Vec2d &v)
Multiplies the two vectors, component by component.

inline Vec2d operator/(const Vec2d &v)
inline Vec2d &operator/=(const Vec2d &v)
Divides the vector by the argument, component by component. Does no checking for divide by zero.

inline Vec2d operator+(const real64 &v)
inline Vec2d &operator+=(const real64 &v)
Adds a constant to all vector components.

inline Vec2d operator-(const real64 &v)
inline Vec2d &operator-=(const real64 &v)
Subtracts a constant from all vector components.

inline Vec2d operator*(const real64 &v)
inline Vec2d &operator*=(const real64 &v)
Multiplies all vector components by the constant.

inline Vec2d operator/(const real64 &v)
inline Vec2d &operator/=(const real64 &v)
Divides all vector components by the constant. No divide by zero error checking is done.

inline int32 operator==(const Vec2d &v)
Equality check. Does no epsilon check, so may not be robust under all circumstances.

inline int32 operator!=(const Vec2d &v)
Inequality check.

inline Vec2d operator -()
Negates all components of the vector.

inline real64 operator^(Vec2d &v)
Cross Product. Returns a single value representing sine of the angle between the two vectors, multiplied by their lengths.

inline real64 operator%(Vec2d &v)
Returns the dot product of the two vectors.

inline real64 Length()
Returns the length of the vector.

inline real64 Length2()
Returns the length of the vector squared.

inline void Normalize()
Ensures the vector has unit length. Does no checking for a zero length vector.

Friend Functions:

The following functions provide a much more readable version of the dot and cross product.

inline real64 DotProd(Vec2d a, Vec2d b)
inline real64 CrossProd(Vec2d a, Vec2d b)

 

Vec3d

class Vec3d
Three dimensional double precision floating point vector class. Use class fVec3d for single precision floating point vectors.

Data:

real64 x, y, z
Components of the vector.

Methods:

inline Vec3d(real64 px, real64 py, real64 pz)
Constructor. Initializes the components.

inline Vec3d()
Constructor. No initialization is done.

inline Vec3d(const Vec3d &v)
Constructor. Copies the components from the argument.

inline real64 &operator[] (const int32 i)
Indexes the vector as an array, x = 0, y = 1, z = 2.

inline Vec3d operator+(const Vec3d &v)
inline Vec3d &operator+=(const Vec3d &v)
Adds two vectors.

inline Vec3d operator-(const Vec3d &v)
inline Vec3d &operator-=(const Vec3d &v)
Subtracts the argument from the vector.

inline Vec3d operator*(const Vec3d &v)
inline Vec3d &operator*=(const Vec3d &v)
Multiplies the two vectors, component by component.

inline Vec3d operator/(const Vec3d &v)
inline Vec3d &operator/=(const Vec3d &v)
Divides the vector by the argument, component by component. Does no checking for divide by zero.

inline Vec3d operator+(const real64 &v)
inline Vec3d &operator+=(const real64 &v)
Adds the constant to all the vector components.

inline Vec3d operator-(const real64 &v)
inline Vec3d &operator-=(const real64 &v)
Subtracts the constant from all the vector components.

inline Vec3d operator*(const real64 &v)
inline Vec3d &operator*=(const real64 &v)
Multiplies all vector components by the constant.

inline Vec3d operator/(const real64 &v)
inline Vec3d &operator/=(const real64 &v)
Divides all vector components by the constant. No checking is done for divide by zero.

Vec3d &operator*=(const Matrix &m)
Vec3d operator*(const Matrix &m)
Multiplies the vector by the matrix. No perspective transformation is done.

inline int32 operator ==(const Vec3d &v)
Equality check. Does no epsilon check, so may not be robust enough in all circumstances.

inline int32 operator !=(const Vec3d &v)
Inequality check.

inline Vec3d operator -()
Negates all components of the vector.

inline Vec3d operator^(Vec3d &v)
Returns the cross product of the vector and the argument.

inline real64 operator%(Vec3d &v)
Returns the dot product of the two vectors.

inline real64 Length()
Returns the length of the vector.

inline real64 Length2()
Returns the length of the vector squared.

inline void Normalize()
Ensures that the vector is a unit length. Does no checking for zero length vectors.

Friend Functions:

The following functions provide a much more readable version of the dot and cross product.

inline real64 DotProd(Vec3d a, Vec3d b)
inline Vec3d CrossProd(Vec3d a, Vec3d b)

 

Vec4d

class Vec4d
Four dimensional double precision floating point vector class. Use fVec4d for a single precision floating point vector class.

Data:

real64 x, y, z, w
Components of the vector.

Methods:

inline Vec4d(real64 px, real64 py, real64 pz, real64 pw)
Constructor. Initializes the components.

inline Vec4d()
Constructor. No initialization is done.

inline Vec4d(const Vec4d &v)
Constructor. Components are copied from the argument.

inline real64 &operator[] (const int32 i)
Indexes the vector as an array. x = 0, y = 1, z = 2, w = 3.

inline Vec4d operator+(const Vec4d &v)
inline Vec4d &operator+=(const Vec4d &v)
Adds two vectors.

inline Vec4d operator-(const Vec4d &v)
inline Vec4d &operator-=(const Vec4d &v)
Subtracts the argument from the vector.

inline Vec4d operator*(const Vec4d &v)
inline Vec4d &operator*=(const Vec4d &v)
Multiples two vectors, component by component.

inline Vec4d operator/(const Vec4d &v)
inline Vec4d &operator/=(const Vec4d &v)
Divides the vector by the argument, component by component. No checking is done for divide by zero.

inline Vec4d operator+(const real64 &v)
inline Vec4d &operator+=(const real64 &v)
Adds the constant to all components of the vector.

inline Vec4d operator-(const real64 &v)
inline Vec4d &operator-=(const real64 &v)
Subtracts the constant from all components of the vector.

inline Vec4d operator*(const real64 &v)
inline Vec4d &operator*=(const real64 &v)
Multiplies all components of the vector by the constant.

inline Vec4d operator/(const real64 &v)
inline Vec4d &operator/=(const real64 &v)
Divides all vector components by the constant. Does no checks for divide by zero.

inline int32 operator ==(const Vec4d &v)
Equality check. Does no epsilon check, so may not be robust under all circumstances.

inline int32 operator !=(const Vec4d &v)
Inequality check.

inline Vec4d operator -()
Negates all components of the vector.

inline real64 operator%(Vec4d &v)
Returns the dot product of the two vectors.

inline real64 Length()
Returns the length of the vector.

inline real64 Length2()
Returns the length of the vector squared.

inline void Normalize()
Ensures the vector has a unit length. Does no zero length checking.

Friend Functions:

The following function provides a much more readable alternative for Dot Product.

inline real64 DotProd(Vec4d a, Vec4d b)