kfbxpose.h

Go to the documentation of this file.
00001 
00004 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXPOSE_H
00005 #define FBXFILESDK_KFBXPLUGINS_KFBXPOSE_H
00006 
00007 /**************************************************************************************
00008 
00009  Copyright (C) 2001 - 2010 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 #include <fbxfilesdk/fbxfilesdk_def.h>
00042 
00043 #include <fbxfilesdk/kfbxplugins/kfbxobject.h>
00044 #include <fbxfilesdk/kfbxplugins/kfbxgroupname.h>
00045 
00046 #include <fbxfilesdk/components/kbaselib/klib/kstring.h>
00047 #include <fbxfilesdk/components/kbaselib/klib/karrayul.h>
00048 #include <fbxfilesdk/components/kbaselib/klib/kname.h>
00049 #include <fbxfilesdk/kfbxmath/kfbxmatrix.h>
00050 
00051 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00052 
00056 typedef struct
00057 {
00058     KFbxMatrix  mMatrix;        
00059     bool        mMatrixIsLocal; 
00060     KFbxNode*   mNode;          
00061 
00062 } KFbxPoseInfo;
00063 
00064 class KFbxAnimStack;
00065 class KFbxScene;
00066 class KFbxUserNotification;
00067 
00121 class KFBX_DLL KFbxPose : public KFbxObject
00122 {
00123     KFBXOBJECT_DECLARE(KFbxPose,KFbxObject);
00124 public:
00128         void SetIsBindPose(bool pIsBindPose);
00129 
00133           bool IsBindPose() const     { return mType == 'b'; }
00134 
00138           bool IsRestPose() const     { return mType == 'r'; }
00139 
00143           int GetCount() const { return mPoseInfo.GetCount(); }
00144 
00153           int Add(KFbxNode* pNode, KFbxMatrix& pMatrix, bool pLocalMatrix = false, bool pMultipleBindPose = true);
00154 
00158           void Remove(int pIndex);
00159 
00165           KName GetNodeName(int pIndex) const;
00166 
00173           KFbxNode* GetNode(int pIndex) const;
00174 
00181           const KFbxMatrix& GetMatrix(int pIndex)       const;
00182 
00188           bool IsLocalMatrix(int pIndex) const;
00189 
00190         
00198           enum KNameComponent {
00199               INITIALNAME_COMPONENT = 1,  
00200               CURRENTNAME_COMPONENT = 2,  
00201               ALL_NAME_COMPONENTS   = 3   
00202           };
00203 
00210           int Find(const KName& pNodeName, char pCompareWhat = ALL_NAME_COMPONENTS) const;
00211 
00217           int Find(const KFbxNode* pNode) const;
00218 
00219 
00221 
00225 
00236         static bool GetPosesContaining(KFbxSdkManager& pManager, KFbxNode* pNode,
00237                                        KArrayTemplate<KFbxPose*>& pPoseList,
00238                                        KArrayTemplate<int>& pIndex);
00239 
00249         static bool GetPosesContaining(KFbxScene* pScene, KFbxNode* pNode,
00250                                        KArrayTemplate<KFbxPose*>& pPoseList,
00251                                        KArrayTemplate<int>& pIndex);
00252 
00263         static bool GetBindPoseContaining(KFbxSdkManager& pManager, KFbxNode* pNode,
00264                                           KArrayTemplate<KFbxPose*>& pPoseList,
00265                                           KArrayTemplate<int>& pIndex);
00266 
00276         static bool GetBindPoseContaining(KFbxScene* pScene, KFbxNode* pNode,
00277                                           KArrayTemplate<KFbxPose*>& pPoseList,
00278                                           KArrayTemplate<int>& pIndex);
00279 
00290         static bool GetRestPoseContaining(KFbxSdkManager& pManager, KFbxNode* pNode,
00291                                           KArrayTemplate<KFbxPose*>& pPoseList,
00292                                           KArrayTemplate<int>& pIndex);
00293 
00303         static bool GetRestPoseContaining(KFbxScene* pScene, KFbxNode* pNode,
00304                                           KArrayTemplate<KFbxPose*>& pPoseList,
00305                                           KArrayTemplate<int>& pIndex);
00306 
00323         bool IsValidBindPose(KFbxNode* pRoot, double pMatrixCmpTolerance=0.0001);
00324 
00336         bool IsValidBindPoseVerbose(KFbxNode* pRoot,
00337                                     KArrayTemplate<KFbxNode*>& pMissingAncestors,
00338                                     KArrayTemplate<KFbxNode*>& pMissingDeformers,
00339                                     KArrayTemplate<KFbxNode*>& pMissingDeformersAncestors,
00340                                     KArrayTemplate<KFbxNode*>& pWrongMatrices,
00341                                     double pMatrixCmpTolerance=0.0001);
00342 
00351         bool IsValidBindPoseVerbose(KFbxNode* pRoot,
00352                                     KFbxUserNotification* pUserNotification,
00353                                     double pMatrixCmpTolerance=0.0001);
00354 
00359 
00363         KError& GetError();
00364 
00369         typedef enum
00370         {
00371             eERROR,
00372             eERROR_VALIDBINDPOSE_FAILURE_INVALIDOBJECT,
00373             eERROR_VALIDBINDPOSE_FAILURE_INVALIDROOT,
00374             eERROR_VALIDBINDPOSE_FAILURE_NOTALLANCESTORS_NODES,
00375             eERROR_VALIDBINDPOSE_FAILURE_NOTALLDEFORMING_NODES,
00376             eERROR_VALIDBINDPOSE_FAILURE_NOTALLANCESTORS_DEFNODES,
00377             eERROR_VALIDBINDPOSE_FAILURE_RELATIVEMATRIX,
00378             eERROR_COUNT
00379         } EError;
00380 
00384         EError GetLastErrorID() const;
00385 
00389         const char* GetLastErrorString() const;
00390 
00392 
00393 
00394 
00396 //
00397 //  WARNING!
00398 //
00399 //  Anything beyond these lines may not be documented accurately and is
00400 //  subject to change without notice.
00401 //
00403 
00404 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00405 
00406     // Clone
00407     virtual KFbxObject* Clone(KFbxObject* pContainer, KFbxObject::ECloneType pCloneType) const;
00408 
00409 protected:
00410 
00415     KFbxPose(KFbxSdkManager& pManager, char const* pName);
00416 
00417     virtual void Destruct(bool pRecursive, bool pDependents);
00418 
00419     // From KFbxObject
00420     virtual KString     GetTypeName() const;
00421 
00422     KError mError;
00423 
00424     // returns false if pNode is already inserted in the list and the current matrix
00425     // is different from the stored one. Also, if this pose is a rest pose, check if
00426     // pNode belongs to other BindPoses (accessed through the scene pointer).
00427     // pos will contains the index of the KFbxPoseInfo if the parameters are already
00428     // stored in this object.
00429     //
00430     bool ValidateParams(const KFbxNode* pNode, const KFbxMatrix& pMatrix, int& pPos);
00431 
00432     // Check only on this object's list.
00433     bool LocalValidateParams(const KFbxNode* pNode, const KFbxMatrix& pMatrix, int& pPos);
00434 
00435     static bool GetSpecificPoseContaining(
00436         int poseType,
00437         KFbxScene* pScene, KFbxNode* pNode,
00438         KArrayTemplate<KFbxPose*>& pPoseList,
00439         KArrayTemplate<int>& pIndex);
00440 
00441 private:
00442     // don't give public access to the info otherwise we will loose the ability
00443     // to maintain data integrity.
00444     KFbxPoseInfo* GetItem(int pIndex) const;
00445 
00446 private:
00447     char        mType;
00448 
00449     KArrayTemplate<KFbxPoseInfo*> mPoseInfo;
00450 
00451     bool IsValidBindPoseCommon(KFbxNode* pRoot,
00452                                 KArrayTemplate<KFbxNode*>* pMissingAncestors,
00453                                 KArrayTemplate<KFbxNode*>* pMissingDeformers,
00454                                 KArrayTemplate<KFbxNode*>* pMissingDeformersAncestors,
00455                                 KArrayTemplate<KFbxNode*>* pWrongMatrices,
00456                                 double pMatrixCmpTolerance=0.0001);
00457 
00458 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00459 
00460 };
00461 
00462 typedef KFbxPose* HKFbxPose;
00463 
00464 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00465 
00466 #endif // FBXFILESDK_KFBXPLUGINS_KFBXPOSE_H
00467