#include <stdio.h>#include "basetype.h"#include "path.h"#include "vfile.h"Go to the source code of this file.
Typedefs | |
| typedef geMotion | geMotion |
Functions | |
| GENESISAPI geMotion *GENESISCC | geMotion_Create (geBoolean ManageNames) |
| GENESISAPI void GENESISCC | geMotion_Destroy (geMotion **PM) |
| GENESISAPI geBoolean GENESISCC | geMotion_IsValid (const geMotion *M) |
| GENESISAPI geBoolean GENESISCC | geMotion_AddPath (geMotion *M, gePath *P, const char *Name, int *Index) |
| GENESISAPI geBoolean GENESISCC | geMotion_HasNames (const geMotion *M) |
| GENESISAPI int32 GENESISCC | geMotion_GetNameChecksum (const geMotion *M) |
| GENESISAPI geBoolean GENESISCC | geMotion_RemoveNames (geMotion *M) |
| GENESISAPI void GENESISCC | geMotion_SampleChannels (const geMotion *M, int PathIndex, geFloat Time, geQuaternion *Rotation, geVec3d *Translation) |
| GENESISAPI geBoolean GENESISCC | geMotion_SampleChannelsNamed (const geMotion *M, const char *PathName, geFloat Time, geQuaternion *Rotation, geVec3d *Translation) |
| GENESISAPI void GENESISCC | geMotion_Sample (const geMotion *M, int PathIndex, geFloat Time, geXForm3d *Transform) |
| GENESISAPI geBoolean GENESISCC | geMotion_SampleNamed (const geMotion *M, const char *PathName, geFloat Time, geXForm3d *Transform) |
| GENESISAPI gePath *GENESISCC | geMotion_GetPathNamed (const geMotion *M, const char *Name) |
| GENESISAPI const char *GENESISCC | geMotion_GetNameOfPath (const geMotion *M, int Index) |
| GENESISAPI gePath *GENESISCC | geMotion_GetPath (const geMotion *M, int Index) |
| GENESISAPI int GENESISCC | geMotion_GetPathCount (const geMotion *M) |
| GENESISAPI geBoolean GENESISCC | geMotion_SetName (geMotion *M, const char *Name) |
| GENESISAPI const char *GENESISCC | geMotion_GetName (const geMotion *M) |
| GENESISAPI int GENESISCC | geMotion_GetSubMotionCount (const geMotion *M) |
| GENESISAPI geMotion *GENESISCC | geMotion_GetSubMotion (const geMotion *M, int Index) |
| GENESISAPI geMotion *GENESISCC | geMotion_GetSubMotionNamed (const geMotion *M, const char *Name) |
| GENESISAPI geBoolean GENESISCC | geMotion_AddSubMotion (geMotion *ParentMotion, geFloat TimeScale, geFloat TimeOffset, geMotion *SubMotion, geFloat StartTime, geFloat StartMagnitude, geFloat EndTime, geFloat EndMagnitude, const geXForm3d *Transform, int *Index) |
| GENESISAPI geMotion *GENESISCC | geMotion_RemoveSubMotion (geMotion *ParentMotion, int SubMotionIndex) |
| GENESISAPI geFloat GENESISCC | geMotion_GetTimeOffset (const geMotion *M, int SubMotionIndex) |
| GENESISAPI geBoolean GENESISCC | geMotion_SetTimeOffset (geMotion *M, int SubMotionIndex, geFloat TimeOffset) |
| GENESISAPI geFloat GENESISCC | geMotion_GetTimeScale (const geMotion *M, int SubMotionIndex) |
| GENESISAPI geBoolean GENESISCC | geMotion_SetTimeScale (geMotion *M, int SubMotionIndex, geFloat TimeScale) |
| GENESISAPI geFloat GENESISCC | geMotion_GetBlendAmount (const geMotion *M, int SubMotionIndex, geFloat Time) |
| GENESISAPI gePath *GENESISCC | geMotion_GetBlendPath (const geMotion *M, int SubMotionIndex) |
| GENESISAPI geBoolean GENESISCC | geMotion_SetBlendPath (geMotion *M, int SubMotionIndex, gePath *Blend) |
| GENESISAPI const geXForm3d *GENESISCC | geMotion_GetBaseTransform (const geMotion *M, int SubMotionIndex) |
| GENESISAPI geBoolean GENESISCC | geMotion_SetBaseTransform (geMotion *M, int SubMotionIndex, geXForm3d *BaseTransform) |
| GENESISAPI geBoolean GENESISCC | geMotion_GetTransform (const geMotion *M, geFloat Time, geXForm3d *Transform) |
| GENESISAPI geBoolean GENESISCC | geMotion_GetTimeExtents (const geMotion *M, geFloat *StartTime, geFloat *EndTime) |
| GENESISAPI geBoolean GENESISCC | geMotion_InsertEvent (geMotion *M, geFloat tKey, const char *String) |
| GENESISAPI geBoolean GENESISCC | geMotion_DeleteEvent (geMotion *M, geFloat tKey) |
| GENESISAPI void GENESISCC | geMotion_SetupEventIterator (geMotion *M, geFloat StartTime, geFloat EndTime) |
| GENESISAPI geBoolean GENESISCC | geMotion_GetNextEvent (geMotion *M, geFloat *pTime, const char **ppEventString) |
| GENESISAPI geBoolean GENESISCC | geMotion_GetEventExtents (const geMotion *M, geFloat *FirstEventTime, geFloat *LastEventTime) |
| GENESISAPI geMotion *GENESISCC | geMotion_CreateFromFile (geVFile *f) |
| GENESISAPI geBoolean GENESISCC | geMotion_WriteToFile (const geMotion *M, geVFile *f) |
| GENESISAPI geBoolean GENESISCC | geMotion_WriteToBinaryFile (const geMotion *M, geVFile *pFile) |
|
|
|
|
||||||||||||||||||||
|
Definition at line 316 of file motion.c. References ERR_MOTION_ADDPATH_BAD_NAME, ERR_MOTION_ADDPATH_ENOMEM, GE_FALSE, GE_TRUE, geBoolean, geErrorLog_Add, geMotion_GetPathNamed(), geMotion_InitNodeAsLeaf(), geMotion_IsValid(), GENESISAPI, GENESISCC, gePath_CreateRef(), gePath_Destroy(), geRam_Realloc, geStrBlock_Append(), geStrBlock_GetChecksum(), geMotion::Leaf, geMotion::MaintainNames, MOTION_NODE_BRANCH, MOTION_NODE_LEAF, MOTION_NODE_UNDECIDED, geMotion_Leaf::NameArray, geMotion_Leaf::NameChecksum, geMotion::NodeType, NULL, geMotion_Leaf::PathArray, and geMotion_Leaf::PathCount.
00318 {
00319 int PathCount;
00320 assert( M != NULL );
00321 assert( geMotion_IsValid(M) != GE_FALSE );
00322
00323 switch (M->NodeType)
00324 {
00325 case (MOTION_NODE_UNDECIDED):
00326 if (geMotion_InitNodeAsLeaf(M,GE_TRUE)==GE_FALSE)
00327 {
00328 geErrorLog_Add(-1, NULL);
00329 return GE_FALSE;
00330 }
00331 break;
00332 case (MOTION_NODE_BRANCH):
00333 geErrorLog_Add(ERR_MOTION_ADDPATH_ENOMEM, NULL); //FIXME!
00334 return GE_FALSE;
00335 case (MOTION_NODE_LEAF):
00336 break;
00337 default:
00338 assert(0);
00339 }
00340
00341 assert( M->Leaf.PathCount >= 0 );
00342
00343 if (Name!=NULL)
00344 {
00345 if (geMotion_GetPathNamed( M, Name) != NULL )
00346 {
00347 geErrorLog_Add(ERR_MOTION_ADDPATH_BAD_NAME, NULL);
00348 return GE_FALSE;
00349 }
00350 }
00351
00352 PathCount = M->Leaf.PathCount;
00353
00354 {
00355 gePath **NewPathArray;
00356
00357 NewPathArray = geRam_Realloc(M->Leaf.PathArray, (1+PathCount) * sizeof(gePath*) );
00358
00359 if ( NewPathArray == NULL )
00360 {
00361 geErrorLog_Add(ERR_MOTION_ADDPATH_ENOMEM, NULL);
00362 return GE_FALSE;
00363 }
00364 M->Leaf.PathArray = NewPathArray;
00365 }
00366
00367 M->Leaf.PathArray[PathCount] = P;
00368
00369 if ( M->MaintainNames == GE_TRUE )
00370 {
00371
00372 assert (M->Leaf.NameArray != NULL);
00373 if (geStrBlock_Append(&(M->Leaf.NameArray),Name)==GE_FALSE)
00374 {
00375 geErrorLog_Add(ERR_MOTION_ADDPATH_ENOMEM, NULL);
00376 assert(M->Leaf.PathArray[PathCount]);
00377 gePath_Destroy(&(M->Leaf.PathArray[PathCount]));
00378 return GE_FALSE;
00379 }
00380 M->Leaf.NameChecksum = geStrBlock_GetChecksum(M->Leaf.NameArray);
00381 }
00382
00383 M->Leaf.PathCount = PathCount+1;
00384 *PathIndex = PathCount;
00385 gePath_CreateRef(P);
00386 return GE_TRUE;
00387 }
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
Definition at line 880 of file motion.c. References geMotion_Mixer::Blend, geMotion::Branch, geMotion::CloneCount, GE_FALSE, GE_PATH_INTERPOLATE_HERMITE_ZERO_DERIV, GE_PATH_INTERPOLATE_SLERP, GE_PATH_TRANSLATION_CHANNEL, GE_TRUE, geBoolean, geErrorLog_Add, geMotion_InitNodeAsBranch(), geMotion_IsValid(), geMotion_SearchForSubMotion(), GENESISAPI, GENESISCC, gePath_Create(), gePath_Destroy(), gePath_InsertKeyframe(), geRam_Realloc, geMotion::MaintainNames, geMotion_Branch::MixerArray, geMotion_Branch::MixerCount, geMotion_Mixer::Motion, MOTION_BLEND_PART_OF_TRANSFORM, MOTION_NODE_BRANCH, MOTION_NODE_LEAF, MOTION_NODE_UNDECIDED, geMotion::NodeType, NULL, geMotion_Mixer::TimeOffset, geMotion_Mixer::TimeScale, geMotion_Mixer::Transform, and geMotion_Mixer::TransformUsed. Referenced by geActor_AnimationCue().
00889 {
00890
00891 int Count;
00892 geMotion_Mixer *NewMixerArray;
00893 assert( ParentMotion != NULL );
00894 assert( TimeScale != 0.0f );
00895 assert( SubMotion != NULL );
00896 assert( Index != NULL );
00897 //assert( Transform != NULL );
00898 assert( ( StartMagnitude >= 0.0f) && ( StartMagnitude <=1.0f ));
00899 assert( ( EndMagnitude >= 0.0f) && ( EndMagnitude <=1.0f ));
00900 assert( geMotion_IsValid(ParentMotion) != GE_FALSE );
00901 assert( geMotion_IsValid(SubMotion) != GE_FALSE );
00902
00903 switch (ParentMotion->NodeType)
00904 {
00905 case (MOTION_NODE_UNDECIDED):
00906 if (geMotion_InitNodeAsBranch(ParentMotion)==GE_FALSE)
00907 {
00908 geErrorLog_Add(-1, NULL);
00909 return GE_FALSE;
00910 }
00911 break;
00912 case (MOTION_NODE_LEAF):
00913 {
00914 geErrorLog_Add(-1, NULL);
00915 return GE_FALSE;
00916 }
00917 case (MOTION_NODE_BRANCH):
00918 break;
00919 default:
00920 assert(0);
00921 }
00922
00923 if (ParentMotion->MaintainNames != SubMotion->MaintainNames)
00924 {
00925 geErrorLog_Add(-1, NULL); //?
00926 return GE_FALSE;
00927 }
00928
00929 if (geMotion_SearchForSubMotion(SubMotion,ParentMotion)!=GE_FALSE)
00930 {
00931 geErrorLog_Add(-1, NULL);
00932 return GE_FALSE;
00933 }
00934
00935 Count = ParentMotion->Branch.MixerCount;
00936 NewMixerArray = geRam_Realloc(ParentMotion->Branch.MixerArray, (1+Count) * sizeof(geMotion_Mixer) );
00937 if ( NewMixerArray == NULL )
00938 {
00939 geErrorLog_Add(-1, NULL);
00940 return GE_FALSE;
00941 }
00942
00943 ParentMotion->Branch.MixerArray = NewMixerArray;
00944 {
00945 geMotion_Mixer *Mixer;
00946 geXForm3d BlendKeyTransform;
00947 Mixer = &(ParentMotion->Branch.MixerArray[Count]);
00948
00949 Mixer->Motion = SubMotion;
00950 Mixer->TimeScale = TimeScale;
00951 Mixer->TimeOffset = TimeOffset;
00952
00953 Mixer->Blend = gePath_Create(GE_PATH_INTERPOLATE_HERMITE_ZERO_DERIV,GE_PATH_INTERPOLATE_SLERP,GE_FALSE);
00954 if (Mixer->Blend==NULL)
00955 {
00956 geErrorLog_Add(-1, NULL);
00957 return GE_FALSE;
00958 }
00959 MOTION_BLEND_PART_OF_TRANSFORM(BlendKeyTransform) = StartMagnitude;
00960 if (gePath_InsertKeyframe(Mixer->Blend,
00961 GE_PATH_TRANSLATION_CHANNEL,StartTime,&BlendKeyTransform)==GE_FALSE)
00962 {
00963 geErrorLog_Add(-1, NULL);
00964 gePath_Destroy(&(Mixer->Blend));
00965 return GE_FALSE;
00966 }
00967
00968 MOTION_BLEND_PART_OF_TRANSFORM(BlendKeyTransform) = EndMagnitude;
00969 if (gePath_InsertKeyframe(Mixer->Blend,
00970 GE_PATH_TRANSLATION_CHANNEL,EndTime,&BlendKeyTransform)==GE_FALSE)
00971 {
00972 geErrorLog_Add(-1, NULL);
00973 gePath_Destroy(&(Mixer->Blend));
00974 return GE_FALSE;
00975 }
00976 if (Transform == NULL)
00977 {
00978 Mixer->TransformUsed = GE_FALSE;
00979 }
00980 else
00981 {
00982 Mixer->TransformUsed = GE_TRUE;
00983 Mixer->Transform = *Transform;
00984 }
00985 }
00986
00987 *Index = Count;
00988 SubMotion->CloneCount++;
00989 ParentMotion->Branch.MixerCount++;
00990
00991 return GE_TRUE;
00992 }
|
|
|
Definition at line 176 of file motion.c. References geMotion::CloneCount, ERR_MOTION_CREATE_ENOMEM, GE_FALSE, GE_RAM_ALLOCATE_STRUCT, GE_TRUE, geErrorLog_Add, GENESISAPI, GENESISCC, geMotion::MaintainNames, MOTION_NODE_UNDECIDED, geMotion::Name, geMotion::NodeType, NULL, and geMotion::SanityCheck. Referenced by geActor_Create(), geMotion_CreateFromBinaryFile(), and geMotion_CreateFromFile().
00177 {
00178 geMotion *M;
00179 assert( (WithNames==GE_TRUE) || (WithNames==GE_FALSE) );
00180
00181 M = GE_RAM_ALLOCATE_STRUCT(geMotion);
00182
00183 if ( M == NULL )
00184 {
00185 geErrorLog_Add(ERR_MOTION_CREATE_ENOMEM, NULL);
00186 return NULL;
00187 }
00188
00189 M->Name = NULL;
00190 M->CloneCount = 0;
00191 M->MaintainNames = WithNames;
00192 M->NodeType = MOTION_NODE_UNDECIDED;
00193 M->SanityCheck = M;
00194 return M;
00195 }
|
|
|
Definition at line 1501 of file motion.c. References count, ERR_MOTION_ADDPATH_ENOMEM, ERR_MOTION_FILE_PARSE, ERR_MOTION_FILE_READ, geMotion_Leaf::Events, GE_FALSE, geErrorLog_Add, geMotion_Create(), geMotion_CreateFromBinaryFile(), geMotion_Destroy(), geMotion_InitNodeAsLeaf(), geMotion_SetName(), GENESISAPI, GENESISCC, gePath_CreateFromFile(), geRam_Allocate, geStrBlock_CreateFromFile(), geTKEvents_CreateFromFile(), geVFile_GetS(), geVFile_Read(), geMotion::Leaf, geMotion::MaintainNames, MOTION_ASCII_FILE_TYPE, MOTION_BIN_FILE_TYPE, MOTION_EVENTS_ID, MOTION_FILE_VERSION, MOTION_MAINTAINNAMES_ID, MOTION_NAME_ID, MOTION_NAMEARRAY_ID, MOTION_NAMECHECKSUM_ID, MOTION_NUM_ASCII_IDS, MOTION_PATHARRAY_ID, MOTION_PATHCOUNT_ID, geMotion_Leaf::NameArray, geMotion_Leaf::NameChecksum, NULL, geMotion_Leaf::PathArray, geMotion_Leaf::PathCount, uint32, and v. Referenced by geActor_DefCreateFromFile(), and LoadMotions().
01502 {
01503 uint32 u, v;
01504 geMotion* M;
01505
01506 assert( pFile != NULL );
01507
01508 if(geVFile_Read(pFile, &u, sizeof(u)) == GE_FALSE)
01509 {
01510 geErrorLog_Add( ERR_MOTION_FILE_READ , NULL);
01511 return NULL;
01512 }
01513
01514 if(u == MOTION_ASCII_FILE_TYPE)
01515 {
01516 int NumItemsNeeded=0;
01517 int NumItemsRead = 0;
01518 #define LINE_LENGTH 256
01519 char line[LINE_LENGTH];
01520
01521 M = geMotion_Create(GE_FALSE);
01522 if( M == NULL )
01523 {
01524 geErrorLog_Add(-1, NULL);
01525 return NULL; // error logged already in geMotion_Create
01526 }
01527
01528 // Read and build the version. Then determine the number of items to read.
01529 if (geVFile_GetS(pFile, line, LINE_LENGTH) == GE_FALSE)
01530 {
01531 geErrorLog_Add( ERR_MOTION_FILE_READ , NULL);
01532 return NULL;
01533 }
01534 if (sscanf(line, "%X.%X\n", &u, &v) != 2)
01535 {
01536 geErrorLog_Add( ERR_MOTION_FILE_READ , NULL);
01537 return NULL;
01538 }
01539 v |= (u << 8);
01540 if(v >= MOTION_FILE_VERSION)
01541 {
01542 NumItemsNeeded = MOTION_NUM_ASCII_IDS;
01543 }
01544
01545 // remove this when leaf/branch split happens.
01546 if (geMotion_InitNodeAsLeaf(M,GE_FALSE)==GE_FALSE)
01547 {
01548 geErrorLog_Add(-1, NULL);
01549 return GE_FALSE;
01550 }
01551
01552
01553 while(NumItemsRead < NumItemsNeeded)
01554 {
01555 if(geVFile_GetS(pFile, line, LINE_LENGTH) == GE_FALSE)
01556 {
01557 geErrorLog_Add( ERR_MOTION_FILE_READ , NULL);
01558 break; // got to read something
01559 }
01560 else if(strnicmp(line, MOTION_NAME_ID, sizeof(MOTION_NAME_ID)-1) == 0)
01561 {
01562 //line[strlen(line)-1]=0; // zap off cr
01563 if ( line[0] != 0 )
01564 line[strlen(line)-1] = 0; // remove trailing /n (textmode)
01565 if ( line[0] != 0 )
01566 {
01567 int len = strlen(line)-1;
01568 if (line[len] == 13) // remove trailing /r (binary file mode)
01569 {
01570 line[len] = 0;
01571 }
01572 }
01573 if (strlen(line) > sizeof(MOTION_NAME_ID))
01574 {
01575 if (geMotion_SetName(M,line+sizeof(MOTION_NAME_ID))==GE_FALSE)
01576 {
01577 geErrorLog_Add( ERR_MOTION_FILE_READ , NULL);
01578 break;
01579 }
01580 }
01581 //NumItemsRead++;
01582 }
01583
01584 else if(strnicmp(line, MOTION_MAINTAINNAMES_ID, sizeof(MOTION_MAINTAINNAMES_ID)-1) == 0)
01585 {
01586 if(sscanf(line + sizeof(MOTION_MAINTAINNAMES_ID)-1, "%d", &M->MaintainNames) != 1)
01587 {
01588 geErrorLog_Add( ERR_MOTION_FILE_READ , NULL);
01589 break;
01590 }
01591 NumItemsRead++;
01592 }
01593 else if(strnicmp(line, MOTION_PATHCOUNT_ID, sizeof(MOTION_PATHCOUNT_ID)-1) == 0)
01594 {
01595 if(sscanf(line + sizeof(MOTION_PATHCOUNT_ID)-1, "%d", &M->Leaf.PathCount) != 1)
01596 {
01597 geErrorLog_Add( ERR_MOTION_FILE_READ , NULL);
01598 break;
01599 }
01600 NumItemsRead++;
01601 }
01602 else if(strnicmp(line, MOTION_NAMECHECKSUM_ID, sizeof(MOTION_NAMECHECKSUM_ID)-1) == 0)
01603 {
01604 if(sscanf(line + sizeof(MOTION_NAMECHECKSUM_ID)-1, "%d", &M->Leaf.NameChecksum) != 1)
01605 {
01606 geErrorLog_Add( ERR_MOTION_FILE_READ , NULL);
01607 break;
01608 }
01609 NumItemsRead++;
01610 }
01611 else if(strnicmp(line, MOTION_EVENTS_ID, sizeof(MOTION_EVENTS_ID)-1) == 0)
01612 {
01613 int flag;
01614 if(sscanf(line + sizeof(MOTION_EVENTS_ID)-1, "%d", &flag) != 1)
01615 {
01616 geErrorLog_Add( ERR_MOTION_FILE_READ , NULL);
01617 break;
01618 }
01619 if (flag!=GE_FALSE)
01620 {
01621 M->Leaf.Events = geTKEvents_CreateFromFile(pFile);
01622 if (M->Leaf.Events == NULL)
01623 {
01624 geErrorLog_Add( ERR_MOTION_FILE_READ , NULL);
01625 break;
01626 }
01627 }
01628 NumItemsRead++;
01629 }
01630 else if(strnicmp(line, MOTION_NAMEARRAY_ID, sizeof(MOTION_NAMEARRAY_ID)-1) == 0)
01631 {
01632 int flag;
01633 if(sscanf(line + sizeof(MOTION_NAMEARRAY_ID)-1, "%d", &flag) != 1)
01634 {
01635 geErrorLog_Add( ERR_MOTION_FILE_READ , NULL);
01636 break;
01637 }
01638 if (flag!=GE_FALSE)
01639 {
01640 M->Leaf.NameArray = geStrBlock_CreateFromFile(pFile);
01641 if (M->Leaf.NameArray == NULL)
01642 {
01643 geErrorLog_Add( ERR_MOTION_FILE_READ , NULL);
01644 break;
01645 }
01646 }
01647 NumItemsRead++;
01648 }
01649 else if(strnicmp(line, MOTION_PATHARRAY_ID, sizeof(MOTION_PATHARRAY_ID)-1) == 0)
01650 {
01651 int i,count;
01652 if(sscanf(line + sizeof(MOTION_PATHARRAY_ID)-1, "%d", &count) != 1)
01653 {
01654 geErrorLog_Add( ERR_MOTION_FILE_READ , NULL);
01655 break;
01656 }
01657
01658 M->Leaf.PathArray = geRam_Allocate( count * sizeof(gePath*) );
01659
01660 if ( M->Leaf.PathArray == NULL )
01661 {
01662 geErrorLog_Add(ERR_MOTION_ADDPATH_ENOMEM, NULL);
01663 break;
01664 }
01665
01666 for (i=0; i<count; i++)
01667 {
01668
01669 M->Leaf.PathArray[i] = gePath_CreateFromFile(pFile);
01670 if (M->Leaf.PathArray[i] == NULL )
01671 {
01672 geErrorLog_Add(ERR_MOTION_FILE_READ, NULL);
01673 break;
01674 }
01675
01676 }
01677 NumItemsRead++;
01678 }
01679
01680
01681 }
01682
01683 if(NumItemsNeeded == NumItemsRead)
01684 {
01685 return M;
01686 }
01687 else
01688 {
01689 geErrorLog_Add( ERR_MOTION_FILE_PARSE , NULL);
01690 geMotion_Destroy(&M); // try to destroy it
01691 return NULL;
01692 }
01693 }
01694 else
01695 {
01696 if (u==MOTION_BIN_FILE_TYPE)
01697 {
01698 return geMotion_CreateFromBinaryFile(pFile);
01699 }
01700 }
01701
01702 geErrorLog_Add( ERR_MOTION_FILE_PARSE , NULL);
01703 return NULL;
01704 }
|
|
||||||||||||
|
|
|
|
||||||||||||
|
Definition at line 1163 of file motion.c. References geMotion::Branch, GE_FALSE, geMotion_IsValid(), GENESISAPI, GENESISCC, geMotion_Branch::MixerArray, MOTION_NODE_BRANCH, geMotion::NodeType, NULL, geMotion_Mixer::Transform, and geMotion_Mixer::TransformUsed. Referenced by geActor_AnimationNudge().
01164 {
01165 assert( M != NULL );
01166 assert( geMotion_IsValid(M) != GE_FALSE );
01167 // wrong node type is neither error nor invalid. return value is just NULL
01168
01169 if (M->NodeType == MOTION_NODE_BRANCH)
01170 {
01171 assert( (SubMotionIndex>=0) && (SubMotionIndex<M->Branch.MixerCount));
01172 if (M->Branch.MixerArray[SubMotionIndex].TransformUsed != GE_FALSE)
01173 {
01174 return &(M->Branch.MixerArray[SubMotionIndex].Transform);
01175 }
01176 else
01177 {
01178 return NULL;
01179 }
01180 }
01181 return NULL;
01182 }
|
|
||||||||||||||||
|
Definition at line 1101 of file motion.c. References geMotion_Mixer::Blend, geMotion::Branch, GE_FALSE, geFloat, geMotion_IsValid(), GENESISAPI, GENESISCC, gePath_SampleChannels(), geMotion_Branch::MixerArray, MOTION_BLEND_PART_OF_VECTOR, MOTION_NODE_BRANCH, geMotion::NodeType, NULL, geMotion_Mixer::TimeOffset, and geMotion_Mixer::TimeScale. Referenced by geActor_AnimationStep(), geActor_AnimationStepBoneOptimized(), and geActor_IsAnimationCueDead().
01102 {
01103 assert( M != NULL );
01104 assert( geMotion_IsValid(M) != GE_FALSE );
01105 // wrong node type is neither error nor invalid. return value is just 0
01106
01107 if (M->NodeType == MOTION_NODE_BRANCH)
01108 {
01109 geQuaternion Dummy;
01110 geVec3d BlendVector;
01111 geFloat BlendAmount;
01112
01113 assert( (SubMotionIndex>=0) && (SubMotionIndex<M->Branch.MixerCount));
01114 assert( M->Branch.MixerArray[SubMotionIndex].Blend != NULL );
01115 gePath_SampleChannels(M->Branch.MixerArray[SubMotionIndex].Blend,
01116 ( Time - M->Branch.MixerArray[SubMotionIndex].TimeOffset )
01117 * M->Branch.MixerArray[SubMotionIndex].TimeScale,
01118 &Dummy,&BlendVector);
01119 BlendAmount = MOTION_BLEND_PART_OF_VECTOR(BlendVector);
01120 return BlendAmount;
01121 }
01122 return 0.0f;
01123 }
|
|
||||||||||||
|
Definition at line 1125 of file motion.c. References geMotion_Mixer::Blend, geMotion::Branch, GE_FALSE, geMotion_IsValid(), GENESISAPI, GENESISCC, geMotion_Branch::MixerArray, MOTION_NODE_BRANCH, geMotion::NodeType, and NULL. Referenced by geActor_IsAnimationCueDead().
01126 {
01127 assert( M != NULL );
01128 assert( geMotion_IsValid(M) != GE_FALSE );
01129 // wrong node type is neither error nor invalid. return value is just NULL
01130
01131 if (M->NodeType == MOTION_NODE_BRANCH)
01132 {
01133 assert( (SubMotionIndex>=0) && (SubMotionIndex<M->Branch.MixerCount));
01134 return M->Branch.MixerArray[SubMotionIndex].Blend;
01135 }
01136 return NULL;
01137 }
|
|
||||||||||||||||
|
Definition at line 1315 of file motion.c. References geMotion_Leaf::Events, GE_FALSE, geBoolean, geMotion_IsValid(), GENESISAPI, GENESISCC, geTKEvents_GetExtents(), geMotion::Leaf, and NULL.
01316 {
01317 assert( M != NULL );
01318 assert( geMotion_IsValid(M) != GE_FALSE );
01319 assert( FirstEventTime != NULL );
01320 assert( LastEventTime != NULL );
01321
01322 return geTKEvents_GetExtents(M->Leaf.Events,FirstEventTime,LastEventTime);
01323 }
|
|
|
Definition at line 126 of file motion.c. References GE_FALSE, geMotion_IsValid(), GENESISAPI, GENESISCC, geMotion::Name, and NULL. Referenced by geActor_GetMotionByName(), and geActor_GetMotionName().
00127 {
00128 assert( M != NULL );
00129 assert( geMotion_IsValid(M) != GE_FALSE );
00130 return M->Name;
00131 }
|
|
|
Definition at line 391 of file motion.c. References geMotion::Branch, GE_FALSE, geMotion_IsValid(), GENESISAPI, GENESISCC, int32, geMotion::Leaf, geMotion_Branch::MixerArray, geMotion_Branch::MixerCount, geMotion_Mixer::Motion, MOTION_NODE_BRANCH, MOTION_NODE_LEAF, MOTION_NODE_UNDECIDED, geMotion_Leaf::NameChecksum, geMotion::NodeType, and NULL. Referenced by gePose_MatchesMotionExactly().
00392 {
00393 assert( M != NULL );
00394 assert( geMotion_IsValid(M) != GE_FALSE );
00395 switch (M->NodeType)
00396 {
00397 case (MOTION_NODE_UNDECIDED):
00398 return 0;
00399 case (MOTION_NODE_BRANCH):
00400 {
00401 int i;
00402 int32 Checksum,FirstChecksum;
00403 if (M->Branch.MixerCount<1)
00404 return 0;
00405 assert( M->Branch.MixerArray[0].Motion );
00406 FirstChecksum = geMotion_GetNameChecksum( M->Branch.MixerArray[0].Motion );
00407
00408 for (i=1; i<M->Branch.MixerCount; i++)
00409 {
00410 assert( M->Branch.MixerArray[i].Motion );
00411 Checksum = geMotion_GetNameChecksum( M->Branch.MixerArray[i].Motion );
00412 if (Checksum != FirstChecksum)
00413 return 0;
00414 }
00415 return FirstChecksum;
00416 }
00417 case (MOTION_NODE_LEAF):
00418 return M->Leaf.NameChecksum;
00419 default:
00420 assert(0);
00421 }
00422 return 0;
00423 }
|
|
||||||||||||
|
Definition at line 682 of file motion.c. References GE_FALSE, geMotion_GetPath(), geMotion_HasNames(), GENESISAPI, GENESISCC, geStrBlock_GetString(), geMotion::Leaf, MOTION_NODE_LEAF, geMotion_Leaf::NameArray, geMotion::NodeType, and NULL.
00683 {
00684 gePath *P;
00685 assert( M != NULL );
00686
00687 if (M->NodeType!=MOTION_NODE_LEAF)
00688 {
00689 return NULL;
00690 }
00691 if (geMotion_HasNames(M)==GE_FALSE)
00692 {
00693 return NULL;
00694 }
00695
00696 P = geMotion_GetPath(M,Index);
00697 if (P==NULL)
00698 {
00699 return NULL;
00700 }
00701 assert( M->Leaf.NameArray!=NULL );
00702
00703 return geStrBlock_GetString(M->Leaf.NameArray,Index);
00704
00705 }
|
|
||||||||||||||||
|
Referenced by geActor_GetAnimationEvent(), and geMotion_GetNextEvent(). |
|
||||||||||||
|
Definition at line 665 of file motion.c. References GE_FALSE, geMotion_IsValid(), GENESISAPI, GENESISCC, geMotion::Leaf, MOTION_NODE_LEAF, geMotion::NodeType, NULL, geMotion_Leaf::PathArray, and geMotion_Leaf::PathCount. Referenced by Door_Control(), Door_Spawn(), geMotion_GetNameOfPath(), ModelCtl_Frame(), Plat_Control(), and Plat_Spawn().
00666 {
00667 assert( M != NULL );
00668 assert( geMotion_IsValid(M) != GE_FALSE );
00669
00670 if (M->NodeType != MOTION_NODE_LEAF)
00671 { // not an error condition.
00672 return NULL;
00673 }
00674
00675 assert( M->Leaf.PathCount >=0 );
00676 assert( Index <= M->Leaf.PathCount );
00677 assert( Index >= 0 );
00678
00679 return M->Leaf.PathArray[Index];
00680 }
|
|
|
Definition at line 709 of file motion.c. References GE_FALSE, geMotion_IsValid(), GENESISAPI, GENESISCC, geMotion::Leaf, MOTION_NODE_LEAF, geMotion::NodeType, NULL, and geMotion_Leaf::PathCount.
00710 {
00711 assert( M != NULL );
00712 assert( geMotion_IsValid(M) != GE_FALSE );
00713
00714 if (M->NodeType != MOTION_NODE_LEAF)
00715 { // not an error condition.
00716 return 0;
00717 }
00718 assert( M->Leaf.PathCount >=0 );
00719 return M->Leaf.PathCount;
00720 }
|
|
||||||||||||
|
Definition at line 434 of file motion.c. References GE_FALSE, GE_TRUE, geMotion_IsValid(), GENESISAPI, GENESISCC, geStrBlock_GetString(), geMotion::Leaf, geMotion::MaintainNames, MOTION_NODE_LEAF, geMotion_Leaf::NameArray, geMotion::NodeType, NULL, geMotion_Leaf::PathArray, and geMotion_Leaf::PathCount. Referenced by geMotion_AddPath(), geMotion_SampleChannelsNamed(), and gePose_AccumulateCoverage().
00435 {
00436 int i;
00437
00438 assert( M != NULL );
00439 assert( geMotion_IsValid(M) != GE_FALSE );
00440
00441 if (M->NodeType != MOTION_NODE_LEAF)
00442 { // not an error condition.
00443 return NULL;
00444 }
00445
00446 assert( M->Leaf.PathCount >=0 );
00447
00448 if (Name != NULL)
00449 {
00450 if ( M->MaintainNames == GE_TRUE )
00451 {
00452 for (i=0; i<M->Leaf.PathCount; i++)
00453 {
00454 if ( strcmp(Name,geStrBlock_GetString(M->Leaf.NameArray,i))==0 )
00455 {
00456 return M->Leaf.PathArray[i];
00457 }
00458 }
00459 }
00460 }
00461 return NULL;
00462 }
|
|
||||||||||||
|
Definition at line 814 of file motion.c. References geMotion::Branch, GE_FALSE, geMotion_IsValid(), GENESISAPI, GENESISCC, geMotion_Branch::MixerArray, geMotion_Mixer::Motion, MOTION_NODE_BRANCH, geMotion::NodeType, and NULL. Referenced by geActor_AnimationStep(), geActor_AnimationStepBoneOptimized(), and gePose_AccumulateCoverage().
00815 {
00816 assert( M != NULL );
00817 assert( geMotion_IsValid(M) != GE_FALSE );
00818 if (M->NodeType != MOTION_NODE_BRANCH )
00819 {
00820 return NULL;
00821 }
00822 assert( (SubMotionIndex>=0) && (SubMotionIndex<M->Branch.MixerCount));
00823 assert( M->Branch.MixerArray != NULL );
00824
00825 return M->Branch.MixerArray[SubMotionIndex].Motion;
00826 }
|
|
|
Definition at line 801 of file motion.c. References geMotion::Branch, GE_FALSE, geMotion_IsValid(), GENESISAPI, GENESISCC, geMotion_Branch::MixerCount, MOTION_NODE_BRANCH, geMotion::NodeType, and NULL. Referenced by geActor_AnimationNudge(), geActor_AnimationRemoveLastCue(), geActor_AnimationStep(), geActor_AnimationStepBoneOptimized(), and gePose_AccumulateCoverage().
00802 {
00803 assert( M != NULL );
00804 assert( geMotion_IsValid(M) != GE_FALSE );
00805 if (M->NodeType == MOTION_NODE_BRANCH)
00806 {
00807 return M->Branch.MixerCount;
00808 }
00809 return 0;
00810 }
|
|
||||||||||||
|
Definition at line 828 of file motion.c. References geMotion::Branch, GE_FALSE, geMotion_IsValid(), GENESISAPI, GENESISCC, geMotion_Branch::MixerArray, geMotion_Branch::MixerCount, geMotion_Mixer::Motion, MOTION_NODE_BRANCH, geMotion::Name, geMotion::NodeType, and NULL.
00829 {
00830 int i;
00831 assert( M != NULL);
00832 assert( Name != NULL );
00833 assert( geMotion_IsValid(M) != GE_FALSE );
00834
00835 if (M->NodeType != MOTION_NODE_BRANCH)
00836 {
00837 return NULL;
00838 }
00839 assert( M->Branch.MixerArray != NULL );
00840 for (i=0; i<M->Branch.MixerCount; i++)
00841 {
00842 geMotion *MI = M->Branch.MixerArray[i].Motion;
00843 assert( MI != NULL );
00844 if (MI->Name!=NULL)
00845 {
00846 if (strcmp(MI->Name,Name)==0)
00847 {
00848 return MI;
00849 }
00850 }
00851 }
00852 return NULL;
00853 }
|
|
||||||||||||||||
|
Referenced by Door_Control(), DoSplashScreen(), geMotion_GetTimeExtents(), Plat_Control(), and Server_GetPlayerTimeExtents(). |
|
||||||||||||
|
Definition at line 1044 of file motion.c. References geMotion::Branch, GE_FALSE, geFloat, geMotion_IsValid(), GENESISAPI, GENESISCC, geMotion_Branch::MixerArray, MOTION_NODE_BRANCH, geMotion::NodeType, NULL, and geMotion_Mixer::TimeOffset. Referenced by geActor_AnimationStep(), geActor_AnimationStepBoneOptimized(), and geActor_IsAnimationCueDead().
01045 {
01046 assert( M != NULL );
01047 assert( geMotion_IsValid(M) != GE_FALSE );
01048 // wrong node type is neither error nor invalid. return value is just 0
01049
01050 if (M->NodeType == MOTION_NODE_BRANCH)
01051 {
01052 assert( (SubMotionIndex>=0) && (SubMotionIndex<M->Branch.MixerCount));
01053 return M->Branch.MixerArray[SubMotionIndex].TimeOffset;
01054 }
01055 return 0.0f;
01056 }
|
|
||||||||||||
|
Definition at line 1072 of file motion.c. References geMotion::Branch, GE_FALSE, geFloat, geMotion_IsValid(), GENESISAPI, GENESISCC, geMotion_Branch::MixerArray, MOTION_NODE_BRANCH, geMotion::NodeType, NULL, and geMotion_Mixer::TimeScale.
01073 {
01074 assert( M != NULL );
01075 assert( geMotion_IsValid(M) != GE_FALSE );
01076 // wrong node type is neither error nor invalid. return value is just 1
01077
01078 if (M->NodeType == MOTION_NODE_BRANCH)
01079 {
01080 assert( (SubMotionIndex>=0) && (SubMotionIndex<M->Branch.MixerCount));
01081 return M->Branch.MixerArray[SubMotionIndex].TimeScale;
01082 }
01083 return 1.0f;
01084 }
|
|
||||||||||||||||
|
Definition at line 1210 of file motion.c. References geMotion_Mixer::Blend, geMotion::Branch, GE_FALSE, GE_TRUE, geBoolean, geFloat, geMotion_IsValid(), GENESISAPI, GENESISCC, gePath_SampleChannels(), geQuaternion_FromMatrix(), geQuaternion_Slerp(), geQuaternion_ToMatrix(), geXForm3d_Multiply(), LINEAR_BLEND, geMotion_Branch::MixerArray, geMotion_Branch::MixerCount, geMotion_Mixer::Motion, MOTION_BLEND_PART_OF_VECTOR, MOTION_NODE_BRANCH, MOTION_NODE_LEAF, MOTION_NODE_UNDECIDED, geMotion::NodeType, NULL, R, geMotion_Mixer::TimeOffset, geMotion_Mixer::TimeScale, geMotion_Mixer::Transform, geMotion_Mixer::TransformUsed, geXForm3d::Translation, geVec3d::X, geVec3d::Y, and geVec3d::Z. Referenced by gePose_BlendMotion(), gePose_SetMotion(), and gePose_SetMotionForABone().
01211 {
01212 assert( M != NULL);
01213 assert( geMotion_IsValid(M) != GE_FALSE );
01214
01215 switch (M->NodeType)
01216 {
01217 case (MOTION_NODE_UNDECIDED):
01218 {
01219 return GE_FALSE;
01220 }
01221 break;
01222 case (MOTION_NODE_BRANCH):
01223 {
01224 geQuaternion R,Rotation;
01225 geVec3d T,Translation;
01226 geMotion_Mixer *Mixer;
01227 geFloat MixTime;
01228 int i;
01229 int MixCount=0;
01230
01231 if ( M->Branch.MixerCount == 0 )
01232 {
01233 return GE_FALSE;
01234 }
01235 assert( M->Branch.MixerCount > 0 );
01236
01237 for (i=0; i<M->Branch.MixerCount; i++)
01238 {
01239 geFloat BlendAmount;
01240 geBoolean DoMix=GE_FALSE;
01241
01242 Mixer = &(M->Branch.MixerArray[i]);
01243
01244 assert( Mixer->Motion != NULL );
01245 assert( Mixer->Blend != NULL );
01246
01247 MixTime = (Time - Mixer->TimeOffset) * Mixer->TimeScale;
01248 if (geMotion_GetTransform(Mixer->Motion,MixTime,Transform)!=GE_FALSE)
01249 {
01250 DoMix=GE_TRUE;
01251 if (Mixer->TransformUsed!=GE_FALSE)
01252 {
01253 geXForm3d_Multiply(&(Mixer->Transform),Transform,Transform);
01254 }
01255 }
01256 else
01257 {
01258 if (Mixer->TransformUsed!=GE_FALSE)
01259 {
01260 DoMix = GE_TRUE;
01261 *Transform = Mixer->Transform;
01262 }
01263 }
01264 if (DoMix!=GE_FALSE)
01265 {
01266 if (MixCount==0)
01267 {
01268 geQuaternion_FromMatrix(Transform,&Rotation);
01269 Translation = Transform->Translation;
01270 }
01271 else
01272 {
01273 geQuaternion_FromMatrix(Transform,&R);
01274 T = Transform->Translation;
01275 {
01276 geVec3d BlendVector;
01277 geQuaternion Dummy;
01278 gePath_SampleChannels(Mixer->Blend,MixTime,&Dummy,&BlendVector);
01279 BlendAmount = MOTION_BLEND_PART_OF_VECTOR(BlendVector);
01280 }
01281 geQuaternion_Slerp(&Rotation,&R,BlendAmount,&Rotation);
01282 Translation.X = LINEAR_BLEND(Translation.X,T.X,BlendAmount);
01283 Translation.Y = LINEAR_BLEND(Translation.Y,T.Y,BlendAmount);
01284 Translation.Z = LINEAR_BLEND(Translation.Z,T.Z,BlendAmount);
01285 }
01286
01287 MixCount++;
01288 }
01289 }
01290 if (MixCount>0)
01291 {
01292 geQuaternion_ToMatrix(&Rotation,Transform);
01293 Transform->Translation = Translation;
01294 return GE_TRUE;
01295 }
01296 return GE_FALSE;
01297 }
01298 break;
01299 case (MOTION_NODE_LEAF):
01300 {
01301 return GE_FALSE;
01302 }
01303 break;
01304 default:
01305 assert(0);
01306 }
01307 return GE_FALSE;
01308 }
|
|
|
Definition at line 425 of file motion.c. References GE_FALSE, GE_TRUE, geBoolean, geMotion_IsValid(), GENESISAPI, GENESISCC, geMotion::MaintainNames, and NULL. Referenced by geMotion_GetNameOfPath(), and gePose_MatchesMotionExactly().
00426 {
00427 assert( M != NULL );
00428 assert( geMotion_IsValid(M) != GE_FALSE );
00429 assert( (M->MaintainNames == GE_TRUE) || (M->MaintainNames == GE_FALSE) );
00430 // if M has names, all children of M have names.
00431 return M->MaintainNames;
00432 }
|
|
||||||||||||||||
|
|
|
|
|
Definition at line 198 of file motion.c. References geMotion::CloneCount, GE_FALSE, GE_TRUE, geBoolean, geErrorLog_AddString, geMotion_IsValid(), GENESISAPI, GENESISCC, geStrBlock_Destroy(), geMotion::Leaf, geMotion::MaintainNames, MOTION_NODE_BRANCH, MOTION_NODE_LEAF, MOTION_NODE_UNDECIDED, geMotion_Leaf::NameArray, geMotion::NodeType, NULL, and geMotion_Leaf::PathCount. Referenced by geMotion_Destroy().
00199 {
00200 assert( M != NULL );
00201 assert( geMotion_IsValid(M) != GE_FALSE );
00202
00203 if (M->CloneCount > 0)
00204 {
00205 geErrorLog_AddString(-1,"Can't remove names from a cloned motion.", NULL);
00206 return GE_FALSE;
00207 }
00208
00209 switch (M->NodeType)
00210 {
00211 case (MOTION_NODE_UNDECIDED):
00212 break;
00213 case (MOTION_NODE_BRANCH):
00214 geErrorLog_AddString(-1,"Can't remove names from a compound motion.", NULL);
00215 return GE_FALSE;
00216 break;
00217 case (MOTION_NODE_LEAF):
00218 assert( M->Leaf.PathCount >= 0 );
00219
00220 if ( M->Leaf.NameArray != NULL )
00221 {
00222 geStrBlock_Destroy(&(M->Leaf.NameArray));
00223 }
00224 M->Leaf.NameArray = NULL;
00225 break;
00226 default:
00227 assert(0);
00228 }
00229
00230 M->MaintainNames = GE_FALSE;
00231 return GE_TRUE;
00232 }
|
|
||||||||||||
|
Definition at line 994 of file motion.c. References geMotion_Mixer::Blend, geMotion::Branch, GE_FALSE, geMotion_Destroy(), geMotion_IsValid(), GENESISAPI, GENESISCC, gePath_Destroy(), geRam_Free, geRam_Realloc, geMotion_Branch::MixerArray, geMotion_Branch::MixerCount, geMotion_Mixer::Motion, MOTION_NODE_BRANCH, geMotion::NodeType, and NULL. Referenced by geActor_KillCue().
00995 {
00996 int Count;
00997 geMotion *M;
00998 assert( ParentMotion != NULL );
00999 assert( geMotion_IsValid(ParentMotion) != GE_FALSE );
01000
01001 if (ParentMotion->NodeType != MOTION_NODE_BRANCH)
01002 {
01003 return NULL;
01004 }
01005
01006 Count = ParentMotion->Branch.MixerCount;
01007 assert( (SubMotionIndex>=0) && (SubMotionIndex<Count));
01008
01009 M = ParentMotion->Branch.MixerArray[SubMotionIndex].Motion;
01010 assert( ParentMotion->Branch.MixerArray[SubMotionIndex].Blend != NULL );
01011 gePath_Destroy( &(ParentMotion->Branch.MixerArray[SubMotionIndex].Blend) );
01012
01013 if (Count>1)
01014 {
01015 memcpy( &(ParentMotion->Branch.MixerArray[SubMotionIndex]),
01016 &(ParentMotion->Branch.MixerArray[SubMotionIndex+1]),
01017 sizeof(geMotion_Mixer) * (Count-(SubMotionIndex+1)));
01018 }
01019 ParentMotion->Branch.MixerCount--;
01020
01021 {
01022 geMotion_Mixer *NewMixerArray;
01023 if (ParentMotion->Branch.MixerCount == 0)
01024 {
01025 geRam_Free(ParentMotion->Branch.MixerArray);
01026 ParentMotion->Branch.MixerArray = NULL;
01027 }
01028 else
01029 {
01030 NewMixerArray = geRam_Realloc(ParentMotion->Branch.MixerArray,
01031 (ParentMotion->Branch.MixerCount) * sizeof(geMotion_Mixer) );
01032 if ( NewMixerArray != NULL )
01033 {
01034 ParentMotion->Branch.MixerArray = NewMixerArray;
01035 }
01036 }
01037 }
01038 geMotion_Destroy( &M );
01039 return M;
01040 }
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||||||
|
Referenced by geMotion_Sample(), geMotion_SampleChannels(), gePose_BlendMotion(), gePose_SetMotion(), and gePose_SetMotionForABoneRecursion(). |
|
||||||||||||||||||||||||
|
Referenced by geMotion_SampleChannelsNamed(), geMotion_SampleNamed(), gePose_BlendMotion(), gePose_SetMotion(), and gePose_SetMotionForABoneRecursion(). |
|
||||||||||||||||||||
|
|
|
||||||||||||||||
|
Definition at line 1184 of file motion.c. References geMotion::Branch, GE_FALSE, GE_TRUE, geBoolean, geMotion_IsValid(), GENESISAPI, GENESISCC, geMotion_Branch::MixerArray, MOTION_NODE_BRANCH, geMotion::NodeType, NULL, geMotion_Mixer::Transform, and geMotion_Mixer::TransformUsed. Referenced by geActor_AnimationNudge().
01185 {
01186 assert( M != NULL );
01187 assert( geMotion_IsValid(M) != GE_FALSE );
01188
01189 if (M->NodeType == MOTION_NODE_BRANCH)
01190 {
01191 assert( (SubMotionIndex>=0) && (SubMotionIndex<M->Branch.MixerCount));
01192 assert( BaseTransform != NULL );
01193 if (BaseTransform!=NULL)
01194 {
01195 M->Branch.MixerArray[SubMotionIndex].Transform = *BaseTransform;
01196 M->Branch.MixerArray[SubMotionIndex].TransformUsed = GE_TRUE;
01197 }
01198 else
01199 {
01200 M->Branch.MixerArray[SubMotionIndex].TransformUsed = GE_FALSE;
01201 }
01202
01203 return GE_TRUE;
01204 }
01205 return GE_FALSE;
01206 }
|
|
||||||||||||||||
|
Definition at line 1139 of file motion.c. References geMotion_Mixer::Blend, geMotion::Branch, GE_FALSE, GE_TRUE, geBoolean, geErrorLog_Add, geMotion_IsValid(), GENESISAPI, GENESISCC, gePath_CreateCopy(), gePath_Destroy(), geMotion_Branch::MixerArray, MOTION_NODE_BRANCH, geMotion::NodeType, and NULL.
01140 {
01141 assert( M != NULL );
01142 assert( geMotion_IsValid(M) != GE_FALSE );
01143 if (M->NodeType == MOTION_NODE_BRANCH)
01144 {
01145 gePath *P;
01146 assert( (SubMotionIndex>=0) && (SubMotionIndex<M->Branch.MixerCount));
01147 assert( Blend != NULL );
01148 P = M->Branch.MixerArray[SubMotionIndex].Blend;
01149 gePath_Destroy(&P);
01150 P = gePath_CreateCopy(Blend);
01151 if ( P == NULL )
01152 {
01153 geErrorLog_Add(-1, NULL);
01154 return GE_FALSE;
01155 }
01156 M->Branch.MixerArray[SubMotionIndex].Blend = P;
01157 return GE_TRUE;
01158 }
01159 return GE_FALSE;
01160 }
|
|
||||||||||||
|
Definition at line 104 of file motion.c. References ERR_MOTION_CREATE_ENOMEM, GE_FALSE, GE_TRUE, geBoolean, geErrorLog_Add, geMotion_IsValid(), GENESISAPI, GENESISCC, geRam_Allocate, geRam_Free, geMotion::Name, and NULL. Referenced by geMotion_CreateFromFile().
00105 {
00106 char *NewName;
00107
00108 assert( M != NULL );
00109 assert( geMotion_IsValid(M) != GE_FALSE );
00110
00111 NewName = geRam_Allocate( strlen(Name)+1 );
00112 if (NewName == NULL )
00113 {
00114 geErrorLog_Add(ERR_MOTION_CREATE_ENOMEM, NULL);
00115 return GE_FALSE;
00116 }
00117 if (M->Name!=NULL)
00118 {
00119 geRam_Free(M->Name);
00120 }
00121 M->Name = NewName;
00122 strcpy(M->Name, Name);
00123 return GE_TRUE;
00124 }
|
|
||||||||||||||||
|
Definition at line 1058 of file motion.c. References geMotion::Branch, GE_FALSE, GE_TRUE, geBoolean, geMotion_IsValid(), GENESISAPI, GENESISCC, geMotion_Branch::MixerArray, MOTION_NODE_BRANCH, geMotion::NodeType, NULL, and geMotion_Mixer::TimeOffset. Referenced by geActor_AnimationStep(), and geActor_AnimationStepBoneOptimized().
01059 {
01060 assert( M != NULL );
01061 assert( geMotion_IsValid(M) != GE_FALSE );
01062
01063 if (M->NodeType == MOTION_NODE_BRANCH)
01064 {
01065 assert( (SubMotionIndex>=0) && (SubMotionIndex<M->Branch.MixerCount));
01066 M->Branch.MixerArray[SubMotionIndex].TimeOffset = TimeOffset;
01067 return GE_TRUE;
01068 }
01069 return GE_FALSE;
01070 }
|
|
||||||||||||||||
|
Definition at line 1086 of file motion.c. References geMotion::Branch, GE_FALSE, GE_TRUE, geBoolean, geMotion_IsValid(), GENESISAPI, GENESISCC, geMotion_Branch::MixerArray, MOTION_NODE_BRANCH, geMotion::NodeType, NULL, and geMotion_Mixer::TimeScale.
01087 {
01088 assert( M != NULL );
01089 assert( geMotion_IsValid(M) != GE_FALSE );
01090 assert( TimeScale != 0.0f);
01091
01092 if (M->NodeType == MOTION_NODE_BRANCH)
01093 {
01094 assert( (SubMotionIndex>=0) && (SubMotionIndex<M->Branch.MixerCount));
01095 M->Branch.MixerArray[SubMotionIndex].TimeScale = TimeScale;
01096 return GE_TRUE;
01097 }
01098 return GE_FALSE;
01099 }
|
|
||||||||||||||||
|
Referenced by geActor_AnimationStep(), geActor_AnimationStepBoneOptimized(), and geMotion_SetupEventIterator(). |
|
||||||||||||
|
Definition at line 2114 of file motion.c. References ERR_MOTION_FILE_WRITE, GE_FALSE, GE_TRUE, geBoolean, geErrorLog_Add, geMotion_IsValid(), geMotion_WriteBinaryBranch(), geMotion_WriteBinaryLeaf(), GENESISAPI, GENESISCC, geVFile_Write(), geMotion::MaintainNames, MOTION_BIN_FILE_TYPE, MOTION_FILE_VERSION, MOTION_NODE_BRANCH, MOTION_NODE_LEAF, MOTION_NODE_UNDECIDED, geMotion::Name, geMotion::NodeType, NULL, and uint32. Referenced by geActor_DefWriteToFile().
02115 {
02116 uint32 u;
02117
02118 assert( M != NULL );
02119 assert( pFile != NULL );
02120 assert( geMotion_IsValid(M) != GE_FALSE );
02121
02122
02123 // Write the format flag
02124 u = MOTION_BIN_FILE_TYPE;
02125 if(geVFile_Write(pFile, &u, sizeof(u)) == GE_FALSE)
02126 {
02127 geErrorLog_Add( ERR_MOTION_FILE_WRITE , NULL);
02128 return GE_FALSE;
02129 }
02130
02131 u = MOTION_FILE_VERSION;
02132 if (geVFile_Write(pFile, &u, sizeof(u)) == GE_FALSE)
02133 {
02134 geErrorLog_Add( ERR_MOTION_FILE_WRITE , NULL);
02135 return GE_FALSE;
02136 }
02137 if ( M->Name != NULL )
02138 {
02139 u = strlen(M->Name)+1;
02140 }
02141 else
02142 {
02143 u = 0;
02144 }
02145 assert( u < 0xFFFF );
02146
02147 if (M->MaintainNames != GE_FALSE)
02148 {
02149 u |= (1<<16);
02150 }
02151 assert( M->NodeType < 0xFF );
02152 u |= (M->NodeType << 24);
02153 if (geVFile_Write(pFile, &u, sizeof(u)) == GE_FALSE)
02154 {
02155 geErrorLog_Add( ERR_MOTION_FILE_WRITE , NULL);
02156 return GE_FALSE;
02157 }
02158 if ((u&0xFFFF) > 0)
02159 {
02160 if (geVFile_Write(pFile, M->Name, (u&0xFFFF)) == GE_FALSE)
02161 {
02162 geErrorLog_Add( ERR_MOTION_FILE_WRITE , NULL);
02163 return GE_FALSE;
02164 }
02165 }
02166
02167 switch (M->NodeType)
02168 {
02169 case (MOTION_NODE_UNDECIDED):
02170 break;
02171 case (MOTION_NODE_BRANCH):
02172 if (geMotion_WriteBinaryBranch(M,pFile)==GE_FALSE)
02173 {
02174 geErrorLog_Add( ERR_MOTION_FILE_WRITE , NULL);
02175 return GE_FALSE;
02176 }
02177 break;
02178 case (MOTION_NODE_LEAF):
02179 if (geMotion_WriteBinaryLeaf(M,pFile)==GE_FALSE)
02180 {
02181 geErrorLog_Add( ERR_MOTION_FILE_WRITE , NULL);
02182 return GE_FALSE;
02183 }
02184 break;
02185 default:
02186 assert(0);
02187 break;
02188 }
02189 return GE_TRUE;
02190 }
|
|
||||||||||||
|
Definition at line 1792 of file motion.c. References ERR_MOTION_FILE_WRITE, GE_FALSE, GE_TRUE, geBoolean, geErrorLog_Add, geMotion_IsValid(), geMotion_WriteBranch(), geMotion_WriteLeaf(), GENESISAPI, GENESISCC, geVFile_Printf(), geVFile_Write(), geMotion::MaintainNames, MOTION_ASCII_FILE_TYPE, MOTION_FILE_VERSION, MOTION_MAINTAINNAMES_ID, MOTION_NAME_ID, MOTION_NODE_BRANCH, MOTION_NODE_LEAF, MOTION_NODE_UNDECIDED, geMotion::Name, geMotion::NodeType, NULL, and uint32.
01793 {
01794 uint32 u;
01795
01796 assert( M != NULL );
01797 assert( pFile != NULL );
01798 assert( geMotion_IsValid(M) != GE_FALSE );
01799
01800
01801 // Write the format flag
01802 u = MOTION_ASCII_FILE_TYPE;
01803 if(geVFile_Write(pFile, &u, sizeof(u)) == GE_FALSE)
01804 {
01805 geErrorLog_Add( ERR_MOTION_FILE_WRITE , NULL);
01806 return GE_FALSE;
01807 }
01808
01809
01810 // Write the version
01811 if (geVFile_Printf(pFile, " %X.%.2X\n", (MOTION_FILE_VERSION & 0xFF00) >> 8,
01812 MOTION_FILE_VERSION & 0x00FF) == GE_FALSE)
01813 {
01814 geErrorLog_Add( ERR_MOTION_FILE_WRITE , NULL);
01815 return GE_FALSE;
01816 }
01817
01818 if (geVFile_Printf(pFile, "%s %s\n", MOTION_NAME_ID,(M->Name==NULL)?(""):(M->Name)) == GE_FALSE)
01819 {
01820 geErrorLog_Add( ERR_MOTION_FILE_WRITE , NULL);
01821 return GE_FALSE;
01822 }
01823
01824 if (geVFile_Printf(pFile, "%s %d\n", MOTION_MAINTAINNAMES_ID,M->MaintainNames) == GE_FALSE)
01825 {
01826 geErrorLog_Add( ERR_MOTION_FILE_WRITE , NULL);
01827 return GE_FALSE;
01828 }
01829
01830 switch (M->NodeType)
01831 {
01832 case (MOTION_NODE_UNDECIDED):
01833 break;
01834 case (MOTION_NODE_BRANCH):
01835 if (geMotion_WriteBranch(M,pFile)==GE_FALSE)
01836 {
01837 geErrorLog_Add( ERR_MOTION_FILE_WRITE , NULL);
01838 return GE_FALSE;
01839 }
01840 break;
01841 case (MOTION_NODE_LEAF):
01842 if (geMotion_WriteLeaf(M,pFile)==GE_FALSE)
01843 {
01844 geErrorLog_Add( ERR_MOTION_FILE_WRITE , NULL);
01845 return GE_FALSE;
01846 }
01847 break;
01848 default:
01849 assert(0);
01850 break;
01851 }
01852 return GE_TRUE;
01853 }
|
1.3.2