FBX SDK Reference Guide: kfbxgeometry.h Source File
Go to the documentation of this file.
00001 
00004 #ifndef _FBXSDK_GEOMETRY_H_
00005 #define _FBXSDK_GEOMETRY_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 <kaydaradef.h>
00043 #ifndef KFBX_DLL
00044     #define KFBX_DLL K_DLLIMPORT
00045 #endif
00046 
00047 #include <kaydara.h>
00048 
00049 #include <kfbxplugins/kfbxgeometrybase.h>
00050 #include <kfbxplugins/kfbxdeformer.h>
00051 
00052 #include <klib/karrayul.h>
00053 #include <klib/kerror.h>
00054 
00055 #include <kfcurve/kfcurve_forward.h>
00056 #ifndef MB_FBXSDK
00057 #include <kfcurve/kfcurve_nsuse.h>
00058 #endif
00059 
00060 #include <kfbxmath/kfbxxmatrix.h>
00061 #include <fbxfilesdk_nsbegin.h>
00062 
00063 class KFbxGeometryWeightedMap;
00064 class KFbxNode;
00065 class KFbxShape;
00066 class KFbxTexture;
00067 class KFbxSdkManager;
00068 class KFbxVector4;
00069 class KFbxTakeNode;
00070 class KFbxScene;
00071 class KFbxCluster;
00072 typedef class KFbxCluster KFbxLink;
00073 
00081 class KFBX_DLL KFbxGeometry : public KFbxGeometryBase
00082 {
00083     KFBXOBJECT_DECLARE(KFbxGeometry,KFbxGeometryBase);
00084 
00085 public:
00089     virtual EAttributeType GetAttributeType() const;
00090 
00095 
00100     int AddDeformer(KFbxDeformer* pDeformer);
00101 
00105     int GetDeformerCount() const;
00106 
00112     KFbxDeformer* GetDeformer(int pIndex) const;
00113 
00118     int GetDeformerCount(KFbxDeformer::EDeformerType pType) const;
00119 
00126     KFbxDeformer* GetDeformer(int pIndex, KFbxDeformer::EDeformerType pType) const;
00127 
00129 
00134 
00138     KFbxGeometryWeightedMap* GetSourceGeometryWeightedMap();
00139 
00143     int GetDestinationGeometryWeightedMapCount();
00144 
00149     KFbxGeometryWeightedMap* GetDestinationGeometryWeightedMap(int pIndex);
00150 
00152 
00157 
00171     virtual int AddShape(KFbxShape* pShape, char const* pShapeName);
00172 
00177     virtual void ClearShape();
00178 
00182     virtual int GetShapeCount() const;
00183 
00189     virtual KFbxShape* GetShape(int pIndex);
00190 
00196     virtual KFbxShape const* GetShape(int pIndex) const;
00197 
00203     virtual char const* GetShapeName(int pIndex) const;
00204 
00216     virtual KFCurve* GetShapeChannel(char const* pShapeName, bool pCreateAsNeeded = false, char const* pTakeName = NULL);
00217 
00229     virtual KFCurve* GetShapeChannel(int pIndex, bool pCreateAsNeeded = false, char const* pTakeName = NULL);
00230 
00232 
00244     typedef enum
00245     {
00246         eRAW,
00247         eLOW_NO_NORMALS,
00248         eLOW,
00249         eHIGH_NO_NORMALS,
00250         eHIGH
00251     } ESurfaceMode;
00252 
00260 
00265     KFbxXMatrix& GetPivot(KFbxXMatrix& pXMatrix) const;
00266 
00270     void SetPivot(KFbxXMatrix& pXMatrix);
00271 
00274     void ApplyPivot();
00275 
00277 
00286 
00294     void SetDefaultShape(int pIndex, double pPercent);
00302     void SetDefaultShape(char const* pShapeName, double pPercent);
00303 
00310     double GetDefaultShape(int pIndex);
00317     double GetDefaultShape(char const* pShapeName);
00318 
00320 
00325 
00329     KError& GetError ();
00330 
00344     typedef enum
00345     {
00346         eINDEX_OUT_OF_RANGE,
00347         eNULL_PARAMETER,
00348         eMATERIAL_NOT_FOUND,
00349         eMATERIAL_ALREADY_ADDED,
00350         eTEXTURE_NOT_FOUND,
00351         eTEXTURE_ALREADY_ADDED,
00352         eSHAPE_ALREADY_ADDED,
00353         eSHAPE_INVALID_NAME,
00354         eSHAPE_NAME_CLASH,
00355         eSHAPE_NO_CURVE_FOUND,
00356         eUNKNOWN_ERROR,
00357         eERROR_COUNT
00358     } EError;
00359 
00363     EError GetLastErrorID() const;
00364 
00368     const char* GetLastErrorString() const;
00369 
00371 
00372     virtual KFbxObject* Clone(KFbxObject* pContainer, KFbxObject::ECloneType pCloneType) const;
00373 
00375 //
00376 //  WARNING!
00377 //
00378 //  Anything beyond these lines may not be documented accurately and is
00379 //  subject to change without notice.
00380 //
00382 
00383 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00384 
00385 protected:
00386     KFbxGeometry(KFbxSdkManager& pManager, char const* pName);
00387     virtual ~KFbxGeometry();
00388 
00390     KFbxGeometry& operator=(KFbxGeometry const& pGeometry);
00391 
00392     virtual void Destruct(bool pRecursive, bool pDependents);
00393 
00394     virtual void SetDocument(KFbxDocument* pDocument);
00395 
00400     virtual void SetNode(KFbxNode& pNode);
00401 
00405     virtual void UnsetNode();
00406 
00410     bool AddShapeChannel(KString pTakeNodeName, int pShapeIndex);
00411 
00415     bool RemoveShapeChannel(KString pTakeNodeName, int pShapeIndex);
00416 
00417     // MotionBuilder 4.01 and earlier versions saved nurb and patch shape channel names
00418     // following the template "Shape 0x (Shape)" where x is the index of the shape starting
00419     // at 1. Since then, Jori modified shape channels to turn them into animated properties.
00420     // As a result, nurb and patch shape channel names are now saved following the template
00421     // "<shape name> (Shape)". The FBX SDK keeps the old shape channel naming scheme but has
00422     // been modifed to handle the new one and convert shape channel names to the old shape
00423     // channel naming scheme.
00424     void CleanShapeChannels(KString pTakeNodeName);
00425     void CleanShapeChannel(KString pTakeNodeName, int pShapeIndex);
00426 
00427     // Shape channel name creation for nurb and patch.
00428     KString CreateShapeChannelName(int pShapeIndex);
00429 
00430     // Shape channel name creation for mesh.
00431     KString CreateShapeChannelName(KString pShapeName);
00432 
00433     void CreateShapeChannelProperties(KString& pShapeName);
00434 
00435     void ConvertShapeNamesToV5Format(KString pTakeNodeName);
00436     void ConvertShapeNamesToV5Format(KString pTakeNodeName, int pShapeIndex);
00437     void RevertShapeNamesToV6Format(KString pTakeNodeName);
00438     void RevertShapeNamesToV6Format(KString pTakeNodeName, int pShapeIndex);
00439     void ClearTemporaryShapeNames();
00440 
00446     KFbxDeformer* RemoveDeformer(int pIndex);
00447 
00453     // This function implies renaming shape channels. The decision has been made to avoid changing
00454     // KFCurveNode interface to allow renaming.
00455     // KFbxShape* RemoveShape(int pIndex);
00456 
00457     void CopyDeformers(KFbxGeometry const* pGeometry);
00458     void CopyShapes(KFbxGeometry const* pGeometry);
00459 
00460     void CopyPivot(KFbxGeometry const* pSource);
00461 
00462     KArrayTemplate <KFbxShape*> mShapeArray;
00463 
00464     KArrayTemplate <KString*> mShapeNameArray;
00465 
00466     // Used during FBX v5 file store
00467     KArrayTemplate<KString*> mShapeNameArrayV6;
00468     KArrayTemplate<KString*> mShapeNameArrayV5;
00469     KArrayTemplate<KString*> mShapeChannelNameArrayV5;
00470 
00471     KFbxXMatrix* mPivot;
00472 
00473 
00474     mutable KError mError;
00475 
00476     friend class KFbxScene;
00477     friend class KFbxWriterFbx;
00478     friend class KFbxWriterFbx6;
00479     friend class KFbxReaderFbx;
00480     friend class KFbxReaderFbx6;
00481 
00482 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00483 
00484 };
00485 
00486 #include <fbxfilesdk_nsend.h>
00487 
00488 #endif // #ifndef _FBXSDK_GEOMETRY_H_
00489 
00490