fbxwriterfbx6.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_FBX6_H_
00014 #define _FBXSDK_FILEIO_FBX_WRITER_FBX6_H_
00015 
00016 #include <fbxsdk.h>
00017 
00018 #include <fbxsdk/fbxsdk_nsbegin.h>
00019 
00020 class Fbx6TypeDefinition;
00021 class Fbx6TypeWriteReferences;
00022 class Fbx6TypeObjectHierarchy;
00023 
00024 //Writable versions for this file type.
00025 //Sync the functions PreProcessScene and PostProcessScene with these elements of this list.
00026 #define FBX2010_00_COMPATIBLE        "FBX201000"
00027 #define FBX2009_00_V7_COMPATIBLE     "FBX200900v7"
00028 #define FBX2009_00_COMPATIBLE        "FBX200900"
00029 #define FBX2006_11_COMPATIBLE        "FBX200611"
00030 #define FBX2006_08_COMPATIBLE        "FBX200608"
00031 #define FBX2006_02_COMPATIBLE        "FBX200602_MB75"
00032 #define FBX2005_08_COMPATIBLE        "FBX200508_MB70"
00033 #define FBX60_COMPATIBLE             "FBX60_MB60"
00034 
00035 typedef FbxArray<FbxTakeInfo*> TakeInfoArray;
00036 
00037 class FbxWriterFbx6 : public FbxWriter
00038 {
00039 public:
00040     FbxWriterFbx6(FbxManager& pManager, FbxExporter& pExporter, int pID);
00041     virtual ~FbxWriterFbx6();
00042 
00043     virtual bool    FileCreate(char* pFileName);
00044     virtual bool    FileCreate(FbxStream* pStream, void* pStreamData);
00045     virtual bool    FileClose();
00046     virtual bool    IsFileOpen();
00047 
00048     typedef enum {eASCII, eBINARY, eENCRYPTED} EExportMode;
00049 
00050     void            SetExportMode(EExportMode pMode);
00051 
00052     virtual void    GetWriteOptions();
00053     virtual bool    Write(FbxDocument* pDocument);
00054     virtual bool    PreprocessScene(FbxScene& pScene);
00055     virtual bool    PostprocessScene(FbxScene& pScene);
00056     virtual void    PluginWriteParameters(FbxObject& pParams);
00057     virtual bool    Write(FbxDocument* pDocument, FbxIO* pFbx);
00058     virtual void    SetProgressHandler(FbxProgress *pProgress);
00059 
00060     virtual bool SupportsStreams() const        { return true; }
00061 
00062 private:
00063     /*************************** new writer ***************************/
00064     void            ConvertShapePropertyToOldStyle(FbxScene& pScene);
00065     void            ConvertShapePropertyToNewStyle(FbxScene& pScene);
00066     void            BuildObjectDefinition(FbxDocument* pDocument, Fbx6TypeDefinition& pDefinitions);
00067     void            SetObjectWriteSupport(const Fbx6TypeDefinition& pDefinitions);
00068     bool            WriteDescriptionSection(FbxDocument* pDocument);
00069     bool            WriteReferenceSection(FbxDocument* pDocument, Fbx6TypeWriteReferences& pReferences);
00070     void            WriteObjectDefinition(FbxDocument* pDocument, Fbx6TypeDefinition& pDefinitions);
00071     void            WriteObjectProperties(FbxDocument* pDocument, Fbx6TypeDefinition& pDefinitions);
00072 
00073     void            FlattenDocument(FbxDocument* pDocument, Fbx6TypeObjectHierarchy& pDocHierarchy, bool pFirstCall=true);
00074     void            UnFlattenDocument(FbxDocument* pDocument, Fbx6TypeObjectHierarchy& pDocHierarchy);
00075     bool            WriteObjectHeaderAndReferenceIfAny(FbxObject& pObj, const char* pObjectType) const;
00076 
00077     FbxObject*     GetObjectIndirection(FbxObject* pObject);
00078     void            WriteObjectConnections(FbxDocument* pDocument);
00079     void            WriteTakesAndAnimation(FbxDocument* pDocument);
00080 
00081     void            WriteConstraints(FbxScene& pScene);
00082     void            WriteConstraint(FbxConstraint& pConstraint, FbxScene& pScene);
00083 
00084     void            WriteGeometryWeightedMap(FbxGeometryWeightedMap& pGeometryWeightedMap);
00085     void            WriteNodeAttributes(const FbxDocument& pDocument);
00086     void            WriteAllGeometries(FbxScene& pScene);
00087 
00088     void            WriteAllGeometryWeightedMaps(FbxScene& pScene);
00089 
00090     int             WriteCharacterPose(FbxScene& pScene);
00091     void            WriteCharacterPose(FbxCharacterPose& pCharacterPose);
00092 
00093     void            WriteCharacterLinkGroup(FbxCharacter& pCharacter, int pCharacterGroupId, FbxScene& pScene);
00094     void            WriteCharacterLink(FbxCharacter& pCharacter, int pCharacterNodeId, FbxScene& pScene);
00095     void            WriteCharacterLinkRotationSpace(FbxCharacterLink& pCharacterLink);
00096 
00097     void            WriteControlSetPlug(FbxScene& pScene);
00098 
00099     /*************************** new writer ***************************/
00100     bool            WriteNodes(FbxScene& pScene, bool pIncludeRoot);
00101     bool            WriteNodes(const FbxDocument& pDocument);
00102 
00103     /*************************** kept functions ***************************/
00104     bool            WriteObjectProperties(FbxObject* pObject);
00105     bool            WriteObjectPropertiesAndFlags(FbxObject* pObject);
00106 
00107     bool            WriteContainers(FbxScene& pScene);
00108 
00109     bool            WriteNode(FbxNode& pNode);
00110     bool            WriteNodeBegin(FbxNode& pNode);
00111     bool            WriteNodeEnd(FbxNode& pNode);
00112     bool            WriteNodeParameters(FbxNode& pNode);
00113     bool            WriteNodeVersion(FbxNode& pNode);
00114     bool            WriteNodeAnimationSettings(FbxNode& pNode);
00115     bool            WriteNodeShading(FbxNode& pNode);
00116     bool            WriteNodeCullingType(FbxNode& pNode);
00117     bool            WriteNodeAttribute(FbxNodeAttribute* pNodeAttribute);
00118     bool            WriteNodeProperties(FbxNode& pNode);
00119 
00120     bool            WriteNodeType(FbxNode& pNode);
00121     bool            WriteNull(FbxNull* pNull);
00122     bool            WriteMarker(FbxNode& pNode);
00123     bool            WriteSkeleton(FbxSkeleton& pSkeleton);
00124     bool            WriteSkeletonRoot(FbxSkeleton& pSkeleton);
00125     bool            WriteSkeletonLimb(FbxSkeleton& pSkeleton);
00126     bool            WriteSkeletonLimbNode(FbxSkeleton& pSkeleton);
00127     bool            WriteSkeletonEffector(FbxSkeleton& pSkeleton);
00128     bool            WriteGenericNodes(FbxScene& pScene);
00129 
00130     bool            WriteGeometry(FbxGeometry& pGeometry);
00131     bool            WriteMesh(FbxMesh& pMesh);
00132     bool            WriteMeshSmoothness(FbxMesh& pMesh);
00133     bool            WriteMeshVertices(FbxMesh& pMesh);
00134     bool            WriteMeshPolyVertexIndex(FbxMesh& pMesh);
00135     bool            WriteMeshEdges(FbxMesh& pMesh);
00136     bool            WriteNurb(FbxNurbs& pNurbs);
00137     bool            WriteNurbsSurface(FbxNurbsSurface& pNurbs);
00138     bool            WriteNurbsCurve(FbxNurbsCurve& pNurbsCurve);
00139     bool            WriteTrimNurbsSurface(FbxTrimNurbsSurface& pNurbs);
00140     bool            WriteBoundary(FbxBoundary& pBoundary);
00141     bool            WriteSubdiv(FbxSubDiv& pSubdiv);
00142 
00143     bool            WritePatch(FbxPatch& pPatch);
00144     bool            WritePatchType(FbxPatch& pPatch, int pType);
00145 
00146     bool            WriteDeformers(FbxScene& pScene);
00147     bool            WriteSkin(FbxSkin& pSkin);
00148     bool            WriteVertexCacheDeformer(FbxVertexCacheDeformer& pDeformer);
00149     bool            WriteCluster(FbxCluster& pCluster);
00150     bool            WriteShape(FbxShape& pShape, FbxString pShapeName, FbxGeometry& pGeometry);
00151     void            FindShapeValidIndices(FbxArray<FbxVector4>& pGeometryControlPoints, FbxArray<FbxVector4>& pShapeControlPoints, FbxArray<int>& lValidIndices);
00152 
00153     bool            WriteFbxLayerElementNormals(FbxLayerContainer& pLayerContainer, FbxSet&);
00154     bool            WriteFbxLayerElementBinormals(FbxLayerContainer& pLayerContainer, FbxSet&);
00155     bool            WriteFbxLayerElementTangents(FbxLayerContainer& pLayerContainer, FbxSet&);
00156     bool            WriteFbxLayerElementMaterials(FbxLayerContainer& pLayerContainer, FbxSet&);
00157     bool            WriteFbxLayerElementTextures(FbxLayerContainer& pLayerContainer, FbxSet&);
00158     bool            WriteFbxLayerElementTexturesChannel(FbxLayerContainer& pLayerContainer, FbxLayerElement::EType pTextureType, FbxSet& pLayerIndexSet);
00159     bool            WriteFbxLayerElementUVsChannel(FbxLayerContainer& pLayerContainer, FbxLayerElement::EType pTextureType, FbxSet& pLayerIndexSet);
00160 
00161     bool            WriteFbxLayerElementPolygonGroups(FbxLayerContainer& pLayerContainer, FbxSet&);
00162     bool            WriteFbxLayerElementVertexColors(FbxLayerContainer& pLayerContainer, FbxSet&);
00163     bool            WriteFbxLayerElementUVs(FbxLayerContainer& pLayerContainer, FbxSet&);
00164     bool            WriteFbxLayerElementSmoothing(FbxLayerContainer& pLayerContainer, FbxSet&);
00165     bool            WriteFbxLayerElementUserData(FbxLayerContainer& pLayerContainer, FbxSet&);
00166     bool            WriteFbxLayerElementVisibility(FbxLayerContainer& pLayerContainer, FbxSet&);
00167     bool            WriteFbxLayerElementVertexCrease(FbxLayerContainer& pLayerContainer, FbxSet&);
00168     bool            WriteFbxLayerElementEdgeCrease(FbxLayerContainer& pLayerContainer, FbxSet&);
00169     bool            WriteFbxLayerElementHole(FbxLayerContainer& pLayerContainer, FbxSet&);
00170 
00171     bool            WriteLayers(FbxLayerContainer& pLayerContainer, FbxSet&);
00172     int             MapLayeredTextureIndexToConnectionIndex(FbxNode* pNode, void* pLET, int pIndex);
00173 
00174     bool            WriteMaterials(FbxDocument* pDocument);
00175     bool            WriteSurfaceMaterial(FbxSurfaceMaterial& pMaterial);
00176 
00177     bool            WritePose(FbxScene& pScene);
00178 
00179     // Write Connections
00180     bool            WriteFieldConnection(FbxDocument* pDocument, FbxObject* pSrcObject, FbxDocument* pDstDocument);
00181     bool            WriteFieldConnection(FbxDocument* pDocument, FbxObject* pSrc,FbxObject* pDst);
00182     bool            WriteFieldConnection(FbxDocument* pDocument, FbxObject* pSrc,FbxProperty& pDst);
00183     bool            WriteFieldConnection(FbxDocument* pDocument, FbxProperty& pSrc,FbxObject* pDst);
00184     bool            WriteFieldConnection(FbxDocument* pDocument, FbxProperty& pSrc,FbxProperty& pDst);
00185     
00186     void            WriteObjectConnections(FbxDocument* pDocument, FbxObject* pObject, bool pRecursive);
00187 
00188     bool            WriteCamera(FbxCamera& pCamera);
00189     bool            WriteCameraStereo(FbxCameraStereo& pCameraStereo);
00190     bool            WriteLight(FbxLight& pLight);
00191     bool            WriteCameraSwitcher(FbxScene& pScene);                   
00192     bool            WriteCameraSwitcher(FbxCameraSwitcher& pCameraSwitcher);
00193 
00194     bool            WriteTextures(FbxDocument* pDocument);
00195     bool            WriteTexture(FbxFileTexture& pTexture);
00196 
00197     bool            WriteTimeWarps(FbxDocument* pDocument, FbxAnimStack* pAnimStack);
00198     bool            WriteThumbnails(FbxDocument* pDocument);
00199     bool            WriteThumbnail(FbxThumbnail& pThumbnail);
00200 
00201     bool            WriteCaches(FbxDocument* pDocument);
00202     bool            WriteCache(FbxCache& pCache);
00203 
00204     bool            WriteBindingTables(FbxDocument* pDocument);
00205     bool            WriteBindingTable(FbxBindingTable& pTable);
00206 
00207     bool            WriteBindingOperators(FbxDocument* pDocument);
00208     bool            WriteBindingOperator(FbxBindingOperator& pOperator);
00209 
00210     bool            WriteImplementations(FbxDocument* pDocument);
00211     bool            WriteImplementation(FbxImplementation& pImplementation);
00212 
00213     bool            WriteCollections(FbxDocument* pDocument);
00214     bool            WriteCollection(FbxCollection& pImplementation);
00215 
00216     bool            WriteDocuments(FbxDocument* pDocument);
00217     bool            WriteDocument(FbxDocument& pSubDocument);
00218 
00219     bool            WriteLayeredTextures(FbxDocument* pDocument);
00220     bool            WriteLayeredTexture(FbxLayeredTexture& pTexture);
00221 
00222     void            WriteGobo(FbxScene& pScene);
00223     void            WriteGoboSection(FbxScene& pScene);
00224     void            WriteGobo(FbxGobo& pGobo);
00225 
00226     bool            WriteVideos(FbxDocument* pDocument);
00227     bool            WriteVideo(FbxVideo& pVideo, FbxString& pFileName, bool pEmbeddedMedia);
00228 
00229     bool            WriteAnimation(FbxDocument* pDocument);
00230     bool            WriteAnimation(FbxDocument* pDocument, FbxAnimLayer* pAnimLayer);
00231 
00232     bool            WriteFCurves(FbxObject& pObject, FbxAnimLayer* pAnimLayer, const char* pBlockName, bool pKeepBlockOpen=false, bool pRescaleShininess=false);
00233 
00234     void            WritePose(FbxPose& pPose);
00235 
00236     bool            WriteSelectionNode(FbxScene& pScene);
00237     void            WriteSelectionNode(FbxSelectionNode& pSelectionNode);
00238 
00239     bool            WriteSelectionSet(FbxScene& pScene);
00240     void            WriteSelectionSet(FbxSelectionSet& pSelectionSet);
00241     
00242     bool            WriteThumbnail(FbxThumbnail* pThumbnail);
00243 
00244     void            WriteSceneInfo(FbxDocumentInfo*);
00245     void            WriteGlobalSettings(FbxGlobalSettings& pGlobalSettings);
00246 
00247     bool            WriteExtensionSection(FbxScene& pScene, int pMediaCount);
00248 
00249     int             FindString(FbxString pString, FbxArray<FbxString*>& pStringArray);
00250 
00251     /****************** Function that write in the v5 section******************/
00252     void            WriteGlobalLightSettings(FbxScene& pScene);
00253     void            WriteShadowPlane(FbxScene& pScene);
00254     void            WriteShadowPlaneSection(FbxScene& pScene);
00255     void            WriteAmbientColor(FbxScene& pScene);
00256     void            WriteFogOption(FbxScene& pScene);
00257 
00258     void            WriteGlobalCameraSettings(FbxScene& pScene);
00259     void            WriteGlobalTimeSettings(FbxScene& pScene);
00260     /****************** Function that write in the v5 section******************/
00261     
00262     void            WritePassword();
00263 
00264     void            WriteLayeredAnimation(FbxScene& pScene);
00265 
00266 private:
00267     void            WritePropertyTemplate(FbxClassId pClassId, FbxDocument* pDocument, bool& pVisitedNodeClass);
00268     void            WriteProperty(FbxProperty& pProperty, bool lSetNodeAttributeFlag);
00269     void            ConnectTimeWarp(FbxAnimCurveNode* pCurveNode, KFCurveNode* pFCurveNode);
00270 
00271     FbxWriterFbx6&    operator=(const FbxWriterFbx6&);
00272 
00273     FbxScene*                   mScene;
00274     FbxIO*                      mFileObject;
00275     FbxExporter&                mExporter;
00276     Fbx6TypeObjectHierarchy*    mDocumentHierarchy;
00277     Fbx6TypeWriteReferences*    mDocumentReferences;
00278 
00279     bool                        mWriteNonDefaultPropertiesOnly;
00280     bool                        mWriteEnhancedProperties;
00281     EExportMode                 mExportMode;
00282 
00283     FbxSet                      mTextureAnimatedChannels;
00284     FbxSet                      mMaterialAnimatedChannels;
00285     FbxSet                      mTimeWarpsCurveNodes;
00286 
00287     struct TextureAnimatedChannels
00288     {
00289         bool mTranslation;
00290         bool mRotation;
00291         bool mScaling;
00292         bool mAlpha;
00293     };
00294 
00295     struct SurfaceMaterialAnimatedChannels
00296     {
00297         bool mAmbient;
00298         bool mDiffuse;
00299         bool mSpecular;
00300         bool mEmissive;
00301         bool mOpacity;
00302         bool mShininess;
00303         bool mReflectivity;
00304     };
00305 
00306     FbxNode*    mCurrentNode;
00307 
00308     struct ModifiedPropertyInfo { FbxObject* mObj; FbxString mPropName; };
00309     FbxArray<ModifiedPropertyInfo*> mModifiedProperties;
00310     void ReplaceUnsupportedProperties(FbxScene* pScene, bool pPreprocessPass, unsigned int pFormatV);
00311     void StoreUnsupportedProperty(FbxObject* pObject, FbxProperty& pProperty);
00312 
00313     FbxProgress* mProgress;
00314     bool mProgressPause;
00315 };
00316 
00317 bool IsNameUnique(FbxScene& pScene, FbxObject* pObject);
00318 
00319 #include <fbxsdk/fbxsdk_nsend.h>
00320 
00321 #endif /* _FBXSDK_FILEIO_FBX_WRITER_FBX6_H_ */