1 // Copyright (c) 2017-2019 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _RWGltf_GltfMaterialMap_HeaderFile
15 #define _RWGltf_GltfMaterialMap_HeaderFile
17 #include <RWMesh_MaterialMap.hxx>
19 class RWGltf_GltfOStreamWriter;
21 //! Material manager for exporting into glTF format.
22 class RWGltf_GltfMaterialMap : public RWMesh_MaterialMap
27 Standard_EXPORT RWGltf_GltfMaterialMap (const TCollection_AsciiString& theFile,
28 const Standard_Integer theDefSamplerId);
31 Standard_EXPORT virtual ~RWGltf_GltfMaterialMap();
33 //! Add material images.
34 Standard_EXPORT void AddImages (RWGltf_GltfOStreamWriter* theWriter,
35 const XCAFPrs_Style& theStyle,
36 Standard_Boolean& theIsStarted);
39 Standard_EXPORT void AddMaterial (RWGltf_GltfOStreamWriter* theWriter,
40 const XCAFPrs_Style& theStyle,
41 Standard_Boolean& theIsStarted);
42 //! Add material textures.
43 Standard_EXPORT void AddTextures (RWGltf_GltfOStreamWriter* theWriter,
44 const XCAFPrs_Style& theStyle,
45 Standard_Boolean& theIsStarted);
47 //! Return extent of images map.
48 Standard_Integer NbImages() const { return myImageMap.Extent(); }
50 //! Return extent of textures map.
51 Standard_Integer NbTextures() const { return myTextureMap.Extent(); }
55 //! Return base color texture.
56 Standard_EXPORT static const Handle(Image_Texture)& baseColorTexture (const Handle(XCAFDoc_VisMaterial)& theMat);
60 //! Add texture image.
61 Standard_EXPORT void addImage (RWGltf_GltfOStreamWriter* theWriter,
62 const Handle(Image_Texture)& theTexture,
63 Standard_Boolean& theIsStarted);
66 Standard_EXPORT void addTexture (RWGltf_GltfOStreamWriter* theWriter,
67 const Handle(Image_Texture)& theTexture,
68 Standard_Boolean& theIsStarted);
71 Standard_EXPORT virtual TCollection_AsciiString AddMaterial (const XCAFPrs_Style& theStyle) Standard_OVERRIDE;
73 //! Virtual method actually defining the material (e.g. export to the file).
74 Standard_EXPORT virtual void DefineMaterial (const XCAFPrs_Style& theStyle,
75 const TCollection_AsciiString& theKey,
76 const TCollection_AsciiString& theName) Standard_OVERRIDE;
80 RWGltf_GltfOStreamWriter* myWriter;
81 NCollection_DoubleMap<Handle(Image_Texture), TCollection_AsciiString, Image_Texture, TCollection_AsciiString> myImageMap;
82 NCollection_Map<Handle(Image_Texture), Image_Texture> myTextureMap;
83 Standard_Integer myDefSamplerId;
84 Standard_Integer myNbImages;
88 #endif // _RWGltf_GltfMaterialMap_HeaderFile