00001 /****************************************************************************************/ 00002 /* QKFRAME.H */ 00003 /* */ 00004 /* Author: Mike Sandige */ 00005 /* Description: Quaternion keyframe 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 /* geQKFrame (geQuaternion - Keyframe) 00023 This module handles interpolation for keyframes that contain a quaternion 00024 This is intended to support Path.c 00025 geTKArray supplies general support for a time-keyed array, and this supplements 00026 that support to include the specific time-keyed arrays: 00027 An array of geQuaternion interpolated linearly 00028 An array of geQuaternion with spherical linear interpolation (SLERP) 00029 An array of geQuaternion with spherical quadrangle 00030 interpolation (SQUAD) as defined by: 00031 Advanced Animation and Rendering Techniques by Alan Watt and Mark Watt 00032 00033 These are phycially separated and have different base structures because 00034 the different interpolation techniques requre different additional data. 00035 00036 The two lists are created with different creation calls, 00037 interpolated with different calls, but insertion and queries share a call. 00038 00039 Quadrangle interpolation requires additional computation after changes are 00040 made to the keyframe list. Call geQKFrame_SquadRecompute() to update the 00041 calculations. 00042 */ 00043 #ifndef GE_QKFRAME_H 00044 #define GE_QKFRAME_H 00045 00046 00047 #include "TKArray.h" 00048 #include "Quatern.h" 00049 #include "vfile.h" 00050 00051 #ifdef __cplusplus 00052 extern "C" { 00053 #endif 00054 00055 typedef enum 00056 { 00057 QKFRAME_LINEAR, 00058 QKFRAME_SLERP, 00059 QKFRAME_SQUAD 00060 } geQKFrame_InterpolationType; 00061 00062 00063 geTKArray *GENESISCC geQKFrame_LinearCreate(void); 00064 // creates a frame list for linear interpolation 00065 00066 geTKArray *GENESISCC geQKFrame_SlerpCreate(); 00067 // creates a frame list for spherical linear interpolation 00068 00069 geTKArray *GENESISCC geQKFrame_SquadCreate(); 00070 // creates a frame list for spherical linear interpolation 00071 00072 00073 geBoolean GENESISCC geQKFrame_Insert( 00074 geTKArray **KeyList, // keyframe list to insert into 00075 geTKArray_TimeType Time, // time of new keyframe 00076 const geQuaternion *Q, // quaternion at new keyframe 00077 int *Index); // index of new frame 00078 // inserts a new keyframe with the given time and vector into the list. 00079 00080 void GENESISCC geQKFrame_Query( 00081 const geTKArray *KeyList, // keyframe list 00082 int Index, // index of frame to return 00083 geTKArray_TimeType *Time, // time of the frame is returned 00084 geQuaternion *V); // vector from the frame is returned 00085 // returns the vector and the time at keyframe[index] 00086 00087 void GENESISCC geQKFrame_Modify( 00088 geTKArray *KeyList, // keyframe list 00089 int Index, // index of frame to change 00090 const geQuaternion *Q); // vector for the new key 00091 // modifies a vector at keyframe[index] 00092 00093 void GENESISCC geQKFrame_LinearInterpolation( 00094 const void *KF1, // pointer to first keyframe 00095 const void *KF2, // pointer to second keyframe 00096 geFloat T, // 0 <= T <= 1 blending parameter 00097 void *Result); // put the result in here (geQuaternion) 00098 // interpolates to get a vector between the two vectors at the two 00099 // keyframes where T==0 returns the vector for KF1 00100 // and T==1 returns the vector for KF2 00101 // interpolates linearly 00102 00103 void GENESISCC geQKFrame_SlerpInterpolation( 00104 const void *KF1, // pointer to first keyframe 00105 const void *KF2, // pointer to second keyframe 00106 geFloat T, // 0 <= T <= 1 blending parameter 00107 void *Result); // put the result in here (geQuaternion) 00108 // interpolates to get a vector between the two vectors at the two 00109 // keyframes where T==0 returns the vector for KF1 00110 // and T==1 returns the vector for KF2 00111 // interpolates using spherical linear blending 00112 00113 void GENESISCC geQKFrame_SquadInterpolation( 00114 const void *KF1, // pointer to first keyframe 00115 const void *KF2, // pointer to second keyframe 00116 geFloat T, // 0 <= T <= 1 blending parameter 00117 void *Result); // put the result in here (geQuaternion) 00118 // interpolates to get a vector between the two vectors at the two 00119 // keyframes where T==0 returns the vector for KF1 00120 // and T==1 returns the vector for KF2 00121 // interpolates using spherical quadratic blending 00122 00123 void GENESISCC geQKFrame_SquadRecompute( 00124 int Looped, // if keylist has the first key connected to last key 00125 geTKArray *KeyList); 00126 // rebuild precomputed data for keyframe list. 00127 00128 void GENESISCC geQKFrame_SlerpRecompute( 00129 geTKArray *KeyList); // list of keys to recompute hermite values for 00130 // rebuild precomputed data for keyframe list. 00131 00132 00133 geBoolean GENESISCC geQKFrame_LinearRead(geVFile* pFile, void* geQKFrame); 00134 geBoolean GENESISCC geQKFrame_SlerpRead(geVFile* pFile, void* geQKFrame); 00135 geBoolean GENESISCC geQKFrame_SquadRead(geVFile* pFile, void* geQKFrame); 00136 00137 geBoolean GENESISCC geQKFrame_WriteToFile(geVFile *pFile, void *geQKFrame, 00138 geQKFrame_InterpolationType InterpolationType, int Looping); 00139 geTKArray *GENESISCC geQKFrame_CreateFromFile(geVFile *pFile, geQKFrame_InterpolationType *InterpolationType, int *Looping); 00140 geTKArray *GENESISCC geQKFrame_CreateFromBinaryFile(geVFile *pFile, int *InterpolationType, int *Looping); 00141 geBoolean GENESISCC geQKFrame_WriteToBinaryFile(geVFile *pFile, geTKArray *KeyList, 00142 geQKFrame_InterpolationType InterpolationType, int Looping); 00143 00144 00145 00146 #ifdef __cplusplus 00147 } 00148 #endif 00149 00150 00151 #endif
1.3.2