fbxwriterfbx5.h

Go to the documentation of this file.
00001 /****************************************************************************************
00002  
00003    Copyright (C) 2012 Autodesk, Inc.
00004    All rights reserved.
00005  
00006    Use of this software is subject to the terms of the Autodesk license agreement
00007    provided at the time of installation or download, or which otherwise accompanies
00008    this software in either electronic or hard copy form.
00009  
00010 ****************************************************************************************/
00011 
00013 #ifndef _FBXSDK_FILEIO_FBX_WRITER_FBX5_H_
00014 #define _FBXSDK_FILEIO_FBX_WRITER_FBX5_H_
00015 
00016 #include <fbxsdk.h>
00017 
00018 #include <fbxsdk/fbxsdk_nsbegin.h>
00019 
00020 //Writable versions for this file type.  
00021 //Sync the functions PreProcessScene and PostProcessScene with these elements of this list.
00022 #define FBX53_MB55_COMPATIBLE "FBX53_MB55"
00023 
00024 class FbxWriterFbx5 : public FbxWriter
00025 {
00026 public:
00027     FbxWriterFbx5(FbxManager& pManager, FbxExporter& pExporter, int pID);
00028     virtual ~FbxWriterFbx5();
00029 
00030     virtual bool FileCreate(char* pFileName);
00031     virtual bool FileCreate(FbxStream* pStream, void* pStreamData);
00032     virtual bool FileClose();
00033     virtual bool IsFileOpen();
00034 
00035     typedef enum 
00036     {
00037         eASCII,
00038         eBINARY,
00039         eENCRYPTED
00040     } EExportMode;
00041 
00042     void SetExportMode(EExportMode pMode);
00043 
00044     virtual void GetWriteOptions();
00045     virtual bool Write(FbxDocument* pDocument);
00046 
00047     virtual bool Write(FbxDocument* pDocument, FbxIO* pFbx);
00048     virtual bool PreprocessScene(FbxScene& pScene);
00049     virtual bool PostprocessScene(FbxScene& pScene);
00050 
00051     virtual bool SupportsStreams() const        { return true; }
00052 
00053 private:
00054     bool WriteAnimation(FbxScene& pScene);
00055     bool WriteAnimation(FbxNode& pRootNode, FbxAnimLayer* pAnimLayer);
00056     void WriteTakeNode(KFCurveNode* pCurveNode, bool pRescaleShininess); 
00057     bool WriteTakeNode(FbxObject& pObj, FbxAnimLayer* pAnimLayer, const char* pBlockName, bool pRescaleShininess = false);
00058 
00059     bool WriteThumbnail(FbxThumbnail* pThumbnail);
00060     void WriteSceneInfo(FbxDocumentInfo*);
00061 
00062     bool WriteExtensionSection(FbxScene& pScene, int pMediaCount);
00063 
00064     bool WriteNode(FbxNode* pNode);
00065 
00066     bool WriteCameraSwitcher(FbxScene& pScene);
00067 
00068     void WriteGobo(FbxScene& pScene);
00069     void WriteGoboSection(FbxScene& pScene);
00070     void WriteGobo(FbxGobo& pGobo);
00071 
00072     void WriteCharacter(FbxScene& pScene);
00073     void WriteCharacter(FbxScene& pScene, int pCharacterIndex);
00074     void WriteCharacterLinkGroup(FbxCharacter& pCharacter, int pCharacterGroupId, FbxScene& pScene, bool pBackwardCompatible);
00075     void WriteCharacterLink(FbxCharacter& pCharacter, int pCharacterNodeId, FbxScene& pScene, bool pBackwardCompatible);
00076     void WriteFilterSet(FbxCharacter& pCharacter);
00077     void WriteControlSet(FbxControlSet& pControlSet, FbxScene& pScene, bool pBackwardCompatible);   
00078     void WriteControlSetLinkGroup(FbxControlSet& pControlSet, int pCharacterGroupId, FbxScene& pScene, bool pBackwardCompatible);
00079     void WriteControlSetLink(FbxControlSet& pControlSet, int pCharacterNodeId, FbxScene& pScene);
00080     void WriteEffector(FbxControlSet& pControlSet, int pEffectorNodeId, FbxScene& pScene);
00081     void WriteEffectorAux(FbxControlSet& pControlSet, int pEffectorNodeId, FbxScene& pScene);
00082 
00083     int  WriteCharacterPose(FbxScene& pScene);
00084     void WriteCharacterPose(FbxCharacterPose& pCharacterPose);
00085 
00086     void WritePose(FbxScene& pScene);
00087     void WritePose(FbxPose& pPose);
00088 
00089     void WriteConstraint(FbxScene& pScene);
00090 
00091     void WriteGlobalLightSettings(FbxScene& pScene);
00092     void WriteShadowPlane(FbxScene& pScene);
00093     void WriteShadowPlaneSection(FbxScene& pScene);
00094     void WriteAmbientColor(FbxScene& pScene);
00095     void WriteFogOption(FbxScene& pScene); 
00096 
00097     void WriteGlobalCameraAndTimeSettings(FbxScene& pScene);
00098     
00099     bool WriteMedia(FbxScene& pScene, bool pMediaEmbedded, int& pMediaCount);
00100     bool WriteMediaClip(FbxString& pFileName, bool pEmbeddedMedia);
00101     void WriteDefaultMedia();
00102 
00103     bool WriteNode                  (FbxNode& pNode);
00104     bool WriteNodeBegin             (FbxNode& pNode);
00105     bool WriteNodeParameters        (FbxNode& pNode);
00106     bool WriteNodeVersion           (FbxNode& pNode);
00107     bool WriteNodeShading           (FbxNode& pNode);
00108     bool WriteNodeAnimationSettings (FbxNode& pNode);
00109     bool WriteNodeCullingType       (FbxNode& pNode);
00110     bool WriteNodeLimits            (FbxNode& pNode);
00111     bool WriteNodeProperties        (FbxNode& pNode);
00112     bool WriteNodeTarget            (FbxNode& pNode);
00113     bool WriteNodeAnimatedProperties(FbxNode& pNode);
00114     bool WriteNodeAttribute         (FbxNode& pNode);
00115     bool WriteNodeDefaultAttributes (FbxNode& pNode);
00116     bool WriteNodeChildrenList      (FbxNode& pNode);
00117     bool WriteNodeEnd               (FbxNode& pNode);
00118 
00119     bool WriteNull                  ( FbxNull* pNull );
00120 
00121     bool WriteMarker                ( FbxNode& pNode );
00122 
00123     bool WriteCamera                ( FbxCamera& pCamera, bool pIsProducerCamera = false ); 
00124 
00125     bool WriteCameraSwitcher        ( FbxCameraSwitcher& pCameraSwitcher );
00126 
00127     bool WriteLight                 ( FbxLight& pLight );
00128 
00129     bool WriteGeometry              ( FbxGeometry& pGeometry );
00130     bool WriteGeometryLayer         ( FbxGeometry& pGeometry );
00131     bool WriteGeometryTextureLayer  ( FbxGeometry& pGeometry, int pIndex );
00132 
00133     bool WriteMesh                  ( FbxMesh& pMesh );
00134     bool WriteMeshVertices          ( FbxMesh& pMesh );
00135     bool WriteMeshNormals           ( FbxMesh& pMesh );
00136     bool WriteMeshMaterial          ( FbxMesh& pMesh );
00137     bool WriteMeshTexture           ( FbxMesh& pMesh );
00138     bool WriteMeshGeometryUVInfo    ( FbxMesh& pMesh );
00139     bool WriteMeshPolyVertexIndex   ( FbxMesh& pMesh );
00140     bool WriteMeshPolyGroupIndex    ( FbxMesh& pMesh );
00141     bool WriteMeshVertexColors      ( FbxMesh& pMesh );
00142 
00143     bool WriteNurb                  ( FbxNurbs& pNurbs );
00144 
00145     bool WritePatch                 ( FbxPatch& pPatch );
00146     bool WritePatchType             ( FbxPatch& pPatch, int pType );
00147 
00148     bool WriteSkeleton              ( FbxSkeleton& pSkeleton );
00149     bool WriteSkeletonRoot          ( FbxSkeleton& pSkeleton );
00150     bool WriteSkeletonLimb          ( FbxSkeleton& pSkeleton );
00151     bool WriteSkeletonLimbNode      ( FbxSkeleton& pSkeleton );
00152     bool WriteSkeletonEffector      ( FbxSkeleton& pSkeleton );
00153     
00154     bool WriteOpticalReference      ( FbxOpticalReference& pOpticalReference );
00155 
00156     bool WriteTexture(FbxFileTexture& pTexture);
00157     bool WriteSurfaceMaterial(FbxSurfaceMaterial& pMaterial);
00158     bool WriteLink(FbxCluster& pCluster);
00159     bool WriteShape(FbxShape& pShape, FbxString pShapeName, FbxGeometry& pGeometry);
00160 
00161     bool WriteProperties(FbxObject* pObject);
00162 
00163     int FindString(FbxString pString, FbxArray<FbxString*>& pStringArray);
00164     void FindShapeValidIndices(FbxArray<FbxVector4>& pGeometryControlPoints, FbxArray<FbxVector4>& pShapeControlPoints, FbxArray<int>& lValidIndices);
00165 
00166     void ConvertShapeNamesToV5Format(FbxNode& pNode);
00167     void RevertShapeNamesToV6Format (FbxNode& pNode);
00168 
00169     void WritePassword();
00170 
00171     void FindAnimatedChannels(FbxScene& pScene);
00172     void ClearAnimatedChannels();
00173 
00174     void WriteSceneGenericPersistenceSection(FbxScene& pScene);
00175 
00176     void ForceKFCurveNodesOnTRS(FbxNode* pNode);
00177     void SetPivotStateRecursive(FbxNode* pNode);
00178 
00179 private:
00180     FbxWriterFbx5& operator=(const FbxWriterFbx5&) { return *this; }
00181 
00182     FbxIO* mFileObject; 
00183     FbxExporter& mExporter;
00184 
00185     EExportMode mExportMode;
00186 
00187     FbxSet mTextureAnimatedChannels;
00188     FbxSet mMaterialAnimatedChannels;
00189 
00190     struct TextureAnimatedChannels
00191     {
00192         bool mTranslation;
00193         bool mRotation;
00194         bool mScaling;
00195         bool mAlpha;
00196     };
00197 
00198     struct SurfaceMaterialAnimatedChannels
00199     {
00200         bool mAmbient;
00201         bool mDiffuse;
00202         bool mSpecular;
00203         bool mEmissive;
00204         bool mOpacity;
00205         bool mShininess;
00206         bool mReflectivity;
00207     };
00208 };
00209 
00210 #include <fbxsdk/fbxsdk_nsend.h>
00211 
00212 #endif /* _FBXSDK_FILEIO_FBX_WRITER_FBX5_H_ */