FBX SDK Reference Guide: kfbxgeometry.h Source File
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 © 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/kfbxgeometrybase.h>
00046 #include <fbxfilesdk/kfbxplugins/kfbxdeformer.h>
00047 
00048 #include <fbxfilesdk/components/kbaselib/klib/karrayul.h>
00049 #include <fbxfilesdk/components/kbaselib/klib/kerror.h>
00050 
00051 #include <fbxfilesdk/components/kfcurve/kfcurve_forward.h>
00052 
00053 #include <fbxfilesdk/kfbxmath/kfbxxmatrix.h>
00054 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00055 
00056 class KFbxGeometryWeightedMap;
00057 class KFbxNode;
00058 class KFbxShape;
00059 class KFbxTexture;
00060 class KFbxSdkManager;
00061 class KFbxVector4;
00062 class KFbxTakeNode;
00063 class KFbxScene;
00064 class KFbxCluster;
00065 typedef class KFbxCluster KFbxLink;
00066 
00074 class KFBX_DLL KFbxGeometry : public KFbxGeometryBase
00075 {
00076     KFBXOBJECT_DECLARE(KFbxGeometry,KFbxGeometryBase);
00077 
00078 public:
00082     virtual EAttributeType GetAttributeType() const;
00083 
00088 
00093     int AddDeformer(KFbxDeformer* pDeformer);
00094 
00098     int GetDeformerCount() const;
00099 
00105     KFbxDeformer* GetDeformer(int pIndex) const;
00106 
00111     int GetDeformerCount(KFbxDeformer::EDeformerType pType) const;
00112 
00119     KFbxDeformer* GetDeformer(int pIndex, KFbxDeformer::EDeformerType pType) const;
00120 
00122 
00127 
00131     KFbxGeometryWeightedMap* GetSourceGeometryWeightedMap();
00132 
00136     int GetDestinationGeometryWeightedMapCount();
00137 
00142     KFbxGeometryWeightedMap* GetDestinationGeometryWeightedMap(int pIndex);
00143 
00145 
00150 
00164     virtual int AddShape(KFbxShape* pShape, char const* pShapeName);
00165 
00170     virtual void ClearShape();
00171 
00175     virtual int GetShapeCount() const;
00176 
00182     virtual KFbxShape* GetShape(int pIndex);
00183 
00189     virtual KFbxShape const* GetShape(int pIndex) const;
00190 
00196     virtual char const* GetShapeName(int pIndex) const;
00197 
00209     virtual KFCurve* GetShapeChannel(char const* pShapeName, bool pCreateAsNeeded = false, char const* pTakeName = NULL);
00210 
00222     virtual KFCurve* GetShapeChannel(int pIndex, bool pCreateAsNeeded = false, char const* pTakeName = NULL);
00223 
00225 
00237     typedef enum
00238     {
00239         eRAW,
00240         eLOW_NO_NORMALS,
00241         eLOW,
00242         eHIGH_NO_NORMALS,
00243         eHIGH
00244     } ESurfaceMode;
00245 
00253 
00258     KFbxXMatrix& GetPivot(KFbxXMatrix& pXMatrix) const;
00259 
00263     void SetPivot(KFbxXMatrix& pXMatrix);
00264 
00267     void ApplyPivot();
00268 
00270 
00279 
00287     void SetDefaultShape(int pIndex, double pPercent);
00295     void SetDefaultShape(char const* pShapeName, double pPercent);
00296 
00303     double GetDefaultShape(int pIndex);
00310     double GetDefaultShape(char const* pShapeName);
00311 
00313 
00318 
00322     KError& GetError ();
00323 
00337     typedef enum
00338     {
00339         eINDEX_OUT_OF_RANGE,
00340         eNULL_PARAMETER,
00341         eMATERIAL_NOT_FOUND,
00342         eMATERIAL_ALREADY_ADDED,
00343         eTEXTURE_NOT_FOUND,
00344         eTEXTURE_ALREADY_ADDED,
00345         eSHAPE_ALREADY_ADDED,
00346         eSHAPE_INVALID_NAME,
00347         eSHAPE_NAME_CLASH,
00348         eSHAPE_NO_CURVE_FOUND,
00349         eUNKNOWN_ERROR,
00350         eERROR_COUNT
00351     } EError;
00352 
00356     EError GetLastErrorID() const;
00357 
00361     const char* GetLastErrorString() const;
00362 
00364 
00365     virtual KFbxObject* Clone(KFbxObject* pContainer, KFbxObject::ECloneType pCloneType) const;
00366 
00368 //
00369 //  WARNING!
00370 //
00371 //  Anything beyond these lines may not be documented accurately and is
00372 //  subject to change without notice.
00373 //
00375 
00376 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00377 
00378 protected:
00379     KFbxGeometry(KFbxSdkManager& pManager, char const* pName);
00380     virtual ~KFbxGeometry();
00381 
00383     KFbxGeometry& operator=(KFbxGeometry const& pGeometry);
00384 
00385     virtual void Destruct(bool pRecursive, bool pDependents);
00386 
00387     virtual void SetDocument(KFbxDocument* pDocument);
00388 
00393     virtual void SetNode(KFbxNode& pNode);
00394 
00398     virtual void UnsetNode();
00399 
00403     bool AddShapeChannel(KString pTakeNodeName, int pShapeIndex);
00404 
00408     bool RemoveShapeChannel(KString pTakeNodeName, int pShapeIndex);
00409 
00410 public:
00411     // MotionBuilder 4.01 and earlier versions saved nurb and patch shape channel names
00412     // following the template "Shape 0x (Shape)" where x is the index of the shape starting
00413     // at 1. Since then, Jori modified shape channels to turn them into animated properties.
00414     // As a result, nurb and patch shape channel names are now saved following the template
00415     // "<shape name> (Shape)". The FBX SDK keeps the old shape channel naming scheme but has
00416     // been modifed to handle the new one and convert shape channel names to the old shape
00417     // channel naming scheme.
00418     void CleanShapeChannels(KString pTakeNodeName);
00419     void CleanShapeChannel(KString pTakeNodeName, int pShapeIndex);
00420 
00421 protected:
00422     // Shape channel name creation for nurb and patch.
00423     KString CreateShapeChannelName(int pShapeIndex);
00424 
00425     // Shape channel name creation for mesh.
00426     KString CreateShapeChannelName(KString pShapeName);
00427 
00428     void CreateShapeChannelProperties(KString& pShapeName);
00429 
00430 public:
00431     void ConvertShapeNamesToV5Format(KString pTakeNodeName);
00432     void ConvertShapeNamesToV5Format(KString pTakeNodeName, int pShapeIndex);
00433     void RevertShapeNamesToV6Format(KString pTakeNodeName);
00434     void RevertShapeNamesToV6Format(KString pTakeNodeName, int pShapeIndex);
00435     void ClearTemporaryShapeNames();
00436 
00437 protected:
00443     KFbxDeformer* RemoveDeformer(int pIndex);
00444 
00450     // This function implies renaming shape channels. The decision has been made to avoid changing
00451     // KFCurveNode interface to allow renaming.
00452     // KFbxShape* RemoveShape(int pIndex);
00453 
00454     void CopyDeformers(KFbxGeometry const* pGeometry);
00455     void CopyShapes(KFbxGeometry const* pGeometry);
00456 
00457     void CopyPivot(KFbxGeometry const* pSource);
00458 
00459     KArrayTemplate <KFbxShape*> mShapeArray;
00460 
00461     KArrayTemplate <KString*> mShapeNameArray;
00462 
00463     // Used during FBX v5 file store
00464     KArrayTemplate<KString*> mShapeNameArrayV6;
00465     KArrayTemplate<KString*> mShapeNameArrayV5;
00466     KArrayTemplate<KString*> mShapeChannelNameArrayV5;
00467 
00468     KFbxXMatrix* mPivot;
00469 
00470 
00471     mutable KError mError;
00472 
00473     friend class KFbxScene;
00474 
00475 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00476 
00477 };
00478 
00479 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00480 
00481 #endif // FBXFILESDK_KFBXPLUGINS_KFBXGEOMETRY_H
00482