Merge Transaction Optimization.

Module description

File Reference and scene assembly workflow load many small files which contain individual entities (model, material, texture, character, props and etc.,).

This section describes the functions provided for saving HumanIK objects to files on disk, and for loading HumanIK objects into memory from saved files.

And it's a quite time consuming process with normal workflow. The following set of merge transaction functions could be used to improve the performance effectively.

A single file load / merge operation mainly includes the following three major stages:

  1. Loading file from disk to memory;
  2. Translate/interpret the file content into the application scene object models;
  3. Post processing (scene object preparation, UI refresh and etc).

The last step (post processing) often is quite heavy. With the merge transaction, however this step could be executed only once for multiple consecutive file merge operations. for example: [code] MergeTransacionBegin() File_Merge(filepath1) File_Merge(filepath1) File_Merge(filepath1) ... MergeTransactionEnd() [/code] This Merge Transaction could be nested.

See also ~{ Saving and Loading HumanIK Objects }~.

Functions

void FBPreventUIUpdateBegin ()
 Call to prevent UI updates when creating/deleting/renaming objects. More...
 
void FBPreventUIUpdateEnd ()
 Call to end blocking the UI updates. More...
 
bool FBPreventUIUpdateIsOn ()
 Call to tell if UI updates are blocked. More...
 
void FBMergeTransactionBegin ()
 Call to begin the transaction for merging multiple files. More...
 
void FBMergeTransactionEnd ()
 Call to end the merge transaction. More...
 
bool FBMergeTransactionIsOn ()
 Call to tell if system is during Merge transaction. More...
 
void FBMergeTransactionFileRefEditBegin ()
 Call to begin the transaction for merging multiple files and applying File Reference edit at the same time. More...
 
void FBMergeTransactionFileRefEditEnd ()
 Call to end merge transaction with File Reference edit. More...
 
bool FBMergeTransactionFileRefEditIsOn ()
 Call to tell if system is during File Reference Edit Merge transaction. More...
 
HIKCharacterHIKLoadCharacter (const char *pFileName, const char *pValidationString, HIKMalloc pMalloc)
 Load file pFileName, and create an HIKCharacter object from its contents. More...
 
bool HIKSaveCharacter (const char *pFileName, HIKCharacter *pCharacter, HIKMalloc pMalloc, HIKFree pFree, float pUnitScale=1.0f)
 Save HIKCharacter pCharacter to file pFileName. More...
 
HIKCharacterStateHIKLoadCharacterState (const char *pFileName, HIKCharacter *pCharacter, HIKMalloc pMalloc)
 Load file pFileName, and create an HIKCharacterState object from its contents. More...
 
bool HIKSaveCharacterState (const char *pFileName, HIKCharacter *pCharacter, HIKCharacterState *pState, int pTransformMode, float pUnitScale=1.0f)
 Save HIKCharacterState pState to file pFileName. More...
 
HIKEffectorSetStateHIKLoadEffectorState (const char *pFileName, HIKMalloc pMalloc)
 Load file pFileName, and create an HIKEffectorSetState object from its contents. More...
 
bool HIKSaveEffectorState (const char *pFileName, HIKEffectorSetState *pState, float pUnitScale=1.0f)
 Save HIKEffectorSetState pState to file pFileName. More...
 
HIKPropertySetStateHIKLoadPropertySetState (const char *pFileName, HIKMalloc pMalloc)
 Load file pFileName, and create an HIKPropertySetState object from its contents. More...
 
bool HIKSavePropertySetState (const char *pFileName, HIKPropertySetState *pState, float pUnitScale=1.0f)
 Save HIKPropertySetState pState to file pFileName. More...
 
void * HIKLoadDataBlock (const char *pFileName, HIKDataDescription &pDataDesc, HIKMalloc pMalloc)
 Load file pFileName, and create a data set from its contents according to the data description provided in the pDataDesc argument. More...
 
void * HIKDefaultAlignedMalloc (size_t pSize, size_t pAlignment, HIKMalloc pMalloc)
 Allocates a data block aligned to the pAlignment pointer boundary. More...
 
void HIKDefaultAlignedFree (void *pAligned, HIKFree pFree)
 Frees a data block allocated using HIKDefaultAlignedMalloc(). More...
 
void HIKSaveDataBlock (const char *pFileName, const HIKDataDescription &pDataDesc, const void *pDataBlock)
 Save the data set located in memory at pDataBlock to file pFileName. More...
 

Function Documentation

void ORSDK2019::FBMergeTransactionBegin ( )

Call to begin the transaction for merging multiple files.

Useful to consecutively merge multiple files into scene.

Note
The transaction need to be closed by calling FBMergeTransactionEnd(). There is no need to call FBPreventUIUpdateBegin() with this function, since it already contains the same optimization.
void ORSDK2019::FBMergeTransactionEnd ( )

Call to end the merge transaction.

void ORSDK2019::FBMergeTransactionFileRefEditBegin ( )

Call to begin the transaction for merging multiple files and applying File Reference edit at the same time.

Useful to consecutively merge multiple files into scene with FileRef edit operation in between.

Note
The transaction need to be closed by calling FBMergeTransactionFileRefEditEnd().
void ORSDK2019::FBMergeTransactionFileRefEditEnd ( )

Call to end merge transaction with File Reference edit.

bool ORSDK2019::FBMergeTransactionFileRefEditIsOn ( )

Call to tell if system is during File Reference Edit Merge transaction.

bool ORSDK2019::FBMergeTransactionIsOn ( )

Call to tell if system is during Merge transaction.

