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

pose.h File Reference

#include <stdio.h>
#include "Motion.h"
#include "XFArray.h"

Go to the source code of this file.

Defines

#define GE_POSE_ROOT_JOINT   (-1)

Typedefs

typedef gePose gePose

Enumerations

enum  gePose_BlendingType { GE_POSE_BLEND_LINEAR, GE_POSE_BLEND_HERMITE }

Functions

gePose *GENESISCC gePose_Create (void)
void GENESISCC gePose_Destroy (gePose **PM)
geBoolean GENESISCC gePose_AddJoint (gePose *P, int ParentJointIndex, const char *JointName, const geXForm3d *Attachment, int *JointIndex)
void GENESISCC gePose_GetScale (const gePose *P, geVec3d *Scale)
void GENESISCC gePose_SetScale (gePose *P, const geVec3d *Scale)
geBoolean GENESISCC gePose_FindNamedJointIndex (const gePose *P, const char *JointName, int *Index)
int GENESISCC gePose_GetJointCount (const gePose *P)
geBoolean GENESISCC gePose_MatchesMotionExactly (const gePose *P, const geMotion *M)
void GENESISCC gePose_Clear (gePose *P, const geXForm3d *Transform)
void GENESISCC gePose_SetMotion (gePose *P, const geMotion *M, geFloat Time, const geXForm3d *Transform)
void GENESISCC gePose_SetMotionForABone (gePose *P, const geMotion *M, geFloat Time, const geXForm3d *Transform, int BoneIndex)
void GENESISCC gePose_BlendMotion (gePose *P, const geMotion *M, geFloat Time, const geXForm3d *Transform, geFloat BlendAmount, gePose_BlendingType BlendingType)
void GENESISCC gePose_GetJointTransform (const gePose *P, int JointIndex, geXForm3d *Transform)
const geXFArray *GENESISCC gePose_GetAllJointTransforms (const gePose *P)
void GENESISCC gePose_GetJointLocalTransform (const gePose *P, int JointIndex, geXForm3d *Transform)
void GENESISCC gePose_SetJointLocalTransform (gePose *P, int JointIndex, const geXForm3d *Transform)
void GENESISCC gePose_GetJointAttachment (const gePose *P, int JointIndex, geXForm3d *AttachmentTransform)
void GENESISCC gePose_SetJointAttachment (gePose *P, int JointIndex, const geXForm3d *AttachmentTransform)
const char *GENESISCC gePose_GetJointName (const gePose *P, int JointIndex)
geBoolean GENESISCC gePose_Attach (gePose *Slave, int SlaveBoneIndex, gePose *Master, int MasterBoneIndex, const geXForm3d *Attachment)
void GENESISCC gePose_Detach (gePose *P)
void GENESISCC gePose_ClearCoverage (gePose *P, int ClearTo)
int GENESISCC gePose_AccumulateCoverage (gePose *P, const geMotion *M, geBoolean QueryOnly)


Define Documentation

#define GE_POSE_ROOT_JOINT   (-1)
 

Definition at line 56 of file pose.h.

Referenced by geActor_AnimationStepBoneOptimized(), geActor_AnimationTestStepBoneOptimized(), geActor_Create(), geActor_GetBoneBoundingBoxByIndex(), geActor_GetBoneIndex(), geActor_RenderPrep(), gePose_AddJoint(), gePose_Attach(), gePose_BlendMotion(), gePose_Clear(), gePose_Create(), gePose_Detach(), gePose_JointByIndex(), gePose_SetMotion(), gePose_SetMotionForABone(), gePose_SetMotionForABoneRecursion(), gePose_UpdateRecursively(), gePose_UpdateRelativeToParent(), gePuppet_Create(), gePuppet_DrawShadow(), and gePuppet_SetLightingOptions().


Typedef Documentation

typedef struct gePose gePose
 

Definition at line 64 of file pose.h.


Enumeration Type Documentation

enum gePose_BlendingType
 

Enumeration values:
GE_POSE_BLEND_LINEAR 
GE_POSE_BLEND_HERMITE 

Definition at line 58 of file pose.h.


Function Documentation

int GENESISCC gePose_AccumulateCoverage gePose P,
const geMotion M,
geBoolean  QueryOnly
 

Definition at line 1068 of file pose.c.

References GE_FALSE, GE_TRUE, geBoolean, geMotion_GetPathNamed(), geMotion_GetSubMotion(), geMotion_GetSubMotionCount(), GENESISCC, gePose_MatchesMotionExactly(), geStrBlock_GetString(), gePose::JointArray, gePose::JointCount, gePose::JointNames, and NULL.

Referenced by geActor_AnimationStep(), and geActor_AnimationStepBoneOptimized().

