kfbxaxissystem.h

Go to the documentation of this file.
00001 
00004 #ifndef _KFbxAxisSystem_h
00005 #define _KFbxAxisSystem_h
00006 
00007 /**************************************************************************************
00008 
00009  Copyright © 2001 - 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 <klib/karrayul.h>
00050 #include <klib/kstring.h>
00051 
00052 #ifndef MB_FBXSDK
00053 #include <kbaselib_nsuse.h>
00054 #endif
00055 
00056 #include <kfcurve/kfcurve_forward.h>
00057 #ifndef MB_FBXSDK
00058 #include <kfcurve/kfcurve_nsuse.h>
00059 #endif
00060 
00061 #include <kfbxmath/kfbxmatrix.h>
00062 
00063 #include <fbxfilesdk_nsbegin.h>
00064 
00065 class KFbxNode;
00066 class KFbxScene;
00067 
00072 class KFBX_DLL KFbxAxisSystem
00073 {
00074 public:
00075 
00081     enum eUpVector {
00082         XAxis = 1,
00083         YAxis = 2,
00084         ZAxis = 3        
00085     };
00086     
00087     /* \enum Vector with origin at the screen pointing toward the camera.
00088      * This is a subset of enum eUpVector because axis cannot be repeated.
00089      * - \e ParityEven
00090      * - \e ParityOdd
00091      */
00092     enum eFrontVector {
00093         ParityEven = 1,
00094         ParityOdd  = 2
00095     };
00096 
00097     enum eCoorSystem {
00098         RightHanded = 0,
00099         LeftHanded  = 1
00100     };
00101 
00102     enum ePreDefinedAxisSystem {
00103         eMayaZUp = 0,
00104         eMayaYUp,
00105         eMax,
00106         eMotionBuilder,
00107         eOpenGL,
00108         eDirectX,
00109         eLightwave
00110     };
00111 
00112     KFbxAxisSystem(eUpVector pUpVector, eFrontVector pFrontVector, eCoorSystem pCoorSystem);
00113     KFbxAxisSystem(const KFbxAxisSystem& pAxisSystem);
00114     KFbxAxisSystem(const ePreDefinedAxisSystem pAxisSystem);
00115     virtual ~KFbxAxisSystem();
00116 
00117     bool operator==(const KFbxAxisSystem& pAxisSystem)const;
00118     bool operator!=(const KFbxAxisSystem& pAxisSystem)const;
00119     KFbxAxisSystem& operator=(const KFbxAxisSystem& pAxisSystem);
00120 
00121     static const KFbxAxisSystem MayaZUp;
00122     static const KFbxAxisSystem MayaYUp;
00123     static const KFbxAxisSystem Max;
00124     static const KFbxAxisSystem Motionbuilder;
00125     static const KFbxAxisSystem OpenGL;
00126     static const KFbxAxisSystem DirectX;
00127     static const KFbxAxisSystem Lightwave;
00128 
00133     void ConvertScene(KFbxScene* pScene) const;
00134 
00142     void ConvertScene(KFbxScene* pScene, KFbxNode* pFbxRoot) const;
00143 
00147     eUpVector GetUpVector( int & pSign ) const;
00148 
00151     eCoorSystem GetCoorSystem() const;
00152 
00158     void ConvertChildren(KFbxNode* pRoot, const KFbxAxisSystem& pSrcSystem) const;
00159 
00161 //
00162 //  WARNING!
00163 //
00164 //  Anything beyond these lines may not be documented accurately and is 
00165 //  subject to change without notice.
00166 //
00168 
00169 protected:
00170 
00171     class KFbxAxis
00172     {
00173     public:
00174         enum eAxis {
00175             eXAxis = 0, eYAxis, eZAxis
00176         };
00177 
00178         eAxis mAxis;
00179         int   mSign;
00180 
00181         bool operator==(const KFbxAxis& pAxis)const
00182         {
00183             return mAxis == pAxis.mAxis && mSign == pAxis.mSign;
00184         }
00185     };
00186 
00187     KFbxAxis mUpVector;
00188     KFbxAxis mFrontVector;
00189     KFbxAxis mCoorSystem;
00190 
00191 protected:
00193     // Conversion engine, here you will find all the step involed into the conversion
00194 
00195     // Convert Translation and Rotation FCurve.
00196     void ConvertFCurve(KArrayTemplate<KFCurveNode*>& pFCurves, const KFbxAxisSystem& pFrom)const;
00197 
00198     // Adjust Pre rotation to orient the node and childs correctly.
00199     void AdjustPreRotation(KFbxNode* pNode, const KFbxMatrix& pConversionRM)const;
00200 
00201     void AdjustPivots(KFbxNode* pNode, const KFbxMatrix& pConversionRM)const;
00202 
00203     void GetConversionMatrix(const KFbxAxisSystem& pFrom, KFbxMatrix& pConversionRM)const;
00204 
00205     void AdjustLimits(KFbxNode* pNode, const KFbxMatrix& pConversionRM)const;
00206 
00207     void AdjustPoses(KFbxScene* pScene, const KFbxMatrix& pConversionRM) const;
00208 
00209     void AdjustCamera(KFbxNode* pNode, const KFbxMatrix& pConversionRM ) const;
00210 
00211     void AdjustCluster(KFbxNode* pNode, const KFbxMatrix& pConversionRM) const;
00212 
00213     void ConvertChildren(KFbxNode* pRoot, const KFbxAxisSystem& pSrcSystem, bool pSubChildrenOnly) const;
00214 
00215     friend class KFbxReaderFbx;
00216     friend class KFbxReaderFbx6;
00217     friend class KFbxWriterFbx;
00218     friend class KFbxWriterFbx6;
00219 
00220     friend class KFbxGlobalSettings;
00221 };
00222 
00223 #include <fbxfilesdk_nsend.h>
00224 
00225 
00226 #endif // _KFbxAxisSystem_h