This class is used to build a reference list of animation nodes.
class linktype : public dbl_llist {
public:
} ;
quark *link;
An instance of keyframe can be used to keep track of either quaternion or spline interpolations or transitions between two animation sets. Transitions between two different animation sets usually happens when one animation switches/changes to another - ie you have a set of keys for a walk, and a set of keys for a run. The transition period is an interpolation step between the last key of the walk, and the first key of the run.
class keyframe {
public:
int status;
This field is set to true, if this instance is in transition between a previous and current set of keys. When the transition period is finished, it is set to false.
int key;
This field contains an index to the current key.
float frame;
This field is a timer between the last key and the current key
float framesperspline, iframesperspline;
These fields contain the time between each key and the inverse (1/z).
int count;
This field contains the number of keys.
int auto_flag;
This field is set to true if the animation repeats itself. If set to false, the animation "locks" to the last key when reached.
vector4f current;
This field contains the current key.
vector4f old;
This field contains the previous key.
float catchup, icatchup;
These fields contain the amount of time between animation transitions, and the inverse (1/z).
vector4f *key_data;
This field contains an array of key points.
keyframe();
virtual ~keyframe();
};
An instance of kinematic can be used to keep track of quaternion and spline data as well as the current state of animation.
class kinematic {
protected:
keyframe orient;
This field keeps track of the current quaternion interpolation.
keyframe pos;
This field keeps track of the current spline keyframe interpolation.
void update_localsp(float deltat);
This method is used to advance the spline keyframe interpolation, where "deltat" is the amount of time between the last frame and the current frame. This method is used exclusively by "calc_localsp()".
void calc_localsp(float *v, float deltat, int liveflag);
This method is used to traverse a predefined path of spline keyframes. "deltat" is the time between the last and current frame. If "liveflag" is false, then the next position is precalulated, otherwise it will wait till the next call to this method. The interpolated position is returned in "v". This method is used exclusively by "calc_localspline()".
int update_preparesp(float deltat);
This method decides if a transition from one set of animation spline keyframes to another is complete. "deltat" is the time between the last and current frame.
void update_localquat(float deltat);
This method will interpolate the current quaternion orientation and is used exclusively by "calc_localquat()". "deltat" is the time between the last and current frames.
public:
float delta[5];
This field is used to hold temporary data used for interpolating quaternions.
float range;
This field is used to control the transition between one set w/ another set of quaternion key frames.
int inverseflag;
This field is an internal variable used to calculate quaternion keyframe interpolation.
vector4f Q[4];
This field contains an internal spline matrix used to interpolate between two spline keyframes.
void query_motion();
This method determines if the object has a scripted motion.
void read_spline(FILE *infile, float timefactor);
This method is used to read in the spline section of a .evt file.
void read_quaternion(FILE *infile, float timefactor);
This method is used to read in the quaternion section of a .evt file.
void calc_localquat(vector4f *mx, float deltat = 1.0f, int liveflag = 0);
This method will interpolate the current quaternion orientation. "deltat" is the time between the last and current frames. if "liveflag" is not set, the next frame's orientation will be precalculated. The result is returned as a 4x4 rotation matrix, "mx".
void calc_localspline(float *v, float deltat = 1.0f, int liveflag = 0);
This method traverses a set of spline keyframes. "deltat" is the time increment. if "liveflag" is false, it precalculates the interpolation for the next frame. The resulting interpolated position is returned in "v".
};
State_type is Anitroll's status class. It's used to keep track of the status/state of an animation node.
class state_type {
protected:
vector4f xmx_buffer[4], node_buffer[4], ixmx_buffer[4];
This fields are matrix buffers that hold the real state matrix data.
public:
vector4f center;
This field is the position of an animation node in world space.
vector4f *xmx;
This field contains a pointer to the transform matrix used by this object, not necessarily "xmx_buffer".
vector4f *node;
This field contains a pointer to the inverse of "xmx", not necessarily "ixmx_buffer". Note this is only valid if the "STATE_FLAG_INVERSE" bit is set of the "state_flags" field.
vector4f *ixmx;
This field contains a pointer to the transform matrix that is passed to its children, not necessarily "node_buffer".
unsigned int state_flags;
This field is a bit field that contains various information about the current state of the node:
STATE_FLAG_NULL 0x0000 STATE_MASK_BOUND 0x0007 // Extracts bounding values of: STATE_FLAG_BNONE 0x0000 // No bounding volume STATE_FLAG_BPOINT 0x0001 // Bounding volume is a point STATE_FLAG_BSPHERE 0x0002 // Bounding volume is a sphere STATE_FLAG_BPLANE 0x0003 // Bounding volume is a plane in 3 space STATE_FLAG_BRECT 0x0004 // Bounding volume is a rectangle box STATE_FLAG_BALL 0x0005 // Bounding volume has no defined volume STATE_MASK_TREE 0x000c // Extracts tree bounding values of STATE_FLAG_TNONE 0x0000 // No bounding volume STATE_FLAG_BSPHERE 0x0008 // Bounding volume is a sphere STATE_FLAG_BALL 0x0009 // Bounding volume has no defined volume STATE_FLAG_AUTO_UPDATE 0x0010 // if set to false, then the programmer is responsible // for updating the bounding data. Otherwise, bounding // data will be automaticly updated based upon the // animated node's current state. STATE_FLAG_INVERSE 0x0020 // if set, then the "ixmx" field is valid.
float bradius;
This field contains the radius of the bounding sphere, if "btype" is set to BSPHERE or BRECT.
union {
vector4f bcenter;
This field contains the center in world space of the bounding sphere, if "btype" == BSPHERE.
vector4f bdata[8];
This field contains 8 vertices of a bounding rectangle, if "btype" == BRECT.
};
union {
vector4f bnormal[6];
This field contains the normals for the 6 sides of the bounding rectangle, if "btype" == BRECT.
vector4f bplane;
This field contains the coefficients for the plane equation, if "btype" == BPLANE.
};
float tree_radius;
This field contains the radius of the tree bounding sphere, if (state_flags & STATE_MASK_TREE) == STATE_FLAG_TSPHERE.
vector4f tree_center;
This field contains the center in world space of the tree bounding sphere, if (state_flags & STATE_MASK_TREE) == STATE_FLAG_TSPHERE.
state_type();
void calc_bound_data();
This method updates the bounding data if the bit STATE_FLAG_AUTO_UPDATE of "state_flags" is set.
void calc_tree_bound_data();
This method updates the tree bounding data
int read_bound(FILE *infile);
This method is desgined to read and parse in bounding data from an ".atm" file, as defined in the user manual.
};
Quark is Anitroll's basic animation class. It supports hiearchical animation - changes in a parent quark's transformation matrix are carryed down to its children. In addition, quarks support quaternion rotations and spline path translations.
class quark : public superclass {
protected:
kinematic motion;
This field contains all the data needed to calculate quaternion orientations and spline based movement.
frameclass *ob;
This field is used to attach a renderable object to the animation quark.
vector4f previous_local_motion[4];
This field contains the result of the last call to calc_initmx() - stored for reuse.
union { vector4uc frustum_fail_data; unsigned int frustum_fail_flag; };
This field contains a reference to the last frustum plane that this object was "outside".
int query_frustum_clip(float radius, float *center, vector4f *frustum, unsigned int *frustum_flag, unsigned char *fail_data);
This function returns TRUE if the object is within a view frustum, and calculates the distances from "center" and "radius" to the 6 sides of a view "frustum". However, if the value returned is FALSE, then "fail_data" contains data that can be used to optimize future calls. "frustum_flag" bit values signify which planes to check, and if the object is "within" the plane, the bit is set to zero.
virtual void calc_initmx(vector4f *in, vector4f *out);
This method takes "in" the transformation matrix of the current quark's parent, and "out"puts a new
transformation matrix to be applied to the current quark. It combines the parent's transformation matrix,
any spline or quaternion based movement, as well as any other matrix operations that have been defined by
the user/programmer.
public:
int query_category();
A replacement for the virtual function defined in "superclass".
int query_whatami();
A replacement for the virtual function defined in "superclass"
int query_whatwasi(int type);
A replacement for the virtual function defined in "superclass".
int parse(FILE *infile, char *token);
A replacement for the virtual function defined in "superclass"
void preprocess(void *data);
A replacement for the virtual function defined in "superclass" "data" is expected to be of type "geneological_type" as is follows:
typedef struct { quark *parent; // the parent of the current animation node atom_list_type *tree; // hiearchy that contains the current animation node } geneological_type;
string_type name;
This field is used to assign a character string for the purposes of searching and identifying quarks.
vector4f initxform[4];
This field contains the quark's initial transformation matrix.
vector4f localmx[4];
This field contains an additional transformation matrix that is concatinated to the current quark's transformation matrix, but does not carry down to its children.
vector3f origin;
This field contains a 3D offset/translation from the quark's parent.
float scale, iscale;
These fields contain a global scale (1/scale) to be applied to this quark and its children.
unsigned int flags;
This field is used to contain state data for the object. The lower 16 bits (0x0000XXXX) are reserved by Anitroll. Currently bit 1 contains the active/inactive state of the object.
state_type state, old_state;
These fields contain the current/previous transformation data for this quark.
linktype *edge;
This field contains a linked list of pointers to this quarks children and parent.
quark();
virtual ~quark();
superclass *get_render_object();
This method allows access to the protected renderable object.
quark *find(quark *parent, char *part, quark **found_parent = NULL);
This method searches for a name match with "part" in the current subtree. "parent" is used to bypass the pointer to the parent quark when searching. If successful, it returns the found quark and sets "found_parent" to the parent of the found quark (if "found_parent" != NULL), else returns NULL.
quark *find(quark *parent, int cat, quark *last, quark **found_parent = NULL);
This function finds quarks of a specific type - ie it calls the query_whatami() method to identify the quark and compare w/ "cat". "parent" is needed to avoid traveling up the tree. If "last" is set, last will be used as the "last" found quark - this allows the programmer to find all quarks of a specific type. if "found_parent" != NULL, it is set w/ a pointer to the found quark's parent.
int remove_link(quark *child);
This method "breaks" off subtrees off of the current quark by removing the parent-child links between "child" and the current quark.
void create_link(quark *child);
This method attaches "child" to the current quark by setting up the parent-child links.
quark *read_quark(FILE *infile, int parent_flag);
This method is designed to read and parse a "quark" from an ".atm" file, as defined in the user manual. "parent_flag" is a boolean value that determines whether or not the "quark" has a link to it's parent. If successfull, this method returns the new quark.
int write_data(FILE *outfile, quark *parent, int frame);
If the renderable object "ob" is valid, this method forces "ob" to dump its state into "outfile" using the ".list" format as defined in the user manual. This allows the animation to be rendered offline at a later date.
virtual superclass *find_ob(quark *parent, int typecode, quark **source);
This method finds the first quark w/ a renderable object whose "query_whatami()" response matches "typecode". If "source" != NULL, then "source" is set to the controlling quark. It then returns renderable object.
virtual void render_object(engine *proc, quark *parent, vector4f *frustum, unsigned int frustum_flag);
This method submits any renderable objects w/in the quark and its children quarks to "proc" for rendering. The parameter "frustum", is an optional array of 5 plane coeefficients ( (A,B,C,D) = Ax + By + Cz + D = 0) representing the back, left, right, top, and bottom viewing frustum planes used to do frustum culling. "frustum_flag" contains 6 bits which indicate if a plane is to be checked.
virtual void update(dbl_llist_manager *hiearchy_manager, quark *parent);
This method is activated after "whereami()" is called, and is used to do any post-animation tasks, where "hiearchy_manager" is a list of all hiearchical animated objects, and "parent" is the immediate hiearchical parent of the current node.
virtual void setup();
This method is usually used by begin() and whereami(). It is used to update a rendering primative (such as the field "ob").
virtual void begin(dbl_llist_manager *hiearchy_manager, quark *parent, vector4f *mx);
This method is a special case. It performs the same tasks as "whereami()", but is only called once, and before whereami() is called. The main difference is that "begin()" initiallizes the quark's animation routines for future wherami() calls.
virtual void whereami(dbl_llist_manager *hiearchy_manager, quark *parent, vector4f *mx);
This method's purpose is to animate the quark. It is called once per frame, just before "render_object()". However, on the first frame, "begin()" should be called instead.
virtual void new_action(FILE *infile, float timefactor, char *buffer = NULL);
This method is used to respond to events, usually involving new spline paths or rotations.
virtual int query_specific_data(unsigned int type, void *data);
This method is used as a generic way of querying a quark for data. "type" is a unique identifier to describe or label a desired chunk of data. "data" is a generic pointer that the queryed quark should know how to handle. Anitroll reserves the range of 0..65535 for internal usage.
virtual void apply_scale(float scale);
This function applies a scale to a quark and its children.
};
The basic_event class is the base class for all events managed by the instances of the atom class.
class basic_event : public dbl_llist {
public:
union { int event; float timer; };
This field contains the "event" frame number to activate for frame based animations, or a countdown "timer" till the event activates for realtime systems.
virtual ~basic_event();
virtual int query_whatami() = 0;
This field is used to identify the type of event.
virtual void evaluate(int frameno, atom *source, dbl_llist_manager *hiearchy_manager) = 0;
This method is used to evaluate the event. "frameno" is the current frame count, "source" is the node which this event applies, and "hiearchy_manager" is a list of all hiearchical trees of type atom_list_type.
};
This is the standard event type for a basic atom.
class eventtype : public basic_event {
public:
int query_whatami();
A replacement for the virtual function defined in basic_event.
void evaluate(int frameno, atom *source, dbl_llist_manager *hiearchy_manager);
A replacement for the virtual function defined in "basic_event"
float timefactor;
This field is a time multiple to be applied to the event itself - used to lengthen or shorten the timespan of the event.
string_type efilename;
This field contains the filename of a .evt file representing the event.
virtual ~eventtype(); };
Instances of the atom class are used as the head node of a kinematic tree.
class atom : public quark {
protected:
int scale_quark(float s, char *part);
This method searches for the quark "part" in the hiearchy, and applies the scale "s".
int move_quark(char *child, char *parent);
This method searches for "child" in the hiearchy, and if found, moves it to a different "parent" node w/in the same hiearchy.
int drop_quark(int frameno, char *child, dbl_llist_manager *hiearchy_manager, FILE *infile);
This method removes a "child" node/subtree from the hiearchy, makes it an independent tree, and placed in the "hiearchy_manager". "infile" is an open .evt file that contains events for the new tree, and "frameno" is used to tell the new tree which frame is currently being animated.
int join_atom(char *part, char *parent, dbl_llist_manager *hiearchy_manager);
This method searches the animation tree list ("hiearchy_manager") for the animation node/subtree who's name matches "part". This node/subtree is removed from its current tree and attached to the animation node who's name matches "parent" w/in the current animation tree. NOTE: this only works if each animation node in the current animation has a unique "name" identifier.
int take_quark(char *dest, char *parent, char *part, dbl_llist_manager *hiearchy_manager);
This method searches the animation tree list ("hiearchy_manager") for the animation tree who's root node name matches "parent". Then the animation node/subtree who's name matches "part" is searched for. If found, this node/subtree is made a subnode/subtree of a child node/subtree of the current animation tree who's name matches "dest".
public:
int query_whatami();
A replacement for the virtual function defined in "superclass"
int query_whatwasi(int type);
A replacement for the virtual function defined in "superclass".
int parse(FILE *infile, char *token);
A replacement for the virtual function defined in "superclass"
void render_object(engine *proc, quark *parent, vector4f *frustum, unsigned int frustum_flag);
A replacement for the virtual function defined in "quark"
void new_action(FILE *infile, float timefactor, char *buffer);
A replacement for the virtual function defined in "quark"
dbl_llist_manager event_manager;
This field contains a list of sorted frame based eventtypes.
virtual ~atom();
virtual void new_action(int frameno, dbl_llist_manager *hiearchy_manager);
This method determines if an event on it's event list has been triggered, and passes the data to the appropriate animation nodes. "frameno" is the current frame being animated, and "hiearchy_manager" is the main list of animation trees of type atom_list_type.
int read_data(char *filename);
This method reads and parses in a .atm file. The method returns 0 if it fails.
virtual basic_event *read_event(FILE *infile, char *token, int frame_offset);
This method reads in a .evt and builds an event list.
};
This class is the base loader for ANITROLL animation objects, and is used to identify, instantiate, and parse quark animation objects.
class quark_loader : public loader {
protected:
char *alias_name;
This field contains an alternate name for the class that the loader instantiates.
public:
quark_loader();
superclass *make_object();
A replacement for the virtual function defined in "loader". This method returns an instance of quark.
superclass *parse(FILE *infile, char *token);
A replacement for the virtual function defined in "superclass"
char *query_alias();
This method returns a pointer to the alternate name for the class that the loader instantiates.
};
This class is a loader used to identify, instantiate, and parse atom animation head nodes.
class atom_loader : public quark_loader {
atom_loader();
superclass *make_object();
public:
A replacement for the virtual function defined in "loader". This method returns an instance of atom.
};
This class is used to create and pass around a double linked list of "atoms"
class atom_list_type : public dbl_llist {
public:
atom *htree;
This member is a pointer to the assocated tree hiearchy.
atom_list_type();
virtual ~atom_list_type();
};