01069 {
01070         int i,SubMotions;
01071         geBoolean NameBinding;
01072         int Covers=0;
01073         gePose_Joint *J;
01074         
01075         assert( P != NULL );
01076         if (M==NULL)
01077                 {
01078                         return P->JointCount;
01079                 }
01080 
01081         SubMotions = geMotion_GetSubMotionCount(M);
01082         if (SubMotions>0)
01083                 {
01084                         for (i=0; i<SubMotions; i++)
01085                                 {
01086                                         int c = gePose_AccumulateCoverage(P, geMotion_GetSubMotion(M,i),QueryOnly);
01087                                         if (c > Covers)
01088                                                 {
01089                                                         Covers = c;
01090                                                 }
01091                                 }
01092                         return Covers;
01093                 }
01094         
01095         if (gePose_MatchesMotionExactly(P,M)==GE_TRUE)
01096                 NameBinding = GE_FALSE;
01097         else
01098                 NameBinding = GE_TRUE;
01099 
01100         for (i=0, J=&(P->JointArray[0]); i<P->JointCount; i++,J++)
01101                 {
01102                         gePath *JointPath;
01103                         if (J->Covered == GE_FALSE)
01104                                 {
01105                                         if (NameBinding == GE_TRUE)
01106                                                 {
01107                                                         JointPath = geMotion_GetPathNamed(M, geStrBlock_GetString(P->JointNames,i));
01108                                                         if (JointPath == NULL)
01109                                                                 continue;
01110                                                 }
01111                                         if (QueryOnly == GE_FALSE)
01112                                                 {
01113                                                         J->Covered = GE_TRUE;
01114                                                 }
01115                                         Covers ++;
01116                                 }
01117                 }
01118         return Covers;
01119 }

geBoolean GENESISCC gePose_AddJoint gePose P,
int  ParentJointIndex,
const char *  JointName,
const geXForm3d Attachment,
int *  JointIndex
 

Definition at line 526 of file pose.c.

References ERR_POSE_ADDJOINT_ENOMEM, GE_FALSE, GE_POSE_ROOT_JOINT, GE_RAM_REALLOC_ARRAY, GE_TRUE, geBoolean, geErrorLog_Add, GENESISCC, gePose_InitializeJoint(), gePose_ReattachTransforms(), geStrBlock_Append(), geStrBlock_GetChecksum(), geStrBlock_GetCount(), geXFArray_Create(), geXFArray_Destroy(), gePose::JointArray, gePose::JointCount, gePose::JointNames, gePose::NameChecksum, NULL, gePose::Touched, and gePose::TransformArray.

Referenced by geActor_Create().

00532 {
00533         int JointCount;
00534         gePose_Joint *Joint;
00535 
00536         assert(  P != NULL );
00537         assert( JointIndex != NULL );
00538         assert( P->JointCount >= 0 );
00539         assert( (ParentJointIndex == GE_POSE_ROOT_JOINT) || 
00540                         ((ParentJointIndex >=0) && (ParentJointIndex <P->JointCount) ) );
00541 
00542         // Duplicate names ARE allowed
00543 
00544         JointCount = P->JointCount;
00545         {
00546                 gePose_Joint *NewJoints;
00547                 NewJoints = GE_RAM_REALLOC_ARRAY(P->JointArray,gePose_Joint,JointCount+1);
00548                 if (NewJoints == NULL)
00549                         {
00550                                 geErrorLog_Add(ERR_POSE_ADDJOINT_ENOMEM, NULL);
00551                                 return GE_FALSE;
00552                         }
00553                 P->JointArray = NewJoints;
00554         }
00555         
00556         assert( P->JointNames != NULL );
00557         assert( geStrBlock_GetCount(P->JointNames) == P->JointCount );
00558 
00559         if (geStrBlock_Append( &(P->JointNames), (JointName==NULL)?"":JointName )==GE_FALSE)
00560                 {
00561                         geErrorLog_Add(ERR_POSE_ADDJOINT_ENOMEM, NULL);
00562                         return GE_FALSE;
00563                 }
00564         
00565 
00566         {
00567                 geXFArray *NewXFA;
00568                 NewXFA = geXFArray_Create(JointCount+1);
00569                 if (NewXFA == NULL)
00570                         {
00571                                 geErrorLog_Add(ERR_POSE_ADDJOINT_ENOMEM, NULL);
00572                                 return GE_FALSE;
00573                         }
00574                 if (P->TransformArray != NULL)
00575                         {
00576                                 geXFArray_Destroy(&(P->TransformArray));
00577                         }
00578                 P->TransformArray = NewXFA;
00579         }
00580 
00581         P->JointCount = JointCount+1;
00582         gePose_ReattachTransforms(P);
00583         
00584         Joint = &( P->JointArray[JointCount] );
00585         gePose_InitializeJoint(Joint,ParentJointIndex, Attachment);
00586         P->Touched = GE_TRUE;
00587 
00588         *JointIndex = JointCount;
00589 
00590         P->NameChecksum = geStrBlock_GetChecksum( P->JointNames );
00591         return GE_TRUE;
00592 }

geBoolean GENESISCC gePose_Attach gePose Slave,
int  SlaveBoneIndex,
gePose Master,
int  MasterBoneIndex,
const geXForm3d Attachment
 

Definition at line 298 of file pose.c.

References GE_FALSE, GE_POSE_ROOT_JOINT, GE_TRUE, geBoolean, geErrorLog_Add, GENESISCC, gePose_InitializeJoint(), NULL, gePose::Parent, gePose::ParentsLastTransform, gePose::RootJoint, gePose::Slave, gePose::SlaveJointIndex, and gePose::Touched.

