KFbxCache Class Reference

#include <kfbxcache.h>

Inherits KFbxObject.

Inheritance diagram for KFbxCache:

Inheritance graph
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:

Definition at line 64 of file kfbxcache.h.

Format Independant Functions.

enum  EFileFormat
 Supported cache file formats. More...
void SetCacheFileFormat (EFileFormat pFileFormat)
 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.

eMC Format Specific Functions.

enum  EMCFileCount
 Number of files used to store the animation
  • eMC_ONE_FILE One file is used for all the frames of animation
  • eMC_ONE_FILE_PER_FRAME One file is used for every frame of animation.
More...
bool OpenFileForWrite (EMCFileCount pFileCount, double pSamplingFrameRate, const char *pChannelName)
 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.
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 Write (int pChannelIndex, KTime &pTime, double *pBuffer, unsigned int pPointCount)
 Write a sample at a given time.

Error Management

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

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.
double GetSamplingFrameRate ()
 Get the sampling frame rate of the cache file.
bool Read (unsigned int pFrameIndex, double *pBuffer, unsigned int pPointCount)
 Read a sample at a given frame index.
bool Write (unsigned int pFrameIndex, double *pBuffer)
 Write a sample at a given frame index.

File conversion Functions.

bool ConvertFromPC2ToMC (EMCFileCount pFileCount, double pSamplingFrameRate)
 Create an eMC cache file from an ePC2 cache file.
bool ConvertFromMCToPC2 (double pSamplingFrameRate, unsigned int pChannelIndex)
 Create an ePC2 cache file from an eMC cache file.

Public Member Functions

KFbxCacheoperator= (const KFbxCache &pOther)
 Assignment operator.
virtual KFbxObject::ENameSpace GetNameSpace () const
 Return the type ID of this class.


Member Enumeration Documentation

Supported cache file formats.

  • eUNKNOWN
  • ePC2 3ds Max Point Cache 2 file format
  • eMC Maya Cache file format

Definition at line 79 of file kfbxcache.h.

Number of files used to store the animation

  • eMC_ONE_FILE One file is used for all the frames of animation
  • eMC_ONE_FILE_PER_FRAME One file is used for every frame of animation.

Definition at line 135 of file kfbxcache.h.

enum EError

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_COUNT

Definition at line 300 of file kfbxcache.h.


Member Function Documentation

void SetCacheFileFormat ( EFileFormat  pFileFormat  ) 

Set the cache file format.

Parameters:
pFileFormat Valid values are ePC2 or eMC.

EFileFormat GetCacheFileFormat (  ) 

Get the cache file format.

Returns:
The current cache file format, or eUNKNOWN if 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 ( KString pRelativeFileName,
KString pAbsoluteFileName 
)

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:
true if the file is successfully opened, false otherwise. See the error management functions for error details.

bool IsOpen (  ) 

Get the open state of the cache file.

Returns:
true if the cache file is currently open, false otherwise.

bool CloseFile (  ) 

Close the cache file.

Returns:
true if the cache file is closed successfully, false otherwise.

bool OpenFileForWrite ( EMCFileCount  pFileCount,
double  pSamplingFrameRate,
const char *  pChannelName 
)

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.

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,
KString pChannelName 
)

Get the channel name for a specific channel index.

Parameters:
pChannelIndex The index of the animation channel, between 0 and GetChannelCount().
pChannelName Returns the name of the requested channel.
Returns:
true if successful, false otherwise. 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,
KTime pTime,
double *  pBuffer,
unsigned int  pPointCount 
)

Read a sample at a given time.

Parameters:
pChannelIndex The index of the animation channel, between 0 and GetChannelCount().
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:
true if successful, false otherwise. See the error management functions for error details.

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

Write a sample at a given time.

Parameters:
pChannelIndex The index of the animation channel, between 0 and GetChannelCount().
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:
true if successful, false otherwise. 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:
true if successful, false otherwise. 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.

double GetSamplingFrameRate (  ) 

Get the sampling frame rate of the cache file.

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

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

Read a sample at a given frame index.

Parameters:
pFrameIndex The index of the animation frame, between 0 and GetSampleCount().
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:
true if successful, false otherwise. 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 function OpenFileForWrite().
Returns:
true if successful, false otherwise. See the error management functions for error details.
Remarks:
Successive calls to Write() must use successive index.

bool ConvertFromPC2ToMC ( EMCFileCount  pFileCount,
double  pSamplingFrameRate 
)

Create an eMC cache 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:
true if successful, false otherwise. 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 an ePC2 cache 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:
true if successful, false otherwise. 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.

EError GetLastErrorID (  ) 

Get last error code.

Returns:
Last error code.

char* GetLastErrorString (  ) 

Get last error string.

Returns:
Textual description of the last error.

KFbxCache& operator= ( const KFbxCache pOther  ) 

Assignment operator.

virtual KFbxObject::ENameSpace GetNameSpace (  )  const [virtual]

Return the type ID of this class.

Returns:
KFbxObject::eCACHE.