Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

motion.h

Go to the documentation of this file.
00001 /****************************************************************************************/
00002 /*  MOTION.H                                                                            */
00003 /*                                                                                      */
00004 /*  Author: Mike Sandige                                                                    */
00005 /*  Description: Motion interface.                                                                          */
00006 /*                                                                                      */
00007 /*  The contents of this file are subject to the Genesis3D Public License               */
00008 /*  Version 1.01 (the "License"); you may not use this file except in                   */
00009 /*  compliance with the License. You may obtain a copy of the License at                */
00010 /*  http://www.genesis3d.com                                                            */
00011 /*                                                                                      */
00012 /*  Software distributed under the License is distributed on an "AS IS"                 */
00013 /*  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See                */
00014 /*  the License for the specific language governing rights and limitations              */
00015 /*  under the License.                                                                  */
00016 /*                                                                                      */
00017 /*  The Original Code is Genesis3D, released March 25, 1999.                            */
00018 /*  Genesis3D Version 1.1 released November 15, 1999                                 */
00019 /*  Copyright (C) 1999 WildTangent, Inc. All Rights Reserved           */
00020 /*                                                                                      */
00021 /****************************************************************************************/
00022 #ifndef GE_MOTION_H
00023 #define GE_MOTION_H
00024 
00025 /*      motion
00026 
00027         This object is a list of named Path objects
00028 
00029 */
00030 
00031 #include <stdio.h>
00032 #include "basetype.h"
00033 #include "path.h"
00034 #include "vfile.h"
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040 // GENESIS_PUBLIC_APIS
00041 typedef struct geMotion geMotion;
00042 
00043 GENESISAPI geMotion *GENESISCC geMotion_Create(geBoolean ManageNames);
00044 
00045 GENESISAPI void GENESISCC geMotion_Destroy(geMotion **PM);
00046 
00047 // GENESIS_PRIVATE_APIS
00048 
00049 GENESISAPI geBoolean GENESISCC geMotion_IsValid(const geMotion *M);
00050 
00051         // AddPath adds a reference of P to the motion M.  Ownership is shared - The caller must destroy P.
00052 GENESISAPI geBoolean GENESISCC geMotion_AddPath(geMotion *M, gePath *P,const char *Name,int *Index);
00053 
00054 GENESISAPI geBoolean GENESISCC geMotion_HasNames(const geMotion *M);
00055 GENESISAPI int32 GENESISCC geMotion_GetNameChecksum(const geMotion *M);
00056 
00057 GENESISAPI geBoolean GENESISCC geMotion_RemoveNames(geMotion *M);
00058 
00059 GENESISAPI void GENESISCC geMotion_SampleChannels(const geMotion *M, int PathIndex, geFloat Time, geQuaternion *Rotation, geVec3d *Translation);
00060 GENESISAPI geBoolean GENESISCC geMotion_SampleChannelsNamed(const geMotion *M, const char *PathName, geFloat Time, geQuaternion *Rotation, geVec3d *Translation);
00061 
00062 GENESISAPI void GENESISCC geMotion_Sample(const geMotion *M, int PathIndex, geFloat Time, geXForm3d *Transform);
00063 GENESISAPI geBoolean GENESISCC geMotion_SampleNamed(const geMotion *M, const char *PathName, geFloat Time, geXForm3d *Transform);
00064 
00065         // the returned Paths from _Get functions should not be destroyed.  
00066         // if ownership is desired, call gePath_CreateRef() to create another owner. 
00067         // an 'owner' has access to the object regardless of the number of other owners, and 
00068         // an owner must call the object's destroy method to relinquish ownership
00069 GENESISAPI gePath *GENESISCC geMotion_GetPathNamed(const geMotion *M,const char *Name);
00070 GENESISAPI const char *GENESISCC geMotion_GetNameOfPath(const geMotion *M, int Index);
00071 
00072 // GENESIS_PUBLIC_APIS
00073 GENESISAPI gePath *GENESISCC geMotion_GetPath(const geMotion *M,int Index);
00074 GENESISAPI int GENESISCC geMotion_GetPathCount(const geMotion *M);
00075 
00076 
00077 GENESISAPI geBoolean GENESISCC geMotion_SetName(geMotion *M, const char * Name);
00078 GENESISAPI const char *GENESISCC geMotion_GetName(const geMotion *M);
00079 
00080 // GENESIS_PRIVATE_APIS
00081 
00082         // support for compound motions.  A motion can either have sub-motions, or be single motion.
00083         // these functions support motions that have sub-motions.
00084 GENESISAPI int GENESISCC geMotion_GetSubMotionCount(const geMotion*M);
00085 
00086         // the returned motions from these _Get functions should not be destroyed.  
00087         // if ownership is desired, call geMotion_CreateRef() to create another owner. 
00088         // an 'owner' has access to the object regardless of the number of other owners, and 
00089         // an owner must call the object's destroy method to relinquish ownership
00090 GENESISAPI geMotion *GENESISCC geMotion_GetSubMotion(const geMotion *M,int Index);
00091 GENESISAPI geMotion *GENESISCC geMotion_GetSubMotionNamed(const geMotion *M,const char *Name);
00092 GENESISAPI geBoolean GENESISCC geMotion_AddSubMotion(
00093                                                                 geMotion *ParentMotion,
00094                                                                 geFloat TimeScale,                      // Scale factor for this submotion
00095                                                                 geFloat TimeOffset,                     // Time in parent motion when submotion should start
00096                                                                 geMotion *SubMotion,
00097                                                                 geFloat StartTime,                      // Blend start time (relative to submotion)
00098                                                                 geFloat StartMagnitude,         // Blend start magnitude (0..1)
00099                                                                 geFloat EndTime,                        // Blend ending time (relative to submotion)
00100                                                                 geFloat EndMagnitude,           // Blend ending magnitude (0..1)
00101                                                                 const geXForm3d *Transform,     // Base transform to apply to this submotion
00102                                                                 int *Index);                            // returned motion index
00103 
00104 GENESISAPI geMotion *GENESISCC  geMotion_RemoveSubMotion(geMotion *ParentMotion, int SubMotionIndex);
00105 
00106 // Get/Set submotion time offset.  The time offset is the offset into the 
00107 // compound (parent) motion at which the submotion should start.
00108 GENESISAPI geFloat   GENESISCC  geMotion_GetTimeOffset( const geMotion *M,int SubMotionIndex );
00109 GENESISAPI geBoolean  GENESISCC geMotion_SetTimeOffset( geMotion *M,int SubMotionIndex,geFloat TimeOffset );
00110 
00111 // Get/Set submotion time scale.  Time scaling is applied to the submotion after the TimeOffset
00112 // is applied.  The formula is:  (CurrentTime - TimeOffset) * TimeScale
00113 GENESISAPI geFloat   GENESISCC  geMotion_GetTimeScale( const geMotion *M,int SubMotionIndex );
00114 GENESISAPI geBoolean  GENESISCC geMotion_SetTimeScale( geMotion *M,int SubMotionIndex,geFloat TimeScale );
00115 
00116 // Get blending amount for a particular submotion.  The Time parameter is parent-relative.
00117 GENESISAPI geFloat    GENESISCC geMotion_GetBlendAmount( const geMotion *M, int SubMotionIndex, geFloat Time);
00118 
00119 // Get/Set blending path.  The keyframe times in the blend path are relative to the submotion.
00120 GENESISAPI gePath    *GENESISCC geMotion_GetBlendPath( const geMotion *M,int SubMotionIndex );
00121 GENESISAPI geBoolean  GENESISCC geMotion_SetBlendPath( geMotion *M,int SubMotionIndex, gePath *Blend );
00122 
00123 GENESISAPI const geXForm3d *GENESISCC geMotion_GetBaseTransform( const geMotion *M,int SubMotionIndex );
00124 GENESISAPI geBoolean  GENESISCC geMotion_SetBaseTransform( geMotion *M,int SubMotionIndex, geXForm3d *BaseTransform );
00125 GENESISAPI geBoolean  GENESISCC geMotion_GetTransform(const geMotion *M, geFloat Time, geXForm3d *Transform);
00126 // GENESIS_PUBLIC_APIS
00127 
00128         // gets time of first key and time of last key (as if motion did not loop)
00129         // if there are no paths in the motion: returns GE_FALSE and times are not set
00130         // otherwise returns GE_TRUE
00131         //
00132         // For a compound motion, GetTimeExtents will return the extents of the scaled submotions.
00133         // For a single motion, no scaling is applied.
00134 GENESISAPI geBoolean GENESISCC geMotion_GetTimeExtents(const geMotion *M,geFloat *StartTime,geFloat *EndTime);
00135 
00136 // Only one event is allowed per time key.
00137 
00138 GENESISAPI geBoolean GENESISCC geMotion_InsertEvent(geMotion *M, geFloat tKey, const char* String);
00139         // Inserts the new event and corresponding string.
00140 
00141 GENESISAPI geBoolean GENESISCC geMotion_DeleteEvent(geMotion *M, geFloat tKey);
00142         // Deletes the event
00143 
00144 GENESISAPI void GENESISCC geMotion_SetupEventIterator(
00145         geMotion *M,
00146         geFloat StartTime,                              // Inclusive search start
00147         geFloat EndTime);                               // Non-inclusive search stop
00148         // For searching or querying the array for events between two times
00149         // times are compaired [StartTime,EndTime), '[' is inclusive, ')' is 
00150         // non-inclusive.  This prepares the geMotion_GetNextEvent() function.
00151 
00152 GENESISAPI geBoolean GENESISCC geMotion_GetNextEvent(
00153         geMotion *M,                                            // Event list to iterate
00154         geFloat *pTime,                         // Return time, if found
00155         const char **ppEventString);    // Return data, if found
00156         // Iterates from StartTime to EndTime as setup in geMotion_SetupEventIterator()
00157         // and for each event between these times [StartTime,EndTime)
00158         // this function will return Time and EventString returned for that event
00159         // and the iterator will be positioned for the next search.  When there 
00160         // are no more events in the range, this function will return GE_FALSE (Time
00161         // will be 0 and ppEventString will be empty).
00162 
00163 GENESISAPI geBoolean GENESISCC geMotion_GetEventExtents(const geMotion *M,
00164                         geFloat *FirstEventTime,
00165                         geFloat *LastEventTime);
00166         // returns the time associated with the first and last events 
00167         // returns GE_FALSE if there are no events (and Times are not set)
00168 
00169 
00170 // GENESIS_PRIVATE_APIS
00171 GENESISAPI geMotion *GENESISCC geMotion_CreateFromFile(geVFile *f);
00172 GENESISAPI geBoolean GENESISCC geMotion_WriteToFile(const geMotion *M, geVFile *f);
00173 GENESISAPI geBoolean GENESISCC geMotion_WriteToBinaryFile(const geMotion *M,geVFile *pFile);
00174 
00175 #ifdef __cplusplus
00176 }
00177 #endif
00178 
00179 
00180 #endif

Generated on Tue Sep 30 12:36:02 2003 for GTestAndEngine by doxygen 1.3.2