fbxpose.h

Go to the documentation of this file.
00001 /****************************************************************************************
00002  
00003    Copyright (C) 2012 Autodesk, Inc.
00004    All rights reserved.
00005  
00006    Use of this software is subject to the terms of the Autodesk license agreement
00007    provided at the time of installation or download, or which otherwise accompanies
00008    this software in either electronic or hard copy form.
00009  
00010 ****************************************************************************************/
00011 
00013 #ifndef _FBXSDK_SCENE_POSE_H_
00014 #define _FBXSDK_SCENE_POSE_H_
00015 
00016 #include <fbxsdk/fbxsdk_def.h>
00017 
00018 #include <fbxsdk/core/fbxobject.h>
00019 #include <fbxsdk/core/base/fbxstring.h>
00020 #include <fbxsdk/core/base/fbxarray.h>
00021 #include <fbxsdk/core/base/fbxerror.h>
00022 #include <fbxsdk/core/math/fbxmatrix.h>
00023 #include <fbxsdk/scene/fbxgroupname.h>
00024 #include <fbxsdk/utils/fbxnamehandler.h>
00025 
00026 #include <fbxsdk/fbxsdk_nsbegin.h>
00027 
00031 typedef struct
00032 {
00034     FbxMatrix  mMatrix;
00036     bool        mMatrixIsLocal;
00038     FbxNode*   mNode;
00039 
00040 } FbxPoseInfo;
00041 
00042 class FbxAnimStack;
00043 class FbxScene;
00044 class FbxUserNotification;
00045 class FbxPose;
00046 
00047 typedef FbxArray<FbxNode*> NodeList;
00048 typedef FbxArray<FbxPose*> PoseList;
00049 typedef FbxArray<FbxPoseInfo*> PoseInfoList;
00050 
00104 class FBXSDK_DLL FbxPose : public FbxObject
00105 {
00106     FBXSDK_OBJECT_DECLARE(FbxPose,FbxObject);
00107 
00108 public:
00112     void SetIsBindPose(bool pIsBindPose);
00113 
00117     bool IsBindPose() const { return mType == 'b'; }
00118 
00122     bool IsRestPose() const { return mType == 'r'; }
00123 
00127     int GetCount() const { return mPoseInfo.GetCount(); }
00128 
00136     int Add(FbxNode* pNode, const FbxMatrix& pMatrix, bool pLocalMatrix = false, bool pMultipleBindPose = true);
00137 
00141     void Remove(int pIndex);
00142 
00148     FbxNameHandler GetNodeName(int pIndex) const;
00149 
00156     FbxNode* GetNode(int pIndex) const;
00157 
00164     const FbxMatrix& GetMatrix(int pIndex)       const;
00165 
00171     bool IsLocalMatrix(int pIndex) const;
00172 
00180         enum ENameComponent
00181         {
00182             eInitialNameComponent = 1,  
00183             eCurrentNameComponent = 2,  
00184             eAllNameComponents = 3      
00185         };
00186 
00192         int Find(const FbxNameHandler& pNodeName, char pCompareWhat = eAllNameComponents) const;
00193 
00198         int Find(const FbxNode* pNode) const;
00200 
00215         static bool GetPosesContaining(FbxManager& pManager, FbxNode* pNode, PoseList& pPoseList, FbxArray<int>& pIndex);
00216 
00226         static bool GetPosesContaining(FbxScene* pScene, FbxNode* pNode, PoseList& pPoseList, FbxArray<int>& pIndex);
00227 
00238         static bool GetBindPoseContaining(FbxManager& pManager, FbxNode* pNode, PoseList& pPoseList, FbxArray<int>& pIndex);
00239 
00249         static bool GetBindPoseContaining(FbxScene* pScene, FbxNode* pNode, PoseList& pPoseList, FbxArray<int>& pIndex);
00250 
00261         static bool GetRestPoseContaining(FbxManager& pManager, FbxNode* pNode, PoseList& pPoseList, FbxArray<int>& pIndex);
00262 
00272         static bool GetRestPoseContaining(FbxScene* pScene, FbxNode* pNode, PoseList& pPoseList, FbxArray<int>& pIndex);
00273 
00290         bool IsValidBindPose(FbxNode* pRoot, double pMatrixCmpTolerance=0.0001);
00291 
00303         bool IsValidBindPoseVerbose(FbxNode* pRoot, NodeList& pMissingAncestors, NodeList& pMissingDeformers, NodeList& pMissingDeformersAncestors, NodeList& pWrongMatrices, double pMatrixCmpTolerance=0.0001);
00304 
00313         bool IsValidBindPoseVerbose(FbxNode* pRoot, FbxUserNotification* pUserNotification, double pMatrixCmpTolerance=0.0001);
00314 
00322         FbxError& GetError();
00323 
00328         enum EErrorCode
00329         {
00330             eError,
00331             eInvalidObject,
00332             eInvalidRoot,
00333             eNotAllAncestorsNodes,
00334             eNotAllDeformingNodes,
00335             eNotAllAncestorsDefinitionNodes,
00336             eRelativeMatrix,
00337             eErrorCount
00338         };
00339 
00343         EErrorCode GetLastErrorID() const;
00344 
00348         const char* GetLastErrorString() const;
00350 
00352 //
00353 //  WARNING!
00354 //
00355 //  Anything beyond these lines may not be documented accurately and is
00356 //  subject to change without notice.
00357 //
00359 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00360 protected:
00361     FbxPose(FbxManager& pManager, char const* pName);
00362 
00363     virtual FbxObject&  Copy(const FbxObject& pObject);
00364     virtual void        Destruct(bool pRecursive, bool pDependents);
00365     virtual const char* GetTypeName() const;
00366 
00367     //Returns false if pNode is already inserted in the list and the current matrix is different from the stored one. Also, if this pose is a rest pose, check if
00368     //pNode belongs to other BindPoses (accessed through the scene pointer). pPos will contains the index of the FbxPoseInfo if the parameters are already stored in this object.
00369     bool                ValidateParams(const FbxNode* pNode, const FbxMatrix& pMatrix, int& pPos);
00370 
00371     bool                LocalValidateParams(const FbxNode* pNode, const FbxMatrix& pMatrix, int& pPos);
00372     static bool         GetSpecificPoseContaining(int poseType, FbxScene* pScene, FbxNode* pNode, PoseList& pPoseList, FbxArray<int>& pIndex);
00373 
00374     FbxError                mError;
00375 
00376 private:
00377     FbxPoseInfo*        GetItem(int pIndex) const;
00378     bool                IsValidBindPoseCommon(FbxNode* pRoot, NodeList* pMissingAncestors, NodeList* pMissingDeformers, NodeList* pMissingDeformersAncestors, NodeList* pWrongMatrices, double pMatrixCmpTolerance=0.0001);
00379 
00380     char                mType;
00381     PoseInfoList        mPoseInfo;
00382 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00383 };
00384 
00385 #include <fbxsdk/fbxsdk_nsend.h>
00386 
00387 #endif /* _FBXSDK_SCENE_POSE_H_ */