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

path.h

Go to the documentation of this file.
00001 /****************************************************************************************/
00002 /*  PATH.H                                                                                                                                                              */
00003 /*                                                                                      */
00004 /*  Author: Mike Sandige                                                                    */
00005 /*  Description: Time-indexed keyframe creation, maintenance, and sampling.                             */
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_PATH_H
00023 #define GE_PATH_H
00024 
00025 #include "basetype.h"
00026 #include "xform3d.h"
00027 #include "quatern.h"
00028 #include "vfile.h"
00029 
00030 #ifdef __cplusplus
00031         extern "C" {
00032 #endif
00033 
00034 
00035 // GENESIS_PUBLIC_APIS
00036 typedef struct _gePath gePath;
00037 
00038 #define GE_PATH_ROTATION_CHANNEL    1
00039 #define GE_PATH_TRANSLATION_CHANNEL 2
00040 
00041 #define GE_PATH_ALL_CHANNELS (GE_PATH_ROTATION_CHANNEL | GE_PATH_TRANSLATION_CHANNEL)
00042 
00043 #ifndef GE_PATH_ENUMS
00044         #define GE_PATH_ENUMS
00045         typedef enum 
00046         {
00047                 GE_PATH_INTERPOLATE_LINEAR  = 0,        // linear blend for translation or rotation channel
00048                 GE_PATH_INTERPOLATE_HERMITE,            // hermite cubic spline for translation channel
00049                 GE_PATH_INTERPOLATE_SLERP,                      // spherical-linear blend for rotation channel
00050                 GE_PATH_INTERPOLATE_SQUAD,                      // higher order blend for rotation channel 'G1' continuity
00051                 //GE_PATH_INTEROPLATE_TRIPOD,            // not supported yet.
00052                 GE_PATH_INTERPOLATE_HERMITE_ZERO_DERIV = 7      // hermite cubic with zero derivative at keyframes ('easing' curve)
00053         }gePath_Interpolator;
00054 #endif
00055 
00056 GENESISAPI void GENESISCC gePath_CreateRef( gePath *P );
00057 
00058 GENESISAPI gePath *GENESISCC gePath_Create(
00059         gePath_Interpolator TranslationInterpolation,   // type of interpolation for translation channel
00060         gePath_Interpolator RotationInterpolation,      // type of interpolation for rotation channel
00061         geBoolean Looped);                              // True if end of path is connected to head
00062         // creates new gePath
00063         //  A looping path should have the same first & last point.  The path
00064         //  generator will choose arbitrarily between these points for a 
00065         //  sample exactly at the end of the loop.
00066 
00067 GENESISAPI gePath *GENESISCC gePath_CreateCopy( const gePath *P );
00068         
00069 GENESISAPI void GENESISCC gePath_Destroy(gePath **PP);          
00070         // destroys path *PP
00071 
00072 //------------------ time based keyframe operations
00073 GENESISAPI geBoolean GENESISCC gePath_InsertKeyframe(
00074         gePath *P, 
00075         int ChannelMask, 
00076         geFloat Time, 
00077         const geXForm3d *Matrix); 
00078         // inserts a keyframe at a specific time.
00079         
00080 GENESISAPI geBoolean GENESISCC gePath_DeleteKeyframe(
00081         gePath *P,
00082         int Index,
00083         int ChannelMask); 
00084         // deletes the nth keyframe
00085 
00086 GENESISAPI geBoolean GENESISCC gePath_GetTimeExtents(
00087         const gePath *P,
00088         geFloat *StartTime, 
00089         geFloat *EndTime);
00090         // gets the time for the first and last keys in the path (ignoring looping)
00091         // if there are no keys, return GE_FALSE and times are not set.
00092         // returns GE_TRUE if there are keys.
00093 
00094 //----------------- index based keyframe operations
00095 GENESISAPI void GENESISCC gePath_GetKeyframe(
00096         const gePath *P, 
00097         int Index,                              // gets keyframe[index]
00098         int Channel,                    // for this channel
00099         geFloat *Time,                  // returns the time of the keyframe
00100         geXForm3d *Matrix);             // returns the matrix of the keyframe
00101         // retrieves keyframe[index], and it's time
00102 
00103 GENESISAPI int GENESISCC gePath_GetKeyframeCount(const gePath *P,int Channel);
00104         // retrieves count of keyframes for a specific channel
00105 
00106 GENESISAPI int GENESISCC gePath_GetKeyframeIndex(const gePath *P, int Channel, geFloat Time);
00107         // retrieves the index of the keyframe at a specific time for a specific channel
00108 
00109 //----------------- sampling a path  (time based)
00110 GENESISAPI void GENESISCC gePath_Sample(const gePath *P, geFloat Time,geXForm3d *Matrix);
00111         // returns a transform matrix sampled at 'Time'.
00112         // p is not const because information is cached in p for next sample
00113 
00114 // GENESIS_PRIVATE_APIS
00115 void GENESISCC gePath_SampleChannels(
00116         const gePath *P, 
00117         geFloat Time, 
00118         geQuaternion *Rotation, 
00119         geVec3d *Translation);
00120         // returns a rotation and a translation for the path at 'Time'
00121         // p is not const because information is cached in p for next sample
00122 
00123 GENESISAPI geBoolean GENESISCC gePath_OffsetTimes(gePath *P, 
00124         int StartingIndex, int ChannelMask, geFloat TimeOffset );
00125                 // slides all samples in path starting with StartingIndex down by TimeOffset
00126 
00127 GENESISAPI geBoolean GENESISCC gePath_ModifyKeyframe(
00128         gePath *P,
00129         int Index,
00130         int ChannelMask,
00131         const geXForm3d *Matrix);
00132         
00133 
00134 // GENESIS_PUBLIC_APIS
00135 
00136 //------------------ saving/loading a path
00137 GENESISAPI gePath* GENESISCC gePath_CreateFromFile(geVFile *F);
00138         // loads a file  (binary or ascii)
00139 
00140 GENESISAPI geBoolean GENESISCC gePath_WriteToFile(const gePath *P, geVFile *F);
00141         // dumps formatted ascii to the file.  
00142 
00143 GENESISAPI geBoolean GENESISCC gePath_WriteToBinaryFile(const gePath *P, geVFile *F);
00144         // dumps a minimal binary image for fastest reading
00145 
00146 
00147 
00148 #ifdef __cplusplus
00149         }
00150 #endif
00151 
00152 
00153 #endif

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