FBX SDK Reference Guide: kfbxpose.h Source File
Go to the documentation of this file.
00001 
00004 #ifndef _FBXSDK_POSE_H_
00005 #define _FBXSDK_POSE_H_
00006 
00007 /**************************************************************************************
00008 
00009  Copyright ?2001 - 2008 Autodesk, Inc. and/or its licensors.
00010  All Rights Reserved.
00011 
00012  The coded instructions, statements, computer programs, and/or related material 
00013  (collectively the "Data") in these files contain unpublished information 
00014  proprietary to Autodesk, Inc. and/or its licensors, which is protected by 
00015  Canada and United States of America federal copyright law and by international 
00016  treaties. 
00017  
00018  The Data may not be disclosed or distributed to third parties, in whole or in
00019  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00020 
00021  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00022  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00023  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00024  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, 
00025  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. 
00026  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00027  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. 
00028  
00029  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00030  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00031  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00032  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00033  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00034  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00035  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00036  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00037  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00038  OR DAMAGE. 
00039 
00040 **************************************************************************************/
00041 
00042 #include <kaydaradef.h>
00043 #ifndef KFBX_DLL
00044     #define KFBX_DLL K_DLLIMPORT
00045 #endif
00046 
00047 #include <kaydara.h>
00048 
00049 #include <kfbxplugins/kfbxobject.h>
00050 #include <kfbxplugins/kfbxgroupname.h>
00051 
00052 #include <klib/kstring.h>
00053 #include <klib/karrayul.h>
00054 #include <klib/kname.h>
00055 #include <kfbxmath/kfbxmatrix.h>
00056 
00057 #include <fbxfilesdk_nsbegin.h>
00058 
00062 typedef struct
00063 {
00064     KFbxMatrix  mMatrix;        
00065     bool        mMatrixIsLocal; 
00066     KFbxNode*   mNode;          
00067 
00068 } KFbxPoseInfo;
00069 
00070 class KFbxScene;
00071 class KFbxUserNotification;
00072 
00126 class KFBX_DLL KFbxPose : public KFbxObject
00127 {
00128     KFBXOBJECT_DECLARE(KFbxPose,KFbxObject);
00129 public:
00133         void SetIsBindPose(bool pIsBindPose);
00134 
00138           bool IsBindPose() const     { return mType == 'b'; }
00139 
00143           bool IsRestPose()     { return mType == 'r'; }
00144 
00148           int GetCount() const { return mPoseInfo.GetCount(); }
00149 
00157           int Add(KFbxNode* pNode, KFbxMatrix& pMatrix, bool pLocalMatrix = false, bool pMultipleBindPose = true);
00158 
00162           void Remove(int pIndex);
00163 
00169           KName GetNodeName(int pIndex) const;
00170 
00177           KFbxNode* GetNode(int pIndex) const;
00178 
00185           const KFbxMatrix& GetMatrix(int pIndex)       const;
00186 
00192           bool IsLocalMatrix(int pIndex);
00193 
00194         
00199           enum KNameComponent {
00200               INITIALNAME_COMPONENT = 1,
00201               CURRENTNAME_COMPONENT = 2,
00202               ALL_NAME_COMPONENTS   = 3
00203           };
00204 
00211           int Find(KName& pNodeName, char pCompareWhat = ALL_NAME_COMPONENTS);
00212 
00218           int Find(KFbxNode* pNode);
00219 
00220 
00222 
00226 
00237         static bool GetPosesContaining(KFbxSdkManager& pManager, KFbxNode* pNode,
00238                                        KArrayTemplate<KFbxPose*>& pPoseList,
00239                                        KArrayTemplate<int>& pIndex);
00240 
00250         static bool GetPosesContaining(KFbxScene* pScene, KFbxNode* pNode,
00251                                        KArrayTemplate<KFbxPose*>& pPoseList,
00252                                        KArrayTemplate<int>& pIndex);
00253 
00264         static bool GetBindPoseContaining(KFbxSdkManager& pManager, KFbxNode* pNode,
00265                                           KArrayTemplate<KFbxPose*>& pPoseList,
00266                                           KArrayTemplate<int>& pIndex);
00267 
00277         static bool GetBindPoseContaining(KFbxScene* pScene, KFbxNode* pNode,
00278                                           KArrayTemplate<KFbxPose*>& pPoseList,
00279                                           KArrayTemplate<int>& pIndex);
00280 
00291         static bool GetRestPoseContaining(KFbxSdkManager& pManager, KFbxNode* pNode,
00292                                           KArrayTemplate<KFbxPose*>& pPoseList,
00293                                           KArrayTemplate<int>& pIndex);
00294 
00304         static bool GetRestPoseContaining(KFbxScene* pScene, KFbxNode* pNode,
00305                                           KArrayTemplate<KFbxPose*>& pPoseList,
00306                                           KArrayTemplate<int>& pIndex);
00307 
00324         bool IsValidBindPose(KFbxNode* pRoot, double pMatrixCmpTolerance=0.0001);
00325 
00337         bool IsValidBindPoseVerbose(KFbxNode* pRoot,
00338                                     KArrayTemplate<KFbxNode*>& pMissingAncestors,
00339                                     KArrayTemplate<KFbxNode*>& pMissingDeformers,
00340                                     KArrayTemplate<KFbxNode*>& pMissingDeformersAncestors,
00341                                     KArrayTemplate<KFbxNode*>& pWrongMatrices,
00342                                     double pMatrixCmpTolerance=0.0001);
00343 
00352         bool IsValidBindPoseVerbose(KFbxNode* pRoot,
00353                                     KFbxUserNotification* pUserNotification,
00354                                     double pMatrixCmpTolerance=0.0001);
00355 
00360 
00364         KError& GetError();
00365 
00370         typedef enum
00371         {
00372             eERROR,
00373             eERROR_VALIDBINDPOSE_FAILURE_INVALIDOBJECT,
00374             eERROR_VALIDBINDPOSE_FAILURE_INVALIDROOT,
00375             eERROR_VALIDBINDPOSE_FAILURE_NOTALLANCESTORS_NODES,
00376             eERROR_VALIDBINDPOSE_FAILURE_NOTALLDEFORMING_NODES,
00377             eERROR_VALIDBINDPOSE_FAILURE_NOTALLANCESTORS_DEFNODES,
00378             eERROR_VALIDBINDPOSE_FAILURE_RELATIVEMATRIX,
00379             eERROR_COUNT
00380         } EError;
00381 
00385         EError GetLastErrorID() const;
00386 
00390         const char* GetLastErrorString() const;
00391 
00393 
00394 
00395 
00397 //
00398 //  WARNING!
00399 //
00400 //  Anything beyond these lines may not be documented accurately and is
00401 //  subject to change without notice.
00402 //
00404 
00405 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00406 
00407     // Clone
00408     virtual KFbxObject* Clone(KFbxObject* pContainer, KFbxObject::ECloneType pCloneType) const;
00409 
00410 protected:
00411 
00416     KFbxPose(KFbxSdkManager& pManager, char const* pName);
00417 
00421     ~KFbxPose();
00422 
00423     virtual void Destruct(bool pRecursive, bool pDependents);
00424 
00425     // From KFbxObject
00426     virtual KString     GetTypeName() const;
00427     virtual KStringList GetTypeFlags() const;
00428 
00429     KError mError;
00430 
00432     KFbxPose& operator=(KFbxPose const& pPose);
00433 
00434     // returns false if pNode is already inserted in the list and the current matrix
00435     // is different from the stored one. Also, if this pose is a rest pose, check if
00436     // pNode belongs to other BindPoses (accessed through the scene pointer).
00437     // pos will contains the index of the KFbxPoseInfo if the parameters are already
00438     // stored in this object.
00439     //
00440     bool ValidateParams(KFbxNode* pNode, KFbxMatrix& pMatrix, int& pPos);
00441 
00442     // Check only on this object's list.
00443     bool LocalValidateParams(KFbxNode* pNode, KFbxMatrix& pMatrix, int& pPos);
00444 
00445     static bool GetSpecificPoseContaining(
00446         int poseType,
00447         KFbxScene* pScene, KFbxNode* pNode,
00448         KArrayTemplate<KFbxPose*>& pPoseList,
00449         KArrayTemplate<int>& pIndex);
00450 
00451     friend class KFbxReaderFbx;
00452     friend class KFbxWriterFbx6;
00453 
00454 private:
00455     // don't give public access to the info otherwise we will loose the ability
00456     // to maintain data integrity.
00457     KFbxPoseInfo* GetItem(int pIndex);
00458 
00459 private:
00460     char        mType;
00461 
00462     KArrayTemplate<KFbxPoseInfo*> mPoseInfo;
00463 
00464     bool IsValidBindPoseCommon(KFbxNode* pRoot,
00465                                 KArrayTemplate<KFbxNode*>* pMissingAncestors,
00466                                 KArrayTemplate<KFbxNode*>* pMissingDeformers,
00467                                 KArrayTemplate<KFbxNode*>* pMissingDeformersAncestors,
00468                                 KArrayTemplate<KFbxNode*>* pWrongMatrices,
00469                                 double pMatrixCmpTolerance=0.0001);
00470 
00471 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00472 
00473 };
00474 
00475 typedef KFbxPose* HKFbxPose;
00476 
00477 #include <fbxfilesdk_nsend.h>
00478 
00479 #endif // #ifndef _FBXSDK_POSE_H_
00480 
00481