Referenced by geActor_Attach().

00301 {
00302         gePose *P;
00303         P = Master;
00304 
00305         assert( Slave != NULL );
00306         assert( Master != NULL );
00307         assert( MasterBoneIndex >= 0);
00308         assert( MasterBoneIndex < Master->JointCount);
00309         assert( Attachment != NULL );
00310         assert( Master != Slave );
00311 
00312 
00313         assert( (SlaveBoneIndex >=0)                 || (SlaveBoneIndex==(GE_POSE_ROOT_JOINT)));
00314         assert( (SlaveBoneIndex < Slave->JointCount) || (SlaveBoneIndex==(GE_POSE_ROOT_JOINT)));
00315 
00316         while (P!=NULL)
00317                 {
00318                         if (P==Slave)
00319                                 {
00320                                         geErrorLog_Add(-1, NULL);//FIXME
00321                                         return GE_FALSE;
00322                                 }
00323                         P=P->Parent;
00324                 }
00325 
00326         Slave->SlaveJointIndex = SlaveBoneIndex;
00327         Slave->Parent = Master;
00328         if (SlaveBoneIndex == GE_POSE_ROOT_JOINT)
00329                 {
00330                         Slave->Slave = GE_FALSE;
00331                 }
00332         else
00333                 {
00334                         Slave->Slave = GE_TRUE;
00335                 }
00336 
00337         gePose_InitializeJoint(&(Slave->RootJoint),MasterBoneIndex,Attachment);
00338         Slave->Touched = GE_TRUE;
00339         Slave->ParentsLastTransform = *(Master->RootJoint.Transform);
00340         
00341         return GE_TRUE;
00342 }

void GENESISCC gePose_BlendMotion gePose P,
const geMotion M,
geFloat  Time,
const geXForm3d Transform,
geFloat  BlendAmount,
gePose_BlendingType  BlendingType
 

Definition at line 892 of file pose.c.

References GE_FALSE, GE_POSE_BLEND_HERMITE, GE_POSE_BLEND_LINEAR, GE_POSE_ROOT_JOINT, GE_TRUE, geBoolean, geFloat, geMotion_GetTransform(), geMotion_SampleChannels(), geMotion_SampleChannelsNamed(), GENESISCC, gePose_MatchesMotionExactly(), geQuaternion_FromMatrix(), geQuaternion_Slerp(), geStrBlock_GetString(), geXForm3d_Multiply(), gePose::JointArray, gePose::JointCount, gePose::JointNames, LINEAR_BLEND, gePose_Joint::LocalRotation, gePose_Joint::LocalTranslation, NULL, gePose::OnlyThisJoint, gePose::Parent, R1, gePose::RootJoint, gePose::Scale, gePose::Touched, gePose_Joint::Touched, geXForm3d::Translation, geVec3d::X, geVec3d::Y, and geVec3d::Z.

Referenced by geActor_BlendPose().