void ORSDK2019::FBPreventUIUpdateBegin ( )

Call to prevent UI updates when creating/deleting/renaming objects.

Useful to speed up script operations. Previously, FBMergeTransactionBegin()/ FBMergeTransactionEnd() could be used to do this kind of optimization, even if no merge operations were done. However, using FBMergeTransactionBegin()/ FBMergeTransactionEnd() with non-merge operation could lead to issues, like objects with invalid namespaces. FBPreventUIUpdateBegin()/FBPreventUIUpdateEnd() fix this issue, while giving the same speed increase.

Note
The transaction need to be closed by calling FBPreventUIUpdateEnd(). There is no need to call this function when using FBMergeTransactionBegin(), since FBMergeTransactionBegin() already has the same optimization.
void ORSDK2019::FBPreventUIUpdateEnd ( )

Call to end blocking the UI updates.

bool ORSDK2019::FBPreventUIUpdateIsOn ( )

Call to tell if UI updates are blocked.

void HIKDefaultAlignedFree ( void *  pAligned,
HIKFree  pFree 
)
inline

Frees a data block allocated using HIKDefaultAlignedMalloc().

Parameters
pAlignedPointer allocated using HIKDefaultAlignedMalloc().
pFreePointer to a memory de-allocation function. If you do not have a custom memory de-allocation function, use &free.

Definition at line 857 of file hikdump.h.

858 {
859  void* lRawPointer = *(void**)((char*)pAligned-sizeof(void*));
860  (*pFree)(lRawPointer);
861 }
void * HIKDefaultAlignedMalloc ( size_t  pSize,
size_t  pAlignment,
HIKMalloc  pMalloc 
)
inline

Allocates a data block aligned to the pAlignment pointer boundary.

This allocator is used in HIKSaveDataBlock() to align the resulting dataset to 16 bytes.

Parameters
pSizeSize of the block of data to allocate.
pAlignmentRequired address alignment.
pMallocPointer to a memory allocation function. If you do not have a custom memory allocation function, use &malloc.
Returns
A void pointer to the aligned block. You must use HIKDefaultAlignedFree() to free this memory.

Definition at line 846 of file hikdump.h.

847 {
848  const size_t lPointerSize = sizeof(void*);
849  const size_t lRequestedSize = pSize + pAlignment - 1 + lPointerSize;
850  void* lRawPointer = (*pMalloc)(lRequestedSize);
851  void* lStart = (char*)lRawPointer + lPointerSize;
852  void* lAligned = (void*)(((size_t)((char*)lStart+pAlignment-1)) & ~(pAlignment-1));
853  *(void**)((char*)lAligned-lPointerSize) = lRawPointer;
854  return lAligned;
855 }
HIKCharacter * HIKLoadCharacter ( const char *  pFileName,
const char *  pValidationString,
HIKMalloc  pMalloc 
)
inline

Load file pFileName, and create an HIKCharacter object from its contents.

Parameters
pFileNamePath and file name of the file to load.
pValidationStringThe customer identification string given to you by Autodesk to license the use of HumanIK in your project.
pMallocPointer to a memory allocation function. If you do not have a custom memory allocation function, use &malloc.
Returns
An HIKCharacter object if the file is valid, otherwise NULL.

Definition at line 353 of file hikdump.h.

356 {
357  // First let retrieve data
358  // We need characterization flag, Default stance pose and Parent offset
359  HIKCharacterStream lStream;
360  HIKCharacter* lCharacter = NULL;
361 
362  lStream.Init();
363 
364  // Load all the data
365  if(Read(pFileName, lStream))
366  {
368 
369  memcpy(lDef.mUsedNodes, lStream.mNodeFlag.mField, sizeof(int)*lStream.mNodeFlag.eCount);
370 
371  lCharacter = HIKCharacterCreate(&lDef, pMalloc, pValidationString);
372  if (!lCharacter)
373  return NULL;
374  int i;
375  for(i=0;i<LastNodeId;i++)
376  {
377  if(lDef.mUsedNodes[i] & HIKNodeUsed)
378  {
379  HIKSetCharacterizeNodeStateTQSfv(lCharacter, i, &lStream.mTOffset.mField[i][0], &lStream.mQOffset.mField[i][0], &lStream.mSOffset.mField[i][0]);
380  }
381 
382  if(lDef.mUsedNodes[i] & HIKNodeParentOffset)
383  {
384  HIKSetParentOffsetfv(lCharacter, i, &lStream.mParentTOffset.mField[i][0], &lStream.mParentQOffset.mField[i][0], &lStream.mParentSOffset.mField[i][0]);
385  }
386  }
387 
388  HIKCharacterizeGeometry(lCharacter);
389  }
390  return lCharacter;
391 }
Field< int, LastNodeId > mNodeFlag
Definition: hikdump.h:277
Node is characterized.
Definition: humanik.h:482
void HIKSetParentOffsetfv(HIKCharacter *pCharacter, int pNodeId, const float pParentTOffset[4], const float pParentQOffset[4], const float pParentSOffset[4])
Set the parent offset for Node pNodeId.
Field2D< float, LastNodeId, 4 > mTOffset
Definition: hikdump.h:278
Py_ssize_t i
Definition: abstract.h:1086
Marks the end of the enumeration.
Definition: humanik.h:257
#define NULL
Definition: kaydara.h:179
FieldType mField[eCount1][eCount2]
Definition: hikdump.h:263
void HIKSetCharacterizeNodeStateTQSfv(HIKCharacter *pCharacter, int pNodeId, const float pT[4], const float pQ[4], const float pS[4])
Set the translation, orientation and scaling for the Node pNodeId when the character is standing in t...
Field2D< float, LastNodeId, 4 > mSOffset
Definition: hikdump.h:280
bool HIKCharacterizeGeometry(HIKCharacter *pCharacter)
Set up and initialize character pCharacter for solving.
bool Read(const char *pFileName, type &pStream)
Field2D< float, LastNodeId, 4 > mParentSOffset
Definition: hikdump.h:283
FieldType mField[eCount]
Definition: hikdump.h:243
Field2D< float, LastNodeId, 4 > mQOffset
Definition: hikdump.h:279
Node has a parent unknown to HumanIK, used for local space transform and DoF.
Definition: humanik.h:483
Defines which Nodes are to be used by an HIKCharacter.
Field2D< float, LastNodeId, 4 > mParentQOffset
Definition: hikdump.h:282
Defines a character to be used with HumanIK.
Field2D< float, LastNodeId, 4 > mParentTOffset
Definition: hikdump.h:281
HIKCharacter * HIKCharacterCreate(const HIKCharacterDefinition *pCharacterDefinition, HIKMalloc pMalloc, const char *pValidationString)
Create a new HIKCharacter.
HIKCharacterState * HIKLoadCharacterState ( const char *  pFileName,
HIKCharacter pCharacter,
HIKMalloc  pMalloc 
)
inline

