FBX SDK Reference Guide: kfbxpose.h Source File
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 © 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 <fbxfilesdk/components/kbaselib/kaydaradef_h.h>
00043 #include <fbxfilesdk/components/kbaselib/kaydara.h>
00044 
00045 #include <fbxfilesdk/kfbxplugins/kfbxobject.h>
00046 #include <fbxfilesdk/kfbxplugins/kfbxgroupname.h>
00047 
00048 #include <fbxfilesdk/components/kbaselib/klib/kstring.h>
00049 #include <fbxfilesdk/components/kbaselib/klib/karrayul.h>
00050 #include <fbxfilesdk/components/kbaselib/klib/kname.h>
00051 #include <fbxfilesdk/kfbxmath/kfbxmatrix.h>
00052 
00053 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00054 
00058 typedef struct
00059 {
00060     KFbxMatrix  mMatrix;        
00061     bool        mMatrixIsLocal; 
00062     KFbxNode*   mNode;          
00063 
00064 } KFbxPoseInfo;
00065 
00066 class KFbxScene;
00067 class KFbxUserNotification;
00068 
00122 class KFBX_DLL KFbxPose : public KFbxObject
00123 {
00124     KFBXOBJECT_DECLARE(KFbxPose,KFbxObject);
00125 public:
00129         void SetIsBindPose(bool pIsBindPose);
00130 
00134           bool IsBindPose() const     { return mType == 'b'; }
00135 
00139           bool IsRestPose()     { return mType == 'r'; }
00140 
00144           int GetCount() const { return mPoseInfo.GetCount(); }
00145 
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);
00189 
00190         
00195           enum KNameComponent {
00196               INITIALNAME_COMPONENT = 1,
00197               CURRENTNAME_COMPONENT = 2,
00198               ALL_NAME_COMPONENTS   = 3
00199           };
00200 
00207           int Find(KName& pNodeName, char pCompareWhat = ALL_NAME_COMPONENTS);
00208 
00214           int Find(KFbxNode* pNode);
00215 
00216 
00218 
00222 
00233         static bool GetPosesContaining(KFbxSdkManager& pManager, KFbxNode* pNode,
00234                                        KArrayTemplate<KFbxPose*>& pPoseList,
00235                                        KArrayTemplate<int>& pIndex);
00236 
00246         static bool GetPosesContaining(KFbxScene* pScene, KFbxNode* pNode,
00247                                        KArrayTemplate<KFbxPose*>& pPoseList,
00248                                        KArrayTemplate<int>& pIndex);
00249 
00260         static bool GetBindPoseContaining(KFbxSdkManager& pManager, KFbxNode* pNode,
00261                                           KArrayTemplate<KFbxPose*>& pPoseList,
00262                                           KArrayTemplate<int>& pIndex);
00263 
00273         static bool GetBindPoseContaining(KFbxScene* pScene, KFbxNode* pNode,
00274                                           KArrayTemplate<KFbxPose*>& pPoseList,
00275                                           KArrayTemplate<int>& pIndex);
00276 
00287         static bool GetRestPoseContaining(KFbxSdkManager& pManager, KFbxNode* pNode,
00288                                           KArrayTemplate<KFbxPose*>& pPoseList,
00289                                           KArrayTemplate<int>& pIndex);
00290 
00300         static bool GetRestPoseContaining(KFbxScene* pScene, KFbxNode* pNode,
00301                                           KArrayTemplate<KFbxPose*>& pPoseList,
00302                                           KArrayTemplate<int>& pIndex);
00303 
00320         bool IsValidBindPose(KFbxNode* pRoot, double pMatrixCmpTolerance=0.0001);
00321 
00333         bool IsValidBindPoseVerbose(KFbxNode* pRoot,
00334                                     KArrayTemplate<KFbxNode*>& pMissingAncestors,
00335                                     KArrayTemplate<KFbxNode*>& pMissingDeformers,
00336                                     KArrayTemplate<KFbxNode*>& pMissingDeformersAncestors,
00337                                     KArrayTemplate<KFbxNode*>& pWrongMatrices,
00338                                     double pMatrixCmpTolerance=0.0001);
00339 
00348         bool IsValidBindPoseVerbose(KFbxNode* pRoot,
00349                                     KFbxUserNotification* pUserNotification,
00350                                     double pMatrixCmpTolerance=0.0001);
00351 
00356 
00360         KError& GetError();
00361 
00366         typedef enum
00367         {
00368             eERROR,
00369             eERROR_VALIDBINDPOSE_FAILURE_INVALIDOBJECT,
00370             eERROR_VALIDBINDPOSE_FAILURE_INVALIDROOT,
00371             eERROR_VALIDBINDPOSE_FAILURE_NOTALLANCESTORS_NODES,
00372             eERROR_VALIDBINDPOSE_FAILURE_NOTALLDEFORMING_NODES,
00373             eERROR_VALIDBINDPOSE_FAILURE_NOTALLANCESTORS_DEFNODES,
00374             eERROR_VALIDBINDPOSE_FAILURE_RELATIVEMATRIX,
00375             eERROR_COUNT
00376         } EError;
00377 
00381         EError GetLastErrorID() const;
00382 
00386         const char* GetLastErrorString() const;
00387 
00389 
00390 
00391 
00393 //
00394 //  WARNING!
00395 //
00396 //  Anything beyond these lines may not be documented accurately and is
00397 //  subject to change without notice.
00398 //
00400 
00401 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00402 
00403     // Clone
00404     virtual KFbxObject* Clone(KFbxObject* pContainer, KFbxObject::ECloneType pCloneType) const;
00405 
00406 protected:
00407 
00412     KFbxPose(KFbxSdkManager& pManager, char const* pName);
00413 
00417     ~KFbxPose();
00418 
00419     virtual void Destruct(bool pRecursive, bool pDependents);
00420 
00421     // From KFbxObject
00422     virtual KString     GetTypeName() const;
00423     virtual KStringList GetTypeFlags() const;
00424 
00425     KError mError;
00426 
00428     KFbxPose& operator=(KFbxPose const& pPose);
00429 
00430     // returns false if pNode is already inserted in the list and the current matrix
00431     // is different from the stored one. Also, if this pose is a rest pose, check if
00432     // pNode belongs to other BindPoses (accessed through the scene pointer).
00433     // pos will contains the index of the KFbxPoseInfo if the parameters are already
00434     // stored in this object.
00435     //
00436     bool ValidateParams(KFbxNode* pNode, KFbxMatrix& pMatrix, int& pPos);
00437 
00438     // Check only on this object's list.
00439     bool LocalValidateParams(KFbxNode* pNode, KFbxMatrix& pMatrix, int& pPos);
00440 
00441     static bool GetSpecificPoseContaining(
00442         int poseType,
00443         KFbxScene* pScene, KFbxNode* pNode,
00444         KArrayTemplate<KFbxPose*>& pPoseList,
00445         KArrayTemplate<int>& pIndex);
00446 
00447 private:
00448     // don't give public access to the info otherwise we will loose the ability
00449     // to maintain data integrity.
00450     KFbxPoseInfo* GetItem(int pIndex);
00451 
00452 private:
00453     char        mType;
00454 
00455     KArrayTemplate<KFbxPoseInfo*> mPoseInfo;
00456 
00457     bool IsValidBindPoseCommon(KFbxNode* pRoot,
00458                                 KArrayTemplate<KFbxNode*>* pMissingAncestors,
00459                                 KArrayTemplate<KFbxNode*>* pMissingDeformers,
00460                                 KArrayTemplate<KFbxNode*>* pMissingDeformersAncestors,
00461                                 KArrayTemplate<KFbxNode*>* pWrongMatrices,
00462                                 double pMatrixCmpTolerance=0.0001);
00463 
00464 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00465 
00466 };
00467 
00468 typedef KFbxPose* HKFbxPose;
00469 
00470 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00471 
00472 #endif // FBXFILESDK_KFBXPLUGINS_KFBXPOSE_H
00473