KFbxCache
#include<kfbxcache.h>

Inheritance diagram for KFbxCache:

Inheritance graph
[legend]

List of all members.

Detailed Description

This object contains methods for accessing point animation in a cache file.

The FBX SDK supports two point cache file formats :

Accessing cache data using these formats differ significantly. To address this difference, two sets of methods have been created. Use theGetCacheFileFormat()function to determine which set of methods to use.

Definition at line67of filekfbxcache.h.


Format Independant Functions.

enum EFileFormat
 Supported cache file formats.More...
void SetCacheFileFormat(EFileFormatpFileFormat)
 Set the cache file format.
EFileFormat GetCacheFileFormat()
 Get the cache file format.
void SetCacheFileName(const char *pRelativeFileName, const char *pAbsoluteFileName)
 Set the cache file name.
void GetCacheFileName(KString&pRelativeFileName,KString&pAbsoluteFileName)
 Get the cache file name.
bool OpenFileForRead()
 Open the cache file for reading.
bool IsOpen()
 Get the open state of the cache file.
bool CloseFile()
 Close the cache file.
double GetSamplingFrameRate()
 Get the sampling frame rate of the cache file.
KTime GetCacheTimePerFrame()
 Get the sampling frame rate of the cache file, as aKTimeobject.

eMC Format Specific Functions.

enum EMCFileCount
 Number of files used to store the animation.More...
enum EMCDataType
 cache datatypes formats.More...
enum EMCSamplingType
 cache channel sampling types.More...
bool OpenFileForWrite(EMCFileCountpFileCount, double pSamplingFrameRate, const char *pChannelName,EMCDataTypepMCDataType=kDoubleVectorArray)
 Open a cache file for writing.
int GetChannelCount()
 Get the number of channels in the cache file.
bool GetChannelName(int pChannelIndex,KString&pChannelName)
 Get the channel name for a specific channel index.
bool GetChannelDataType(int pChannelIndex,EMCDataType&pChannelType)
 Get the DataType of the specified channel.
int GetChannelIndex(const char *pChannelName)
 Get the index of the specified channel.
bool Read(int pChannelIndex,KTime&pTime, double *pBuffer, unsigned int pPointCount)
 Read a sample at a given time.
bool Read(int pChannelIndex,KTime&pTime, float *pBuffer, unsigned int pPointCount)
 Read a sample at a given time.
bool Write(int pChannelIndex,KTime&pTime, double *pBuffer, unsigned int pPointCount)
 Write a sample at a given time.
bool Write(int pChannelIndex,KTime&pTime, float *pBuffer, unsigned int pPointCount)
 Write a sample at a given time.
bool GetAnimationRange(int pChannelIndex,KTime&pTimeStart,KTime&pTimeEnd)
 Get the Animation Range of the specified channel.
bool GetCacheType(EMCFileCount&pFileCount)
 Get the cache type.
bool GetChannelInterpretation(int pChannelIndex,KString&pInterpretation)
 Get the cache channel interpretation.
bool GetChannelSamplingType(int pChannelIndex,EMCSamplingType&pSamplingType)
 Get the cache channel sampling type.
bool GetChannelSamplingRate(int pChannelIndex,KTime&pSamplingRate)
 Get the cache channel sampling rate, in frames per second.
bool GetChannelSampleCount(int pChannelIndex, unsigned int&pSampleCount)
 Get the number of data points for a channel.
bool GetChannelPointCount(int pChannelIndex,KTimepTime, unsigned int&pPointCount)
 Get the number of points animated in the cache file, for a channel, for a given time.
int GetCacheDataFileCount()
 Returns the number of cache data files.
bool GetCacheDataFileName(int pIndex,KString&pRelativeFileName,KString&pAbsoluteFileName)
 Get the nth cache file name.
bool EnableMultiChannelFetching(bool pMultiChannelFetching)
 Enable multi-channel fetching.

Error Management

enum EError
 Error identifiers.More...
KErrorGetError()
 Retrieve error object.
EError GetLastErrorID() const
 Get last error code.
const char * GetLastErrorString() const
 Get last error string.

Public Member Functions

KFbxCacheoperator=(constKFbxCache&pOther)
 Assignment operator.
ePC2 Format Specific Functions.
bool OpenFileForWrite(double pFrameStartOffset, double pSamplingFrameRate, unsigned int pSampleCount, unsigned int pPointCount)
 Open a cache file for writing.