00896 {
00897         int i;
00898         geBoolean NameBinding;
00899         gePose_Joint *J;
00900         geQuaternion R1;
00901         geVec3d      T1;
00902         geXForm3d    RootTransform;
00903         
00904         assert( P != NULL );
00905         //assert( M != NULL );  // M can be NULL
00906         assert( BlendingType == GE_POSE_BLEND_HERMITE || BlendingType == GE_POSE_BLEND_LINEAR);
00907         assert( BlendAmount >= 0.0f );
00908         assert( BlendAmount <= 1.0f );
00909 
00910         P->OnlyThisJoint = GE_POSE_ROOT_JOINT-1;                // calling this function disables one-joint optimizations
00911         if (BlendingType == GE_POSE_BLEND_HERMITE)
00912                 {
00913                         geFloat t2,t3;
00914                         t2 = BlendAmount * BlendAmount;
00915                         t3 = t2 * BlendAmount;
00916                         BlendAmount = t2*3.0f -t3-t3;
00917                 }
00918 
00919         if (P->Parent==NULL)
00920                 {
00921                         geBoolean SetRoot = GE_FALSE;
00922                         if (geMotion_GetTransform(M,Time,&RootTransform)!=GE_FALSE)
00923                                 {
00924                                         SetRoot = GE_TRUE;
00925 
00926                                         if ( Transform != NULL )
00927                                                 {
00928                                                         geXForm3d_Multiply(Transform,&RootTransform,&RootTransform);
00929                                                 }
00930                                 }
00931                         else
00932                                 {
00933                                         if ( Transform != NULL )
00934                                                 {
00935                                                         SetRoot = GE_TRUE;
00936                                                         RootTransform = *Transform;
00937                                                 }
00938                                 }
00939 
00940                         if (SetRoot != GE_FALSE)
00941                                 {
00942                                         geQuaternion_FromMatrix(&RootTransform,&R1);
00943                                         T1 = RootTransform.Translation;
00944                                         J  = &(P->RootJoint);
00945                                         geQuaternion_Slerp(&(J->LocalRotation),&(R1),BlendAmount,&(J->LocalRotation));
00946                                         {
00947                                                 geVec3d      *LT = &(J->LocalTranslation);
00948                                                 LT->X = LINEAR_BLEND(LT->X,T1.X,BlendAmount);
00949                                                 LT->Y = LINEAR_BLEND(LT->Y,T1.Y,BlendAmount);
00950                                                 LT->Z = LINEAR_BLEND(LT->Z,T1.Z,BlendAmount);
00951                                         }
00952                                         J->Touched = GE_TRUE;
00953                                 }
00954                 }
00955 
00956         if (M==NULL)
00957                 {
00958                         return;
00959                 }
00960 
00961         
00962         if (gePose_MatchesMotionExactly(P,M)==GE_TRUE)
00963                 NameBinding = GE_FALSE;
00964         else
00965                 NameBinding = GE_TRUE;
00966         
00967         P->Touched = GE_TRUE;
00968 
00969         for (i=0, J=&(P->JointArray[0]); i<P->JointCount; i++,J++)
00970                 {
00971                         //gePath *JointPath;
00972                                                         
00973                         if (NameBinding == GE_FALSE)
00974                                 {
00975                                         geMotion_SampleChannels(M,i,Time,&R1,&T1);
00976                                         //JointPath = geMotion_GetPath(M,i);
00977                                         //assert( JointPath != NULL );
00978                                 }
00979                         else
00980                                 {
00981                                         //JointPath = geMotion_GetPathNamed(M, geStrBlock_GetString(P->JointNames,i));
00982                                         //if (JointPath == NULL)
00983                                         //      continue;
00984                                         if (geMotion_SampleChannelsNamed(M,
00985                                                 geStrBlock_GetString(P->JointNames,i),
00986                                                 Time,&R1,&T1)==GE_FALSE)
00987                                                 continue;
00988 
00989                                 }
00990                         J->Touched = GE_TRUE;
00991 
00992                         //gePath_SampleChannels(JointPath,Time,&(R1),&(T1));
00993                         
00994                         T1.X *= P->Scale.X;
00995                         T1.Y *= P->Scale.Y;
00996                         T1.Z *= P->Scale.Z;
00997                         
00998                         geQuaternion_Slerp(&(J->LocalRotation),&(R1),BlendAmount,&(J->LocalRotation));
00999                                                 
01000                         {
01001                                 geVec3d      *LT = &(J->LocalTranslation);
01002                                 LT->X = LINEAR_BLEND(LT->X,T1.X,BlendAmount);
01003                                 LT->Y = LINEAR_BLEND(LT->Y,T1.Y,BlendAmount);
01004                                 LT->Z = LINEAR_BLEND(LT->Z,T1.Z,BlendAmount);
01005                         }
01006                 }
01007 }

void GENESISCC gePose_Clear gePose P,
const geXForm3d Transform
 

Definition at line 685 of file pose.c.

References GE_POSE_ROOT_JOINT, GE_TRUE, GENESISCC, geQuaternion_FromMatrix(), geQuaternion_SetNoRotation(), geVec3d_Set(), gePose::JointArray, gePose::JointCount, gePose_Joint::LocalRotation, gePose_Joint::LocalTranslation, NULL, gePose::OnlyThisJoint, gePose::Parent, gePose::RootJoint, gePose::Touched, gePose_Joint::Touched, and geXForm3d::Translation.

Referenced by geActor_ClearPose().

00686 {
00687         int i;
00688         gePose_Joint *J;
00689         
00690         assert( P != NULL );
00691         assert( P->JointCount >= 0 );
00692         P->OnlyThisJoint = GE_POSE_ROOT_JOINT-1;                // calling this function disables one-joint optimizations
00693         if (P->Parent==NULL)
00694                 {
00695                         if (Transform!=NULL)
00696                                 {
00697                                         geQuaternion_FromMatrix(Transform,&(P->RootJoint.LocalRotation));
00698                                         P->RootJoint.LocalTranslation = Transform->Translation;
00699                                 }
00700                         P->RootJoint.Touched = GE_TRUE;
00701                 }
00702                         
00703         for (i=0, J=&(P->JointArray[0]); i<P->JointCount; i++,J++)
00704                 {
00705                         geVec3d_Set( (&J->LocalTranslation),0.0f,0.0f,0.0f);
00706                         geQuaternion_SetNoRotation(&(J->LocalRotation));
00707                         assert( J->ParentJoint < i);
00708                         P->Touched = GE_TRUE;
00709                 }       
00710         P->Touched = GE_TRUE;
00711 }       

void GENESISCC gePose_ClearCoverage gePose P,
int  ClearTo
 

Definition at line 1054 of file pose.c.

References GE_FALSE, GE_TRUE, GENESISCC, gePose::JointArray, gePose::JointCount, and NULL.

Referenced by geActor_AnimationStep(), and geActor_AnimationStepBoneOptimized().

01055 {
01056         int i;
01057         gePose_Joint *J;
01058 
01059         assert( P != NULL );
01060         assert( (ClearTo == GE_FALSE) || (ClearTo == GE_TRUE) );
01061 
01062         for (i=0, J=&(P->JointArray[0]); i<P->JointCount; i++,J++)
01063                 {       
01064                         J->Covered = ClearTo;
01065                 }
01066 }

gePose* GENESISCC gePose_Create void   ) 
 

