FBX C++ API Reference
fbxreaderfbx5.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_READER_FBX5_H_
14 #define _FBXSDK_FILEIO_FBX_READER_FBX5_H_
15 
16 #include <fbxsdk.h>
17 
18 #include <fbxsdk/fbxsdk_nsbegin.h>
19 
20 class FbxAnimLayer;
21 class Fbx5ObjectTypeInfo;
22 
24  FbxImporter& pImporter,
25  int pID,
26  FbxStatus& pStatus);
27 void GetInfoFBXReader(int* pCount,
28  const char* * pExtensions,
29  const char* * pDescriptions);
30 
31 class FbxReaderFbx5 : public FbxReader
32 {
33 public:
34  FbxReaderFbx5(FbxManager& pManager, FbxImporter& pImporter, int pID, FbxStatus& pStatus);
35  virtual ~FbxReaderFbx5();
36 
37  virtual bool FileOpen(char* pFileName, bool pIgnoredArg);
38  bool FileOpen(char* pFileName, EFileOpenSpecialFlags pFlags) override { return FbxReader::FileOpen(pFileName, pFlags); }
39  bool FileOpen(char* pFileName) override;
40  bool FileOpen(FbxFile * pFile) override;
41  bool FileOpen(FbxStream * pStream, void* pStreamData) override;
42  bool FileClose() override;
43  bool IsFileOpen() override;
44 
45  void SetEmbeddingExtractionFolder(const char* pExtractFolder) override;
46  void SetEmbeddedFileCallback(FbxEmbeddedFileCallback* pCallback) override;
47 
48  typedef enum
49  {
53  } EImportMode;
54 
56  void GetVersion(int& pMajor, int& pMinor, int& pRevision) override;
57 
58  bool GetReadOptions(bool pParseFileAsNeeded = true) override;
59  bool Read(FbxDocument* pDocument) override;
60 
61  virtual bool GetReadOptions(FbxIO* pFbx, bool pParseFileAsNeeded = true);
62  virtual bool Read(FbxScene& pScene, FbxIO* pFbx);
63 
64  FbxDocumentInfo* GetSceneInfo() override { return mSceneInfo; }
65  FbxArray<FbxTakeInfo*>* GetTakeInfo() override { return &mTakeInfo; }
66 
67  bool SupportsStreams() const override { return true; }
68 
69 private:
70  void ReadOptionsInMainSection();
71  void ReadTakeOptions();
72  bool ReadOptionsInExtensionSection(int& pSectionIndex);
73  void ReadOptionsInGenericSection();
74  bool WriteOptionsInExtensionSection(bool pOverwriteLastExtensionSection=false);
75  bool WriteThumbnail(FbxThumbnail*);
76  FbxDocumentInfo* ReadSceneInfo();
77  FbxDocumentInfo* ReadSceneInfo(FbxString& pType);
78  void WriteSceneInfo(FbxDocumentInfo*);
79  void SetIsBeforeVersion6WithMainSection(bool pOpenMainSection);
80 
81  bool ReadDefinitionSection(FbxScene& pScene, FbxArray<Fbx5ObjectTypeInfo*>& pObjectContent);
82  bool ReadObjectSection(FbxScene& pScene, FbxArray<Fbx5ObjectTypeInfo*>& pObjectContent);
83  bool ReadObject(FbxScene& pScene, FbxString& pObjectType, FbxString& pObjectSubType, FbxString& pObjectName, FbxString& pObjectUniqueId);
84  bool ReadNode();
85  //bool ReadGenericNode(FbxScene& pScene);
86  bool ReadAnimation(FbxScene& pScene);
87  bool ReadTakeAnimation(FbxScene& pScene, FbxTakeInfo* pTakeInfo);
88  FbxThumbnail* ReadThumbnail();
89  bool ReadNodeAnimation(FbxIO& pFileObject, FbxScene& pScene, FbxTakeInfo* pTakeInfo);
90  bool TimeShiftNodeAnimation(FbxScene& pScene, FbxTakeInfo* pTakeInfo);
91  bool ReadHierarchy(FbxNode& pRootNode);
92  bool ResolveHierarchy(FbxNode& pRootNode);
93  bool ResolveLinks(FbxNode& pRootNode, FbxNode& pCurrentNode);
94  bool ResolveTargets(FbxNode& pRootNode);
95  bool ResolveUpNodes(FbxNode& pRootNode);
96  bool ResolveCameraBackgrounds(FbxScene& pScene);
97  void RemoveDuplicateTextures(FbxScene& pScene);
98  void RemoveDuplicateMaterials(FbxScene& pScene);
99 
100  void ReadPose(FbxScene& pScene);
101  bool ReadPose(FbxScene& pScene, FbxPose* pPose, bool pAsBindPose);
102 
103  void ReadCameraSwitcher(FbxScene& pScene);
104  void ReorderCameraSwitcherIndices(FbxScene& pScene);
105 
106  void ReadGobo(FbxScene& pScene);
107  void ReadGoboSection(FbxScene& pScene);
108  void ReadGobo(FbxGobo& pGobo);
109 
110  void ReadCharacter(FbxScene& pScene);
111  void ReadCharacter(FbxCharacter& pCharacter,int& pInputType, int& pInputIndex);
112  void ReadCharacterLinkGroup(FbxCharacter& pCharacter, int pCharacterGroupId);
113  void ReadCharacterLink(FbxCharacter& pCharacter, int pCharacterNodeId);
114  void ReadCharacterLinkRotationSpace(FbxCharacterLink& pCharacterLink);
115  void ReadFilterSet(FbxCharacter& pCharacter);
116  void ReadControlSet(FbxControlSet& pControlSet);
117  void ReadControlSetLinkGroup(FbxControlSet& pControlSet, int pCharacterGroupId);
118  void ReadControlSetLink(FbxControlSet& pControlSet, int pCharacterNodeId);
119  void ReadEffector(FbxControlSet& pControlSet);
120  void ReadEffectorAux(FbxControlSet& pControlSet);
121 
122  int ReadCharacterPose(FbxScene& pScene);
123  bool ReadCharacterPose(FbxCharacterPose& pCharacterPose);
124 
125  void ReadGlobalLightSettings(FbxScene& pScene);
126  void ReadShadowPlane(FbxScene& pScene);
127  void ReadAmbientColor(FbxScene& pScene);
128  void ReadFogOption(FbxScene& pScene);
129 
130  void ReadGlobalCameraAndTimeSettings(FbxScene& pScene); // for pre v6 files
131  void ReadGlobalTimeSettings(FbxScene& pScene);
132 
133  void ReadGlobalCameraSettings(FbxScene& pScene);
134 
135  bool ReadMedia(FbxScene& pScene, const char* pEmbeddedMediaDirectory = "");
136  FbxString ReadMediaClip(const char* pEmbeddedMediaDirectory);
137 
138  bool ReadNode ( FbxNode& pNode );
139  bool ReadGenericNode ( FbxGenericNode& pNode );
140  bool ReadNodeChildrenName ( FbxNode& pNode );
141  bool ReadNodeShading ( FbxNode& pNode );
142  bool ReadNodeCullingType ( FbxNode& pNode );
143  bool ReadNodeLimits ( FbxNode& pNode );
144  bool ReadNodeTarget ( FbxNode& pNode );
145  bool ReadNodeAttribute ( FbxNode& pNode );
146  bool ReadNodePivots ( FbxNode& pNode );
147  bool ReadNodeDefaultAttributes ( FbxNode& pNode );
148  bool ReadNodeProperties ( FbxNode& pNode );
149  bool ReadGeometry ( FbxGeometry& pGeometry );
150  bool ReadGeometryMaterial ( FbxGeometry& pGeometry );
151  bool ReadGeometryTexture ( FbxGeometry& pGeometry );
152  bool ReadGeometryLinks ( FbxGeometry& pGeometry );
153  bool ReadGeometryShapes ( FbxGeometry& pGeometry );
154  bool ReadGeometryLayer ( FbxGeometry& pGeometry );
155  bool ReadGeometryTextureLayer ( FbxGeometry& pGeometry, int pLayerIndex );
156 
157  bool ReadNull ( FbxNull& pNull );
158 
159  bool ReadMarker ( FbxMarker& pMarker );
160 
161  bool ReadCamera ( FbxCamera& pCamera );
162  bool ReadCameraSwitcher ( FbxCameraSwitcher& pCameraSwitcher );
163 
164  bool ReadLight ( FbxLight& pLight );
165 
166  bool ReadMesh ( FbxMesh& pMesh );
167  bool ReadMeshVertices ( FbxMesh& pMesh );
168  bool ReadMeshNormals ( FbxMesh& pMesh );
169  bool ReadMeshAssignation ( FbxMesh& pMesh );
170  bool ReadMeshPolygonIndex ( FbxMesh& pMesh );
171  bool ReadMeshPolyGroupIndex ( FbxMesh& pMesh );
172  bool ReadMeshMaterialsID ( FbxMesh& pMesh );
173  bool ReadMeshTexturesID ( FbxMesh& pMesh );
174  bool ReadMeshTextureType ( FbxMesh& pMesh );
175  bool ReadMeshTextureUV ( FbxMesh& pMesh );
176  bool ReadMeshTextureIndex ( FbxMesh& pMesh );
177  bool ReadMeshVertexColors ( FbxMesh& pMesh );
178 
179 
180  // Layer elements
181  bool ReadLayerElements (FbxGeometry& pGeometry);
182  bool ReadLayerElementsMaterial (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsMaterial);
183  bool ReadLayerElementsNormal (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsNormal);
184  bool ReadLayerElementsVertexColor (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsVertexColor);
185  bool ReadLayerElementsTexture (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsTexture);
186  bool ReadLayerElementsUV (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsUV);
187  bool ReadLayerElementsPolygonGroup (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsPolygonGroup);
188 
189  bool ReadNurb ( FbxNurbs& pNurbs );
190 
191  bool ReadPatch ( FbxPatch& pPatch );
192  int ReadPatchType ( FbxPatch& pPatch );
193 
194  bool ReadTexture(FbxFileTexture& pTexture);
195  bool ReadSurfaceMaterial(FbxSurfacePhong& pMaterial);
196  bool ReadLink(FbxCluster& pLink);
197  bool ReadSkin(FbxSkin& pSkin);
198  bool ReadCluster(FbxCluster& pCluster);
199  bool ReadShape(FbxShape& pShape, FbxGeometry& pGeometry);
200  bool ReadVideo(FbxVideo& pVideo);
201  bool ReadConstraint(FbxConstraint& pPosition);
202 
203  bool ReadUserProperties (FbxNode& pNode);
204  bool ReadProperties(FbxObject *pObject);
205 
206  //
207  // 6.0 Format specific
208  //
209  bool ReadConnectionSection();
210  void ReadPoses(FbxScene& pScene);
211 
212  FbxString ConvertCameraName(FbxString pCameraName);
213 
214  bool GenerateParametricGeometryLayer(FbxGeometry& pGeometry);
215  void CorrectTextureLayers(FbxMesh& pMesh);
216 
217  void TransferAnimation(void* pRootCurveNode, FbxProperty& pRootProperty, bool pValueOnly = false);
218  void ReadAnimation(FbxIO& pFileObject, void* pCurveNode);
219  void ReadAnimation(FbxIO& pFileObject, FbxObject* pObj);
220 
221  void ReadTimeWarps(FbxIO& pFileObject, FbxMultiMap& pTimeWarpSet);
222  void DestroyTimeWarps(FbxMultiMap& pTimeWarpSet);
223 
224  FbxNode* FindNode (char* pName);
225  int FindString(FbxString pString, FbxArray<FbxString*>& pStringArray);
226  FbxString FindFile(FbxString pFullFilePath, FbxString pRelativeFilePath = "");
227 
228  bool ReadPassword(FbxString pPassword);
229 
230  void ReadSceneGenericPersistenceSection(FbxScene& pScene);
231 
232 
233 
234 
235 private:
236  FbxReaderFbx5& operator=(FbxReaderFbx5 const&) { return *this; }
237 
238  FbxIO* mFileObject;
239  FbxImporter& mImporter;
240 
241  FbxCharPtrSet mNodeArrayName;
242  FbxCharPtrSet mTargetArrayName;
243  FbxCharPtrSet mUpNodeArrayName;
244  FbxCharPtrSet mCameraBackgroundArrayName;
245 
246  FbxObjectStringMap mObjectMap;
247  FbxArray<FbxTakeInfo *> mTakeInfo;
248  FbxDocumentInfo * mSceneInfo;
249  FbxAnimLayer* mAnimLayer;
250 
251  // Temporary storage
252  FbxArray<FbxTexture*> mTemporaryTextures;
253 };
254 
255 #include <fbxsdk/fbxsdk_nsend.h>
256 
257 #endif /* _FBXSDK_FILEIO_FBX_READER_FBX5_H_ */
The animation layer is a collection of animation curve nodes.
Definition: fbxanimlayer.h:30
FbxReader * CreateFBXReader(FbxManager &pManager, FbxImporter &pImporter, int pID, FbxStatus &pStatus)
This class describes image mapping on top of geometry.
EFileOpenSpecialFlags
Flags for reading parts of file.
Definition: fbxreader.h:92
void GetVersion(int &pMajor, int &pMinor, int &pRevision) override
Returns the file version.
Callback to operate on the embedded data while it is processed.
Definition: fbxcallbacks.h:166
FbxReaderFbx5(FbxManager &pManager, FbxImporter &pImporter, int pID, FbxStatus &pStatus)
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
FbxArray< FbxTakeInfo * > * GetTakeInfo() override
Returns the list of take infos from the file.
Definition: fbxreaderfbx5.h:65
bool GetReadOptions(bool pParseFileAsNeeded=true) override
Returns file stream options.
FBX SDK video class.
Definition: fbxvideo.h:25
Abstract class for implementing I/O operations through a stream of data.
Definition: fbxstream.h:26
bool Read(FbxDocument *pDocument) override
Reads file with stream options.
Utility class to manipulate strings.
Definition: fbxstring.h:66
FbxDocument is a base class for FbxScene and FbxLibrary classes.
Definition: fbxdocument.h:46
virtual ~FbxReaderFbx5()
virtual bool FileOpen(char *pFileName, bool pIgnoredArg)
A class that maps strings to objects with a basic string comparator.
Definition: fbxmap.h:366
Class for clusters (links).
Definition: fbxcluster.h:47
Base class of other readers used internally.
Definition: fbxreader.h:65
void GetInfoFBXReader(int *pCount, const char **pExtensions, const char **pDescriptions)
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
This class contains scene thumbnails and user-defined summary data.
This node attribute contains the properties of a marker.
Definition: fbxmarker.h:26
Base class for weighted animation constraints.
Definition: fbxconstraint.h:27
Empty node containing properties.
EImportMode GetImportMode()
void SetEmbeddingExtractionFolder(const char *pExtractFolder) override
A character pose is a character and an associated hierarchy of nodes.
The base class of most FBX objects.
Definition: fbxobject.h:157
Represents an element in the scene graph.
Definition: fbxnode.h:72
A patch is a type of node attribute with parametric surface.
Definition: fbxpatch.h:26
bool FileClose() override
Closes the file stream.
This class contains settings for Phong Materials.
This node attribute contains methods for accessing the properties of a light.
Definition: fbxlight.h:27
FbxDocumentInfo * GetSceneInfo() override
Returns the scene info from the file.
Definition: fbxreaderfbx5.h:64
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
This class contains the data structure support for char pointer set.
Definition: fbxcharptrset.h:22
A shape describes the deformation on a set of control points, which is similar to the cluster deforme...
Definition: fbxshape.h:42
bool SupportsStreams() const override
Returns true if this reader supports FbxStream I/O.
Definition: fbxreaderfbx5.h:67
Class to hold user properties.
Definition: fbxproperty.h:39
Skin deformer class.
Definition: fbxskin.h:37
FbxIO represents an FBX file.
Definition: fbxio.h:347
void SetEmbeddedFileCallback(FbxEmbeddedFileCallback *pCallback) override
This class contains take information from an imported file or exported to an output file...
Definition: fbxtakeinfo.h:56
This node attribute contains methods for accessing the properties of a camera.
Definition: fbxcamera.h:34
A NURBS surface is a type of parametric geometry.
Definition: fbxnurbs.h:31
virtual bool FileOpen(char *pFileName)=0
Opens the file with default flag.
This node attribute contains the properties of a null node.
Definition: fbxnull.h:25
This class contains all methods to either set-up an exported control rig or query information on an i...
A Character is a person or animal with pre-defined skeleton system.
Definition: fbxcharacter.h:109
Class for interfacing with files, providing a similar interface for files independant of the OS or fi...
Definition: fbxfile.h:27
The base class of geometric objects that support control point deformations (e.g. ...
Definition: fbxgeometry.h:45
bool IsFileOpen() override
Checks if the file stream is open.
Class to manipulate a map that can contain multiple times the same key.
Definition: fbxmultimap.h:22
Simple class to hold RGBA values of a thumbnail image.
Definition: fbxthumbnail.h:27
bool FileOpen(char *pFileName, EFileOpenSpecialFlags pFlags) override
Opens the file with specific EFileOpenSpecialFlags.
Definition: fbxreaderfbx5.h:38
Class to import an FBX file into SDK objects.
Definition: fbximporter.h:91
A mesh is a geometry made of polygons.
Definition: fbxmesh.h:33