unsigned int GetSampleCount()
 Get the number of frames of animation found in the point cache file.
unsigned int GetPointCount()
 Get the number of points animated in the cache file.
double GetFrameStartOffset()
 Get the start time of the animation.
bool Read(unsigned int pFrameIndex, double *pBuffer, unsigned int pPointCount)
 Get the sampling frame rate of the cache file.
bool Write(unsigned int pFrameIndex, double *pBuffer)
 Write a sample at a given frame index.
File conversion Functions.
bool ConvertFromPC2ToMC(EMCFileCountpFileCount, double pSamplingFrameRate)
 Create aneMCcache file from an ePC2 cache file.
bool ConvertFromMCToPC2(double pSamplingFrameRate, unsigned int pChannelIndex)
 Create anePC2cache file from an eMC cache file.

Member Enumeration Documentation

Supported cache file formats.

  • eUNKNOWN
  • ePC23ds Max Point Cache 2 file format
  • eMCMaya Cache file format

Definition at line82of filekfbxcache.h.

Number of files used to store the animation.

  • eMC_ONE_FILEOne file is used for all the frames of animation
  • eMC_ONE_FILE_PER_FRAMEOne file is used for every frame of animation

Definition at line148of filekfbxcache.h.

cache datatypes formats.

  • kUnknownData
  • kDoubleis a double
  • kDoubleArraywould be double*
  • kDoubleVectorArrayis double* [3]
  • kInt32Arrayis int*
  • kFloatVectorArrayis float* [3]

Definition at line162of filekfbxcache.h.

cache channel sampling types.

  • eSAMPLING_REGULARRegular sampling
  • eSAMPLING_IRREGULARIrregular sampling

Definition at line281of filekfbxcache.h.

enumEError

Error identifiers.

  • eUNSUPPORTED_ARCHITECTURE
  • eINVALID_ABSOLUTE_PATH
  • eINVALID_SAMPLING_RATE
  • eINVALID_CACHE_FORMAT
  • eUNSUPPORTED_FILE_VERSION
  • eCONVERSION_FROM_PC2_FAILED
  • eCONVERSION_FROM_MC_FAILED
  • eCACHE_FILE_NOT_FOUND
  • eCACHE_FILE_NOT_OPENED
  • eCACHE_FILE_NOT_CREATED
  • eINVALID_OPEN_FLAG
  • eERROR_WRITING_SAMPLE
  • eERROR_READING_SAMPLE
  • eERROR_DATATYPE
  • eERROR_INVALIDCHANNELINDEX
  • eERROR_IRREGULARCHANNELSAMPLING
  • eERROR_CHANNELINTERPRETATION
  • eERROR_CHANNELSAMPLING
  • eERROR_INVALID_FILEINDEX
  • eERROR_CACHEDATAFILENAME
  • eERROR_COUNT
  • eERROR_CHANNELSTARTTIME
  • eERROR_CHANNELPOINTCOUNT
  • eERROR_INVALIDTIME

Definition at line468of filekfbxcache.h.

Member Function Documentation

void SetCacheFileFormat(EFileFormat pFileFormat ) 

Set the cache file format.

Parameters:
pFileFormat Valid values areePC2oreMC.

EFileFormatGetCacheFileFormat( ) 

Get the cache file format.

Returns:
The current cache file format, oreUNKNOWNif it is not set.

void SetCacheFileName(const char * pRelativeFileName,
const char * pAbsoluteFileName 
)

Set the cache file name.

Parameters:
pRelativeFileName The point cache file, relative to the FBX file name.
pAbsoluteFileName The point cache file absolute path.

void GetCacheFileName(KStringpRelativeFileName,
KStringpAbsoluteFileName 
)

Get the cache file name.

Parameters:
pRelativeFileName Return the point cache file name, relative to the FBX File name.
pAbsoluteFileName Return the point cache file absolute path.

bool OpenFileForRead( ) 

Open the cache file for reading.

Returns:
trueif the file is successfully opened,falseotherwise. See the error management functions for error details.

bool IsOpen( ) 

Get the open state of the cache file.

Returns:
trueif the cache file is currently open,falseotherwise.

bool CloseFile( ) 

Close the cache file.

Returns:
trueif the cache file is closed successfully,falseotherwise.

double GetSamplingFrameRate( ) 

Get the sampling frame rate of the cache file.

Returns:
The sampling frame rate of the cache file, in frames per second.

