fbxsdk/fileio/fbx/fbxreaderfbx5.h Source File

fbxreaderfbx5.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_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  virtual bool FileOpen(char* pFileName, EFileOpenSpecialFlags pFlags){ return FbxReader::FileOpen(pFileName, pFlags); }
39  virtual bool FileOpen(char* pFileName);
40  virtual bool FileOpen(FbxFile * pFile);
41  virtual bool FileOpen(FbxStream * pStream, void* pStreamData);
42  virtual bool FileClose();
43  virtual bool IsFileOpen();
44 
45  virtual void SetEmbeddingExtractionFolder(const char* pExtractFolder);
46 
47  typedef enum
48  {
52  } EImportMode;
53 
55  virtual void GetVersion(int& pMajor, int& pMinor, int& pRevision);
56 
57  virtual bool GetReadOptions(bool pParseFileAsNeeded = true);
58  virtual bool Read(FbxDocument* pDocument);
59 
60  virtual bool GetReadOptions(FbxIO* pFbx, bool pParseFileAsNeeded = true);
61  virtual bool Read(FbxScene& pScene, FbxIO* pFbx);
62 
63  virtual FbxDocumentInfo* GetSceneInfo() { return mSceneInfo; }
64  virtual FbxArray<FbxTakeInfo*>* GetTakeInfo() { return &mTakeInfo; }
65 
66  virtual bool SupportsStreams() const { return true; }
67 
68 private:
69  void ReadOptionsInMainSection();
70  void ReadTakeOptions();
71  bool ReadOptionsInExtensionSection(int& pSectionIndex);
72  void ReadOptionsInGenericSection();
73  bool WriteOptionsInExtensionSection(bool pOverwriteLastExtensionSection=false);
74  bool WriteThumbnail(FbxThumbnail*);
75  FbxDocumentInfo* ReadSceneInfo();
76  FbxDocumentInfo* ReadSceneInfo(FbxString& pType);
77  void WriteSceneInfo(FbxDocumentInfo*);
78  void SetIsBeforeVersion6WithMainSection(bool pOpenMainSection);
79 
80  bool ReadDefinitionSection(FbxScene& pScene, FbxArray<Fbx5ObjectTypeInfo*>& pObjectContent);
81  bool ReadObjectSection(FbxScene& pScene, FbxArray<Fbx5ObjectTypeInfo*>& pObjectContent);
82  bool ReadObject(FbxScene& pScene, FbxString& pObjectType, FbxString& pObjectSubType, FbxString& pObjectName, FbxString& pObjectUniqueId);
83  bool ReadNode();
84  //bool ReadGenericNode(FbxScene& pScene);
85  bool ReadAnimation(FbxScene& pScene);
86  bool ReadTakeAnimation(FbxScene& pScene, FbxTakeInfo* pTakeInfo);
87  FbxThumbnail* ReadThumbnail();
88  bool ReadNodeAnimation(FbxIO& pFileObject, FbxScene& pScene, FbxTakeInfo* pTakeInfo);
89  bool TimeShiftNodeAnimation(FbxScene& pScene, FbxTakeInfo* pTakeInfo);
90  bool ReadHierarchy(FbxNode& pRootNode);
91  bool ResolveHierarchy(FbxNode& pRootNode);
92  bool ResolveLinks(FbxNode& pRootNode, FbxNode& pCurrentNode);
93  bool ResolveTargets(FbxNode& pRootNode);
94  bool ResolveUpNodes(FbxNode& pRootNode);
95  bool ResolveCameraBackgrounds(FbxScene& pScene);
96  void RemoveDuplicateTextures(FbxScene& pScene);
97  void RemoveDuplicateMaterials(FbxScene& pScene);
98 
99  void ReadPose(FbxScene& pScene);
100  bool ReadPose(FbxScene& pScene, FbxPose* pPose, bool pAsBindPose);
101 
102  void ReadCameraSwitcher(FbxScene& pScene);
103  void ReorderCameraSwitcherIndices(FbxScene& pScene);
104 
105  void ReadGobo(FbxScene& pScene);
106  void ReadGoboSection(FbxScene& pScene);
107  void ReadGobo(FbxGobo& pGobo);
108 
109  void ReadCharacter(FbxScene& pScene);
110  void ReadCharacter(FbxCharacter& pCharacter,int& pInputType, int& pInputIndex);
111  void ReadCharacterLinkGroup(FbxCharacter& pCharacter, int pCharacterGroupId);
112  void ReadCharacterLink(FbxCharacter& pCharacter, int pCharacterNodeId);
113  void ReadCharacterLinkRotationSpace(FbxCharacterLink& pCharacterLink);
114  void ReadFilterSet(FbxCharacter& pCharacter);
115  void ReadControlSet(FbxControlSet& pControlSet);
116  void ReadControlSetLinkGroup(FbxControlSet& pControlSet, int pCharacterGroupId);
117  void ReadControlSetLink(FbxControlSet& pControlSet, int pCharacterNodeId);
118  void ReadEffector(FbxControlSet& pControlSet);
119  void ReadEffectorAux(FbxControlSet& pControlSet);
120 
121  int ReadCharacterPose(FbxScene& pScene);
122  bool ReadCharacterPose(FbxCharacterPose& pCharacterPose);
123 
124  void ReadGlobalLightSettings(FbxScene& pScene);
125  void ReadShadowPlane(FbxScene& pScene);
126  void ReadAmbientColor(FbxScene& pScene);
127  void ReadFogOption(FbxScene& pScene);
128 
129  void ReadGlobalCameraAndTimeSettings(FbxScene& pScene); // for pre v6 files
130  void ReadGlobalTimeSettings(FbxScene& pScene);
131 
132  void ReadGlobalCameraSettings(FbxScene& pScene);
133 
134  bool ReadMedia(FbxScene& pScene, const char* pEmbeddedMediaDirectory = "");
135  FbxString ReadMediaClip(const char* pEmbeddedMediaDirectory);
136 
137  bool ReadNode ( FbxNode& pNode );
138  bool ReadGenericNode ( FbxGenericNode& pNode );
139  bool ReadNodeChildrenName ( FbxNode& pNode );
140  bool ReadNodeShading ( FbxNode& pNode );
141  bool ReadNodeCullingType ( FbxNode& pNode );
142  bool ReadNodeLimits ( FbxNode& pNode );
143  bool ReadNodeTarget ( FbxNode& pNode );
144  bool ReadNodeAttribute ( FbxNode& pNode );
145  bool ReadNodePivots ( FbxNode& pNode );
146  bool ReadNodeDefaultAttributes ( FbxNode& pNode );
147  bool ReadNodeProperties ( FbxNode& pNode );
148  bool ReadGeometry ( FbxGeometry& pGeometry );
149  bool ReadGeometryMaterial ( FbxGeometry& pGeometry );
150  bool ReadGeometryTexture ( FbxGeometry& pGeometry );
151  bool ReadGeometryLinks ( FbxGeometry& pGeometry );
152  bool ReadGeometryShapes ( FbxGeometry& pGeometry );
153  bool ReadGeometryLayer ( FbxGeometry& pGeometry );
154  bool ReadGeometryTextureLayer ( FbxGeometry& pGeometry, int pLayerIndex );
155 
156  bool ReadNull ( FbxNull& pNull );
157 
158  bool ReadMarker ( FbxMarker& pMarker );
159 
160  bool ReadCamera ( FbxCamera& pCamera );
161  bool ReadCameraSwitcher ( FbxCameraSwitcher& pCameraSwitcher );
162 
163  bool ReadLight ( FbxLight& pLight );
164 
165  bool ReadMesh ( FbxMesh& pMesh );
166  bool ReadMeshVertices ( FbxMesh& pMesh );
167  bool ReadMeshNormals ( FbxMesh& pMesh );
168  bool ReadMeshAssignation ( FbxMesh& pMesh );
169  bool ReadMeshPolygonIndex ( FbxMesh& pMesh );
170  bool ReadMeshPolyGroupIndex ( FbxMesh& pMesh );
171  bool ReadMeshMaterialsID ( FbxMesh& pMesh );
172  bool ReadMeshTexturesID ( FbxMesh& pMesh );
173  bool ReadMeshTextureType ( FbxMesh& pMesh );
174  bool ReadMeshTextureUV ( FbxMesh& pMesh );
175  bool ReadMeshTextureIndex ( FbxMesh& pMesh );
176  bool ReadMeshVertexColors ( FbxMesh& pMesh );
177 
178 
179  // Layer elements
180  bool ReadLayerElements (FbxGeometry& pGeometry);
181  bool ReadLayerElementsMaterial (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsMaterial);
182  bool ReadLayerElementsNormal (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsNormal);
183  bool ReadLayerElementsVertexColor (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsVertexColor);
184  bool ReadLayerElementsTexture (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsTexture);
185  bool ReadLayerElementsUV (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsUV);
186  bool ReadLayerElementsPolygonGroup (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsPolygonGroup);
187 
188  bool ReadNurb ( FbxNurbs& pNurbs );
189 
190  bool ReadPatch ( FbxPatch& pPatch );
191  int ReadPatchType ( FbxPatch& pPatch );
192 
193  bool ReadTexture(FbxFileTexture& pTexture);
194  bool ReadSurfaceMaterial(FbxSurfacePhong& pMaterial);
195  bool ReadLink(FbxCluster& pLink);
196  bool ReadSkin(FbxSkin& pSkin);
197  bool ReadCluster(FbxCluster& pCluster);
198  bool ReadShape(FbxShape& pShape, FbxGeometry& pGeometry);
199  bool ReadVideo(FbxVideo& pVideo);
200  bool ReadConstraint(FbxConstraint& pPosition);
201 
202  bool ReadUserProperties (FbxNode& pNode);
203  bool ReadProperties(FbxObject *pObject);
204 
205  //
206  // 6.0 Format specific
207  //
208  bool ReadConnectionSection();
209  void ReadPoses(FbxScene& pScene);
210 
211  FbxString ConvertCameraName(FbxString pCameraName);
212 
213  bool GenerateParametricGeometryLayer(FbxGeometry& pGeometry);
214  void CorrectTextureLayers(FbxMesh& pMesh);
215 
216  void TransferAnimation(void* pRootCurveNode, FbxProperty& pRootProperty, bool pValueOnly = false);
217  void ReadAnimation(FbxIO& pFileObject, void* pCurveNode);
218  void ReadAnimation(FbxIO& pFileObject, FbxObject* pObj);
219 
220  void ReadTimeWarps(FbxIO& pFileObject, FbxMultiMap& pTimeWarpSet);
221  void DestroyTimeWarps(FbxMultiMap& pTimeWarpSet);
222 
223  FbxNode* FindNode (char* pName);
224  int FindString(FbxString pString, FbxArray<FbxString*>& pStringArray);
225  FbxString FindFile(FbxString pFullFilePath, FbxString pRelativeFilePath = "");
226 
227  bool ReadPassword(FbxString pPassword);
228 
229  void ReadSceneGenericPersistenceSection(FbxScene& pScene);
230 
231 
232 
233 
234 private:
235  FbxReaderFbx5& operator=(FbxReaderFbx5 const&) { return *this; }
236 
237  FbxIO* mFileObject;
238  FbxImporter& mImporter;
239 
240  FbxCharPtrSet mNodeArrayName;
241  FbxCharPtrSet mTargetArrayName;
242  FbxCharPtrSet mUpNodeArrayName;
243  FbxCharPtrSet mCameraBackgroundArrayName;
244 
245  FbxObjectStringMap mObjectMap;
246  FbxArray<FbxTakeInfo *> mTakeInfo;
247  FbxDocumentInfo * mSceneInfo;
248  FbxAnimLayer* mAnimLayer;
249 
250  // Temporary storage
251  FbxArray<FbxTexture*> mTemporaryTextures;
252 };
253 
254 #include <fbxsdk/fbxsdk_nsend.h>
255 
256 #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:91
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
virtual FbxDocumentInfo * GetSceneInfo()
Returns the scene info from the file.
Definition: fbxreaderfbx5.h:63
FBX SDK video class.
Definition: fbxvideo.h:25
Abstract class for implementing I/O operations through a stream of data.
Definition: fbxstream.h:26
virtual bool FileClose()
Closes the file stream.
Utility class to manipulate strings.
Definition: fbxstring.h:66
virtual void SetEmbeddingExtractionFolder(const char *pExtractFolder)
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
virtual FbxArray< FbxTakeInfo * > * GetTakeInfo()
Returns the list of take infos from the file.
Definition: fbxreaderfbx5.h:64
Class for clusters (links).
Definition: fbxcluster.h:47
Base class of other readers used internally.
Definition: fbxreader.h:64
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:26
virtual bool IsFileOpen()
Checks if the file stream is open.
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()
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
This class contains settings for Phong Materials.
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
This class contains the data structure support for char pointer set.
Definition: fbxcharptrset.h:22
virtual bool SupportsStreams() const
Returns true if this reader supports FbxStream I/O.
Definition: fbxreaderfbx5.h:66
virtual bool GetReadOptions(bool pParseFileAsNeeded=true)
Returns file stream options.
A shape describes the deformation on a set of control points, which is similar to the cluster deforme...
Definition: fbxshape.h:32
Class to hold user properties.
Definition: fbxproperty.h:37
virtual bool Read(FbxDocument *pDocument)
Reads file with stream options.
virtual void GetVersion(int &pMajor, int &pMinor, int &pRevision)
Returns the file version.
Skin deformer class.
Definition: fbxskin.h:37
FbxIO represents an FBX file.
Definition: fbxio.h:324
virtual bool FileOpen(char *pFileName, EFileOpenSpecialFlags pFlags)
Opens the file with specific EFileOpenSpecialFlags.
Definition: fbxreaderfbx5.h:38
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:91
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
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
Class to import an FBX file into SDK objects.
Definition: fbximporter.h:90
A mesh is a geometry made of polygons.
Definition: fbxmesh.h:32