Load file pFileName, and create an HIKCharacterState object from its contents.

Parameters
pFileNamePath and file name of the file to load.
pCharacterHIKCharacter used to create the HIKCharacterState loaded from the file.
pMallocPointer to a memory allocation function. If you do not have a custom memory allocation function, use &malloc.
Returns
An HIKCharacterState if the file is valid, otherwise NULL.

Definition at line 483 of file hikdump.h.

484 {
485  HIKCharacterStateStream lStateStream;
486  HIKCharacterState* lState = NULL;
487 
488  lStateStream.Init();
489 
490  if(Read(pFileName, lStateStream))
491  {
492  lState = HIKCharacterStateCreate(pCharacter, pMalloc);
493 
494  HIKDataDescription lDataDesc;
495 
496  lDataDesc.mTransformSpace = lStateStream.mTransformMode.mField[0] == HIKDataDescription::HIKLocalSpace ? HIKDataDescription::HIKLocalSpace : HIKDataDescription::HIKGlobalSpace;
497  lDataDesc.mTOffset = 0;
498  lDataDesc.mQOffset = 16;
499  lDataDesc.mSOffset = 32;
500  lDataDesc.mStride = 48;
501  lDataDesc.mHIKNodeId = &lStateStream.mNodeId.mField[0];
502 
503  HIKSetCharacterStateTransformTQS(pCharacter, lState, &lDataDesc, &lStateStream.mTransformData);
504  }
505  return lState;
506 }
#define NULL
Definition: kaydara.h:179
A description of a data set that contains separate translation, quaternion rotation, and scaling values for multiple different Nodes in an HIKCharacterState.
bool Read(const char *pFileName, type &pStream)
FieldType mField[eCount]
Definition: hikdump.h:243
Defines a pose for a character.
Definition: humanik.h:441
HIKCharacterState * HIKCharacterStateCreate(const HIKCharacter *pCharacter, HIKMalloc pMalloc)
Create a new HIKCharacterState.
Field< int, 1 > mTransformMode
Definition: hikdump.h:440
Field< int, LastNodeId > mNodeId
Definition: hikdump.h:441
void HIKSetCharacterStateTransformTQS(const HIKCharacter *pCharacter, HIKCharacterState *pCharacterState, const HIKDataDescription *pDataDescription, const void *pDataSet)
Set the translation (T), quaternion rotation (Q) and scaling (S) of multiple Nodes from data set pDat...
void * HIKLoadDataBlock ( const char *  pFileName,
HIKDataDescription pDataDesc,
HIKMalloc  pMalloc 
)
inline

Load file pFileName, and create a data set from its contents according to the data description provided in the pDataDesc argument.

For more information about data sets, see ~{ Setting and Retrieving Animation Data }~.

Parameters
pFileNamePath and file name of the file to load.
pDataDescData description that defines the memory layout of the data set contained in the file.
pMallocPointer to a memory allocation function. If you do not have a custom memory allocation function, use &malloc.
Returns
A void pointer to the new data set.

Definition at line 863 of file hikdump.h.