KTimeGetCacheTimePerFrame( ) 

Get the sampling frame rate of the cache file, as aKTimeobject.

Returns:
The sampling frame rate of the cache file.

bool OpenFileForWrite(EMCFileCount pFileCount,
double pSamplingFrameRate,
const char * pChannelName,
EMCDataType pMCDataType=kDoubleVectorArray 
)

Open a cache file for writing.

Parameters:
pFileCount Create one file for each frame of animation, or one file for all the frames.
pSamplingFrameRate Number of frames per second.
pChannelName The name of the channel of animation to create.
pMCDataType The MC DataType of the cache.

int GetChannelCount( ) 

Get the number of channels in the cache file.

Returns:
The number of animation channels in the cache file.

bool GetChannelName(int pChannelIndex,
KStringpChannelName 
)

Get the channel name for a specific channel index.

Parameters:
pChannelIndex The index of the animation channel, between 0 andGetChannelCount().
pChannelName Returns the name of the requested channel.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

bool GetChannelDataType(int pChannelIndex,
EMCDataTypepChannelType 
)

Get the DataType of the specified channel.

Parameters:
pChannelIndex The index of the channel.
pChannelType The channel's datatype
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

int GetChannelIndex(const char * pChannelName ) 

Get the index of the specified channel.

Parameters:
pChannelName The name of the channel.
Returns:
The index of the channel in the cache file, or -1 if an error occured. See the error management functions for error details.

bool Read(int pChannelIndex,
KTimepTime,
double * pBuffer,
unsigned int pPointCount 
)

Read a sample at a given time.

Parameters:
pChannelIndex The index of the animation channel, between 0 andGetChannelCount().
pTime Time at which the point animation must be evaluated.
pBuffer The place where the point value will be copied. This buffer must be of size 3*pPointCount.
pPointCount The number of points to read from the point cache file.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

bool Read(int pChannelIndex,
KTimepTime,
float * pBuffer,
unsigned int pPointCount 
)

Read a sample at a given time.

Parameters:
pChannelIndex The index of the animation channel, between 0 andGetChannelCount().
pTime Time at which the point animation must be evaluated.
pBuffer The place where the point value will be copied. This buffer must be of size 3*pPointCount.
pPointCount The number of points to read from the point cache file.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

bool Write(int pChannelIndex,
KTimepTime,
double * pBuffer,
unsigned int pPointCount 
)

Write a sample at a given time.

Parameters:
pChannelIndex The index of the animation channel, between 0 andGetChannelCount().
pTime Time at which the point animation must be inserted.
pBuffer Point to the values to be copied. This buffer must be of size 3*pPointCount.
pPointCount The number of points to write in the point cache file.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

bool Write(int pChannelIndex,
KTimepTime,
float * pBuffer,
unsigned int pPointCount 
)

Write a sample at a given time.

Parameters:
pChannelIndex The index of the animation channel, between 0 andGetChannelCount().
pTime Time at which the point animation must be inserted.
pBuffer Point to the values to be copied. This buffer must be of size 3*pPointCount.
pPointCount The number of points to write in the point cache file.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

bool GetAnimationRange(int pChannelIndex,
KTimepTimeStart,
KTimepTimeEnd 
)

Get the Animation Range of the specified channel.

Parameters:
pChannelIndex The index of the channel.
pTimeStart The Channel's Animation Start Time
pTimeEnd The Channel's Animation End Time
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

bool GetCacheType(EMCFileCountpFileCount ) 

Get the cache type.

Parameters:
pFileCount The cache type.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

bool GetChannelInterpretation(int pChannelIndex,
KStringpInterpretation 
)

Get the cache channel interpretation.

Parameters:
pChannelIndex The index of the animation channel, between 0 andGetChannelCount().
pInterpretation The channel interpretation; user-defined.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

bool GetChannelSamplingType(int pChannelIndex,
EMCSamplingTypepSamplingType 
)

Get the cache channel sampling type.

Parameters:
pChannelIndex The index of the animation channel, between 0 andGetChannelCount().
pSamplingType The sampling type of the channel.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

bool GetChannelSamplingRate(int pChannelIndex,
KTimepSamplingRate 
)

Get the cache channel sampling rate, in frames per second.

Parameters:
pChannelIndex The index of the animation channel, between 0 andGetChannelCount().
pSamplingRate The sampling rate of the channel. The channel must have a regular sampling type.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

