fbxreaderfbx5.h

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