864 {
865  void *lDataBlock = NULL;
866  HIKDataDescriptionStream lStream;
867  lStream.Init();
868 
869  if(Read(pFileName, lStream))
870  {
871  pDataDesc.mTransformSpace = lStream.mTransformSpace.mField[0] == HIKDataDescription::HIKLocalSpace ? HIKDataDescription::HIKLocalSpace : HIKDataDescription::HIKGlobalSpace;;
872  pDataDesc.mTOffset = (size_t)lStream.mTOffset.mField[0];
873  pDataDesc.mQOffset = (size_t)lStream.mQOffset.mField[0];
874  pDataDesc.mSOffset = (size_t)lStream.mSOffset.mField[0];
875  pDataDesc.mStride = (size_t)lStream.mStride.mField[0];
876 
877  int i = 0;
878  do
879  {
880  pDataDesc.mHIKNodeId[i] = lStream.mHIKNodeId.mField[i];
881  }
882  while(lStream.mHIKNodeId.mField[i++] != HIKLastNode);
883 
884  // allocate the data bloc
885  const size_t align = 16;
886  lDataBlock = HIKDefaultAlignedMalloc(pDataDesc.mStride*i-1, align, pMalloc);
887  ReadBlock(pFileName, sizeof(HIKDataDescriptionStream), (size_t)pDataDesc.mStride, (size_t)(i-1), lDataBlock);
888  }
889  return lDataBlock;
890 }
Field< int, 1 > mQOffset
Definition: hikdump.h:794
Py_ssize_t i
Definition: abstract.h:1086
Field< int, 1 > mStride
Definition: hikdump.h:796
#define NULL
Definition: kaydara.h:179
Field< int, 1 > mTransformSpace
Definition: hikdump.h:792
bool ReadBlock(const char *pFileName, const size_t pOffset, const size_t &pElementSize, const size_t &pElementCount, type &pStream)
void * HIKDefaultAlignedMalloc(size_t pSize, size_t pAlignment, HIKMalloc pMalloc)
Allocates a data block aligned to the pAlignment pointer boundary.
Definition: hikdump.h:846
Indicates the end of the list of Nodes.
Definition: humanik.h:1592
Field< int, LastNodeId > mHIKNodeId
Definition: hikdump.h:797
Field< int, 1 > mTOffset
Definition: hikdump.h:793
PyObject char size_t
Definition: import.h:39
Field< int, 1 > mSOffset
Definition: hikdump.h:795
bool Read(const char *pFileName, type &pStream)
FieldType mField[eCount]
Definition: hikdump.h:243
HIKEffectorSetState * HIKLoadEffectorState ( const char *  pFileName,
HIKMalloc  pMalloc 
)
inline

Load file pFileName, and create an HIKEffectorSetState object from its contents.

Parameters
pFileNamePath and file name of the file to load.
pMallocPointer to a memory allocation function. If you do not have a custom memory allocation function, use &malloc.
Returns
An HIKEffectorSetState if the file is valid, otherwise NULL.

Definition at line 611 of file hikdump.h.

612 {
613  HIKEffectorSetStateStream lEffectorStream;
614  HIKEffectorSetState* lState = NULL;
615 
616  lEffectorStream.Init();
617 
618  if(Read(pFileName, lEffectorStream))
619  {
620  lState = HIKEffectorSetStateCreate(pMalloc);
621 
622  int i;
623  for(i=0;i<LastEffectorId;i++)
624  {
625  HIKSetTranslationActive(lState, i, lEffectorStream.mReachT.mField[i]);
626  HIKSetRotationActive(lState, i, lEffectorStream.mReachR.mField[i]);
627  HIKSetResist(lState, i, lEffectorStream.mResist.mField[i]);
628  HIKSetPull(lState, i, lEffectorStream.mPull.mField[i]);
629  HIKSetEffectorStateTQSfv(lState, i, &lEffectorStream.mTQS.mField[i][0],&lEffectorStream.mTQS.mField[i][4], &lEffectorStream.mTQS.mField[i][8]);
630  }
631 
632  HIKSetHandPullHips(lState, 0, lEffectorStream.mHandPullHips.mField[0]);
633  HIKSetHandPullHips(lState, 1, lEffectorStream.mHandPullHips.mField[1]);
634 
635  for(i=0;i<HIKLastFloorId;i++)
636  {
637  HIKSetEffectorFloorStatefv(lState, i, &lEffectorStream.mFloorTQS.mField[i][0]);
638  }
639 
640  }
641  return lState;
642 }
HIKEffectorSetState * HIKEffectorSetStateCreate(HIKMalloc pMalloc)
Create a new HIKEffectorSetState.
void HIKSetEffectorFloorStatefv(HIKEffectorSetState *pEffectorSetState, int pFloor, const float pXForm[16])
Set the transform matrix of the oriented plane that the floor contact engine applies to one of your c...
Field< float, 2 > mHandPullHips
Definition: hikdump.h:557
Marks the end of the enumeration.
Definition: humanik.h:332
Py_ssize_t i
Definition: abstract.h:1086
Field< float, LastEffectorId > mResist
Definition: hikdump.h:555
#define NULL
Definition: kaydara.h:179
FieldType mField[eCount1][eCount2]
Definition: hikdump.h:263
void HIKSetResist(HIKEffectorSetState *pEffectorSetState, int pEffectorIndex, float pValue)
Set the Resist constraint for Effector pEffectorIndex.
Field2D< float, LastEffectorId, 12 > mTQS
Definition: hikdump.h:559
Defines an HIKEffectorSetState.
Definition: humanik.h:418
void HIKSetEffectorStateTQSfv(HIKEffectorSetState *pEffectorSetState, int pEffectorIndex, const float pT[4], const float pQ[4], const float pS[4])
Set the translation (T), quaternion rotation (Q) and scaling (S) in global space of Effector pEffecto...
Field< float, LastEffectorId > mReachT
Definition: hikdump.h:553
Field2D< float, HIKLastFloorId, 16 > mFloorTQS
Definition: hikdump.h:560
void HIKSetHandPullHips(HIKEffectorSetState *pEffectorSetState, int pLeft, float pValue)
Set the amount of pull the left or right hand can exert on the hips.
Field< float, LastEffectorId > mReachR
Definition: hikdump.h:554
void HIKSetTranslationActive(HIKEffectorSetState *pEffectorSetState, int pEffectorIndex, float pValue)
Set the Reach Translation constraint for Effector pEffectorIndex.
Field< float, LastEffectorId > mPull
Definition: hikdump.h:556
bool Read(const char *pFileName, type &pStream)
FieldType mField[eCount]
Definition: hikdump.h:243
void HIKSetPull(HIKEffectorSetState *pEffectorSetState, int pEffectorIndex, float pValue)
Set the Pull constraint for Effector pEffectorIndex.
Marks the end of the enumeration.
Definition: humanik.h:315
void HIKSetRotationActive(HIKEffectorSetState *pEffectorSetState, int pEffectorIndex, float pValue)
Set the Reach Rotation constraint for Effector pEffectorIndex.
HIKPropertySetState * HIKLoadPropertySetState ( const char *  pFileName,
HIKMalloc  pMalloc 
)
inline