Definition at line 174 of file pose.c.

References ERR_POSE_CREATE_ENOMEM, GE_FALSE, GE_POSE_ROOT_JOINT, GE_RAM_ALLOCATE_STRUCT, geErrorLog_Add, GENESISCC, gePose_InitializeJoint(), gePose_ReattachTransforms(), geRam_Free, geStrBlock_Create(), geStrBlock_Destroy(), gePose::JointArray, gePose::JointCount, gePose::JointNames, NULL, gePose::OnlyThisJoint, gePose::Parent, gePose::RootJoint, gePose::Scale, gePose::Slave, gePose::Touched, gePose::TransformArray, geVec3d::X, geVec3d::Y, and geVec3d::Z.

Referenced by geActor_Create().

00175 {
00176         gePose *P;
00177 
00178         P = GE_RAM_ALLOCATE_STRUCT(gePose);
00179 
00180         if ( P == NULL )
00181                 {
00182                         geErrorLog_Add(ERR_POSE_CREATE_ENOMEM, NULL);
00183                         goto PoseCreateFailure;
00184                 }
00185         P->JointCount = 0;
00186         P->OnlyThisJoint = GE_POSE_ROOT_JOINT-1;                
00187         P->JointNames = geStrBlock_Create();
00188         P->Touched = GE_FALSE;
00189         if ( P->JointNames == NULL )
00190                 {
00191                         geErrorLog_Add(ERR_POSE_CREATE_ENOMEM, NULL);
00192                         goto PoseCreateFailure;
00193                 }
00194         P->JointArray = GE_RAM_ALLOCATE_STRUCT( gePose_Joint );
00195         if (P->JointArray == NULL)
00196                 {
00197                         geErrorLog_Add(ERR_POSE_CREATE_ENOMEM, NULL);
00198                         goto PoseCreateFailure;
00199                 }
00200         P->TransformArray=NULL;
00201 
00202         P->Slave = GE_FALSE;
00203         P->Parent = NULL;
00204         gePose_ReattachTransforms(P);
00205         gePose_InitializeJoint(&(P->RootJoint),GE_POSE_ROOT_JOINT,NULL);
00206 
00207         P->Scale.X = P->Scale.Y = P->Scale.Z = 1.0f;
00208         return P;
00209         PoseCreateFailure:
00210         if (P!=NULL)
00211                 {
00212                         if (P->JointNames != NULL)
00213                                 geStrBlock_Destroy(&(P->JointNames));
00214                         if (P->JointArray != NULL)
00215                                 geRam_Free(P->JointArray);
00216                         geRam_Free(P);
00217                 }
00218         return NULL;
00219 }

void GENESISCC gePose_Destroy gePose **  PM  ) 
 

Definition at line 221 of file pose.c.

References GENESISCC, geRam_Free, geStrBlock_Destroy(), geStrBlock_GetCount(), geXFArray_Destroy(), and NULL.

Referenced by geActor_Create(), geActor_Destroy(), and geActor_DestroyDirect().

00222 {
00223         assert(PP   != NULL );
00224         assert(*PP  != NULL );
00225 
00226         assert( (*PP)->JointNames != NULL );
00227         assert( geStrBlock_GetCount((*PP)->JointNames) == (*PP)->JointCount );
00228         geStrBlock_Destroy( &( (*PP)->JointNames ) );
00229         if ((*PP)->TransformArray!=NULL)
00230                 {
00231                         geXFArray_Destroy(&( (*PP)->TransformArray) );
00232                 }
00233         if ((*PP)->JointArray != NULL)
00234                 geRam_Free((*PP)->JointArray);
00235         geRam_Free( *PP );
00236 
00237         *PP = NULL;
00238 }

void GENESISCC gePose_Detach gePose P  ) 
 

Definition at line 345 of file pose.c.

References GE_FALSE, GE_POSE_ROOT_JOINT, GENESISCC, gePose_InitializeJoint(), NULL, gePose::Parent, gePose::RootJoint, and gePose::Slave.

Referenced by geActor_Detach().

00346 {
00347         P->Parent = NULL;
00348         P->Slave = GE_FALSE;
00349         gePose_InitializeJoint(&(P->RootJoint),GE_POSE_ROOT_JOINT,NULL);
00350 }

geBoolean GENESISCC gePose_FindNamedJointIndex const gePose P,
const char *  JointName,
int *  Index
 

Definition at line 503 of file pose.c.

References GE_FALSE, GE_TRUE, geBoolean, GENESISCC, geStrBlock_GetString(), gePose::JointCount, gePose::JointNames, and NULL.

00504 {
00505         int i;
00506 
00507         assert( P != NULL );
00508         assert( Index!= NULL );
00509         if (JointName == NULL )
00510                 return GE_FALSE;
00511 
00512         for (i=0; i<P->JointCount; i++)
00513                 {
00514                         const char *NthName = geStrBlock_GetString(P->JointNames,i);
00515                         assert( NthName!= NULL );
00516                         if ( strcmp(JointName,NthName)==0 )
00517                                 {
00518                                         *Index = i;
00519                                         return GE_TRUE;
00520                                 }       
00521                 }
00522         return GE_FALSE;
00523 }

