FBX C++ API Reference
fbxwriterfbx6.h
Go to the documentation of this file.
1 /****************************************************************************************
2 
3  Copyright (C) 2019 Autodesk, Inc.
4  All rights reserved.
5 
6  Use of this software is subject to the terms of the Autodesk license agreement
7  provided at the time of installation or download, or which otherwise accompanies
8  this software in either electronic or hard copy form.
9 
10 ****************************************************************************************/
11 
13 #ifndef _FBXSDK_FILEIO_FBX_WRITER_FBX6_H_
14 #define _FBXSDK_FILEIO_FBX_WRITER_FBX6_H_
15 
16 #include <fbxsdk.h>
17 
18 #include <fbxsdk/fbxsdk_nsbegin.h>
19 
20 class Fbx6TypeDefinition;
21 class Fbx6TypeWriteReferences;
22 class Fbx6TypeObjectHierarchy;
23 
25 
26 class FbxWriterFbx6 : public FbxWriter
27 {
28 public:
29  FbxWriterFbx6(FbxManager& pManager, FbxExporter& pExporter, int pID, FbxStatus& pStatus);
30  virtual ~FbxWriterFbx6();
31 
32  bool FileCreate(char* pFileName) override;
33  bool FileCreate(FbxStream* pStream, void* pStreamData) override;
34  bool FileClose() override;
35  bool IsFileOpen() override;
36 
38 
39  void SetExportMode(EExportMode pMode);
40 
41  void GetWriteOptions() override;
42  bool Write(FbxDocument* pDocument) override;
43  bool PreprocessScene(FbxScene& pScene) override;
44  bool PostprocessScene(FbxScene& pScene) override;
45 #ifndef FBXSDK_ENV_WINSTORE
46  void PluginWriteParameters(FbxObject& pParams) override;
47 #endif // FBXSDK_ENV_WINSTORE
48  virtual bool Write(FbxDocument* pDocument, FbxIO* pFbx);
49  void SetProgressHandler(FbxProgress *pProgress) override;
50  void SetEmbeddedFileCallback(FbxEmbeddedFileCallback* pCallback) override;
51 
52  bool SupportsStreams() const override { return true; }
53 
54 private:
55  /*************************** new writer ***************************/
56  void ConvertShapePropertyToOldStyle(FbxScene& pScene);
57  void ConvertShapePropertyToNewStyle(FbxScene& pScene);
58  void BuildObjectDefinition(FbxDocument* pDocument, Fbx6TypeDefinition& pDefinitions);
59  void SetObjectWriteSupport(const Fbx6TypeDefinition& pDefinitions);
60  bool WriteDescriptionSection(FbxDocument* pDocument);
61  bool WriteReferenceSection(FbxDocument* pDocument, Fbx6TypeWriteReferences& pReferences);
62  void WriteObjectDefinition(FbxDocument* pDocument, Fbx6TypeDefinition& pDefinitions);
63  void WriteObjectProperties(FbxDocument* pDocument, Fbx6TypeDefinition& pDefinitions);
64 
65  void FlattenDocument(FbxDocument* pDocument, Fbx6TypeObjectHierarchy& pDocHierarchy, bool pFirstCall=true);
66  void UnFlattenDocument(FbxDocument* pDocument, Fbx6TypeObjectHierarchy& pDocHierarchy);
67  bool WriteObjectHeaderAndReferenceIfAny(FbxObject& pObj, const char* pObjectType) const;
68 
69  FbxObject* GetObjectIndirection(FbxObject* pObject);
70  void WriteObjectConnections(FbxDocument* pDocument);
71  void WriteTakesAndAnimation(FbxDocument* pDocument);
72 
73  void WriteConstraints(FbxScene& pScene);
74  void WriteConstraint(FbxConstraint& pConstraint, FbxScene& pScene);
75 
76  void WriteGeometryWeightedMap(FbxGeometryWeightedMap& pGeometryWeightedMap);
77  void WriteNodeAttributes(const FbxDocument& pDocument);
78  void WriteAllGeometries(FbxScene& pScene);
79 
80  void WriteAllGeometryWeightedMaps(FbxScene& pScene);
81 
82  int WriteCharacterPose(FbxScene& pScene);
83  void WriteCharacterPose(FbxCharacterPose& pCharacterPose);
84 
85  void WriteCharacterLinkGroup(FbxCharacter& pCharacter, int pCharacterGroupId, FbxScene& pScene);
86  void WriteCharacterLink(FbxCharacter& pCharacter, int pCharacterNodeId, FbxScene& pScene);
87  void WriteCharacterLinkRotationSpace(FbxCharacterLink& pCharacterLink);
88 
89  void WriteControlSetPlug(FbxScene& pScene);
90 
91  /*************************** new writer ***************************/
92  bool WriteNodes(FbxScene& pScene, bool pIncludeRoot);
93  bool WriteNodes(const FbxDocument& pDocument);
94 
95  /*************************** kept functions ***************************/
96  bool WriteObjectProperties(FbxObject* pObject);
97  bool WriteObjectPropertiesAndFlags(FbxObject* pObject);
98 
99  bool WriteContainers(FbxScene& pScene);
100 
101  bool WriteNode(FbxNode& pNode);
102  bool WriteNodeBegin(FbxNode& pNode);
103  bool WriteNodeEnd(FbxNode& pNode);
104  bool WriteNodeParameters(FbxNode& pNode);
105  bool WriteNodeVersion(FbxNode& pNode);
106  bool WriteNodeAnimationSettings(FbxNode& pNode);
107  bool WriteNodeShading(FbxNode& pNode);
108  bool WriteNodeCullingType(FbxNode& pNode);
109  bool WriteNodeAttribute(FbxNodeAttribute* pNodeAttribute);
110  bool WriteNodeProperties(FbxNode& pNode);
111 
112  bool WriteNodeType(FbxNode& pNode);
113  bool WriteNull(FbxNull* pNull);
114  bool WriteMarker(FbxNode& pNode);
115  bool WriteSkeleton(FbxSkeleton& pSkeleton);
116  bool WriteSkeletonRoot(FbxSkeleton& pSkeleton);
117  bool WriteSkeletonLimb(FbxSkeleton& pSkeleton);
118  bool WriteSkeletonLimbNode(FbxSkeleton& pSkeleton);
119  bool WriteSkeletonEffector(FbxSkeleton& pSkeleton);
120  bool WriteGenericNodes(FbxScene& pScene);
121 
122  bool WriteGeometry(FbxGeometry& pGeometry);
123  bool WriteMesh(FbxMesh& pMesh);
124  bool WriteMeshSmoothness(FbxMesh& pMesh);
125  bool WriteMeshVertices(FbxMesh& pMesh);
126  bool WriteMeshPolyVertexIndex(FbxMesh& pMesh);
127  bool WriteMeshEdges(FbxMesh& pMesh);
128  bool WriteNurb(FbxNurbs& pNurbs);
129  bool WriteNurbsSurface(FbxNurbsSurface& pNurbs);
130  bool WriteNurbsCurve(FbxNurbsCurve& pNurbsCurve);
131  bool WriteTrimNurbsSurface(FbxTrimNurbsSurface& pNurbs);
132  bool WriteBoundary(FbxBoundary& pBoundary);
133  bool WriteSubdiv(FbxSubDiv& pSubdiv);
134 
135  bool WritePatch(FbxPatch& pPatch);
136  bool WritePatchType(FbxPatch& pPatch, int pType);
137 
138  bool WriteDeformers(FbxScene& pScene);
139  bool WriteSkin(FbxSkin& pSkin);
140  bool WriteVertexCacheDeformer(FbxVertexCacheDeformer& pDeformer);
141  bool WriteCluster(FbxCluster& pCluster);
142  bool WriteShape(FbxShape& pShape, FbxString pShapeName, FbxGeometry& pGeometry);
143  void FindShapeValidIndices(FbxArray<FbxVector4>& pGeometryControlPoints, FbxArray<FbxVector4>& pShapeControlPoints, FbxArray<int>& lValidIndices);
144 
145  bool WriteFbxLayerElementNormals(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
146  bool WriteFbxLayerElementBinormals(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
147  bool WriteFbxLayerElementTangents(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
148  bool WriteFbxLayerElementMaterials(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
149  bool WriteFbxLayerElementTextures(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
150  bool WriteFbxLayerElementTexturesChannel(FbxLayerContainer& pLayerContainer, FbxLayerElement::EType pTextureType, FbxMultiMap& pLayerIndexSet);
151  bool WriteFbxLayerElementUVsChannel(FbxLayerContainer& pLayerContainer, FbxLayerElement::EType pTextureType, FbxMultiMap& pLayerIndexSet);
152 
153  bool WriteFbxLayerElementPolygonGroups(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
154  bool WriteFbxLayerElementVertexColors(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
155  bool WriteFbxLayerElementUVs(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
156  bool WriteFbxLayerElementSmoothing(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
157  bool WriteFbxLayerElementUserData(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
158  bool WriteFbxLayerElementVisibility(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
159  bool WriteFbxLayerElementVertexCrease(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
160  bool WriteFbxLayerElementEdgeCrease(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
161  bool WriteFbxLayerElementHole(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
162 
163  bool WriteLayers(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
164  int MapLayeredTextureIndexToConnectionIndex(FbxNode* pNode, void* pLET, int pIndex);
165 
166  bool WriteMaterials(FbxDocument* pDocument);
167  bool WriteSurfaceMaterial(FbxSurfaceMaterial& pMaterial);
168 
169  bool WritePose(FbxScene& pScene);
170 
171  // Write Connections
172  bool WriteFieldConnection(FbxDocument* pDocument, FbxObject* pSrcObject, FbxDocument* pDstDocument);
173  bool WriteFieldConnection(FbxDocument* pDocument, FbxObject* pSrc,FbxObject* pDst);
174  bool WriteFieldConnection(FbxDocument* pDocument, FbxObject* pSrc,FbxProperty& pDst);
175  bool WriteFieldConnection(FbxDocument* pDocument, FbxProperty& pSrc,FbxObject* pDst);
176  bool WriteFieldConnection(FbxDocument* pDocument, FbxProperty& pSrc,FbxProperty& pDst);
177 
178  void WriteObjectConnections(FbxDocument* pDocument, FbxObject* pObject, bool pRecursive);
179 
180  bool WriteCamera(FbxCamera& pCamera);
181  bool WriteCameraStereo(FbxCameraStereo& pCameraStereo);
182  bool WriteLight(FbxLight& pLight);
183  bool WriteCameraSwitcher(FbxScene& pScene);
184  bool WriteCameraSwitcher(FbxCameraSwitcher& pCameraSwitcher);
185 
186  bool WriteTextures(FbxDocument* pDocument);
187  bool WriteTexture(FbxFileTexture& pTexture);
188 
189  bool WriteTimeWarps(FbxDocument* pDocument, FbxAnimStack* pAnimStack);
190  bool WriteThumbnails(FbxDocument* pDocument);
191  bool WriteThumbnail(FbxThumbnail& pThumbnail);
192 
193  bool WriteCaches(FbxDocument* pDocument);
194  bool WriteCache(FbxCache& pCache);
195 
196  bool WriteBindingTables(FbxDocument* pDocument);
197  bool WriteBindingTable(FbxBindingTable& pTable);
198 
199  bool WriteBindingOperators(FbxDocument* pDocument);
200  bool WriteBindingOperator(FbxBindingOperator& pOperator);
201 
202  bool WriteImplementations(FbxDocument* pDocument);
203  bool WriteImplementation(FbxImplementation& pImplementation);
204 
205  bool WriteCollections(FbxDocument* pDocument);
206  bool WriteCollection(FbxCollection& pImplementation);
207 
208  bool WriteDocuments(FbxDocument* pDocument);
209  bool WriteDocument(FbxDocument& pSubDocument);
210 
211  bool WriteLayeredTextures(FbxDocument* pDocument);
212  bool WriteLayeredTexture(FbxLayeredTexture& pTexture);
213 
214  void WriteGobo(FbxScene& pScene);
215  void WriteGoboSection(FbxScene& pScene);
216  void WriteGobo(FbxGobo& pGobo);
217 
218  bool WriteVideos(FbxDocument* pDocument);
219  bool WriteVideo(FbxVideo& pVideo, FbxString& pFileName, bool pEmbeddedMedia);
220 
221  bool WriteAnimation(FbxDocument* pDocument);
222  bool WriteAnimation(FbxDocument* pDocument, FbxAnimLayer* pAnimLayer);
223 
224  bool WriteFCurves(FbxObject& pObject, FbxAnimLayer* pAnimLayer, const char* pBlockName, bool pKeepBlockOpen=false, bool pRescaleShininess=false);
225 
226  void WritePose(FbxPose& pPose);
227 
228  bool WriteSelectionNode(FbxScene& pScene);
229  void WriteSelectionNode(FbxSelectionNode& pSelectionNode);
230 
231  bool WriteSelectionSet(FbxScene& pScene);
232  void WriteSelectionSet(FbxSelectionSet& pSelectionSet);
233 
234  bool WriteThumbnail(FbxThumbnail* pThumbnail);
235 
236  void WriteSceneInfo(FbxDocumentInfo*);
237  void WriteGlobalSettings(FbxGlobalSettings& pGlobalSettings);
238 
239  bool WriteExtensionSection(FbxScene& pScene, int pMediaCount);
240 
241  int FindString(FbxString pString, FbxArray<FbxString*>& pStringArray);
242 
243  /****************** Function that write in the v5 section******************/
244  void WriteGlobalLightSettings(FbxScene& pScene);
245  void WriteShadowPlane(FbxScene& pScene);
246  void WriteShadowPlaneSection(FbxScene& pScene);
247  void WriteAmbientColor(FbxScene& pScene);
248  void WriteFogOption(FbxScene& pScene);
249 
250  void WriteGlobalCameraSettings(FbxScene& pScene);
251  void WriteGlobalTimeSettings(FbxScene& pScene);
252  /****************** Function that write in the v5 section******************/
253 
254  void WritePassword();
255 
256  void WriteLayeredAnimation(FbxScene& pScene);
257 
258 private:
259  void WritePropertyTemplate(FbxClassId pClassId, FbxDocument* pDocument, bool& pVisitedNodeClass);
260  void WriteProperty(FbxProperty& pProperty, bool lSetNodeAttributeFlag);
261  void ConnectTimeWarp(FbxAnimCurveNode* pCurveNode, KFCurveNode* pFCurveNode);
262 
263  FbxWriterFbx6& operator=(const FbxWriterFbx6&);
264 
265  FbxScene* mScene;
266  FbxIO* mFileObject;
267  FbxExporter& mExporter;
268  Fbx6TypeObjectHierarchy* mDocumentHierarchy;
269  Fbx6TypeWriteReferences* mDocumentReferences;
270 
271  bool mWriteNonDefaultPropertiesOnly;
272  bool mWriteEnhancedProperties;
273  EExportMode mExportMode;
274 
275  FbxMultiMap mTextureAnimatedChannels;
276  FbxMultiMap mMaterialAnimatedChannels;
277  FbxMultiMap mTimeWarpsCurveNodes;
278 
279  struct TextureAnimatedChannels
280  {
281  bool mTranslation;
282  bool mRotation;
283  bool mScaling;
284  bool mAlpha;
285  };
286 
287  struct SurfaceMaterialAnimatedChannels
288  {
289  bool mAmbient;
290  bool mDiffuse;
291  bool mSpecular;
292  bool mEmissive;
293  bool mOpacity;
294  bool mShininess;
295  bool mReflectivity;
296  };
297 
298  FbxNode* mCurrentNode;
299 
300  struct ModifiedPropertyInfo { FbxObject* mObj; FbxString mPropName; };
301  FbxArray<ModifiedPropertyInfo*> mModifiedProperties;
302  void ReplaceUnsupportedProperties(FbxScene* pScene, bool pPreprocessPass, int pFormatV);
303  void StoreUnsupportedProperty(FbxObject* pObject, FbxProperty& pProperty);
304  bool IsLeafRoll(const FbxString& pNameWithoutNameSpacePrefix);
305 
306  FbxProgress* mProgress;
307  bool mProgressPause;
308 };
309 
310 bool IsNameUnique(FbxScene& pScene, FbxObject* pObject);
311 
312 #include <fbxsdk/fbxsdk_nsend.h>
313 
314 #endif /* _FBXSDK_FILEIO_FBX_WRITER_FBX6_H_ */
The animation layer is a collection of animation curve nodes.
Definition: fbxanimlayer.h:30
This class describes image mapping on top of geometry.
Callback to operate on the embedded data while it is processed.
Definition: fbxcallbacks.h:166
bool IsNameUnique(FbxScene &pScene, FbxObject *pObject)
A gobo is a filter placed over a spot light to project light patterns through fog on a surface...
Definition: fbxgobo.h:26
SDK object manager.
Definition: fbxmanager.h:56
The Animation stack is a collection of animation layers.
Definition: fbxanimstack.h:37
bool IsFileOpen() override
Test if the file is open.
bool SupportsStreams() const override
Returns true if this writer supports FbxStream I/O.
Definition: fbxwriterfbx6.h:52
This class is an composite of animation curves and is called as animation curve node.
FBX SDK video class.
Definition: fbxvideo.h:25
Abstract class for implementing I/O operations through a stream of data.
Definition: fbxstream.h:26
This class contains material settings.
Utility class to manipulate strings.
Definition: fbxstring.h:66
FbxDocument is a base class for FbxScene and FbxLibrary classes.
Definition: fbxdocument.h:46
Contains a collection of FbxLayer objects.
Class for clusters (links).
Definition: fbxcluster.h:47
This node attribute contains methods for accessing the properties of a camera switcher.
This class facilitates the testing/reporting of errors.
Definition: fbxstatus.h:29
FbxWriterFbx6(FbxManager &pManager, FbxExporter &pExporter, int pID, FbxStatus &pStatus)
This object represents the shading node implementation.
This class contains scene thumbnails and user-defined summary data.
This class contains functions for accessing global settings.
bool PostprocessScene(FbxScene &pScene) override
Post-processes the scene.
Base class for weighted animation constraints.
Definition: fbxconstraint.h:27
A character pose is a character and an associated hierarchy of nodes.
FBX SDK selection set class.
The base class of most FBX objects.
Definition: fbxobject.h:157
This class deforms control points of a geometry using control point positions stored in the associate...
FbxTrimNurbsSurface describes a NURBS surface with regions trimmed or cut away with trimming boundari...
Represents an element in the scene graph.
Definition: fbxnode.h:72
Class to export SDK objects into an FBX file.
Definition: fbxexporter.h:90
A patch is a type of node attribute with parametric surface.
Definition: fbxpatch.h:26
This node attribute contains methods for accessing the properties of a light.
Definition: fbxlight.h:27
This class contains the description of a 3D scene.
Definition: fbxscene.h:61
This class contains the description of a Pose and provide some methods to access Pose info in one FBX...
Definition: fbxpose.h:96
bool Write(FbxDocument *pDocument) override
Writes content to the specified file with given stream options.
Base class of other writers used internally.
Definition: fbxwriter.h:59
A NURBS surface is a type of parametric geometry.
A shape describes the deformation on a set of control points, which is similar to the cluster deforme...
Definition: fbxshape.h:42
Class for progress reporting.
Definition: fbxprogress.h:31
bool PreprocessScene(FbxScene &pScene) override
Pre-processes the scene.
FbxBoundary describes a trimming boundary for a trimmed NURBS object.
Internal class used to differentiate objects during run-time.
Definition: fbxclassid.h:39
EType
Layer Element type identifier.
Definition: fbxlayer.h:75
FbxSelectionNode is an auxiliary class for Selection Set.
Class to hold user properties.
Definition: fbxproperty.h:39
FbxLayeredTexture is a combination of multiple textures(FbxTexture) blended sequentially.
Skin deformer class.
Definition: fbxskin.h:37
A FbxObject derived container for FbxObject.
Definition: fbxcollection.h:28
FbxIO represents an FBX file.
Definition: fbxio.h:347
A binding table represents a collection of bindings from source types such as FbxObject, or FbxLayerElements to corresponding destinations, usually a third party shader parameters.
void SetEmbeddedFileCallback(FbxEmbeddedFileCallback *pCallback) override
FbxArray< FbxTakeInfo * > TakeInfoArray
Definition: fbxwriterfbx6.h:22
This node attribute contains methods for accessing the properties of a camera.
Definition: fbxcamera.h:34
This object represents a binding operation on a FbxObject or FbxProperty.
A NURBS surface is a type of parametric geometry.
Definition: fbxnurbs.h:31
A Non-Uniform Rational B-Spline (NURBS) curve is a type of parametric geometry.
Definition: fbxnurbscurve.h:60
This node attribute contains the properties of a null node.
Definition: fbxnull.h:25
bool FileCreate(char *pFileName) override
Creates a new file.
void SetProgressHandler(FbxProgress *pProgress) override
Pass a progress handler to the writer.
This class specializes a node attribute to represent the elements forming "bone" chains.
Definition: fbxskeleton.h:34
A Character is a person or animal with pre-defined skeleton system.
Definition: fbxcharacter.h:109
void PluginWriteParameters(FbxObject &pParams) override
Writes extension plug-ins name, version and parameters, so that we can remember if a plug-in was used...
This class provides the structure to build a correspondence between 2 geometries. ...
The base class of geometric objects that support control point deformations (e.g. ...
Definition: fbxgeometry.h:45
This class is the base class to all types of node attributes.
Class to manipulate a map that can contain multiple times the same key.
Definition: fbxmultimap.h:22
void SetExportMode(EExportMode pMode)
bool FileClose() override
Closes the file.
Simple class to hold RGBA values of a thumbnail image.
Definition: fbxthumbnail.h:27
virtual ~FbxWriterFbx6()
This object contains methods for accessing point animation in a cache file.
Definition: fbxcache.h:33
void GetWriteOptions() override
Setup write options.
A mesh is a geometry made of polygons.
Definition: fbxmesh.h:33
This node attribute contains methods for accessing the properties of a stereo camera.