Load file pFileName, and create an HIKPropertySetState object from its contents.

Parameters
pFileNamePath and file name of the file to load.
pMallocPointer to a memory allocation function. If you do not have a custom memory allocation function, use &malloc.
Returns
An HIKPropertySetState if the file is valid, otherwise NULL.

Definition at line 719 of file hikdump.h.

720 {
721  HIKPropertySetStream lStream;
722  HIKPropertySetState* lState = NULL;
723 
724  lStream.Init();
725 
726  if(Read(pFileName, lStream))
727  {
728  lState = HIKPropertySetStateCreate(pMalloc);
729 
730  int i;
731  for(i=0;i<HIKLastPropertyId;i++)
732  {
733  HIKSetPropertyMode(lState, i, lStream.mMode.mField[i]);
734  HIKSetPropertyValue(lState, i, lStream.mValue.mField[i]);
735  }
736  }
737 
738  return lState;
739 }
Py_ssize_t i
Definition: abstract.h:1086
#define NULL
Definition: kaydara.h:179
HIKPropertySetState * HIKPropertySetStateCreate(HIKMalloc pMalloc)
Create a new HIKPropertySetState.
void HIKSetPropertyValue(HIKPropertySetState *pState, int pPropertyId, float pValue)
Sets the current value for property pPropertyId in HIKPropertySetState pState.
Defines a character's properties.
Definition: humanik.h:457
Field< int, HIKLastPropertyId > mMode
Definition: hikdump.h:680
bool Read(const char *pFileName, type &pStream)
FieldType mField[eCount]
Definition: hikdump.h:243
void HIKSetPropertyMode(HIKPropertySetState *pState, int pPropertyId, int pMode)
Sets the current mode for property pPropertyId in HIKPropertySetState pState.
Field< float, HIKLastPropertyId > mValue
Definition: hikdump.h:681
Marks the end of the enumeration.
Definition: hikproperty.h:513
bool HIKSaveCharacter ( const char *  pFileName,
HIKCharacter pCharacter,
HIKMalloc  pMalloc,
HIKFree  pFree,
float  pUnitScale = 1.0f 
)
inline

Save HIKCharacter pCharacter to file pFileName.

Where possible, it is recommended that you use the HIKWriteToStream() function to export your HIKCharacter instead, as it saves more information about your character. See HIKWriteToStream() and HIKReadFromStream().

Parameters
pFileNamePath and file name of the file to create. If the file already exists, it is overwritten.
pCharacterHIKCharacter to be saved.
pMallocPointer to a memory allocation function. If you do not have a custom memory allocation function, use &malloc.
pFreePointer to a memory de-allocation function. If you do not have a custom memory de-allocation function, use &free.
Returns
True if the operation was succesful, otherwise false.
+ Examples:

Definition at line 393 of file hikdump.h.

