fbxmaterialconverter.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /****************************************************************************************
  2. Copyright (C) 2015 Autodesk, Inc.
  3. All rights reserved.
  4. Use of this software is subject to the terms of the Autodesk license agreement
  5. provided at the time of installation or download, or which otherwise accompanies
  6. this software in either electronic or hard copy form.
  7. ****************************************************************************************/
  8. //! \file fbxmaterialconverter.h
  9. #ifndef _FBXSDK_UTILS_MATERIAL_CONVERTER_H_
  10. #define _FBXSDK_UTILS_MATERIAL_CONVERTER_H_
  11. #include <fbxsdk/fbxsdk_def.h>
  12. #include <fbxsdk/scene/geometry/fbxlayer.h>
  13. #include <fbxsdk/fbxsdk_nsbegin.h>
  14. class LayerConfig;
  15. class FbxMaterialConverter_Impl;
  16. /**
  17. * \brief This class provides functions to restructure the material and textures
  18. * applied to geometries from FBX v5 material system to v6-and-up or the other way around.
  19. * \nosubgrouping
  20. * \see FbxSurfaceMaterial, FbxTexture
  21. */
  22. class FBXSDK_DLL FbxMaterialConverter
  23. {
  24. public:
  25. FbxMaterialConverter( FbxManager& mManager, FbxSurfaceMaterial* pDefaultMaterial = NULL);
  26. ~FbxMaterialConverter();
  27. /** Moves textures in texture layer elements to connections
  28. * on the corresponding material's color properties, for all geometries
  29. * in the scene.(Convert scene from FBX v5 material system to v6-and-up)
  30. * \param pScene The scene whose geometries should be converted.
  31. * \return true on success, false otherwise
  32. */
  33. bool ConnectTexturesToMaterials( FbxScene& pScene );
  34. /** Moves textures in texture layer elements to connections
  35. * on the corresponding material's color properties, for the given geometry
  36. * in the scene.(Convert scene from FBX v5 material system to v6-and-up)
  37. * \param pNode The geometry node to be converted.
  38. * \return true on success, false otherwise
  39. */
  40. bool ConnectTexturesToMaterials( FbxNode* pNode );
  41. /** This is the reverse operation of ConnectTexturesToMaterials()
  42. * Textures connected to Materials' color properties are stored
  43. * in layer elements, and their connections to the color properties
  44. * are broken.(Convert scene from FBX v6-and-up material system to v5)
  45. * \param pScene The scene whose geometries should be converted.
  46. * \return true if all geometries were converted, false otherwise
  47. */
  48. bool AssignTexturesToLayerElements( FbxScene& pScene );
  49. /*****************************************************************************************************************************
  50. ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
  51. *****************************************************************************************************************************/
  52. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  53. private:
  54. typedef FbxPair<FbxTexture*, FbxLayerElementTexture::EBlendMode> TexData;
  55. FbxMaterialConverter& operator=(const FbxMaterialConverter&);
  56. FbxManager& mManager;
  57. FbxSurfaceMaterial* mDefaultMaterial;
  58. FbxMaterialConverter_Impl* mImpl;
  59. void GetTextures( int pComponent, FbxLayer* pLayer, LayerConfig& pLayerConfig ) const;
  60. FbxSurfaceMaterial* GetMaterial( int pComponent, FbxLayer* pLayer, FbxNode* pNode, bool pLookOnNode );
  61. int GetMaterialOrder( int pComponent, FbxLayer* pLayer, FbxNode* pNode, bool pLookOnNode );
  62. bool HasGoodMappingModes( FbxNode* pNode, FbxGeometry* pGeom ) const;
  63. void ConnectTextures( FbxSurfaceMaterial* pMat, FbxObject* pTexture, int pTextureType ) const;
  64. bool HasPerFaceMaterialMapping( FbxGeometry* pGeom ) const;
  65. void SetTextureUVSets( FbxGeometry* pGeom ) const;
  66. bool HasTextures( FbxGeometry* pGeom ) const;
  67. void GetTextureList( FbxArray<TexData>& pTextures, FbxLayeredTexture* pTex ) const;
  68. FbxLayer* FindLayerForTexture( FbxTexture* pTex,
  69. FbxLayerElement::EType pTexType,
  70. FbxLayerElementTexture::EBlendMode pTexBlendMode,
  71. FbxGeometry* pGeom,
  72. int lComponentIndex,
  73. int lStartIndex = 0 ) const;
  74. void InitTextureElement( FbxLayerElementTexture* pTexElm, int pComponentCount,
  75. FbxLayerElementTexture::EBlendMode pMode) const;
  76. bool AssignTexturesToLayerElements( FbxNode* pNode);
  77. bool HasTextureLayerElements( FbxGeometry& pGeom ) const;
  78. void ConvertToPerFaceMapping( FbxMesh* pGeom ) const;
  79. #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
  80. };
  81. #include <fbxsdk/fbxsdk_nsend.h>
  82. #endif /* _FBXSDK_UTILS_MATERIAL_CONVERTER_H_ */