00001 /****************************************************************************************/ 00002 /* POSE.H */ 00003 /* */ 00004 /* Author: Mike Sandige */ 00005 /* Description: Bone hierarchy 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_POSE_H 00023 #define GE_POSE_H 00024 00025 /* gePose 00026 00027 This object is a hierarchical set of attached joints. The joints can have names. 00028 A 'gePose' keeps track of which children joints move in the hierarchy when a parent 00029 joint moves. A gePose also remembers the position transform matrices for each joint. 00030 00031 The gePose is set by applying a motion at a specific time. This queries the motion 00032 to determine each joint's change and applies them to the hierarchy. Each joint can 00033 then be queried for it's world transform (for drawing, etc.) 00034 00035 Additional motions can modify or be blended into the pose. A motion that describes 00036 only a few joint changes can be applied to only those joints, or a motion can be 00037 blended with the current pose. 00038 00039 Something to watch for: since setting the pose by applying a motion is powerful 00040 enough to resolve intentionally mismatched motion-pose sets, this can lead to 00041 problems if the motion UNintentionally does not match the pose. Use 00042 gePose_MatchesgeMotionExactly() to test for an exact name-based match. 00043 00044 00045 */ 00046 00047 #include <stdio.h> 00048 #include "Motion.h" 00049 #include "XFArray.h" 00050 00051 #ifdef __cplusplus 00052 extern "C" { 00053 #endif 00054 00055 00056 #define GE_POSE_ROOT_JOINT (-1) 00057 00058 typedef enum 00059 { 00060 GE_POSE_BLEND_LINEAR, 00061 GE_POSE_BLEND_HERMITE 00062 } gePose_BlendingType; 00063 00064 typedef struct gePose gePose; 00065 00066 // Creates a new pose with no joints. 00067 gePose *GENESISCC gePose_Create(void); 00068 00069 // Destroys an existing pose. 00070 void GENESISCC gePose_Destroy(gePose **PM); 00071 00072 // Adds a new joint to a pose. 00073 geBoolean GENESISCC gePose_AddJoint( 00074 gePose *P, 00075 int ParentJointIndex, 00076 const char *JointName, 00077 const geXForm3d *Attachment, 00078 int *JointIndex); 00079 00080 00081 void GENESISCC gePose_GetScale(const gePose *P, geVec3d *Scale); 00082 // Retrieves current joint attachment scaling factors 00083 00084 void GENESISCC gePose_SetScale(gePose *P, const geVec3d *Scale); 00085 // Scales all joint attachments by component scaling factors in Scale 00086 00087 // Returns the index of a joint named JointName. Returns GE_TRUE if it is 00088 // located, and Index is set. Returns GE_FALSE if not, and Index is not changed. 00089 geBoolean GENESISCC gePose_FindNamedJointIndex(const gePose *P, const char *JointName, int *Index); 00090 00091 // returns the number of joints in the pose 00092 int GENESISCC gePose_GetJointCount(const gePose *P); 00093 00094 geBoolean GENESISCC gePose_MatchesMotionExactly(const gePose *P, const geMotion *M); 00095 00096 void GENESISCC gePose_Clear(gePose *P, const geXForm3d *Transform); 00097 00098 // set the pose according to a motion. Use the motion at time 'Time'. 00099 // if the motion does not describe motion for all joints, name-based resolution 00100 // will be used to decide which motion to attach to which joints. 00101 // joints that are unaffected are unchanged. 00102 // if Transform is non-NULL, it is applied to the Motion 00103 void GENESISCC gePose_SetMotion(gePose *P, const geMotion *M,geFloat Time,const geXForm3d *Transform); 00104 00105 // optimization: if this is called, then all pose computations are limited to the BoneIndex'th bone, and 00106 // it's parents (including the root bone). This is true for all queries until an entire motion is set or blended 00107 // into the pose. 00108 void GENESISCC gePose_SetMotionForABone(gePose *P, const geMotion *M, geFloat Time, 00109 const geXForm3d *Transform,int BoneIndex); 00110 00111 00112 // blend in the pose according to a motion. Use the motion at time 'Time'. 00113 // the blending is between the 'current' pose and the pose described by the motion. 00114 // a BlendAmount of 0 will result in the 'current' pose, and a BlendAmount of 1.0 00115 // will result in the pose according to the new motion. 00116 // if the motion does not describe motion for all joints, name-based resolution 00117 // will be used to decide which motion to attach to which joints. 00118 // joints that are unaffected are unchanged. 00119 // if Transform is non-NULL, it is applied to the Motion prior to blending 00120 void GENESISCC gePose_BlendMotion(gePose *P, const geMotion *M, geFloat Time, 00121 const geXForm3d *Transform, 00122 geFloat BlendAmount, gePose_BlendingType BlendingType); 00123 00124 // get a joint's current transform (relative to world space) 00125 void GENESISCC gePose_GetJointTransform(const gePose *P, int JointIndex,geXForm3d *Transform); 00126 00127 // get the transforms for the entire pose. *TransformArray must not be changed. 00128 const geXFArray *GENESISCC gePose_GetAllJointTransforms(const gePose *P); 00129 00130 // query a joint's current transform relative to it's attachment to it's parent. 00131 void GENESISCC gePose_GetJointLocalTransform(const gePose *P, int JointIndex,geXForm3d *Transform); 00132 00133 // adjust a joint's current transform relative to it's attachment to it's parent. 00134 // this is like setting a mini-motion into this joint only: this will only affect 00135 // the current pose 00136 void GENESISCC gePose_SetJointLocalTransform(gePose *P, int JointIndex,const geXForm3d *Transform); 00137 00138 // query how a joint is attached to it's parent. (it's base attachment) 00139 void GENESISCC gePose_GetJointAttachment(const gePose *P,int JointIndex,geXForm3d *AttachmentTransform); 00140 00141 // adjust how a joint is attached to it's parent. These changes are permanent: all 00142 // future pose motions will incorporate this joint's new relation to it's parent */ 00143 void GENESISCC gePose_SetJointAttachment(gePose *P,int JointIndex,const geXForm3d *AttachmentTransform); 00144 00145 const char* GENESISCC gePose_GetJointName(const gePose* P, int JointIndex); 00146 00147 geBoolean GENESISCC gePose_Attach(gePose *Slave, int SlaveBoneIndex, 00148 gePose *Master, int MasterBoneIndex, 00149 const geXForm3d *Attachment); 00150 00151 void GENESISCC gePose_Detach(gePose *P); 00152 00153 // a pose can also maintain a record of which joints are touched by a given motion. 00154 // these funtions set,clear and query the record. 00155 // ClearCoverage clears the coverage flag for all joints 00156 void GENESISCC gePose_ClearCoverage(gePose *P, int ClearTo); 00157 // AccumulateCoverage returns the number of joints that are not already 'covered' 00158 // that will be affected by a motion M, 00159 // if QueryOnly is GE_FALSE, affected joints are tagged as 'covered', otherwise no changes 00160 // are made to the joint coverage flags. 00161 int GENESISCC gePose_AccumulateCoverage(gePose *P, const geMotion *M, geBoolean QueryOnly); 00162 00163 00164 #ifdef __cplusplus 00165 } 00166 #endif 00167 00168 00169 #endif
1.3.2