394 {
395  // First let prepare data to save
396  // We need characterization flag, Default stance pose and Parent offset
397  HIKCharacterStream lStream;
398 
399  lStream.Init();
400 
401  int i;
402  for(i=0;i<LastNodeId;i++)
403  {
404  lStream.mNodeFlag.mField[i] = HIKGetNodeUse(pCharacter, i);
405  }
406 
407  for(i=0;i<LastNodeId;i++)
408  {
409  if(lStream.mNodeFlag.mField[i] & HIKNodeParentOffset)
410  {
411  HIKGetParentOffsetfv(pCharacter, i, &lStream.mParentTOffset.mField[i][0], &lStream.mParentQOffset.mField[i][0], &lStream.mParentSOffset.mField[i][0]);
412  lStream.mParentTOffset.mField[i][0] *= pUnitScale;
413  lStream.mParentTOffset.mField[i][1] *= pUnitScale;
414  lStream.mParentTOffset.mField[i][2] *= pUnitScale;
415  }
416  }
417 
418  HIKCharacterState* lState = HIKCharacterStateCreate(pCharacter, pMalloc);
419  HIKGetDefaultState(pCharacter, lState);
420 
421  for(i=0;i<LastNodeId;i++)
422  {
423  if(lStream.mNodeFlag.mField[i] & HIKNodeUsed)
424  {
425  HIKGetNodeStateTQSfv(pCharacter, lState, i, &lStream.mTOffset.mField[i][0], &lStream.mQOffset.mField[i][0], &lStream.mSOffset.mField[i][0]);
426  lStream.mTOffset.mField[i][0] *= pUnitScale;
427  lStream.mTOffset.mField[i][1] *= pUnitScale;
428  lStream.mTOffset.mField[i][2] *= pUnitScale;
429  }
430  }
431 
432  HIKCharacterStateDestroy(lState , pFree);
433 
434  return Write(pFileName, lStream);
435 }
void HIKCharacterStateDestroy(HIKCharacterState *pCharacterState, HIKFree pFree)
Destroy HIKCharacterState pCharacterState.
Field< int, LastNodeId > mNodeFlag
Definition: hikdump.h:277
Node is characterized.
Definition: humanik.h:482
Field2D< float, LastNodeId, 4 > mTOffset
Definition: hikdump.h:278
bool Write(const char *pFileName, const type &pStream)
Py_ssize_t i
Definition: abstract.h:1086
void HIKGetDefaultState(const HIKCharacter *pCharacter, HIKCharacterState *pCharacterState)
Retrieve the default T-stance for character pCharacter, storing it in HIKCharacterState pCharacterSta...
Marks the end of the enumeration.
Definition: humanik.h:257
FieldType mField[eCount1][eCount2]
Definition: hikdump.h:263
void HIKGetNodeStateTQSfv(const HIKCharacter *pCharacter, const HIKCharacterState *pCharacterState, int pNodeId, float pT[4], float pQ[4], float pS[4])
Retrieve the translation (T), quaternion rotation (Q) and scaling (S) in global space of Node pNodeId...
int HIKGetNodeUse(const HIKCharacter *pCharacter, int pNodeId)
Retrieve the characterization flag set for Node pNodeId in HIKCharacter pCharacter.
Field2D< float, LastNodeId, 4 > mSOffset
Definition: hikdump.h:280
void HIKGetParentOffsetfv(const HIKCharacter *pCharacter, int pNodeId, float pParentTOffset[4], float pParentQOffset[4], float pParentSOffset[4])
Retrieve the parent offset set for Node pNodeId.
Field2D< float, LastNodeId, 4 > mParentSOffset
Definition: hikdump.h:283
FieldType mField[eCount]
Definition: hikdump.h:243
Defines a pose for a character.
Definition: humanik.h:441
HIKCharacterState * HIKCharacterStateCreate(const HIKCharacter *pCharacter, HIKMalloc pMalloc)
Create a new HIKCharacterState.
Field2D< float, LastNodeId, 4 > mQOffset
Definition: hikdump.h:279
Node has a parent unknown to HumanIK, used for local space transform and DoF.
Definition: humanik.h:483
Field2D< float, LastNodeId, 4 > mParentQOffset
Definition: hikdump.h:282
Field2D< float, LastNodeId, 4 > mParentTOffset
Definition: hikdump.h:281
bool HIKSaveCharacterState ( const char *  pFileName,
HIKCharacter pCharacter,
HIKCharacterState pState,
int  pTransformMode,
float  pUnitScale = 1.0f 
)
inline

Save HIKCharacterState pState to file pFileName.

Parameters
pFileNamePath and file name of the file to create. If the file already exists, it is overwritten.
pCharacterThe HIKCharacter used to create the HIKCharacterState being saved.
pStateHIKCharacterState to save.
pTransformModeDetermines whether the Node transforms in the saved HIKCharacterState will be expressed in global space or local space. 0 = global space, 1 = local space.
Returns
True if the operation was succesful, otherwise false.
+ Examples:

Definition at line 508 of file hikdump.h.

509 {
510  HIKCharacterStateStream lStateStream;
511  HIKDataDescription lDataDesc;
512 
513  lStateStream.Init();
514 
515  lDataDesc.mTransformSpace = pTransformMode == HIKDataDescription::HIKLocalSpace ? HIKDataDescription::HIKLocalSpace : HIKDataDescription::HIKGlobalSpace;
516  lDataDesc.mTOffset = 0;
517  lDataDesc.mQOffset = 16;
518  lDataDesc.mSOffset = 32;
519  lDataDesc.mStride = 48;
520  lDataDesc.mHIKNodeId = &lStateStream.mNodeId.mField[0];
521 
522  // First let prepare data to save
523  // We need transform mode and all joint transform
524  int i, lLastId = 0;
525  for(i=0;i<LastNodeId;i++)
526  {
527  if( HIKGetNodeUse(pCharacter, i) & HIKNodeUsed)
528  {
529  lStateStream.mNodeId.mField[lLastId++] = i;
530  }
531  }
532 
533  lStateStream.mNodeId.mField[lLastId] = HIKLastNode;
534  lStateStream.mTransformMode.mField[0] = pTransformMode;
535 
536  HIKGetCharacterStateTransformTQS(pCharacter, pState, &lDataDesc, &lStateStream.mTransformData);
537  for(i=0;i<LastNodeId;i++)
538  {
539  //if(HIKGetNodeUse(pCharacter, i) & HIKNodeUsed)
540  {
541  lStateStream.mTransformData.mField[i][0] *= pUnitScale;
542  lStateStream.mTransformData.mField[i][1] *= pUnitScale;
543  lStateStream.mTransformData.mField[i][2] *= pUnitScale;
544  }
545  }
546 
547  return Write(pFileName, lStateStream);
548 }
Node is characterized.
Definition: humanik.h:482
bool Write(const char *pFileName, const type &pStream)
Py_ssize_t i
Definition: abstract.h:1086
Marks the end of the enumeration.
Definition: humanik.h:257
A description of a data set that contains separate translation, quaternion rotation, and scaling values for multiple different Nodes in an HIKCharacterState.
int HIKGetNodeUse(const HIKCharacter *pCharacter, int pNodeId)
Retrieve the characterization flag set for Node pNodeId in HIKCharacter pCharacter.
Indicates the end of the list of Nodes.
Definition: humanik.h:1592
FieldType mField[eCount]
Definition: hikdump.h:243
Field< int, 1 > mTransformMode
Definition: hikdump.h:440
Field< int, LastNodeId > mNodeId
Definition: hikdump.h:441
void HIKGetCharacterStateTransformTQS(const HIKCharacter *pCharacter, HIKCharacterState *pCharacterState, const HIKDataDescription *pDataDescription, void *pDataSet)
Retrieve the translation (T), quaternion rotation (Q) and scaling (S) of multiple Nodes from HIKChara...
void HIKSaveDataBlock ( const char *  pFileName,
const HIKDataDescription pDataDesc,
const void *  pDataBlock 
)
inline

