kfbxgeometry.h

Go to the documentation of this file.
00001 
00004 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXGEOMETRY_H
00005 #define FBXFILESDK_KFBXPLUGINS_KFBXGEOMETRY_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/kfbxgeometrybase.h>
00044 #include <fbxfilesdk/kfbxplugins/kfbxdeformer.h>
00045 
00046 #include <fbxfilesdk/components/kbaselib/klib/karrayul.h>
00047 #include <fbxfilesdk/components/kbaselib/klib/kerror.h>
00048 
00049 #include <fbxfilesdk/kfbxmath/kfbxxmatrix.h>
00050 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00051 
00052 class KFbxGeometryWeightedMap;
00053 class KFbxNode;
00054 class KFbxShape;
00055 class KFbxTexture;
00056 class KFbxSdkManager;
00057 class KFbxVector4;
00058 class KFbxAnimCurve;
00059 class KFbxAnimLayer;
00060 class KFbxScene;
00061 class KFbxCluster;
00062 typedef class KFbxCluster KFbxLink;
00063 
00083 class KFBX_DLL KFbxGeometry : public KFbxGeometryBase
00084 {
00085     KFBXOBJECT_DECLARE(KFbxGeometry,KFbxGeometryBase);
00086 
00087 public:
00094     virtual EAttributeType GetAttributeType() const;
00095 
00100 
00106     int AddDeformer(KFbxDeformer* pDeformer);
00107 
00113     KFbxDeformer* RemoveDeformer(int pIndex);
00114 
00118     int GetDeformerCount() const;
00119 
00125     KFbxDeformer* GetDeformer(int pIndex) const;
00126 
00131     int GetDeformerCount(KFbxDeformer::EDeformerType pType) const;
00132 
00139     KFbxDeformer* GetDeformer(int pIndex, KFbxDeformer::EDeformerType pType) const;
00140 
00142 
00147 
00151     KFbxGeometryWeightedMap* GetSourceGeometryWeightedMap();
00152 
00156     int GetDestinationGeometryWeightedMapCount() const;
00157 
00162     KFbxGeometryWeightedMap* GetDestinationGeometryWeightedMap(int pIndex);
00163 
00165 
00170 
00184     virtual int AddShape(KFbxShape* pShape, char const* pShapeName);
00185 
00190     virtual void ClearShape();
00191 
00195     virtual int GetShapeCount() const;
00196 
00202     virtual KFbxShape* GetShape(int pIndex);
00203 
00209     virtual KFbxShape const* GetShape(int pIndex) const;
00210 
00216     virtual char const* GetShapeName(int pIndex) const;
00217 
00224     K_DEPRECATED virtual KFCurve* GetShapeChannel(char const* pShapeName, bool pCreateAsNeeded = false, char const* pTakeName = NULL);
00225 
00238     virtual KFbxAnimCurve* GetShapeChannel(char const* pShapeName, KFbxAnimLayer* pLayer, bool pCreateAsNeeded = false);
00239 
00246      virtual KFCurve* GetShapeChannel(int pIndex, bool pCreateAsNeeded=false, char const* pTakeName = NULL);
00247 
00260     virtual KFbxAnimCurve* GetShapeChannel(int pIndex, KFbxAnimLayer* pLayer, bool pCreateAsNeeded = false);
00261 
00263 
00270     typedef enum
00271     {
00272         eRAW,
00273         eLOW_NO_NORMALS,
00274         eLOW,
00275         eHIGH_NO_NORMALS,
00276         eHIGH
00277     } ESurfaceMode;
00278 
00286 
00291     KFbxXMatrix& GetPivot(KFbxXMatrix& pXMatrix) const;
00292 
00296     void SetPivot(KFbxXMatrix& pXMatrix);
00297 
00300     void ApplyPivot();
00301 
00303 
00310 
00318     void SetDefaultShape(int pIndex, double pPercent);
00319 
00327     void SetDefaultShape(char const* pShapeName, double pPercent);
00328 
00335     double GetDefaultShape(int pIndex) const;
00336 
00343     double GetDefaultShape(char const* pShapeName) const;
00344 
00346 
00351 
00355     KError& GetError ();
00356 
00359     typedef enum
00360     {
00361         eINDEX_OUT_OF_RANGE,            
00362         eNULL_PARAMETER,                
00363         eSHAPE_ALREADY_ADDED,           
00364         eSHAPE_INVALID_NAME,            
00365         eSHAPE_NAME_CLASH,              
00366         eSHAPE_NO_CURVE_FOUND,          
00367         eUNKNOWN_ERROR,                 
00368         eERROR_COUNT
00369     } EError;
00370 
00374     EError GetLastErrorID() const;
00375 
00379     const char* GetLastErrorString() const;
00380 
00382 
00383     virtual KFbxObject* Clone(KFbxObject* pContainer, KFbxObject::ECloneType pCloneType) const;
00384 
00386 //
00387 //  WARNING!
00388 //
00389 //  Anything beyond these lines may not be documented accurately and is
00390 //  subject to change without notice.
00391 //
00393 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00394 
00395     virtual KFbxObject& Copy(const KFbxObject& pObject);
00396 
00397 protected:
00398     KFbxGeometry(KFbxSdkManager& pManager, char const* pName);
00399     virtual void Destruct(bool pRecursive, bool pDependents);
00400 
00401     virtual void SetDocument(KFbxDocument* pDocument);
00402 
00413     bool AddShapeChannel(KString pAnimStackName, int pShapeIndex);
00414 
00420      bool AddShapeChannel(KFbxAnimLayer* pLayer, int pShapeIndex);
00421 
00431     bool RemoveShapeChannel(KString pAnimStackName, int pShapeIndex);
00432 
00438     bool RemoveShapeChannel(KFbxAnimLayer* pLayer, int pShapeIndex);
00439 
00440 public:
00441     // MotionBuilder 4.01 and earlier versions saved nurb and patch shape channel names
00442     // following the template "Shape 0x (Shape)" where x is the index of the shape starting
00443     // at 1. Since then, shape channels have been made animated properties.
00444     // As a result, nurb and patch shape channel names are now saved following the template
00445     // "<shape name> (Shape)". The FBX SDK keeps the old shape channel naming scheme but has
00446     // been modifed to handle the new one and convert shape channel names to the old shape
00447     // channel naming scheme.
00448     K_DEPRECATED void CleanShapeChannels(KString pTakeNodeName);
00449     K_DEPRECATED void CleanShapeChannel(KString pTakeNodeName, int pShapeIndex);
00450 
00452     void CleanShapeChannels(KFbxAnimLayer* pAnimLayer);
00454     void CleanShapeChannel(KFbxAnimLayer* pAnimLayer, int pShapeIndex);
00455 
00456 protected:
00457     // Shape channel name creation for nurb and patch.
00458     KString CreateShapeChannelName(int pShapeIndex);
00459 
00460     // Shape channel name creation for mesh.
00461     KString CreateShapeChannelName(KString pShapeName);
00462 
00463     void CreateShapeChannelProperties(KString& pShapeName);
00464 
00465 public:
00466     void ConvertShapeNamesToV5Format(KString pTakeNodeName);
00467     void ConvertShapeNamesToV5Format(KString pTakeNodeName, int pShapeIndex);
00468     void RevertShapeNamesToV6Format(KString pTakeNodeName);
00469     void RevertShapeNamesToV6Format(KString pTakeNodeName, int pShapeIndex);
00470     void ClearTemporaryShapeNames();
00471 
00472 protected:
00473     void CopyDeformers(KFbxGeometry const* pGeometry);
00474     void CopyShapes(KFbxGeometry const* pGeometry);
00475 
00476     void CopyPivot(KFbxGeometry const* pSource);
00477 
00478     KArrayTemplate <KFbxShape*> mShapeArray;
00479 
00480     KArrayTemplate <KString*> mShapeNameArray;
00481 
00482     // Used during FBX v5 file store
00483     KArrayTemplate<KString*> mShapeNameArrayV6;
00484     KArrayTemplate<KString*> mShapeNameArrayV5;
00485     KArrayTemplate<KString*> mShapeChannelNameArrayV5;
00486 
00487     KFbxXMatrix* mPivot;
00488 
00489 
00490     mutable KError mError;
00491 
00492     friend class KFbxScene;
00493 
00494 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00495 
00496 };
00497 
00498 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00499 
00500 #endif // FBXFILESDK_KFBXPLUGINS_KFBXGEOMETRY_H
00501