const geXFArray* GENESISCC gePose_GetAllJointTransforms const gePose P  ) 
 

Definition at line 1014 of file pose.c.

References GENESISCC, gePose_UpdateRelativeToParent(), NULL, and gePose::TransformArray.

Referenced by gePuppet_DrawShadow(), gePuppet_Render(), and gePuppet_RenderThroughFrustum().

01015 {
01016         assert( P != NULL );
01017 
01018         gePose_UpdateRelativeToParent((gePose *)P);
01019         return P->TransformArray;
01020 }

void GENESISCC gePose_GetJointAttachment const gePose P,
int  JointIndex,
geXForm3d AttachmentTransform
 

Definition at line 594 of file pose.c.

References gePose_Joint::AttachmentTransform, GENESISCC, gePose_JointByIndex(), and NULL.

Referenced by geActor_GetBoneAttachment().

00595 {
00596         assert( P != NULL );
00597         assert( AttachmentTransform != NULL );
00598         {
00599                 const gePose_Joint *J;
00600                 J = gePose_JointByIndex(P, JointIndex);
00601                 *AttachmentTransform = J->AttachmentTransform;
00602         }
00603 }

int GENESISCC gePose_GetJointCount const gePose P  ) 
 

Definition at line 663 of file pose.c.

References GENESISCC, gePose::JointCount, and NULL.

Referenced by gePuppet_DrawShadow().

00664 {
00665         assert( P != NULL );
00666         assert( P->JointCount >= 0 );
00667         
00668         return P->JointCount;
00669 }

void GENESISCC gePose_GetJointLocalTransform const gePose P,
int  JointIndex,
geXForm3d Transform
 

Definition at line 637 of file pose.c.

References GENESISCC, gePose_JointByIndex(), geQuaternion_ToMatrix(), gePose_Joint::LocalRotation, gePose_Joint::LocalTranslation, NULL, and geXForm3d::Translation.

00638 {
00639         assert( P != NULL );
00640         assert( Transform != NULL );
00641         {
00642                 const gePose_Joint *J;
00643                 J = gePose_JointByIndex(P, JointIndex);
00644                 geQuaternion_ToMatrix(&(J->LocalRotation), Transform);
00645                 Transform->Translation = J->LocalTranslation;
00646         }
00647 }

const char* GENESISCC gePose_GetJointName const gePose P,
int  JointIndex
 

Definition at line 1009 of file pose.c.

References GENESISCC, geStrBlock_GetString(), and gePose::JointNames.

01010 {
01011         return geStrBlock_GetString(P->JointNames, JointIndex);
01012 }

void GENESISCC gePose_GetJointTransform const gePose P,
int  JointIndex,
geXForm3d Transform
 

Definition at line 623 of file pose.c.

References GENESISCC, gePose_JointByIndex(), gePose_UpdateRelativeToParent(), NULL, and gePose_Joint::Transform.

Referenced by geActor_GetBoneBoundingBoxByIndex(), geActor_GetBoneTransform(), geActor_GetBoneTransformByIndex(), geActor_GetExtBox(), geActor_GetPosition(), geActor_GetRenderHintExtBox(), gePuppet_DrawShadow(), gePuppet_Render(), and gePuppet_RenderThroughFrustum().

00624 {
00625         assert( P != NULL );
00626         assert( Transform != NULL );
00627         
00628         gePose_UpdateRelativeToParent((gePose *)P);
00629         
00630         {
00631                 const gePose_Joint *J;
00632                 J = gePose_JointByIndex(P, JointIndex);
00633                 *Transform = *(J->Transform);
00634         }
00635 }

void GENESISCC gePose_GetScale const gePose P,
geVec3d Scale
 

Definition at line 1022 of file pose.c.

References GENESISCC, NULL, and gePose::Scale.

Referenced by geActor_GetBoneBoundingBoxByIndex(), gePuppet_Render(), and gePuppet_RenderThroughFrustum().

01023 {
01024         assert( P     != NULL );
01025         assert( Scale != NULL );
01026         *Scale = P->Scale;
01027 }

geBoolean GENESISCC gePose_MatchesMotionExactly const gePose P,
const geMotion M
 

Definition at line 671 of file pose.c.

References GE_FALSE, GE_TRUE, geBoolean, geMotion_GetNameChecksum(), geMotion_HasNames(), GENESISCC, and gePose::NameChecksum.

Referenced by gePose_AccumulateCoverage(), gePose_BlendMotion(), gePose_SetMotion(), and gePose_SetMotionForABone().

00672 {
00673         if (geMotion_HasNames(M) != GE_FALSE)
00674                 {
00675                         if (geMotion_GetNameChecksum(M) == P->NameChecksum)
00676                                 return GE_TRUE;
00677                         else
00678                                 return GE_FALSE;
00679                 }
00680         return GE_FALSE;
00681 }

void GENESISCC gePose_SetJointAttachment gePose P,
int  JointIndex,
const geXForm3d AttachmentTransform
 

Definition at line 605 of file pose.c.