Save the data set located in memory at pDataBlock to file pFileName.

For more information about data sets, see ~{ Setting and Retrieving Animation Data }~.

Parameters
pFileNamePath and file name of the file to create. If the file already exists, it is overwritten.
pDataDescData description that defines the memory layout of the data set to be saved.
pDataBlockPointer to the beginning of the data set in memory.

Definition at line 892 of file hikdump.h.

893 {
894  HIKDataDescriptionStream lStream;
895  lStream.Init();
896 
897  lStream.mTransformSpace.mField[0] = pDataDesc.mTransformSpace;
898  lStream.mTOffset.mField[0] = (int)pDataDesc.mTOffset;
899  lStream.mQOffset.mField[0] = (int)pDataDesc.mQOffset;
900  lStream.mSOffset.mField[0] = (int)pDataDesc.mSOffset;
901  lStream.mStride.mField[0] = (int)pDataDesc.mStride;
902 
903  int i = 0;
904  do
905  {
906  lStream.mHIKNodeId.mField[i] = pDataDesc.mHIKNodeId[i];
907  }
908  while(pDataDesc.mHIKNodeId[i++] != HIKLastNode);
909 
910  // Save descriptor
911  if(Write(pFileName, lStream))
912  {
913  // Save all the collected data
914  WriteBlock(pFileName, (size_t)pDataDesc.mStride, (size_t)(i-1), pDataBlock);
915  }
916 }
int
Definition: code.h:72
Field< int, 1 > mQOffset
Definition: hikdump.h:794
bool Write(const char *pFileName, const type &pStream)
Py_ssize_t i
Definition: abstract.h:1086
Field< int, 1 > mStride
Definition: hikdump.h:796
Field< int, 1 > mTransformSpace
Definition: hikdump.h:792
Indicates the end of the list of Nodes.
Definition: humanik.h:1592
Field< int, LastNodeId > mHIKNodeId
Definition: hikdump.h:797
bool WriteBlock(const char *pFileName, const size_t &pElementSize, const size_t &pElementCount, type &pStream)
Field< int, 1 > mTOffset
Definition: hikdump.h:793
Field< int, 1 > mSOffset
Definition: hikdump.h:795
FieldType mField[eCount]
Definition: hikdump.h:243
bool HIKSaveEffectorState ( const char *  pFileName,
HIKEffectorSetState pState,
float  pUnitScale = 1.0f 
)
inline

Save HIKEffectorSetState pState to file pFileName.

Parameters
pFileNamePath and file name of the file to create. If the file already exists, it is overwritten.
pStateHIKEffectorSetState to save.
Returns
True if the operation was succesful, otherwise false.
+ Examples:

Definition at line 644 of file hikdump.h.

645 {
646  HIKEffectorSetStateStream lEffectorStream;
647  lEffectorStream.Init();
648 
649  int i;
650  for(i=0;i<LastEffectorId;i++)
651  {
652  lEffectorStream.mReachT.mField[i] = HIKGetTranslationActive(pState, i);
653  lEffectorStream.mReachR.mField[i] = HIKGetRotationActive(pState, i);
654  lEffectorStream.mResist.mField[i] = HIKGetResist(pState, i);
655  lEffectorStream.mPull.mField[i] = HIKGetPull(pState, i);
656 
657  HIKGetEffectorStateTQSfv(pState, i, &lEffectorStream.mTQS.mField[i][0], &lEffectorStream.mTQS.mField[i][4], &lEffectorStream.mTQS.mField[i][8]);
658  lEffectorStream.mTQS.mField[i][0] *= pUnitScale;
659  lEffectorStream.mTQS.mField[i][1] *= pUnitScale;
660  lEffectorStream.mTQS.mField[i][2] *= pUnitScale;
661  }
662 
663  lEffectorStream.mHandPullHips.mField[0] = HIKGetHandPullHips(pState, 0);
664  lEffectorStream.mHandPullHips.mField[1] = HIKGetHandPullHips(pState, 1);
665 
666  for(i=0;i<HIKLastFloorId;i++)
667  {
668  HIKGetEffectorFloorStatefv(pState, i, &lEffectorStream.mFloorTQS.mField[i][0]);
669  lEffectorStream.mFloorTQS.mField[i][0] *= pUnitScale;
670  lEffectorStream.mFloorTQS.mField[i][1] *= pUnitScale;
671  lEffectorStream.mFloorTQS.mField[i][2] *= pUnitScale;
672  }
673 
674  return Write(pFileName, lEffectorStream);
675 }
float HIKGetRotationActive(const HIKEffectorSetState *pEffectorSetState, int pEffectorIndex)
Retrieve the Reach Rotation constraint for Effector pEffectorIndex.
Field< float, 2 > mHandPullHips
Definition: hikdump.h:557
bool Write(const char *pFileName, const type &pStream)
Marks the end of the enumeration.
Definition: humanik.h:332
Py_ssize_t i
Definition: abstract.h:1086
void HIKGetEffectorFloorStatefv(const HIKEffectorSetState *pEffectorSetState, int pFloor, float pXForm[16])
Retrieve the transform matrix of the oriented plane that the floor contact engine applies to one of y...
float HIKGetHandPullHips(const HIKEffectorSetState *pEffectorSetState, int pLeft)
Retrieve the amount of pull the left or right hand can exert on the hips.
Field< float, LastEffectorId > mResist
Definition: hikdump.h:555
float HIKGetTranslationActive(const HIKEffectorSetState *pEffectorSetState, int pEffectorIndex)
Retrieve the Reach Translation constraint for Effector pEffectorIndex.
FieldType mField[eCount1][eCount2]
Definition: hikdump.h:263
void HIKGetEffectorStateTQSfv(const HIKEffectorSetState *pEffectorSetState, int pEffectorIndex, float pT[4], float pQ[4], float pS[4])
Retrieve the translation (T), quaternion rotation (Q) and scaling (S) in global space of Effector pEf...
Field2D< float, LastEffectorId, 12 > mTQS
Definition: hikdump.h:559
float HIKGetPull(const HIKEffectorSetState *pEffectorSetState, int pEffectorIndex)
Retrieve the Pull constraint for Effector pEffectorIndex.
Field< float, LastEffectorId > mReachT
Definition: hikdump.h:553
Field2D< float, HIKLastFloorId, 16 > mFloorTQS
Definition: hikdump.h:560
Field< float, LastEffectorId > mReachR
Definition: hikdump.h:554
Field< float, LastEffectorId > mPull
Definition: hikdump.h:556
FieldType mField[eCount]
Definition: hikdump.h:243
float HIKGetResist(const HIKEffectorSetState *pEffectorSetState, int pEffectorIndex)
Retrieve the Resist constraint for Effector pEffectorIndex.
Marks the end of the enumeration.
Definition: humanik.h:315
bool HIKSavePropertySetState ( const char *  pFileName,
HIKPropertySetState pState,
float  pUnitScale = 1.0f 
)
inline

