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 {
00059     KFbxMatrix  mMatrix;
00061     bool        mMatrixIsLocal;
00063     KFbxNode*   mNode;
00064 
00065 } KFbxPoseInfo;
00066 
00067 class KFbxAnimStack;
00068 class KFbxScene;
00069 class KFbxUserNotification;
00070 class KFbxPose;
00071 
00072 typedef KArrayTemplate<KFbxNode*> NodeList;
00073 typedef KArrayTemplate<KFbxPose*> PoseList;
00074 typedef KArrayTemplate<KFbxPoseInfo*> PoseInfoList;
00075 
00129 class KFBX_DLL KFbxPose : public KFbxObject
00130 {
00131     KFBXOBJECT_DECLARE(KFbxPose,KFbxObject);
00132 
00133 public:
00137     void SetIsBindPose(bool pIsBindPose);
00138 
00142     bool IsBindPose() const { return mType == 'b'; }
00143 
00147     bool IsRestPose() const { return mType == 'r'; }
00148 
00152     int GetCount() const { return mPoseInfo.GetCount(); }
00153 
00161     int Add(KFbxNode* pNode, const KFbxMatrix& pMatrix, bool pLocalMatrix = false, bool pMultipleBindPose = true);
00162 
00166     void Remove(int pIndex);
00167 
00173     KName GetNodeName(int pIndex) const;
00174 
00181     KFbxNode* GetNode(int pIndex) const;
00182 
00189     const KFbxMatrix& GetMatrix(int pIndex)       const;
00190 
00196     bool IsLocalMatrix(int pIndex) const;
00197 
00205         enum KNameComponent {
00206             INITIALNAME_COMPONENT = 1,  
00207             CURRENTNAME_COMPONENT = 2,  
00208             ALL_NAME_COMPONENTS   = 3   
00209         };
00210 
00216         int Find(const KName& pNodeName, char pCompareWhat = ALL_NAME_COMPONENTS) const;
00217 
00222         int Find(const KFbxNode* pNode) const;
00224 
00239         static bool GetPosesContaining(KFbxSdkManager& pManager, KFbxNode* pNode, PoseList& pPoseList, KArrayTemplate<int>& pIndex);
00240 
00250         static bool GetPosesContaining(KFbxScene* pScene, KFbxNode* pNode, PoseList& pPoseList, KArrayTemplate<int>& pIndex);
00251 
00262         static bool GetBindPoseContaining(KFbxSdkManager& pManager, KFbxNode* pNode, PoseList& pPoseList, KArrayTemplate<int>& pIndex);
00263 
00273         static bool GetBindPoseContaining(KFbxScene* pScene, KFbxNode* pNode, PoseList& pPoseList, KArrayTemplate<int>& pIndex);
00274 
00285         static bool GetRestPoseContaining(KFbxSdkManager& pManager, KFbxNode* pNode, PoseList& pPoseList, KArrayTemplate<int>& pIndex);
00286 
00296         static bool GetRestPoseContaining(KFbxScene* pScene, KFbxNode* pNode, PoseList& pPoseList, KArrayTemplate<int>& pIndex);
00297 
00314         bool IsValidBindPose(KFbxNode* pRoot, double pMatrixCmpTolerance=0.0001);
00315 
00327         bool IsValidBindPoseVerbose(KFbxNode* pRoot, NodeList& pMissingAncestors, NodeList& pMissingDeformers, NodeList& pMissingDeformersAncestors, NodeList& pWrongMatrices, double pMatrixCmpTolerance=0.0001);
00328 
00337         bool IsValidBindPoseVerbose(KFbxNode* pRoot, KFbxUserNotification* pUserNotification, double pMatrixCmpTolerance=0.0001);
00338 
00346         KError& GetError();
00347 
00352         typedef enum
00353         {
00354             eERROR,
00355             eERROR_VALIDBINDPOSE_FAILURE_INVALIDOBJECT,
00356             eERROR_VALIDBINDPOSE_FAILURE_INVALIDROOT,
00357             eERROR_VALIDBINDPOSE_FAILURE_NOTALLANCESTORS_NODES,
00358             eERROR_VALIDBINDPOSE_FAILURE_NOTALLDEFORMING_NODES,
00359             eERROR_VALIDBINDPOSE_FAILURE_NOTALLANCESTORS_DEFNODES,
00360             eERROR_VALIDBINDPOSE_FAILURE_RELATIVEMATRIX,
00361             eERROR_COUNT
00362         } EError;
00363 
00367         EError GetLastErrorID() const;
00368 
00372         const char* GetLastErrorString() const;
00374 
00376 //
00377 //  WARNING!
00378 //
00379 //  Anything beyond these lines may not be documented accurately and is
00380 //  subject to change without notice.
00381 //
00383 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00384 protected:
00385     KFbxPose(KFbxSdkManager& pManager, char const* pName);
00386 
00387     virtual KFbxObject& Copy(const KFbxObject& pObject);
00388     virtual void        Destruct(bool pRecursive, bool pDependents);
00389     virtual const char* GetTypeName() const;
00390 
00391     //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
00392     //pNode belongs to other BindPoses (accessed through the scene pointer). pPos will contains the index of the KFbxPoseInfo if the parameters are already stored in this object.
00393     bool                ValidateParams(const KFbxNode* pNode, const KFbxMatrix& pMatrix, int& pPos);
00394 
00395     bool                LocalValidateParams(const KFbxNode* pNode, const KFbxMatrix& pMatrix, int& pPos);
00396     static bool         GetSpecificPoseContaining(int poseType, KFbxScene* pScene, KFbxNode* pNode, PoseList& pPoseList, KArrayTemplate<int>& pIndex);
00397 
00398     KError              mError;
00399 
00400 private:
00401     KFbxPoseInfo*       GetItem(int pIndex) const;
00402     bool                IsValidBindPoseCommon(KFbxNode* pRoot, NodeList* pMissingAncestors, NodeList* pMissingDeformers, NodeList* pMissingDeformersAncestors, NodeList* pWrongMatrices, double pMatrixCmpTolerance=0.0001);
00403 
00404     char                mType;
00405     PoseInfoList        mPoseInfo;
00406 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00407 };
00408 
00409 typedef KFbxPose* HKFbxPose;
00410 
00411 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00412 
00413 #endif // FBXFILESDK_KFBXPLUGINS_KFBXPOSE_H
00414