fbxsdk/fileio/fbx/fbxwriterfbx6.h Source File

fbxwriterfbx6.h
Go to the documentation of this file.
1 /****************************************************************************************
2 
3  Copyright (C) 2015 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  virtual bool FileCreate(char* pFileName);
33  virtual bool FileCreate(FbxStream* pStream, void* pStreamData);
34  virtual bool FileClose();
35  virtual bool IsFileOpen();
36 
38 
39  void SetExportMode(EExportMode pMode);
40 
41  virtual void GetWriteOptions();
42  virtual bool Write(FbxDocument* pDocument);
43  virtual bool PreprocessScene(FbxScene& pScene);
44  virtual bool PostprocessScene(FbxScene& pScene);
45  virtual void PluginWriteParameters(FbxObject& pParams);
46  virtual bool Write(FbxDocument* pDocument, FbxIO* pFbx);
47  virtual void SetProgressHandler(FbxProgress *pProgress);
48 
49  virtual bool SupportsStreams() const { return true; }
50 
51 private:
52  /*************************** new writer ***************************/
53  void ConvertShapePropertyToOldStyle(FbxScene& pScene);
54  void ConvertShapePropertyToNewStyle(FbxScene& pScene);
55  void BuildObjectDefinition(FbxDocument* pDocument, Fbx6TypeDefinition& pDefinitions);
56  void SetObjectWriteSupport(const Fbx6TypeDefinition& pDefinitions);
57  bool WriteDescriptionSection(FbxDocument* pDocument);
58  bool WriteReferenceSection(FbxDocument* pDocument, Fbx6TypeWriteReferences& pReferences);
59  void WriteObjectDefinition(FbxDocument* pDocument, Fbx6TypeDefinition& pDefinitions);
60  void WriteObjectProperties(FbxDocument* pDocument, Fbx6TypeDefinition& pDefinitions);
61 
62  void FlattenDocument(FbxDocument* pDocument, Fbx6TypeObjectHierarchy& pDocHierarchy, bool pFirstCall=true);
63  void UnFlattenDocument(FbxDocument* pDocument, Fbx6TypeObjectHierarchy& pDocHierarchy);
64  bool WriteObjectHeaderAndReferenceIfAny(FbxObject& pObj, const char* pObjectType) const;
65 
66  FbxObject* GetObjectIndirection(FbxObject* pObject);
67  void WriteObjectConnections(FbxDocument* pDocument);
68  void WriteTakesAndAnimation(FbxDocument* pDocument);
69 
70  void WriteConstraints(FbxScene& pScene);
71  void WriteConstraint(FbxConstraint& pConstraint, FbxScene& pScene);
72 
73  void WriteGeometryWeightedMap(FbxGeometryWeightedMap& pGeometryWeightedMap);
74  void WriteNodeAttributes(const FbxDocument& pDocument);
75  void WriteAllGeometries(FbxScene& pScene);
76 
77  void WriteAllGeometryWeightedMaps(FbxScene& pScene);
78 
79  int WriteCharacterPose(FbxScene& pScene);
80  void WriteCharacterPose(FbxCharacterPose& pCharacterPose);
81 
82  void WriteCharacterLinkGroup(FbxCharacter& pCharacter, int pCharacterGroupId, FbxScene& pScene);
83  void WriteCharacterLink(FbxCharacter& pCharacter, int pCharacterNodeId, FbxScene& pScene);
84  void WriteCharacterLinkRotationSpace(FbxCharacterLink& pCharacterLink);
85 
86  void WriteControlSetPlug(FbxScene& pScene);
87 
88  /*************************** new writer ***************************/
89  bool WriteNodes(FbxScene& pScene, bool pIncludeRoot);
90  bool WriteNodes(const FbxDocument& pDocument);
91 
92  /*************************** kept functions ***************************/
93  bool WriteObjectProperties(FbxObject* pObject);
94  bool WriteObjectPropertiesAndFlags(FbxObject* pObject);
95 
96  bool WriteContainers(FbxScene& pScene);
97 
98  bool WriteNode(FbxNode& pNode);
99  bool WriteNodeBegin(FbxNode& pNode);
100  bool WriteNodeEnd(FbxNode& pNode);
101  bool WriteNodeParameters(FbxNode& pNode);
102  bool WriteNodeVersion(FbxNode& pNode);
103  bool WriteNodeAnimationSettings(FbxNode& pNode);
104  bool WriteNodeShading(FbxNode& pNode);
105  bool WriteNodeCullingType(FbxNode& pNode);
106  bool WriteNodeAttribute(FbxNodeAttribute* pNodeAttribute);
107  bool WriteNodeProperties(FbxNode& pNode);
108 
109  bool WriteNodeType(FbxNode& pNode);
110  bool WriteNull(FbxNull* pNull);
111  bool WriteMarker(FbxNode& pNode);
112  bool WriteSkeleton(FbxSkeleton& pSkeleton);
113  bool WriteSkeletonRoot(FbxSkeleton& pSkeleton);
114  bool WriteSkeletonLimb(FbxSkeleton& pSkeleton);
115  bool WriteSkeletonLimbNode(FbxSkeleton& pSkeleton);
116  bool WriteSkeletonEffector(FbxSkeleton& pSkeleton);
117  bool WriteGenericNodes(FbxScene& pScene);
118 
119  bool WriteGeometry(FbxGeometry& pGeometry);
120  bool WriteMesh(FbxMesh& pMesh);
121  bool WriteMeshSmoothness(FbxMesh& pMesh);
122  bool WriteMeshVertices(FbxMesh& pMesh);
123  bool WriteMeshPolyVertexIndex(FbxMesh& pMesh);
124  bool WriteMeshEdges(FbxMesh& pMesh);
125  bool WriteNurb(FbxNurbs& pNurbs);
126  bool WriteNurbsSurface(FbxNurbsSurface& pNurbs);
127  bool WriteNurbsCurve(FbxNurbsCurve& pNurbsCurve);
128  bool WriteTrimNurbsSurface(FbxTrimNurbsSurface& pNurbs);
129  bool WriteBoundary(FbxBoundary& pBoundary);
130  bool WriteSubdiv(FbxSubDiv& pSubdiv);
131 
132  bool WritePatch(FbxPatch& pPatch);
133  bool WritePatchType(FbxPatch& pPatch, int pType);
134 
135  bool WriteDeformers(FbxScene& pScene);
136  bool WriteSkin(FbxSkin& pSkin);
137  bool WriteVertexCacheDeformer(FbxVertexCacheDeformer& pDeformer);
138  bool WriteCluster(FbxCluster& pCluster);
139  bool WriteShape(FbxShape& pShape, FbxString pShapeName, FbxGeometry& pGeometry);
140  void FindShapeValidIndices(FbxArray<FbxVector4>& pGeometryControlPoints, FbxArray<FbxVector4>& pShapeControlPoints, FbxArray<int>& lValidIndices);
141 
142  bool WriteFbxLayerElementNormals(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
143  bool WriteFbxLayerElementBinormals(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
144  bool WriteFbxLayerElementTangents(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
145  bool WriteFbxLayerElementMaterials(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
146  bool WriteFbxLayerElementTextures(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
147  bool WriteFbxLayerElementTexturesChannel(FbxLayerContainer& pLayerContainer, FbxLayerElement::EType pTextureType, FbxMultiMap& pLayerIndexSet);
148  bool WriteFbxLayerElementUVsChannel(FbxLayerContainer& pLayerContainer, FbxLayerElement::EType pTextureType, FbxMultiMap& pLayerIndexSet);
149 
150  bool WriteFbxLayerElementPolygonGroups(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
151  bool WriteFbxLayerElementVertexColors(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
152  bool WriteFbxLayerElementUVs(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
153  bool WriteFbxLayerElementSmoothing(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
154  bool WriteFbxLayerElementUserData(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
155  bool WriteFbxLayerElementVisibility(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
156  bool WriteFbxLayerElementVertexCrease(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
157  bool WriteFbxLayerElementEdgeCrease(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
158  bool WriteFbxLayerElementHole(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
159 
160  bool WriteLayers(FbxLayerContainer& pLayerContainer, FbxMultiMap&);
161  int MapLayeredTextureIndexToConnectionIndex(FbxNode* pNode, void* pLET, int pIndex);
162 
163  bool WriteMaterials(FbxDocument* pDocument);
164  bool WriteSurfaceMaterial(FbxSurfaceMaterial& pMaterial);
165 
166  bool WritePose(FbxScene& pScene);
167 
168  // Write Connections
169  bool WriteFieldConnection(FbxDocument* pDocument, FbxObject* pSrcObject, FbxDocument* pDstDocument);
170  bool WriteFieldConnection(FbxDocument* pDocument, FbxObject* pSrc,FbxObject* pDst);
171  bool WriteFieldConnection(FbxDocument* pDocument, FbxObject* pSrc,FbxProperty& pDst);
172  bool WriteFieldConnection(FbxDocument* pDocument, FbxProperty& pSrc,FbxObject* pDst);
173  bool WriteFieldConnection(FbxDocument* pDocument, FbxProperty& pSrc,FbxProperty& pDst);
174 
175  void WriteObjectConnections(FbxDocument* pDocument, FbxObject* pObject, bool pRecursive);
176 
177  bool WriteCamera(FbxCamera& pCamera);
178  bool WriteCameraStereo(FbxCameraStereo& pCameraStereo);
179  bool WriteLight(FbxLight& pLight);
180  bool WriteCameraSwitcher(FbxScene& pScene);
181  bool WriteCameraSwitcher(FbxCameraSwitcher& pCameraSwitcher);
182 
183  bool WriteTextures(FbxDocument* pDocument);
184  bool WriteTexture(FbxFileTexture& pTexture);
185 
186  bool WriteTimeWarps(FbxDocument* pDocument, FbxAnimStack* pAnimStack);
187  bool WriteThumbnails(FbxDocument* pDocument);
188  bool WriteThumbnail(FbxThumbnail& pThumbnail);
189 
190  bool WriteCaches(FbxDocument* pDocument);
191  bool WriteCache(FbxCache& pCache);
192 
193  bool WriteBindingTables(FbxDocument* pDocument);
194  bool WriteBindingTable(FbxBindingTable& pTable);
195 
196  bool WriteBindingOperators(FbxDocument* pDocument);
197  bool WriteBindingOperator(FbxBindingOperator& pOperator);
198 
199  bool WriteImplementations(FbxDocument* pDocument);
200  bool WriteImplementation(FbxImplementation& pImplementation);
201 
202  bool WriteCollections(FbxDocument* pDocument);
203  bool WriteCollection(FbxCollection& pImplementation);
204 
205  bool WriteDocuments(FbxDocument* pDocument);
206  bool WriteDocument(FbxDocument& pSubDocument);
207 
208  bool WriteLayeredTextures(FbxDocument* pDocument);
209  bool WriteLayeredTexture(FbxLayeredTexture& pTexture);
210 
211  void WriteGobo(FbxScene& pScene);
212  void WriteGoboSection(FbxScene& pScene);
213  void WriteGobo(FbxGobo& pGobo);
214 
215  bool WriteVideos(FbxDocument* pDocument);
216  bool WriteVideo(FbxVideo& pVideo, FbxString& pFileName, bool pEmbeddedMedia);
217 
218  bool WriteAnimation(FbxDocument* pDocument);
219  bool WriteAnimation(FbxDocument* pDocument, FbxAnimLayer* pAnimLayer);
220 
221  bool WriteFCurves(FbxObject& pObject, FbxAnimLayer* pAnimLayer, const char* pBlockName, bool pKeepBlockOpen=false, bool pRescaleShininess=false);
222 
223  void WritePose(FbxPose& pPose);
224 
225  bool WriteSelectionNode(FbxScene& pScene);
226  void WriteSelectionNode(FbxSelectionNode& pSelectionNode);
227 
228  bool WriteSelectionSet(FbxScene& pScene);
229  void WriteSelectionSet(FbxSelectionSet& pSelectionSet);
230 
231  bool WriteThumbnail(FbxThumbnail* pThumbnail);
232 
233  void WriteSceneInfo(FbxDocumentInfo*);
234  void WriteGlobalSettings(FbxGlobalSettings& pGlobalSettings);
235 
236  bool WriteExtensionSection(FbxScene& pScene, int pMediaCount);
237 
238  int FindString(FbxString pString, FbxArray<FbxString*>& pStringArray);
239 
240  /****************** Function that write in the v5 section******************/
241  void WriteGlobalLightSettings(FbxScene& pScene);
242  void WriteShadowPlane(FbxScene& pScene);
243  void WriteShadowPlaneSection(FbxScene& pScene);
244  void WriteAmbientColor(FbxScene& pScene);
245  void WriteFogOption(FbxScene& pScene);
246 
247  void WriteGlobalCameraSettings(FbxScene& pScene);
248  void WriteGlobalTimeSettings(FbxScene& pScene);
249  /****************** Function that write in the v5 section******************/
250 
251  void WritePassword();
252 
253  void WriteLayeredAnimation(FbxScene& pScene);
254 
255 private:
256  void WritePropertyTemplate(FbxClassId pClassId, FbxDocument* pDocument, bool& pVisitedNodeClass);
257  void WriteProperty(FbxProperty& pProperty, bool lSetNodeAttributeFlag);
258  void ConnectTimeWarp(FbxAnimCurveNode* pCurveNode, KFCurveNode* pFCurveNode);
259 
260  FbxWriterFbx6& operator=(const FbxWriterFbx6&);
261 
262  FbxScene* mScene;
263  FbxIO* mFileObject;
264  FbxExporter& mExporter;
265  Fbx6TypeObjectHierarchy* mDocumentHierarchy;
266  Fbx6TypeWriteReferences* mDocumentReferences;
267 
268  bool mWriteNonDefaultPropertiesOnly;
269  bool mWriteEnhancedProperties;
270  EExportMode mExportMode;
271 
272  FbxMultiMap mTextureAnimatedChannels;
273  FbxMultiMap mMaterialAnimatedChannels;
274  FbxMultiMap mTimeWarpsCurveNodes;
275 
276  struct TextureAnimatedChannels
277  {
278  bool mTranslation;
279  bool mRotation;
280  bool mScaling;
281  bool mAlpha;
282  };
283 
284  struct SurfaceMaterialAnimatedChannels
285  {
286  bool mAmbient;
287  bool mDiffuse;
288  bool mSpecular;
289  bool mEmissive;
290  bool mOpacity;
291  bool mShininess;
292  bool mReflectivity;
293  };
294 
295  FbxNode* mCurrentNode;
296 
297  struct ModifiedPropertyInfo { FbxObject* mObj; FbxString mPropName; };
298  FbxArray<ModifiedPropertyInfo*> mModifiedProperties;
299  void ReplaceUnsupportedProperties(FbxScene* pScene, bool pPreprocessPass, int pFormatV);
300  void StoreUnsupportedProperty(FbxObject* pObject, FbxProperty& pProperty);
301 
302  FbxProgress* mProgress;
303  bool mProgressPause;
304 };
305 
306 bool IsNameUnique(FbxScene& pScene, FbxObject* pObject);
307 
308 #include <fbxsdk/fbxsdk_nsend.h>
309 
310 #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.
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
This class is an composite of animation curves and is called as animation curve node.
virtual bool PostprocessScene(FbxScene &pScene)
Post-processes the scene.
FBX SDK video class.
Definition: fbxvideo.h:25
virtual bool Write(FbxDocument *pDocument)
Writes content to the specified file with given stream options.
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.
virtual void SetProgressHandler(FbxProgress *pProgress)
Pass a progress handler to the writer.
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:26
FbxWriterFbx6(FbxManager &pManager, FbxExporter &pExporter, int pID, FbxStatus &pStatus)
This object represents the shading node implementation.
virtual void GetWriteOptions()
Setup write options.
This class contains scene thumbnails and user-defined summary data.
This class contains functions for accessing global settings.
Base class for weighted animation constraints.
Definition: fbxconstraint.h:27
virtual bool PreprocessScene(FbxScene &pScene)
Pre-processes the scene.
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:89
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
Base class of other writers used internally.
Definition: fbxwriter.h:58
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:32
Class for progress reporting.
Definition: fbxprogress.h:31
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:37
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
virtual bool FileClose()
Closes the file.
FbxIO represents an FBX file.
Definition: fbxio.h:324
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.
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.
virtual bool FileCreate(char *pFileName)
Creates a new file.
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
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:91
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
virtual bool IsFileOpen()
Test if the file is open.
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)
virtual void PluginWriteParameters(FbxObject &pParams)
Writes extension plug-ins name, version and parameters, so that we can remember if a plug-in was used...
virtual bool SupportsStreams() const
Returns true if this writer supports FbxStream I/O.
Definition: fbxwriterfbx6.h:49
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
A mesh is a geometry made of polygons.
Definition: fbxmesh.h:32
This node attribute contains methods for accessing the properties of a stereo camera.