References gePose_Joint::AttachmentRotation, gePose_Joint::AttachmentTransform, GE_TRUE, GENESISCC, gePose_JointByIndex(), gePose_SetAttachmentRotationFlag(), geQuaternion_FromMatrix(), NULL, gePose::Touched, gePose_Joint::Touched, geXForm3d::Translation, and gePose_Joint::UnscaledAttachmentTranslation.

Referenced by geActor_SetBoneAttachment().

00608 {
00609         assert( P != NULL );
00610         assert( AttachmentTransform != NULL );
00611         {
00612                 gePose_Joint *J;
00613                 J = (gePose_Joint *)gePose_JointByIndex(P, JointIndex);
00614                 geQuaternion_FromMatrix(AttachmentTransform,&(J->AttachmentRotation));
00615                 J->Touched = GE_TRUE;
00616                 J->AttachmentTransform = *AttachmentTransform;
00617                 J->UnscaledAttachmentTranslation = J->AttachmentTransform.Translation;
00618                 gePose_SetAttachmentRotationFlag(J);
00619         }
00620         P->Touched = GE_TRUE;
00621 }

void GENESISCC gePose_SetJointLocalTransform gePose P,
int  JointIndex,
const geXForm3d Transform
 

Definition at line 649 of file pose.c.

References GE_TRUE, GENESISCC, gePose_JointByIndex(), geQuaternion_FromMatrix(), gePose_Joint::LocalRotation, gePose_Joint::LocalTranslation, NULL, gePose::Touched, gePose_Joint::Touched, and geXForm3d::Translation.

00650 {
00651         assert( P != NULL );
00652         assert( Transform != NULL );
00653         {
00654                 gePose_Joint *J;
00655                 J = (gePose_Joint *)gePose_JointByIndex(P, JointIndex);
00656                 geQuaternion_FromMatrix(Transform,&(J->LocalRotation));
00657                 J->LocalTranslation = Transform->Translation;
00658                 J->Touched = GE_TRUE;
00659         }
00660         P->Touched = GE_TRUE;
00661 }

void GENESISCC gePose_SetMotion gePose P,
const geMotion M,
geFloat  Time,
const geXForm3d Transform
 

Definition at line 713 of file pose.c.

References GE_FALSE, GE_POSE_ROOT_JOINT, GE_TRUE, geBoolean, geMotion_GetTransform(), geMotion_SampleChannels(), geMotion_SampleChannelsNamed(), GENESISCC, gePose_MatchesMotionExactly(), geQuaternion_FromMatrix(), geStrBlock_GetString(), geXForm3d_Multiply(), gePose::JointArray, gePose::JointCount, gePose::JointNames, gePose_Joint::LocalRotation, gePose_Joint::LocalTranslation, NULL, gePose::OnlyThisJoint, gePose::Parent, gePose::RootJoint, gePose::Scale, gePose::Touched, gePose_Joint::Touched, geXForm3d::Translation, geVec3d::X, geVec3d::Y, and geVec3d::Z.

Referenced by geActor_AnimationStep(), geActor_AnimationTestStep(), and geActor_SetPose().

00715 {
00716         geBoolean NameBinding;
00717         int i;
00718         gePose_Joint *J;
00719         geXForm3d RootTransform;
00720         
00721         assert( P != NULL );
00722 
00723         P->OnlyThisJoint = GE_POSE_ROOT_JOINT-1;                // calling this function disables one-joint optimizations
00724 
00725         if (P->Parent==NULL)
00726                 {
00727                         geBoolean SetRoot = GE_FALSE;
00728                         if (geMotion_GetTransform(M,Time,&RootTransform)!=GE_FALSE)
00729                                 {
00730                                         SetRoot = GE_TRUE;
00731 
00732                                         if ( Transform != NULL )
00733                                                 {
00734                                                         geXForm3d_Multiply(Transform,&RootTransform,&RootTransform);
00735                                                 }
00736                                 }
00737                         else
00738                                 {
00739                                         if ( Transform != NULL )
00740                                                 {
00741                                                         SetRoot = GE_TRUE;
00742                                                         RootTransform = *Transform;
00743                                                 }
00744                                 }
00745 
00746                         if (SetRoot != GE_FALSE)
00747                                 {
00748                                         geQuaternion_FromMatrix(&RootTransform,&(P->RootJoint.LocalRotation));
00749                                         P->RootJoint.LocalTranslation = RootTransform.Translation;
00750                                         P->RootJoint.Touched = GE_TRUE;
00751                                 }
00752                 }
00753 
00754         if (M==NULL)
00755                 {
00756                         return;
00757                 }
00758 
00759         if (gePose_MatchesMotionExactly(P,M)==GE_TRUE)
00760                 NameBinding = GE_FALSE;
00761         else
00762                 NameBinding = GE_TRUE;
00763 
00764         P->Touched = GE_TRUE;
00765         #pragma message("could optimize this by looping two ways (min(jointcount,pathcount))")
00766         for (i=0, J=&(P->JointArray[0]); i<P->JointCount; i++,J++)
00767                 {
00768                         //gePath *JointPath;
00769                         if (NameBinding == GE_FALSE)
00770                                 {
00771                                         geMotion_SampleChannels(M,i,Time,&(J->LocalRotation),&(J->LocalTranslation));
00772 
00773                                         //JointPath = geMotion_GetPath(M,i);
00774                                         //assert( JointPath != NULL );
00775                                 }
00776                         else
00777                                 {
00778                                         if (geMotion_SampleChannelsNamed(M,
00779                                                 geStrBlock_GetString(P->JointNames,i),
00780                                                 Time,&(J->LocalRotation),&(J->LocalTranslation))==GE_FALSE)
00781                                                 continue;
00782 
00783                                 }
00784                         J->Touched = GE_TRUE;
00785                         J->LocalTranslation.X *= P->Scale.X;
00786                         J->LocalTranslation.Y *= P->Scale.Y;
00787                         J->LocalTranslation.Z *= P->Scale.Z;
00788                 }
00789 }

