kfbxgeometry.h

Go to the documentation of this file.
00001 
00004 #ifndef _FBXSDK_GEOMETRY_H_ 
00005 #define _FBXSDK_GEOMETRY_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 <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 
00074 class KFbxGeometry_internal;
00075 
00083 class KFBX_DLL KFbxGeometry : public KFbxGeometryBase
00084 {
00085     KFBXOBJECT_DECLARE(KFbxGeometry);
00086 
00087 public:
00091     virtual EAttributeType GetAttributeType() const { return eUNIDENTIFIED; } 
00092 
00105 
00111     K_DEPRECATED int AddLink(KFbxLink* pLink);
00112 
00118     K_DEPRECATED void ClearLink();
00119 
00124     K_DEPRECATED int GetLinkCount();
00125 
00132     K_DEPRECATED KFbxLink* GetLink(int pIndex);
00133 
00135 
00140 
00145     int AddDeformer(KFbxDeformer* pDeformer);
00146 
00150     int GetDeformerCount() const;
00151 
00157     KFbxDeformer* GetDeformer(int pIndex);
00158 
00164     KFbxDeformer const* GetDeformer(int pIndex) const;
00165 
00170     int GetDeformerCount(KFbxDeformer::EDeformerType pType) const;
00171 
00178     KFbxDeformer* GetDeformer(int pIndex, KFbxDeformer::EDeformerType pType);
00179 
00181 
00186 
00190     KFbxGeometryWeightedMap* GetSourceGeometryWeightedMap();
00191 
00195     int GetDestinationGeometryWeightedMapCount();
00196 
00201     KFbxGeometryWeightedMap* GetDestinationGeometryWeightedMap(int pIndex);
00202 
00204 
00209 
00223     virtual int AddShape(KFbxShape* pShape, char const* pShapeName);
00224 
00229     virtual void ClearShape();
00230 
00234     virtual int GetShapeCount() const;
00235 
00241     virtual KFbxShape* GetShape(int pIndex);
00242 
00248     virtual KFbxShape const* GetShape(int pIndex) const;
00249 
00255     virtual char const* GetShapeName(int pIndex) const;
00256 
00268     virtual KFCurve* GetShapeChannel(KFbxTakeNode* pTakeNode, int pShapeIndex);
00269 
00271 
00283     typedef enum 
00284     {
00285         eRAW,
00286         eLOW_NO_NORMALS,
00287         eLOW,
00288         eHIGH_NO_NORMALS,
00289         eHIGH
00290     } ESurfaceMode;
00291 
00299 
00304     KFbxXMatrix& GetPivot(KFbxXMatrix& pXMatrix) const;
00305     
00309     void SetPivot(KFbxXMatrix& pXMatrix);
00310 
00313     void ApplyPivot();
00314 
00316 
00326 
00334     void SetDefaultShape(int pIndex, double pPercent); 
00335 
00342     double GetDefaultShape(int pIndex); 
00343 
00345 
00350 
00354     KError& GetError ();
00355 
00369     typedef enum 
00370     {
00371         eINDEX_OUT_OF_RANGE,
00372         eNULL_PARAMETER,
00373         eMATERIAL_NOT_FOUND,
00374         eMATERIAL_ALREADY_ADDED,
00375         eTEXTURE_NOT_FOUND,
00376         eTEXTURE_ALREADY_ADDED,
00377         eSHAPE_ALREADY_ADDED,
00378         eSHAPE_INVALID_NAME,
00379         eSHAPE_NAME_CLASH,
00380         eSHAPE_NO_CURVE_FOUND,
00381         eUNKNOWN_ERROR,
00382         eERROR_COUNT
00383     } EError;   
00384 
00388     EError GetLastErrorID();
00389 
00393     char* GetLastErrorString();
00394 
00396 
00398 //
00399 //  WARNING!
00400 //
00401 //  Anything beyond these lines may not be documented accurately and is 
00402 //  subject to change without notice.
00403 //
00405 
00406 #ifndef DOXYGEN_SHOULD_SKIP_THIS    
00407 
00408 public:
00409 
00410     KFCurveNode* GetShapeCurveNode(KFbxTakeNode* pTakeNode, int pShapeIndex);
00411 
00412 protected:
00413     KFbxGeometry(KFbxSdkManager& pManager, char const* pName);
00414     static char const* GetNamePrefix() { return 0; }
00415     virtual ~KFbxGeometry();
00416 
00418     KFbxGeometry& operator=(KFbxGeometry const& pGeometry);
00419 
00420     virtual void Destruct(bool pRecursive, bool pDependents);
00421 
00422     virtual void SetScene(KFbxScene* pScene);
00423 
00428     virtual void SetNode(KFbxNode& pNode);
00429 
00433     virtual void UnsetNode();
00434 
00438     virtual void AddChannels(KFbxTakeNode *pTakeNode);
00439     bool AddShapeChannel(KFbxTakeNode *pTakeNode, int pShapeIndex);
00440 
00444     virtual void RemoveChannels(KFbxTakeNode *pTakeNode);
00445     bool RemoveShapeChannel(KFbxTakeNode *pTakeNode, int pShapeIndex);
00446 
00447     // MotionBuilder 4.01 and earlier versions saved nurb and patch shape channel names 
00448     // following the template "Shape 0x (Shape)" where x is the index of the shape starting 
00449     // at 1. Since then, Jori modified shape channels to turn them into animated properties. 
00450     // As a result, nurb and patch shape channel names are now saved following the template 
00451     // "<shape name> (Shape)". The FBX SDK keeps the old shape channel naming scheme but has 
00452     // been modifed to handle the new one and convert shape channel names to the old shape 
00453     // channel naming scheme.
00454     void CleanShapeChannels(KFbxTakeNode *pTakeNode);
00455     void CleanShapeChannel(KFbxTakeNode *pTakeNode, int pShapeIndex);
00456 
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     void ConvertShapeNamesToV5Format(KFbxTakeNode *pTakeNode);
00466     void ConvertShapeNamesToV5Format(KFbxTakeNode *pTakeNode, int pShapeIndex);
00467     void RevertShapeNamesToV6Format(KFbxTakeNode *pTakeNode);
00468     void RevertShapeNamesToV6Format(KFbxTakeNode *pTakeNode, int pShapeIndex);
00469     void ClearTemporaryShapeNames();
00470 
00476     KFbxDeformer* RemoveDeformer(int pIndex);
00477 
00483     // This function implies renaming shape channels. The decision has been made to avoid changing 
00484     // KFCurveNode interface to allow renaming.
00485     // KFbxShape* RemoveShape(int pIndex);
00486 
00487     void CopyDeformers(KFbxGeometry const* pGeometry);
00488     void CopyShapes(KFbxGeometry const* pGeometry);
00489 
00490     void PivotInit();
00491     void CopyPivot(KFbxGeometry const* pSource);
00492     
00493     KArrayTemplate <KFbxShape*> mShapeArray;
00494 
00495     KArrayTemplate <KString*> mShapeNameArray;
00496 
00497     // Used during FBX v5 file store
00498     KArrayTemplate<KString*> mShapeNameArrayV6;
00499     KArrayTemplate<KString*> mShapeNameArrayV5;
00500     KArrayTemplate<KString*> mShapeChannelNameArrayV5;
00501 
00502     KFbxXMatrix mPivot;
00503     
00504         
00505     mutable KError mError;
00506 
00507     friend class KFbxScene;
00508     friend class KFbxWriterFbx;
00509     friend class KFbxWriterFbx6;
00510     friend class KFbxReaderFbx;
00511     friend class KFbxReaderFbx6;
00512 
00513 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00514 
00515 };
00516 
00517 #include <fbxfilesdk_nsend.h>
00518 
00519 #endif // #ifndef _FBXSDK_GEOMETRY_H_
00520 
00521