bool GetChannelSampleCount(int pChannelIndex,
unsigned int& pSampleCount 
)

Get the number of data points for a channel.

Parameters:
pChannelIndex The index of the animation channel, between 0 andGetChannelCount().
pSampleCount Number of available samples.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

bool GetChannelPointCount(int pChannelIndex,
KTime pTime,
unsigned int& pPointCount 
)

Get the number of points animated in the cache file, for a channel, for a given time.

Parameters:
pChannelIndex The index of the animation channel, between 0 andGetChannelCount().
pTime Reference time; must be within the boundaries of the animation.
pPointCount Number of available points.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

int GetCacheDataFileCount( ) 

Returns the number of cache data files.

Returns:
The count returned does not include the main cache file, and depends on the cache type. WIll return -1 point cache support is not enabled.

bool GetCacheDataFileName(int pIndex,
KStringpRelativeFileName,
KStringpAbsoluteFileName 
)

Get the nth cache file name.

Parameters:
pIndex Index of the cache file to return; index is zero-based, and must be<GetCacheDataFileCount().
pRelativeFileName Return the point cache file name, relative to the FBX File name.
pAbsoluteFileName Return the point cache file absolute path.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

bool EnableMultiChannelFetching(bool pMultiChannelFetching ) 

Enable multi-channel fetching.

Parameters:
pMultiChannelFetching Enable/disable multi-channel fetching. When multi-channel is enabled, any load of data on a channel at a specific time will prefetch data from all channels, for that specific time. This can reduce disk access, and increase performance (but requires more memory).
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

bool OpenFileForWrite(double pFrameStartOffset,
double pSamplingFrameRate,
unsigned int pSampleCount,
unsigned int pPointCount 
)

Open a cache file for writing.

Parameters:
pFrameStartOffset Start time of the animation, in frames.
pSamplingFrameRate Number of frames per second.
pSampleCount The number of samples to write to the file.
pPointCount The number of points to write in the point cache file.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

unsigned int GetSampleCount( ) 

Get the number of frames of animation found in the point cache file.

Returns:
The number of frames of animation.

unsigned int GetPointCount( ) 

Get the number of points animated in the cache file.

Returns:
The number of points.

double GetFrameStartOffset( ) 

Get the start time of the animation.

Returns:
The start time of the animation, in frames.

bool Read(unsigned int pFrameIndex,
double * pBuffer,
unsigned int pPointCount 
)

Get the sampling frame rate of the cache file.

Returns:
The sampling frame rate of the cache file, in frames per second. Read a sample at a given frame index.
Parameters:
pFrameIndex The index of the animation frame, between 0 andGetSampleCount().
pBuffer The place where the point value will be copied. This buffer must be of size 3*pPointCount.
pPointCount The number of points to read from the point cache file.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.

bool Write(unsigned int pFrameIndex,
double * pBuffer 
)

Write a sample at a given frame index.

Parameters:
pFrameIndex The index of the animation frame.
pBuffer Point to the values to be copied. This buffer must be of size 3*pPointCount, as passed to the functionOpenFileForWrite().
Returns:
trueif successful,falseotherwise. See the error management functions for error details.
Remarks:
Successive calls toWrite()must use successive index.

bool ConvertFromPC2ToMC(EMCFileCount pFileCount,
double pSamplingFrameRate 
)

Create aneMCcache file from an ePC2 cache file.

Parameters:
pFileCount Create one file for each frame of animation, or one file for all the frames.
pSamplingFrameRate Number of frames per second used to resample the point animation.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.
Remarks:
The created point cache file will be located in the _fpc folder associate with the FBX file.

bool ConvertFromMCToPC2(double pSamplingFrameRate,
unsigned int pChannelIndex 
)

Create anePC2cache file from an eMC cache file.

Parameters:
pSamplingFrameRate Number of frames per second to resample the point animation.
pChannelIndex Index of the channel of animation to read from.
Returns:
trueif successful,falseotherwise. See the error management functions for error details.
Remarks:
The created point cache file will be located in the _fpc folder associate with the FBX file.

KError&GetError( ) 

Retrieve error object.

Returns:
Reference to error object.

EErrorGetLastErrorID( ) const

Get last error code.

Returns:
Last error code.

const char* GetLastErrorString( ) const

Get last error string.

Returns:
Textual description of the last error.

KFbxCache&operator=(constKFbxCachepOther ) 

Assignment operator.