![]()
geMotion
Description: Motion interface.
Source file: …\genesis3d\include\motion.h
(in Genesis3D v1.6 this is located in ..\G3D\Actor\motion.h)
Functions:
Create, DeleteEvent, Destroy, GetEventExtents, GetName, GetNextEvent, GetPath, GetPathCount, GetTimeExtents, InsertEvent, SetName, SetupEventIteratorPrivate API Functions
(available in API, but best reserved for advanced applications): AddPath, AddSubMotion, CreateFromFile, GetBaseTransform, GetBlendAmount, GetBlendPath, GetSubMotion, GetSubMotionCount, GetSubMotionNamed, GetNameChecksum, GetNameOfPath, GetPathNamed, GetTimeOffset, GetTransform, GetTimeScale, HasNames, IsValid, RemoveNames, RemoveSubMotion, SampleChannels, SampleChannelsNamed, Sample, SampleNamed, SetBaseTransform, SetBlendPath, SetTimeOffset, SetTimeScale, WriteToBinaryFile, WriteToFileTypes:
geMotionOverview:
viewAdditions to Genesis3D v1.6: None
![]()
(From the official Genesis3D documentation)
Summary
The Motion module provides support for creating and maintaining lists of named Paths and associated time-indexed events, and methods to sample the animation paths at any arbitrary time.
Overview
A Motion is a set of Paths and an associated list of time-indexed events. The most common use of Motions is to hold Actor animation. See documentation for gePath for more information on individual paths. See documentation for geActor for more information about Actor animations.
Motions are reference counted.
A number of functions return pointers to the Paths or sub motions that are maintained by the Motion object. Clients should not destroy these objects, as they are owned by the Motion. If you want to own a Path that's maintained by a Motion, call gePath_CreateRef to increase the Path's reference count.
Creating and Maintaining Motions
To create a Motion, call geMotion_Create. This will create an initially-empty Motion with with no Paths, Events, or sub motions. The Motion's type (simple or compound) is not set until the first Path or sub motion is added to the Motion. Once a motion's type is set, it cannot be changed.
To add a Path to the Motion, call geMotion_AddPath. There is no way to remove a path from the Motion.
To add a sub motion, call geMotion_AddSubMotion. To remove a sub motion, call geMotion_RemoveSubMotion. See the discussion of compound motions below for more information on sub motions.
To add an event, call geMotion_InsertEvent. To remove an event, call geMotion_DeleteEvent. See the discussion of Events below for more information.
Compound Motions
Instead of individual paths, a motion may contain other motions. This type of motion is called a compound motion and the motions that it contains are called sub motions. Motions that contain other motions are also known as branch motions, and motions that contain path information are called leaf motions. Just like in a tree, a branch may have other branches subordinate to it, and it may also have leaves on it. But leaves are the end of the line.
A sub motion's time offset is its starting time, relative to the parent motion's starting time. So a sub motion that starts when the parent motion starts has a time offset of 0.0f.
Compound motions own their sub motions, and destroy them if the compound motion is destroyed. However, if you remove a sub motion from a compound motion, a pointer to the sub motion is returned and it is the caller's responsibility to destroy it.
Return to Contents
![]()
Types:
geMotion;NOTE: The contents of this structure have been intentionally left out of the interface, by the designers of this module. Think of this as a handle only.
Return to Contents
Note: The following structures are PRIVATE (not included in the interface). I have included it here only to help me understand the geMotion data structures.
typedef enum {
MOTION_NODE_UNDECIDED,
MOTION_NODE_BRANCH,
MOTION_NODE_LEAF
} geMotion_NodeType;
typedef struct geMotion_Leaf {
int PathCount;
int32 NameChecksum; // checksum based on names and list order
geTKEvents* Events;
geStrBlock * NameArray;
gePath** PathArray;
} geMotion_Leaf;
typedef struct geMotion_Mixer {
geFloat TimeScale; // multipler for time
geFloat TimeOffset; // already scaled.
gePath* Blend; // path used to interpolate blending amounts.
geXForm3d Transform; // base transform for this motion (if TransformUsed==GE_TRUE)
geBoolean TransformUsed; // GE_FALSE if there is no base transform.
geMotion* Motion;
} geMotion_Mixer;
typedef struct geMotion_Branch {
int MixerCount;
int CurrentEventIterator;
geMotion_Mixer* MixerArray;
} geMotion_Branch;
typedef struct geMotion {
char* Name;
int CloneCount;
geBoolean MaintainNames;
geMotion_NodeType NodeType;
union {
geMotion_Leaf Leaf;
geMotion_Branch Branch;
};
geMotion* SanityCheck;
} geMotion;
![]()
Functions:
![]()
GENESISAPI geBoolean GENESISCC geMotion_AddPath(geMotion* M, gePath* P, const char * Name, int * Index);
This function adds the specifiedgePath P to geMotion M at the specified index naming the path Name. If no name is desired, NULL may be specified.
Returns:GE_TRUE on success, GE_FALSE otherwise.
Notes:
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_AddSubMotion(geMotion* ParentMotion, geFloat TimeScale, geFloat TimeOffset, geMotion* SubMotion, geFloat StartTime, geFloat StartMagnitude, geFloat EndTime, geFloat EndMagnitude, const geXForm3d* Transform, int * Index);
This function addsgeMotion SubMotion to the compound geMotion ParentMotion at time TimeOffset relative the start of ParentMotion. The time of SubMotion is scaled by TimeScale. Blending times and magnitudes are specifed by StartTime, StartMagnitude, EndTime, and EndMagnitude. Transform is a transformation matrix which can be used to specify the relative positioning of the SubMotion within the ParentMotion. The index of SubMotion within ParentMotion is returned in Index.
Returns:GE_TRUE on success, GE_FALSE otherwise
Questions:
Return to Contents
![]()
GENESISAPI geMotion* GENESISCC geMotion_Create(geBoolean ManageNames);
This function creates a newgeMotion object and returns it. If ManageNames is GE_TRUE resources are allocated to provide naming of paths, if it is GE_FALSE the resources are not allocated and paths may not be named.
Returns: the newly createdgeMotion.
Return to Contents
![]()
GENESISAPI geMotion* GENESISCC geMotion_CreateFromFile(geVFile* f);
This function creates a newgeMotion object from the data in the specified geVFile f.
Returns: the newly createdgeMotion.
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_DeleteEvent(geMotion* M, geFloat tKey);
This function deletes the event at at time tKey fromgeMotion M.
Returns:GE_TRUE on success, GE_FALSE otherwise.
Notes:
Return to Contents
![]()
GENESISAPI void GENESISCC geMotion_Destroy(geMotion* *PM);
This function deletes one from the reference count forgeMotion PM. If the reference count goes to 0 then the resources of PM are all freed.
Returns: nothing.
Return to Contents
![]()
GENESISAPI const geXForm3d* GENESISCC geMotion_GetBaseTransform(const geMotion* M, int SubMotionIndex);
This function returns the base transformation for the submotion ofgeMotion M at index SubMotionIndex.
Returns: the base transform.
Return to Contents
![]()
GENESISAPI geFloat GENESISCC geMotion_GetBlendAmount(const geMotion* M, int SubMotionIndex, geFloat Time);
This function returns the blend amount for the submotion ofgeMotion M specifed by SubMotionIndex at the time Time relative to M.
Returns: the blend amount.
Notes:
Return to Contents
![]()
GENESISAPI gePath* GENESISCC geMotion_GetBlendPath(const geMotion* M, int SubMotionIndex);
This function returns the blending path for the submotion ofgeMotion M specified by SubMotionIndex. The times in the blending path are relative to the submotion start time.
Returns: the blending path.
Notes:
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_GetEventExtents(const geMotion* M, geFloat* FirstEventTime, geFloat* LastEventTime);
This function returns the times of the first and last events ingeMotion M.
Returns:GE_TRUE if there is at least one event in M, GE_FALSE otherwise.
Notes:
Return to Contents
![]()
GENESISAPI const char * GENESISCC geMotion_GetName(const geMotion* M);
This function returns the name associated withgeMotion M.
Returns: the name orNULL if there is no name.
Return to Contents
![]()
GENESISAPI int32 GENESISCC geMotion_GetNameChecksum(const geMotion* M);
This function returns the checksom ofgeMotion M's name pool. This only seems to have any internal use.
Returns: the checksum.
Return to Contents
![]()
GENESISAPI const char * GENESISCC geMotion_GetNameOfPath(const geMotion* M, int Index);
This function returns the name of thegePath at index Index of geMotion M. If M is a compound motion, NULL is returned.
Returns: the name of thegePath or NULL.
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_GetNextEvent(geMotion* M, geFloat* pTime, const char * *ppEventString);
This function iterates over the list of events ofgeMotion M returning the time of the event in pTime and the event string ppEventString.
Returns:GE_TRUE if an event is returned, GE_FALSE if there are no more events to return.
Notes:
Return to Contents
![]()
GENESISAPI gePath* GENESISCC geMotion_GetPath(const geMotion* M, int Index);
This function returns thegePath at index Index of geMotion M. This function does not increase the reference count of the gePath and so the returned gePath must not be destroyed unless the caller increases the reference count.
Returns: thegePath.
Return to Contents
![]()
GENESISAPI int GENESISCC geMotion_GetPathCount(const geMotion* M);
This function returns the number ofgePath objects contained by geMotion M.
Returns: the result.
Return to Contents
![]()
GENESISAPI gePath* GENESISCC geMotion_GetPathNamed(const geMotion* M, const char * Name);
This function returns thegePath named Name in geMotion M. This function does not increase the reference count of the gePath and so the returned gePath must not be destroyed unless the caller increases the reference count.
Returns: thegePath.
Notes:
Return to Contents
![]()
GENESISAPI geMotion* GENESISCC geMotion_GetSubMotion(const geMotion* M, int Index);
This function returns the sub motion at index Index ofgeMotion M. This function does not increase the reference count of the geMotion and so the returned geMotion must not be destroyed unless the caller increase the reference count.
Returns: the sub motion.
Notes:
Return to Contents
![]()
GENESISAPI int GENESISCC geMotion_GetSubMotionCount(const geMotion*M);
This function returns the number of sub motions ofgeMotion M.
Returns: the number of sub motions, or 0 if M is not a compound motion.
Notes:
Return to Contents
![]()
GENESISAPI geMotion* GENESISCC geMotion_GetSubMotionNamed(const geMotion* M, const char * Name);
This function returns the sub motion ofgeMotion M named Name. This function does not increase the reference count of the geMotion and so the returned geMotion must not be destroyed unless the caller increase the reference count.
Returns: the sub motion.
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_GetTimeExtents(const geMotion* M, geFloat* StartTime, geFloat* EndTime);
This function returns the start and end times of thegeMotion M. If M is a compound motion, the start time of the first motion and end time of the last motion with scaling applied are returned. If M is not a compound motion then the start time of the earliest path and the end time of the latest path are returned.
Returns:GE_TRUE if there are paths or sub motions in the motion, GE_FALSE otherwise.
Notes:
Return to Contents
![]()
GENESISAPI geFloat GENESISCC geMotion_GetTimeOffset(const geMotion* M, int SubMotionIndex);
This function returns the originally set TimeOffset of the sub motion at SubMotionIndex of thegeMotion M.
Returns: the time offset.
Notes:
Return to Contents
![]()
GENESISAPI geFloat GENESISCC geMotion_GetTimeScale(const geMotion* M, int SubMotionIndex);
This function returns the original set TimeScale of the sub motion at SubMotionIndex of thegeMotion M.
Returns: the time scale.
Notes:
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_GetTransform(const geMotion* M, geFloat Time, geXForm3d* Transform);
This function returns the blending of the base transforms of all sub motions of thegeMotion M at time Time.
Returns: the resulting tranform.
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_HasNames(const geMotion* M);
This function checks whether thegeMotion M supports names.
Returns:GE_TRUE if M supports names, GE_FALSE otherwise.
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_InsertEvent(geMotion* M, geFloat tKey, const char * String);
This function inserts an event string String at time tKey into thegeMotion M.
Returns:GE_TRUE on success, GE_FALSE otherwise.
Notes:
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_IsValid(const geMotion* M);
This function checks to see if M is a validgeMotion. This doesn't seem to be of all that much use externally.
Returns:GE_TRUE if the motion is valid, GE_FALSE otherwise.
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_RemoveNames(geMotion* M);
This function deletes all names from the paths ingeMotion M. M will no longer support named paths after this function is called and this is not reversible. M must be a simple motion.
Returns:GE_TRUE if successful, GE_FALSE otherwise.
Return to Contents
![]()
GENESISAPI geMotion* GENESISCC geMotion_RemoveSubMotion(geMotion* ParentMotion, int SubMotionIndex);
This function removes the sub motion ofgeMotion ParentMotion indicated by SubMotionIndex and returns it.
Returns: the sub motion removed orNULL if unsuccessful.
Return to Contents
![]()
GENESISAPI void GENESISCC geMotion_Sample(const geMotion* M, int PathIndex, geFloat Time, geXForm3d* Transform);
This function returns the transform of the specified path PathIndex of M at time Time. If M is a compound motion then the indexed path of all sub motions are blended using the leaf motions blending and scaling values and the blended transform is returned. The function will fail if the specifed path does not exist in all leafs of the motion.
Returns: nothing.
Return to Contents
![]()
GENESISAPI void GENESISCC geMotion_SampleChannels(const geMotion* M, int PathIndex, geFloat Time, geQuaternion* Rotation, geVec3d* Translation);
This function returns the positional transformation in Translation and rotational transformation ingeQuaternion Rotation of the specified path PathIndex of M at time Time. If M is a compound motion then the indexed path of all sub motions are blended using the leaf motions blending and scaling values and the blended transform is returned. The function will fail if the specifed path does not exist in all leafs of the motion.
Returns: nothing.
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_SampleChannelsNamed(const geMotion* M, const char * PathName, geFloat Time, geQuaternion* Rotation, geVec3d* Translation);
This function returns the positional transformation in Translation and rotational transformation ingeQuaternion Rotation of the named path PathName of M at time Time. If M is a compound motion then the named path of all sub motions are blended using the leaf motions blending and scaling values and the blended transform is returned.
Returns:GE_TRUE if the named path exists in all leafs, GE_FALSE otherwise.
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_SampleNamed(const geMotion* M, const char * PathName, geFloat Time, geXForm3d* Transform);
This function returns the transform of the named path PathName of M at time Time. If M is a compound motion then the named path of all sub motions are blended using the leaf motions blending and scaling values and the blended transform is returned.
Returns:GE_TRUE if the named path exists in all leafs, GE_FALSE otherwise.
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_SetBaseTransform(geMotion* M, int SubMotionIndex, geXForm3d* BaseTransform);
This function sets the base transform of the sub motion specified by index SubMotionIndex of M to BaseTransform.
Returns:GE_TRUE on success, GE_FALSE otherwise.
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_SetBlendPath(geMotion* M, int SubMotionIndex, gePath* Blend);
This function sets the blend path of the sub motion specified by index SubMotionIndex of M to Blend.
Returns:GE_TRUE on success, GE_FALSE otherwise.
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_SetName(geMotion* M, const char * Name);
This function sets the name ofgeMotion M to Name.
Returns:GE_TRUE on success, GE_FALSE otherwise.
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_SetTimeOffset(geMotion* M, int SubMotionIndex, geFloat TimeOffset);
This function sets the time offset of the sub motion specified by index SubMotionIndex ofgeMotion M to TimeOffset.
Returns:GE_TRUE on success, GE_FALSE otherwise.
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_SetTimeScale(geMotion* M, int SubMotionIndex, geFloat TimeScale);
This function sets the time scale of the sub motion specified by index SubMotionIndex ofgeMotion M to TimeScale.
Returns:GE_TRUE on success, GE_FALSE otherwise.
Return to Contents
![]()
GENESISAPI void GENESISCC geMotion_SetupEventIterator(geMotion* M, geFloat StartTime, geFloat EndTime);
This function initializes the event iterator ofgeMotion M to start at StartTime and stop before EndTime.
Returns: nothing.
Notes:
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_WriteToBinaryFile(const geMotion* M, geVFile* pFile);
This function writes the data ofgeMotion M to geVFile pFile in binary format.
Returns:GE_TRUE on success, GE_FALSE otherwise.
Return to Contents
![]()
GENESISAPI geBoolean GENESISCC geMotion_WriteToFile(const geMotion* M, geVFile* f);
This function writes the data ofgeMotion M to geVFile f in ascii format.
Returns:GE_TRUE on success, GE_FALSE otherwise.
Return to Contents
![]()