fbxsdk/fileio/fbx/fbxreaderfbx5.h Source File
 
 
 
fbxsdk/fileio/fbx/fbxreaderfbx5.h
Go to the documentation of this file.
00001 /****************************************************************************************
00002  
00003    Copyright (C) 2013 Autodesk, Inc.
00004    All rights reserved.
00005  
00006    Use of this software is subject to the terms of the Autodesk license agreement
00007    provided at the time of installation or download, or which otherwise accompanies
00008    this software in either electronic or hard copy form.
00009  
00010 ****************************************************************************************/
00011 
00013 #ifndef _FBXSDK_FILEIO_FBX_READER_FBX5_H_
00014 #define _FBXSDK_FILEIO_FBX_READER_FBX5_H_
00015 
00016 #include <fbxsdk.h>
00017 
00018 #include <fbxsdk/fbxsdk_nsbegin.h>
00019 
00020 class FbxAnimLayer;
00021 class Fbx5ObjectTypeInfo;       
00022 
00023 FbxReader* CreateFBXReader(FbxManager& pManager, 
00024                                                         FbxImporter& pImporter,
00025                                                         int pID,
00026                             FbxStatus& pStatus);
00027 void GetInfoFBXReader(int* pCount, 
00028                                           const char* * pExtensions, 
00029                                           const char* * pDescriptions);
00030 
00031 class FbxReaderFbx5 : public FbxReader
00032 {
00033 public:
00034         FbxReaderFbx5(FbxManager& pManager, FbxImporter& pImporter, int pID, FbxStatus& pStatus);
00035         virtual ~FbxReaderFbx5();
00036 
00037     virtual bool FileOpen(char* pFileName, bool pIgnoredArg);
00038         virtual bool FileOpen(char* pFileName);
00039     virtual bool FileOpen(FbxFile * pFile);
00040         virtual bool FileOpen(FbxStream * pStream, void* pStreamData);
00041         virtual bool FileClose();
00042         virtual bool IsFileOpen();
00043 
00044         virtual void SetEmbeddingExtractionFolder(const char* pExtractFolder);
00045 
00046         typedef enum 
00047         {
00048                 eASCII,
00049                 eBINARY,
00050                 eENCRYPTED
00051         } EImportMode;
00052 
00053         EImportMode GetImportMode();
00054         virtual void GetVersion(int& pMajor, int& pMinor, int& pRevision);
00055 
00056         virtual bool GetReadOptions(bool pParseFileAsNeeded = true);
00057         virtual bool Read(FbxDocument* pDocument);
00058 
00059         virtual bool GetReadOptions(FbxIO* pFbx, bool pParseFileAsNeeded = true);
00060         virtual bool Read(FbxScene& pScene, FbxIO* pFbx);
00061 
00062     virtual FbxDocumentInfo* GetSceneInfo() { return mSceneInfo; }
00063     virtual FbxArray<FbxTakeInfo*>* GetTakeInfo() { return &mTakeInfo; }
00064 
00065         virtual bool SupportsStreams() const { return true; }
00066 
00067 private:
00068         void ReadOptionsInMainSection();
00069         void ReadTakeOptions();
00070         bool ReadOptionsInExtensionSection(int& pSectionIndex);
00071         void ReadOptionsInGenericSection();
00072         bool WriteOptionsInExtensionSection(bool pOverwriteLastExtensionSection=false);
00073         bool WriteThumbnail(FbxThumbnail*);
00074         FbxDocumentInfo* ReadSceneInfo();
00075         FbxDocumentInfo* ReadSceneInfo(FbxString& pType);
00076         void WriteSceneInfo(FbxDocumentInfo*);
00077         void SetIsBeforeVersion6WithMainSection(bool pOpenMainSection);
00078         
00079         bool ReadDefinitionSection(FbxScene& pScene, FbxArray<Fbx5ObjectTypeInfo*>& pObjectContent);
00080         bool ReadObjectSection(FbxScene& pScene, FbxArray<Fbx5ObjectTypeInfo*>& pObjectContent);
00081         bool ReadObject(FbxScene& pScene, FbxString& pObjectType, FbxString& pObjectSubType, FbxString& pObjectName, FbxString& pObjectUniqueId);
00082         bool ReadNode();
00083         //bool ReadGenericNode(FbxScene& pScene);
00084         bool ReadAnimation(FbxScene& pScene);
00085         bool ReadTakeAnimation(FbxScene& pScene, FbxTakeInfo* pTakeInfo);
00086         FbxThumbnail* ReadThumbnail();
00087         bool ReadNodeAnimation(FbxIO& pFileObject, FbxScene& pScene, FbxTakeInfo* pTakeInfo);   
00088         bool TimeShiftNodeAnimation(FbxScene& pScene, FbxTakeInfo* pTakeInfo);
00089     bool ReadHierarchy(FbxNode& pRootNode);
00090         bool ResolveHierarchy(FbxNode& pRootNode);
00091         bool ResolveLinks(FbxNode& pRootNode, FbxNode& pCurrentNode);
00092         bool ResolveTargets(FbxNode& pRootNode);
00093         bool ResolveUpNodes(FbxNode& pRootNode);
00094         bool ResolveCameraBackgrounds(FbxScene& pScene);
00095         void RemoveDuplicateTextures(FbxScene& pScene);
00096         void RemoveDuplicateMaterials(FbxScene& pScene);
00097 
00098         void ReadPose(FbxScene& pScene);
00099         bool ReadPose(FbxScene& pScene, FbxPose* pPose, bool pAsBindPose);
00100 
00101         void ReadCameraSwitcher(FbxScene& pScene);
00102         void ReorderCameraSwitcherIndices(FbxScene& pScene);
00103 
00104     void ReadGobo(FbxScene& pScene);
00105     void ReadGoboSection(FbxScene& pScene);
00106         void ReadGobo(FbxGobo& pGobo);
00107 
00108     void ReadCharacter(FbxScene& pScene);
00109         void ReadCharacter(FbxCharacter& pCharacter,int& pInputType, int& pInputIndex);
00110         void ReadCharacterLinkGroup(FbxCharacter& pCharacter, int pCharacterGroupId);
00111         void ReadCharacterLink(FbxCharacter& pCharacter, int pCharacterNodeId);
00112         void ReadCharacterLinkRotationSpace(FbxCharacterLink& pCharacterLink);
00113         void ReadFilterSet(FbxCharacter& pCharacter);
00114         void ReadControlSet(FbxControlSet& pControlSet);
00115         void ReadControlSetLinkGroup(FbxControlSet& pControlSet, int pCharacterGroupId);
00116         void ReadControlSetLink(FbxControlSet& pControlSet, int pCharacterNodeId);
00117         void ReadEffector(FbxControlSet& pControlSet);  
00118         void ReadEffectorAux(FbxControlSet& pControlSet);
00119 
00120         int  ReadCharacterPose(FbxScene& pScene);
00121         bool ReadCharacterPose(FbxCharacterPose& pCharacterPose);
00122 
00123         void ReadGlobalLightSettings(FbxScene& pScene);
00124     void ReadShadowPlane(FbxScene& pScene);
00125     void ReadAmbientColor(FbxScene& pScene);
00126     void ReadFogOption(FbxScene& pScene);
00127 
00128         void ReadGlobalCameraAndTimeSettings(FbxScene& pScene); // for pre v6 files
00129         void ReadGlobalTimeSettings(FbxScene& pScene);
00130 
00131         void ReadGlobalCameraSettings(FbxScene& pScene);
00132 
00133     bool ReadMedia(FbxScene& pScene, const char* pEmbeddedMediaDirectory = "");
00134         FbxString ReadMediaClip(const char* pEmbeddedMediaDirectory);
00135 
00136         bool ReadNode                       ( FbxNode& pNode );
00137         bool ReadGenericNode                ( FbxGenericNode& pNode );
00138         bool ReadNodeChildrenName           ( FbxNode& pNode );
00139         bool ReadNodeShading                ( FbxNode& pNode );
00140         bool ReadNodeCullingType            ( FbxNode& pNode );
00141         bool ReadNodeLimits                 ( FbxNode& pNode );
00142         bool ReadNodeTarget                 ( FbxNode& pNode );
00143         bool ReadNodeAttribute              ( FbxNode& pNode );
00144         bool ReadNodePivots                 ( FbxNode& pNode );
00145         bool ReadNodeDefaultAttributes      ( FbxNode& pNode );
00146         bool ReadNodeProperties                         ( FbxNode& pNode );
00147         bool ReadGeometry                   ( FbxGeometry& pGeometry );
00148         bool ReadGeometryMaterial           ( FbxGeometry& pGeometry );
00149         bool ReadGeometryTexture            ( FbxGeometry& pGeometry );
00150         bool ReadGeometryLinks              ( FbxGeometry& pGeometry );
00151         bool ReadGeometryShapes             ( FbxGeometry& pGeometry );
00152         bool ReadGeometryLayer              ( FbxGeometry& pGeometry );
00153         bool ReadGeometryTextureLayer       ( FbxGeometry& pGeometry, int pLayerIndex );
00154 
00155         bool ReadNull                       ( FbxNull& pNull );
00156 
00157         bool ReadMarker                     ( FbxMarker& pMarker );
00158 
00159         bool ReadCamera                     ( FbxCamera& pCamera );
00160         bool ReadCameraSwitcher             ( FbxCameraSwitcher& pCameraSwitcher );
00161 
00162         bool ReadLight                      ( FbxLight& pLight );
00163 
00164         bool ReadMesh                       ( FbxMesh& pMesh );
00165         bool ReadMeshVertices               ( FbxMesh& pMesh );
00166         bool ReadMeshNormals                ( FbxMesh& pMesh );
00167         bool ReadMeshAssignation            ( FbxMesh& pMesh );
00168         bool ReadMeshPolygonIndex           ( FbxMesh& pMesh );
00169         bool ReadMeshPolyGroupIndex         ( FbxMesh& pMesh );
00170         bool ReadMeshMaterialsID            ( FbxMesh& pMesh );
00171         bool ReadMeshTexturesID             ( FbxMesh& pMesh );
00172         bool ReadMeshTextureType            ( FbxMesh& pMesh );
00173         bool ReadMeshTextureUV              ( FbxMesh& pMesh );
00174         bool ReadMeshTextureIndex           ( FbxMesh& pMesh );
00175         bool ReadMeshVertexColors           ( FbxMesh& pMesh );
00176 
00177 
00178         // Layer elements       
00179         bool ReadLayerElements                          (FbxGeometry& pGeometry);
00180         bool ReadLayerElementsMaterial          (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsMaterial);        
00181         bool ReadLayerElementsNormal            (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsNormal);
00182         bool ReadLayerElementsVertexColor       (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsVertexColor);
00183         bool ReadLayerElementsTexture           (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsTexture);
00184         bool ReadLayerElementsUV                        (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsUV);
00185         bool ReadLayerElementsPolygonGroup      (FbxGeometry* pGeometry, FbxArray<FbxLayerElement*>& pElementsPolygonGroup);
00186         
00187         bool ReadNurb                       ( FbxNurbs& pNurbs );
00188 
00189         bool ReadPatch                      ( FbxPatch& pPatch );
00190         int ReadPatchType                  ( FbxPatch& pPatch );
00191 
00192         bool ReadTexture(FbxFileTexture& pTexture);
00193         bool ReadSurfaceMaterial(FbxSurfacePhong& pMaterial);
00194         bool ReadLink(FbxCluster& pLink);
00195         bool ReadSkin(FbxSkin& pSkin);
00196         bool ReadCluster(FbxCluster& pCluster);
00197         bool ReadShape(FbxShape& pShape, FbxGeometry& pGeometry);
00198         bool ReadVideo(FbxVideo& pVideo);
00199         bool ReadConstraint(FbxConstraint& pPosition);
00200 
00201         bool ReadUserProperties                                 (FbxNode& pNode);
00202         bool ReadProperties(FbxObject *pObject);
00203 
00204         //
00205         // 6.0 Format specific
00206         //
00207         bool ReadConnectionSection();
00208         void ReadPoses(FbxScene& pScene);
00209 
00210         FbxString ConvertCameraName(FbxString pCameraName);
00211 
00212         bool GenerateParametricGeometryLayer(FbxGeometry& pGeometry);
00213         void CorrectTextureLayers(FbxMesh& pMesh);
00214 
00215     void TransferAnimation(void* pRootCurveNode, FbxProperty& pRootProperty, bool pValueOnly = false);
00216     void ReadAnimation(FbxIO& pFileObject, void* pCurveNode);
00217         void ReadAnimation(FbxIO& pFileObject, FbxObject*  pObj);
00218     
00219     void ReadTimeWarps(FbxIO& pFileObject, FbxSet& pTimeWarpSet);
00220         void DestroyTimeWarps(FbxSet& pTimeWarpSet);
00221 
00222         FbxNode* FindNode (char* pName);
00223         int FindString(FbxString pString, FbxArray<FbxString*>& pStringArray);
00224         FbxString FindFile(FbxString pFullFilePath, FbxString pRelativeFilePath = "");
00225 
00226         bool ReadPassword(FbxString pPassword);
00227 
00228         void ReadSceneGenericPersistenceSection(FbxScene& pScene);      
00229 
00230 
00231 
00232 
00233 private:
00234     FbxReaderFbx5& operator=(FbxReaderFbx5 const&) { return *this; }
00235 
00236     FbxIO*                      mFileObject;    
00237         FbxImporter&    mImporter;
00238 
00239         FbxCharPtrSet mNodeArrayName;
00240         FbxCharPtrSet mTargetArrayName;
00241         FbxCharPtrSet mUpNodeArrayName;
00242         FbxCharPtrSet mCameraBackgroundArrayName;
00243 
00244         FbxObjectStringMap              mObjectMap;
00245     FbxArray<FbxTakeInfo *> mTakeInfo;
00246     FbxDocumentInfo * mSceneInfo;
00247     FbxAnimLayer* mAnimLayer;
00248 
00249         // Temporary storage
00250         FbxArray<FbxTexture*> mTemporaryTextures;
00251 };
00252 
00253 #include <fbxsdk/fbxsdk_nsend.h>
00254 
00255 #endif /* _FBXSDK_FILEIO_FBX_READER_FBX5_H_ */