kfbxpose.h

Go to the documentation of this file.
00001 
00004 #ifndef _FBXSDK_POSE_H_
00005 #define _FBXSDK_POSE_H_
00006 
00007 /**************************************************************************************
00008 
00009  Copyright © 2003 - 2007 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 KFbxPose_internal;
00072 class KFbxUserNotification;
00073 
00127 class KFBX_DLL KFbxPose : public KFbxObject
00128 {
00129     KFBXOBJECT_DECLARE(KFbxPose);
00130 public:
00134         void SetIsBindPose(bool pIsBindPose);
00135 
00139           bool IsBindPose() const     { return mType == 'b'; }
00140 
00144           bool IsRestPose()     { return mType == 'r'; }
00145 
00149           int GetCount() const { return mPoseInfo.GetCount(); }
00150 
00157           int Add(KFbxNode* pNode, KFbxMatrix& pMatrix, bool pLocalMatrix = false);
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 
00195 
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();
00386 
00390         char* GetLastErrorString();
00391 
00393 
00397         virtual KFbxObject::ENameSpace GetNameSpace() const;
00398 
00399 
00401 //
00402 //  WARNING!
00403 //
00404 //  Anything beyond these lines may not be documented accurately and is 
00405 //  subject to change without notice.
00406 //
00408 
00409 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00410 
00411     // Clone
00412     virtual KFbxObject* Clone(KFbxObject::ECloneType pCloneType) const;
00413 
00414 protected:
00415     static char const* GetNamePrefix() { return POSE_PREFIX; }
00416     
00421     KFbxPose(KFbxSdkManager& pManager, char const* pName);
00422     
00426     ~KFbxPose();
00427     
00428     virtual void Destruct(bool pRecursive, bool pDependents);
00429 
00430     // From KFbxObject
00431     virtual KString     GetTypeName() const;
00432     virtual KStringList GetTypeFlags() const;
00433 
00434     // Properties Handler
00435     KFbxPose_internal* mPH;
00436 
00437     KError mError;
00438 
00439     virtual KObject*          GetFbxObject_internal();
00440     virtual KObject const*  GetFbxObject_internal() const;
00441 
00443     KFbxPose& operator=(KFbxPose const& pPose);
00444 
00445     // returns false if pNode is already inserted in the list and the current matrix
00446     // is different from the stored one. Also, if this pose is a rest pose, check if
00447     // pNode belongs to other BindPoses (accessed through the scene pointer).
00448     // pos will contains the index of the KFbxPoseInfo if the parameters are already
00449     // stored in this object.
00450     //
00451     bool ValidateParams(KFbxNode* pNode, KFbxMatrix& pMatrix, int& pPos);
00452 
00453     // Check only on this object's list.
00454     bool LocalValidateParams(KFbxNode* pNode, KFbxMatrix& pMatrix, int& pPos);
00455 
00456     static bool GetSpecificPoseContaining(
00457         int poseType,
00458         KFbxScene* pScene, KFbxNode* pNode, 
00459         KArrayTemplate<KFbxPose*>& pPoseList,
00460         KArrayTemplate<int>& pIndex);
00461 
00462     friend class KFbxReaderFbx;
00463     friend class KFbxWriterFbx6;
00464 
00465 private:
00466     // don't give public access to the info otherwise we will loose the ability
00467     // to maintain data integrity.
00468     KFbxPoseInfo* GetItem(int pIndex);
00469 
00470 private:
00471     char        mType;
00472 
00473     KArrayTemplate<KFbxPoseInfo*> mPoseInfo;
00474 
00475     bool IsValidBindPoseCommon(KFbxNode* pRoot, 
00476                                 KArrayTemplate<KFbxNode*>* pMissingAncestors,
00477                                 KArrayTemplate<KFbxNode*>* pMissingDeformers,
00478                                 KArrayTemplate<KFbxNode*>* pMissingDeformersAncestors,
00479                                 KArrayTemplate<KFbxNode*>* pWrongMatrices,
00480                                 double pMatrixCmpTolerance=0.0001);
00481 
00482 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS 
00483 
00484 };
00485 
00486 typedef KFbxPose* HKFbxPose;
00487 
00488 #include <fbxfilesdk_nsend.h>
00489 
00490 #endif // #ifndef _FBXSDK_POSE_H_
00491 
00492