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