Save HIKPropertySetState pState to file pFileName.

Parameters
pFileNamePath and file name of the file to create. If the file already exists, it is overwritten.
pStateHIKPropertySetState to save.
Returns
True if the operation was succesful, otherwise false.
+ Examples:

Definition at line 741 of file hikdump.h.

742 {
743  HIKPropertySetStream lStream;
744  lStream.Init();
745 
746  int i;
747  for(i=0;i<HIKLastPropertyId;i++)
748  {
749  lStream.mMode.mField[i] = HIKGetPropertyMode(pState, i);
750  lStream.mValue.mField[i] = HIKGetPropertyValue(pState, i);
751 
752  // Handle unitScale
753 
754  switch(i)
755  {
756  case HIKHipsTOffsetXId :
757  case HIKHipsTOffsetYId :
758  case HIKHipsTOffsetZId :
759  case HIKChestTOffsetXId :
760  case HIKChestTOffsetYId :
761  case HIKChestTOffsetZId :
762 
764  case HIKFootBackToAnkleId :
767  case HIKFootInToAnkleId :
768  case HIKFootOutToAnkleId :
769 
771  case HIKHandBackToWristId :
774  case HIKHandInToWristId :
775  case HIKHandOutToWristId :
776 
780 
781  lStream.mValue.mField[i] *= pUnitScale;
782  break;
783  }
784  }
785 
786  return Write(pFileName, lStream);
787 }
Defines the distance from the wrist to the inside edge of the model's hand (the side of the thumb)...
Definition: hikproperty.h:158
Defines the distance from the ankle to the inside edge of the model's foot (the instep).
Definition: hikproperty.h:151
Defines the distance from the ankle to the middle of the model's foot (its ball, or toe base)...
Definition: hikproperty.h:149
If your source and target character have their ankles at different heights above the floor...
Definition: hikproperty.h:77
Defines the distance from the wrist to the outside edge of the model's hand (the side with the pinky)...
Definition: hikproperty.h:159
int HIKGetPropertyMode(HIKPropertySetState *pState, int pPropertyId)
Retrieves the current mode set for property pPropertyId in HIKPropertySetState pState.
bool Write(const char *pFileName, const type &pStream)
Py_ssize_t i
Definition: abstract.h:1086
Defines the distance from the wrist to the bottom of the model's hand.
Definition: hikproperty.h:154
float HIKGetPropertyValue(HIKPropertySetState *pState, int pPropertyId)
Retrieves the current value set for property pPropertyId in HIKPropertySetState pState.
Defines the distance from the ankle to the outside edge of the model's foot.
Definition: hikproperty.h:152
Defines the distance from the wrist to the back of the model's hand.
Definition: hikproperty.h:155
Defines the distance from the wrist to the front end of the model's fingers.
Definition: hikproperty.h:157
The Hips and Chest Offset properties offset the translation of the character's hips and chest along e...
Definition: hikproperty.h:276
Adjusts the height of the target character's hips.
Definition: hikproperty.h:87
Defines the distance from the ankle to the bottom of the model's foot.
Definition: hikproperty.h:147
Adjusts the spacing between the left and right ankles of the target character relative to the source ...
Definition: hikproperty.h:82
Field< int, HIKLastPropertyId > mMode
Definition: hikdump.h:680
Defines the distance from the ankle to the back of the model's foot.
Definition: hikproperty.h:148
Defines the distance from the wrist to the middle of the model's hand (its knuckles, or finger base).
Definition: hikproperty.h:156
FieldType mField[eCount]
Definition: hikdump.h:243
Defines the distance from the ankle to the front end of the model's toes.
Definition: hikproperty.h:150
Field< float, HIKLastPropertyId > mValue
Definition: hikdump.h:681
Marks the end of the enumeration.
Definition: hikproperty.h:513