void GENESISCC gePose_SetMotionForABone gePose P,
const geMotion M,
geFloat  Time,
const geXForm3d Transform,
int  BoneIndex
 

Definition at line 826 of file pose.c.

References GE_FALSE, GE_POSE_ROOT_JOINT, GE_TRUE, geBoolean, geMotion_GetTransform(), GENESISCC, gePose_MatchesMotionExactly(), gePose_SetMotionForABoneRecursion(), geQuaternion_FromMatrix(), geXForm3d_Multiply(), gePose_Joint::LocalRotation, gePose_Joint::LocalTranslation, NULL, gePose::OnlyThisJoint, gePose::Parent, gePose::RootJoint, gePose::Touched, gePose_Joint::Touched, and geXForm3d::Translation.

Referenced by geActor_AnimationStepBoneOptimized(), and geActor_AnimationTestStepBoneOptimized().

00828 {
00829         geBoolean NameBinding;
00830         geXForm3d RootTransform;
00831         
00832         assert( P != NULL );
00833         //assert( M != NULL );
00834         P->OnlyThisJoint = BoneIndex;           // calling this function enables single-joint optimizations
00835         
00836         if (P->Parent==NULL)
00837                 {
00838                         geBoolean SetRoot = GE_FALSE;
00839                         if (geMotion_GetTransform(M,Time,&RootTransform)!=GE_FALSE)
00840                                 {
00841                                         SetRoot = GE_TRUE;
00842 
00843                                         if ( Transform != NULL )
00844                                                 {
00845                                                         geXForm3d_Multiply(Transform,&RootTransform,&RootTransform);
00846                                                 }
00847                                 }
00848                         else
00849                                 {
00850                                         if ( Transform != NULL )
00851                                                 {
00852                                                         SetRoot = GE_TRUE;
00853                                                         RootTransform = *Transform;
00854                                                 }
00855                                 }
00856 
00857                         if (SetRoot != GE_FALSE)
00858                                 {
00859                                         geQuaternion_FromMatrix(&RootTransform,&(P->RootJoint.LocalRotation));
00860                                         P->RootJoint.LocalTranslation = RootTransform.Translation;
00861                                         P->RootJoint.Touched = GE_TRUE;
00862                                 }
00863                 }
00864 
00865         if (M==NULL)
00866                 {
00867                         return;
00868                 }
00869         if (BoneIndex == GE_POSE_ROOT_JOINT)
00870                 {
00871                         return;
00872                 }
00873 
00874         if (gePose_MatchesMotionExactly(P,M)==GE_TRUE)
00875                 NameBinding = GE_FALSE;
00876         else
00877                 NameBinding = GE_TRUE;
00878 
00879         P->Touched = GE_TRUE;
00880 
00881         gePose_SetMotionForABoneRecursion(P, M, Time, BoneIndex, NameBinding);
00882 }

void GENESISCC gePose_SetScale gePose P,
const geVec3d Scale
 

Definition at line 1030 of file pose.c.

References GE_FALSE, GE_TRUE, GENESISCC, geVec3d_IsValid(), gePose::JointArray, gePose::JointCount, NULL, gePose::Scale, gePose::Touched, geVec3d::X, geVec3d::Y, and geVec3d::Z.

Referenced by geActor_SetScale().

01031 {
01032         assert( P != NULL );
01033         assert( geVec3d_IsValid(Scale) != GE_FALSE );
01034 
01035         {
01036                 int i;
01037                 gePose_Joint *J;
01038 
01039                 P->Scale = *Scale;
01040                 //geVec3d_Set(&(P->Scale),ScaleX,ScaleY,ScaleZ);
01041 
01042                 for (i=0, J=&(P->JointArray[0]); i<P->JointCount; i++,J++)
01043                         {       
01044                                 J->AttachmentTransform.Translation.X = J->UnscaledAttachmentTranslation.X * Scale->X;
01045                                 J->AttachmentTransform.Translation.Y = J->UnscaledAttachmentTranslation.Y * Scale->Y;
01046                                 J->AttachmentTransform.Translation.Z = J->UnscaledAttachmentTranslation.Z * Scale->Z;
01047                                 //J->AttachmentTransform.Translation = J->AttachmentTranslation;
01048                                 J->Touched = GE_TRUE;
01049                         }
01050                 P->Touched = GE_TRUE;
01051         }
01052 }


Generated on Tue Sep 30 12:37:56 2003 for GTestAndEngine by doxygen 1.3.2