| 1 | /**************************************************************************************** |
| 2 | |
| 3 | Copyright (C) 2015 Autodesk, Inc. |
| 4 | All rights reserved. |
| 5 | |
| 6 | Use of this software is subject to the terms of the Autodesk license agreement |
| 7 | provided at the time of installation or download, or which otherwise accompanies |
| 8 | this software in either electronic or hard copy form. |
| 9 | |
| 10 | ****************************************************************************************/ |
| 11 | |
| 12 | //! \file fbxcache.h |
| 13 | #ifndef _FBXSDK_SCENE_GEOMETRY_CACHE_H_ |
| 14 | #define _FBXSDK_SCENE_GEOMETRY_CACHE_H_ |
| 15 | |
| 16 | #include <fbxsdk/fbxsdk_def.h> |
| 17 | |
| 18 | #include <fbxsdk/core/fbxobject.h> |
| 19 | #include <fbxsdk/core/base/fbxstatus.h> |
| 20 | |
| 21 | #include <fbxsdk/fbxsdk_nsbegin.h> |
| 22 | |
| 23 | class FbxCache_internal; |
| 24 | |
| 25 | /** This object contains methods for accessing point animation in a cache file. |
| 26 | * The FBX SDK supports three point cache file formats : |
| 27 | * - \e eMaxPointCacheV2: the 3ds Max Point Cache 2 file format. |
| 28 | * - \e eMayaCache: the Maya Cache file format. |
| 29 | * - \e eAlembic: Alembic Cache file format. |
| 30 | * |
| 31 | * Accessing cache data using these formats differs significantly. To address this difference, several sets of methods have been created. |
| 32 | * Use the GetCacheFileFormat() function to determine which set of methods to use. */ |
| 33 | class FBXSDK_DLL FbxCache : public FbxObject |
| 34 | { |
| 35 | FBXSDK_OBJECT_DECLARE(FbxCache, FbxObject); |
| 36 | |
| 37 | public: |
| 38 | //! \name Format Independent Functions. |
| 39 | //@{ |
| 40 | /** Supported cache file formats. */ |
| 41 | enum EFileFormat |
| 42 | { |
| 43 | eUnknownFileFormat, //!< Unknown cache file format. |
| 44 | eMaxPointCacheV2, //!< 3ds Max Point Cache 2 file format. |
| 45 | eMayaCache, //!< Maya Cache file format. |
| 46 | eAlembic //!< Alembic Cache file format. |
| 47 | }; |
| 48 | |
| 49 | /** Set the cache file format. |
| 50 | * \param pFileFormat Valid values are \e eMaxPointCacheV2 or \e eMayaCache. |
| 51 | * \param pStatus The FbxStatus object to hold error codes. */ |
| 52 | void SetCacheFileFormat(EFileFormat pFileFormat, FbxStatus* pStatus=NULL); |
| 53 | |
| 54 | /** Get the cache file format. |
| 55 | * \return The current cache file format, or \e eUnknown if it is not set. */ |
| 56 | EFileFormat GetCacheFileFormat() const; |
| 57 | |
| 58 | /** Set the cache file name. |
| 59 | * \param pRelativeFileName_UTF8 The point cache file, relative to the FBX file name. |
| 60 | * \param pAbsoluteFileName_UTF8 The point cache file absolute path. |
| 61 | * \param pStatus The FbxStatus object to hold error codes. */ |
| 62 | void SetCacheFileName(const char* pRelativeFileName_UTF8, const char* pAbsoluteFileName_UTF8, FbxStatus* pStatus=NULL); |
| 63 | |
| 64 | /** Get the cache file name. |
| 65 | * \param pRelativeFileName_UTF8 Return the point cache file name, relative to the FBX File name. |
| 66 | * \param pAbsoluteFileName_UTF8 Return the point cache file absolute path. */ |
| 67 | void GetCacheFileName(FbxString& pRelativeFileName_UTF8, FbxString& pAbsoluteFileName_UTF8) const; |
| 68 | |
| 69 | /** Open the cache file for reading. |
| 70 | * \param pStatus The FbxStatus object to hold error codes. |
| 71 | * \return \c true if the file is successfully opened, \c false otherwise. */ |
| 72 | bool OpenFileForRead(FbxStatus* pStatus=NULL); |
| 73 | |
| 74 | /** Get the open state of the cache file. |
| 75 | * \param pStatus The FbxStatus object to hold error codes. |
| 76 | * \return \c true if the cache file is currently open, \c false otherwise. */ |
| 77 | bool IsOpen(FbxStatus* pStatus=NULL) const; |
| 78 | |
| 79 | /** Read data from the cache file. |
| 80 | * \param pBuffer The buffer containing the data from the cache file. This parameter can be NULL if interested to get buffer length only. |
| 81 | * \param pBufferLength The length of the buffer (NOT in bytes). |
| 82 | * \param pTime The time at which the data should be read. |
| 83 | * \param pChannel The cache file channel to read, when multiple channels are available. |
| 84 | * \return \c True if the cache data was successfully read, \c false otherwise. |
| 85 | * \remark The buffer will be allocated by FbxCache and will be returned if read successful. The buffer will be freed by FbxCache upon its destruction. */ |
| 86 | bool Read(float** pBuffer, unsigned int& pBufferLength, const FbxTime& pTime, unsigned int pChannel=0); |
| 87 | |
| 88 | /** Close the cache file. |
| 89 | * \param pStatus The FbxStatus object to hold error codes. |
| 90 | * \return \c true if the cache file is closed successfully, \c false otherwise. */ |
| 91 | bool CloseFile(FbxStatus* pStatus=NULL); |
| 92 | |
| 93 | /** Get the sampling frame rate of the cache file. |
| 94 | * \param pStatus The FbxStatus object to hold error codes. |
| 95 | * \return The sampling frame rate of the cache file, in frames per second. */ |
| 96 | double GetSamplingFrameRate(FbxStatus* pStatus=NULL); |
| 97 | |
| 98 | /** Get the sampling frame rate of the cache file, as a FbxTime object. |
| 99 | * \param pStatus The FbxStatus object to hold error codes. |
| 100 | * \return The sampling frame rate of the cache file. */ |
| 101 | FbxTime GetCacheTimePerFrame(FbxStatus* pStatus=NULL); |
| 102 | |
| 103 | /** Get the number of channels in the cache file. |
| 104 | * \param pStatus The FbxStatus object to hold error codes. |
| 105 | * \return The number of animation channels in the cache file. */ |
| 106 | int GetChannelCount(FbxStatus* pStatus=NULL); |
| 107 | |
| 108 | /** Get the channel name for a specific channel index. |
| 109 | * \param pChannelIndex The index of the animation channel, between 0 and GetChannelCount(). |
| 110 | * \param pChannelName Returns the name of the requested channel. |
| 111 | * \param pStatus The FbxStatus object to hold error codes. |
| 112 | * \return \c true if successful, \c false otherwise. */ |
| 113 | bool GetChannelName(int pChannelIndex, FbxString& pChannelName, FbxStatus* pStatus=NULL); |
| 114 | //@} |
| 115 | |
| 116 | //! \name eMayaCache Format Specific Functions. |
| 117 | //@{ |
| 118 | //! Number of files used to store the animation. |
| 119 | enum EMCFileCount |
| 120 | { |
| 121 | eMCOneFile, //!< One file is used for all the frames of animation. |
| 122 | eMCOneFilePerFrame //!< For every frame of animation, a cache file is used. The number of the frames is the number of the cache files. |
| 123 | }; |
| 124 | |
| 125 | //! Data types in the MC cache file. |
| 126 | enum EMCDataType |
| 127 | { |
| 128 | eUnknownData, //!< Unknown data. |
| 129 | eDouble, //!< No use but has to be defined for consistency reasons. |
| 130 | eDoubleArray, //!< double* |
| 131 | eDoubleVectorArray, //!< double* [3] |
| 132 | eInt32Array, //!< int* |
| 133 | eFloatArray, //!< float* |
| 134 | eFloatVectorArray //!< float* [3] |
| 135 | }; |
| 136 | |
| 137 | //! Binary cache format. |
| 138 | enum EMCBinaryFormat |
| 139 | { |
| 140 | eMCC, //!< MCC cache file format, 32bit (older format) |
| 141 | eMCX //!< MCX cache file format, 64bit (newer format) |
| 142 | }; |
| 143 | |
| 144 | //! Cache channel sampling types. |
| 145 | enum EMCSamplingType |
| 146 | { |
| 147 | eSamplingRegular, //!< Regular sampling. |
| 148 | eSamplingIrregular //!< Irregular sampling. |
| 149 | }; |
| 150 | |
| 151 | /** Open a cache file for writing. |
| 152 | * \param pFileCount Create one file for each frame of animation, or one file for all the frames. |
| 153 | * \param pSamplingFrameRate Number of frames per second. |
| 154 | * \param pChannelName The name of the channel of animation to create. |
| 155 | * \param pBinaryFormat Binary format type (32 bit=eMCC or 64bit=eMCX) |
| 156 | * \param pMCDataType The data type of the MC cache file. |
| 157 | * \param pInterpretation A piece of meta data to help users of the cache understand how to interpret the data. |
| 158 | * \param pStatus The FbxStatus object to hold error codes. */ |
| 159 | bool OpenFileForWrite(EMCFileCount pFileCount, double pSamplingFrameRate, const char* pChannelName, EMCBinaryFormat pBinaryFormat, EMCDataType pMCDataType=eDoubleVectorArray, const char* pInterpretation="Points" , FbxStatus* pStatus=NULL); |
| 160 | |
| 161 | /** Creates a new channel in the cache. |
| 162 | * \param pChannelName The name of the channel of animation to create. |
| 163 | * \param pMCDataType The MC DataType of the cache. |
| 164 | * \param pInterpretation A piece of meta data to help users of the cache understand how to interpret the data. |
| 165 | * \param pChannelIndex The index of the new animation channel. |
| 166 | * \param pStatus The FbxStatus object to hold error codes. |
| 167 | * \remark \b pChannelName must be unique within the cache. |
| 168 | * \remark \b pChannelName and \b pInterpretation cannot be NULL pointers. |
| 169 | * \remark This method must be called before adding any data to the cache but after the OpenFileForWrite. */ |
| 170 | bool AddChannel(const char* pChannelName, EMCDataType pMCDataType, const char* pInterpretation, unsigned int& pChannelIndex, FbxStatus* pStatus=NULL); |
| 171 | |
| 172 | /** Get the data type of the specified channel. |
| 173 | * \param pChannelIndex The index of the channel. |
| 174 | * \param pChannelType The channel's data type. |
| 175 | * \param pStatus The FbxStatus object to hold error codes. |
| 176 | * \return \c true if successful, \c false otherwise. */ |
| 177 | bool GetChannelDataType(int pChannelIndex, EMCDataType& pChannelType, FbxStatus* pStatus=NULL); |
| 178 | |
| 179 | /** Get the index of the specified channel. |
| 180 | * \param pChannelName The name of the channel. |
| 181 | * \param pStatus The FbxStatus object to hold error codes. |
| 182 | * \return The index of the channel in the cache file, or -1 if an error occurred. */ |
| 183 | int GetChannelIndex(const char* pChannelName, FbxStatus* pStatus=NULL); |
| 184 | |
| 185 | /** Read a sample at a given time. |
| 186 | * \param pChannelIndex The index of the animation channel, between 0 and GetChannelCount(). |
| 187 | * \param pTime Time at which the point animation must be evaluated. |
| 188 | * \param pBuffer The place where the point value will be copied. If the channel's data type is DoubleVectorArray this buffer must be of size 3*pPointCount. |
| 189 | * \param pPointCount The number of points to read from the point cache file. |
| 190 | * \param pStatus The FbxStatus object to hold error codes. |
| 191 | * \return \c true if successful, \c false otherwise. */ |
| 192 | bool Read(int pChannelIndex, FbxTime& pTime, double* pBuffer, unsigned int pPointCount, FbxStatus* pStatus=NULL); |
| 193 | |
| 194 | /** Read a sample at a given time. |
| 195 | * \param pChannelIndex The index of the animation channel, between 0 and GetChannelCount(). |
| 196 | * \param pTime Time at which the point animation must be evaluated. |
| 197 | * \param pBuffer The place where the point value will be copied. If the channel's data type is FloatVectorArray this buffer must be of size 3*pPointCount. |
| 198 | * \param pPointCount The number of points to read from the point cache file. |
| 199 | * \param pStatus The FbxStatus object to hold error codes. |
| 200 | * \return \c true if successful, \c false otherwise. */ |
| 201 | bool Read(int pChannelIndex, FbxTime& pTime, float* pBuffer, unsigned int pPointCount, FbxStatus* pStatus=NULL); |
| 202 | |
| 203 | /** Read a sample at a given time. |
| 204 | * \param pChannelIndex The index of the animation channel, between 0 and GetChannelCount(). |
| 205 | * \param pTime Time at which the point animation must be evaluated. |
| 206 | * \param pBuffer The place where the point value will be copied. This buffer must be of size pPointCount. |
| 207 | * \param pPointCount The number of points to read from the point cache file. |
| 208 | * \param pStatus The FbxStatus object to hold error codes. |
| 209 | * \return \c true if successful, \c false otherwise. */ |
| 210 | bool Read(int pChannelIndex, FbxTime& pTime, int* pBuffer, unsigned int pPointCount, FbxStatus* pStatus=NULL); |
| 211 | |
| 212 | /** Instruct the cache system that data is about to be written to it. This call must appear before any calls to the Write() methods on any channel and terminated by a call to EndWriteAt(). |
| 213 | * \param pTime Time at which the point animation must be inserted. |
| 214 | * \param pStatus The FbxStatus object to hold error codes. |
| 215 | * \return \c true if successful, \c false otherwise. */ |
| 216 | bool BeginWriteAt( FbxTime& pTime, FbxStatus* pStatus=NULL ); |
| 217 | |
| 218 | /** Write a sample at a given time. |
| 219 | * \param pChannelIndex The index of the animation channel, between 0 and GetChannelCount(). |
| 220 | * \param pTime Time at which the point animation must be inserted. |
| 221 | * \param pBuffer Point to the values to be copied. If the channel's data type is DoubleVectorArray this buffer must be of size 3*pPointCount. |
| 222 | * \param pPointCount The number of points to write in the point cache file. |
| 223 | * \param pStatus The FbxStatus object to hold error codes. |
| 224 | * \return \c true if successful, \c false otherwise. |
| 225 | * \remark This method will fail if the time \e pTime is different from the time set using the call BeginWriteAt(). |
| 226 | * \remark For backward compatibility reasons you can still call this method without the prior call to BeginWriteAt() |
| 227 | * only if this cachedsystem has been defined with one channel. Any other configuration will result in a failure. */ |
| 228 | bool Write(int pChannelIndex, FbxTime& pTime, double* pBuffer, unsigned int pPointCount, FbxStatus* pStatus=NULL); |
| 229 | |
| 230 | /** Write a sample at a given time. |
| 231 | * \param pChannelIndex The index of the animation channel, between 0 and GetChannelCount(). |
| 232 | * \param pTime Time at which the point animation must be inserted. |
| 233 | * \param pBuffer Point to the values to be copied. If the channel's data type is FloatVectorArray this buffer must be of size 3*pPointCount. |
| 234 | * \param pPointCount The number of points to write in the point cache file. |
| 235 | * \param pStatus The FbxStatus object to hold error codes. |
| 236 | * \return \c true if successful, \c false otherwise. |
| 237 | * \remark This method will fail if the time \e pTime is different from the time set using the call BeginWriteAt(). |
| 238 | * \remark For backward compatibility reasons you can still call this method without the prior call to BeginWriteAt() |
| 239 | * only if this cached system has been defined with one channel. Any other configuration will result in a failure. */ |
| 240 | bool Write(int pChannelIndex, FbxTime& pTime, float* pBuffer, unsigned int pPointCount, FbxStatus* pStatus=NULL); |
| 241 | |
| 242 | /** Write a sample at a given time. |
| 243 | * \param pChannelIndex The index of the animation channel, between 0 and GetChannelCount(). |
| 244 | * \param pTime Time at which the point animation must be inserted. |
| 245 | * \param pBuffer Point to the values to be copied. This buffer must be of size pPointCount. |
| 246 | * \param pPointCount The number of points to write in the point cache file. |
| 247 | * \param pStatus The FbxStatus object to hold error codes. |
| 248 | * \return \c true if successful, \c false otherwise. |
| 249 | * \remark This method will fail if the time \e pTime is different from the time set using the call BeginWriteAt(). |
| 250 | * \remark For backward compatibility reasons you can still call this method without the prior call to BeginWriteAt() |
| 251 | * only if this cached system has been defined with one channel. Any other configuration will result in a failure. */ |
| 252 | bool Write(int pChannelIndex, FbxTime& pTime, int* pBuffer, unsigned int pPointCount, FbxStatus* pStatus=NULL); |
| 253 | |
| 254 | /** Instruct the cache system that all the data on all the channels has been written to it for the given time (specified |
| 255 | * by the BeginWriteAt() call). The call to this method must be made after all the Write() for every channel defined. |
| 256 | * \param pStatus The FbxStatus object to hold error codes. |
| 257 | * \return \c true if successful, \c false otherwise. */ |
| 258 | bool EndWriteAt(FbxStatus* pStatus=NULL); |
| 259 | |
| 260 | /** Get the Animation Range of the specified channel. |
| 261 | * \param pChannelIndex The index of the channel. |
| 262 | * \param pTimeStart The start time of the channel's animation. |
| 263 | * \param pTimeEnd The end time of the channel's animation. |
| 264 | * \param pStatus The FbxStatus object to hold error codes. |
| 265 | * \return \c true if successful, \c false otherwise. */ |
| 266 | bool GetAnimationRange(int pChannelIndex, FbxTime &pTimeStart, FbxTime &pTimeEnd, FbxStatus* pStatus=NULL); |
| 267 | |
| 268 | /** Get the cache type. |
| 269 | * \param pFileCount The cache type. |
| 270 | * \param pStatus The FbxStatus object to hold error codes. |
| 271 | * \return \c true if successful, \c false otherwise. */ |
| 272 | bool GetCacheType(EMCFileCount& pFileCount, FbxStatus* pStatus=NULL); |
| 273 | |
| 274 | /** Get the cache channel interpretation. |
| 275 | * \param pChannelIndex The index of the animation channel, between 0 and GetChannelCount(). |
| 276 | * \param pInterpretation The channel interpretation, user-defined. |
| 277 | * \param pStatus The FbxStatus object to hold error codes. |
| 278 | * \return \c true if successful, \c false otherwise. */ |
| 279 | bool GetChannelInterpretation(int pChannelIndex, FbxString& pInterpretation, FbxStatus* pStatus=NULL); |
| 280 | |
| 281 | /** Get the cache channel sampling type. |
| 282 | * \param pChannelIndex The index of the animation channel, between 0 and GetChannelCount(). |
| 283 | * \param pSamplingType The sampling type of the channel. |
| 284 | * \param pStatus The FbxStatus object to hold error codes. |
| 285 | * \return \c true if successful, \c false otherwise. */ |
| 286 | bool GetChannelSamplingType(int pChannelIndex, EMCSamplingType& pSamplingType, FbxStatus* pStatus=NULL); |
| 287 | |
| 288 | /** Get the cache channel sampling rate, in frames per second. |
| 289 | * \param pChannelIndex The index of the animation channel, between 0 and GetChannelCount(). |
| 290 | * \param pSamplingRate The sampling rate of the channel. The channel must have a regular sampling type. |
| 291 | * \param pStatus The FbxStatus object to hold error codes. |
| 292 | * \return \c true if successful, \c false otherwise. */ |
| 293 | bool GetChannelSamplingRate(int pChannelIndex, FbxTime& pSamplingRate, FbxStatus* pStatus=NULL); |
| 294 | |
| 295 | /** Get the number of data points for a channel. |
| 296 | * \param pChannelIndex The index of the animation channel, between 0 and GetChannelCount(). |
| 297 | * \param pSampleCount Number of available samples. |
| 298 | * \param pStatus The FbxStatus object to hold error codes. |
| 299 | * \return \c true if successful, \c false otherwise. */ |
| 300 | bool GetChannelSampleCount(int pChannelIndex, unsigned int& pSampleCount, FbxStatus* pStatus=NULL); |
| 301 | |
| 302 | /** Get the number of points animated in the cache file, for a channel, for a given time. |
| 303 | * \param pChannelIndex The index of the animation channel, between 0 and GetChannelCount(). |
| 304 | * \param pTime Reference time; must be within the boundaries of the animation. |
| 305 | * \param pPointCount Number of available points. |
| 306 | * \param pStatus The FbxStatus object to hold error codes. |
| 307 | * \return \c true if successful, \c false otherwise. */ |
| 308 | bool GetChannelPointCount(int pChannelIndex, FbxTime pTime, unsigned int& pPointCount, FbxStatus* pStatus=NULL); |
| 309 | |
| 310 | /** Returns the number of cache data files. |
| 311 | * \param pStatus The FbxStatus object to hold error codes. |
| 312 | * \return The count returned does not include the main cache file, and depends on the cache type. Will return -1 if point cache support is not enabled. */ |
| 313 | int GetCacheDataFileCount(FbxStatus* pStatus=NULL) const; |
| 314 | |
| 315 | /** Get the nth cache file name. |
| 316 | * \param pIndex Index of the cache file to return; index is zero-based, and must be less than GetCacheDataFileCount(). |
| 317 | * \param pRelativeFileName Return the point cache file name, relative to the FBX File name. |
| 318 | * \param pAbsoluteFileName Return the point cache file absolute path. |
| 319 | * \param pStatus The FbxStatus object to hold error codes. |
| 320 | * \return \c true if successful, \c false otherwise. See the error management functions for error details. */ |
| 321 | bool GetCacheDataFileName(int pIndex, FbxString& pRelativeFileName, FbxString& pAbsoluteFileName, FbxStatus* pStatus=NULL); |
| 322 | |
| 323 | /** Enable multi-channel fetching. |
| 324 | * \param pMultiChannelFetching Enable/disable multi-channel fetching. When multi-channel is enabled, any load of data on a channel at a specific |
| 325 | * time will pre-fetch data from all channels, for that specific time. This can reduce disk access, and increase performance (but requires more memory). |
| 326 | * \param pStatus The FbxStatus object to hold error codes. |
| 327 | * \return \c true if successful, \c false otherwise. */ |
| 328 | bool EnableMultiChannelFetching(bool pMultiChannelFetching, FbxStatus* pStatus=NULL); |
| 329 | |
| 330 | /** Get the next time where data is stored. |
| 331 | * \param pCurTime Current time; must be within the boundaries of the animation time. |
| 332 | * \param pNextTime Next time (filled if the function is successful). |
| 333 | * \param pChannelIndex The index of the animation channel, between 0 and GetChannelCount(). If pChannel is left at -1, get the next time for any channel. |
| 334 | * \param pStatus The FbxStatus object to hold error codes. |
| 335 | * \return \c true if successful, \c false otherwise. */ |
| 336 | bool GetNextTimeWithData(FbxTime pCurTime, FbxTime& pNextTime, int pChannelIndex = -1, FbxStatus* pStatus=NULL); |
| 337 | |
| 338 | /** Get the number of data points the channel contains. |
| 339 | * \param pChannelIndex The index of the animation channel, between 0 and GetChannelCount(). |
| 340 | * \param pStatus The FbxStatus object to hold error codes. |
| 341 | * \return The number of the channel's data points. */ |
| 342 | int GetDataCount(int pChannelIndex, FbxStatus* pStatus=NULL); |
| 343 | |
| 344 | /** Get the time of the specified data point. |
| 345 | * \param pChannelIndex The index of the animation channel, between 0 and GetChannelCount(). |
| 346 | * \param pDataIndex Index of the data point. |
| 347 | * \param pTime Time of the data point (filled if the function is successful). |
| 348 | * \param pStatus The FbxStatus object to hold error codes. |
| 349 | * \return \c true if successful, \c false otherwise. */ |
| 350 | bool GetDataTime(int pChannelIndex, unsigned int pDataIndex, FbxTime& pTime, FbxStatus* pStatus=NULL); |
| 351 | //@} |
| 352 | |
| 353 | //! \name eMaxPointCacheV2 Format Specific Functions. |
| 354 | //@{ |
| 355 | /** Open a cache file for writing. |
| 356 | * \param pFrameStartOffset Start time of the animation, in frames. |
| 357 | * \param pSamplingFrameRate Number of frames per second. |
| 358 | * \param pSampleCount The number of samples to write to the file. |
| 359 | * \param pPointCount The number of points to write in the point cache file. |
| 360 | * \param pStatus The FbxStatus object to hold error codes. |
| 361 | * \return \c true if successful, \c false otherwise. See the error management functions for error details. */ |
| 362 | bool OpenFileForWrite(double pFrameStartOffset, double pSamplingFrameRate, unsigned int pSampleCount, unsigned int pPointCount, FbxStatus* pStatus=NULL); |
| 363 | |
| 364 | /** Get the number of frames of animation found in the point cache file. |
| 365 | * \param pStatus The FbxStatus object to hold error codes. |
| 366 | * \return The number of frames of animation. |
| 367 | */ |
| 368 | unsigned int GetSampleCount(FbxStatus* pStatus=NULL); |
| 369 | |
| 370 | /** Get the number of points animated in the cache file. |
| 371 | * \param pStatus The FbxStatus object to hold error codes. |
| 372 | * \return The number of points. |
| 373 | */ |
| 374 | unsigned int GetPointCount(FbxStatus* pStatus=NULL); |
| 375 | |
| 376 | /** Get the start time of the animation |
| 377 | * \param pStatus The FbxStatus object to hold error codes. |
| 378 | * \return The start time of the animation, in frames. */ |
| 379 | double GetFrameStartOffset(FbxStatus* pStatus=NULL); |
| 380 | |
| 381 | /** Read a sample at a given frame index. |
| 382 | * \param pFrameIndex The index of the animation frame, between 0 and GetSampleCount(). |
| 383 | * \param pBuffer The place where the point value will be copied. This buffer must be of size 3 * pPointCount. |
| 384 | * \param pPointCount The number of points to read from the point cache file. |
| 385 | * \param pStatus The FbxStatus object to hold error codes. |
| 386 | * \return \c true if successful, \c false otherwise. */ |
| 387 | bool Read(unsigned int pFrameIndex, double* pBuffer, unsigned int pPointCount, FbxStatus* pStatus=NULL); |
| 388 | |
| 389 | /** Write a sample at a given frame index. |
| 390 | * \param pFrameIndex The index of the animation frame. |
| 391 | * \param pBuffer Point to the values to be copied. This buffer must be of size 3 * pPointCount, as passed to the function OpenFileForWrite(). |
| 392 | * \param pStatus The FbxStatus object to hold error codes. |
| 393 | * \return \c true if successful, \c false otherwise. |
| 394 | * \remark Successive calls to Write() must use successive index. */ |
| 395 | bool Write(unsigned int pFrameIndex, double* pBuffer, FbxStatus* pStatus=NULL); |
| 396 | //@} |
| 397 | |
| 398 | //! \name File conversion Functions. |
| 399 | //@{ |
| 400 | /** Create an MC cache file from an PC2 cache file. |
| 401 | * \param pFileCount Create one file for each frame of animation, or one file for all the frames. |
| 402 | * \param pSamplingFrameRate Number of frames per second used to re-sample the point animation. |
| 403 | * \param pBinaryFormat Binary format type (32 bit=eMCC or 64bit=eMCX) |
| 404 | * \param pStatus The FbxStatus object to hold error codes. |
| 405 | * \return \c true if successful, \c false otherwise. |
| 406 | * \remark The created point cache file will be located in the _fpc folder associate with the FBX file. */ |
| 407 | bool ConvertFromPC2ToMC(EMCFileCount pFileCount, double pSamplingFrameRate, EMCBinaryFormat pBinaryFormat, FbxStatus* pStatus=NULL); |
| 408 | |
| 409 | /** Create a PC2 cache file from an MC cache file. |
| 410 | * \param pSamplingFrameRate Number of frames per second to re-sample the point animation. |
| 411 | * \param pChannelIndex Index of the channel of animation to read from. |
| 412 | * \param pStatus The FbxStatus object to hold error codes. |
| 413 | * \return \c true if successful, \c false otherwise. |
| 414 | * \remark The created point cache file will be located in the _fpc folder associate with the FBX file. */ |
| 415 | bool ConvertFromMCToPC2(double pSamplingFrameRate, unsigned int pChannelIndex, FbxStatus* pStatus=NULL); |
| 416 | //@} |
| 417 | |
| 418 | /***************************************************************************************************************************** |
| 419 | ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** |
| 420 | *****************************************************************************************************************************/ |
| 421 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 422 | enum EOpenFlag |
| 423 | { |
| 424 | eReadOnly, |
| 425 | eWriteOnly |
| 426 | }; |
| 427 | |
| 428 | protected: |
| 429 | bool OpenFile(EOpenFlag pFlag, EMCFileCount pFileCount, double pSamplingFrameRate, const char* pChannelName, const char* pInterpretation, unsigned int pSampleCount, unsigned int pPointCount, double pFrameStartOffset, FbxStatus* pStatus, EMCDataType pMCDataType = eDoubleVectorArray, EMCBinaryFormat pBinaryFormat = eMCX); |
| 430 | |
| 431 | virtual void Construct( const FbxObject* pFrom ); |
| 432 | virtual void ConstructProperties(bool pForceSet); |
| 433 | virtual void Destruct(bool pRecursive); |
| 434 | |
| 435 | FbxCache_internal* mData; |
| 436 | |
| 437 | private: |
| 438 | bool AllocateReadBuffer(unsigned int pTypeSize, unsigned int pTypeLength, unsigned int pLength, bool pAllocateConvertBuffer); |
| 439 | bool ReadMayaCache(float** pBuffer, unsigned int& pBufferLength, const FbxTime& pTime, unsigned int pChannel); |
| 440 | bool ReadMaxCache(float** pBuffer, unsigned int& pBufferLength, const FbxTime& pTime); |
| 441 | bool ReadAlembicCache(float** pBuffer, unsigned int& pBufferLength, const FbxTime& pTime, unsigned int pChannel); |
| 442 | |
| 443 | FbxPropertyT<FbxString> CacheFile; |
| 444 | FbxPropertyT<FbxString> CacheFileAbsolutePath; |
| 445 | FbxPropertyT<FbxEnum> CacheFileType; |
| 446 | |
| 447 | void* mReadBuffer; |
| 448 | unsigned int mReadBufferLength; |
| 449 | unsigned int mReadBufferSize; |
| 450 | unsigned int mReadTypeSize; |
| 451 | unsigned int mReadTypeLength; |
| 452 | unsigned int mReadLength; |
| 453 | void* mConvertBuffer; |
| 454 | #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ |
| 455 | }; |
| 456 | |
| 457 | inline EFbxType FbxTypeOf(const FbxCache::EFileFormat&){ return eFbxEnum; } |
| 458 | |
| 459 | #include <fbxsdk/fbxsdk_nsend.h> |
| 460 | |
| 461 | #endif /* _FBXSDK_SCENE_GEOMETRY_CACHE_H_ */ |
| 462 | |