01b2f506 |
1 | // Copyright (c) 2017-2019 OPEN CASCADE SAS |
2 | // |
3 | // This file is part of Open CASCADE Technology software library. |
4 | // |
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. |
10 | // |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
13 | |
14 | #ifndef _RWGltf_GltfMaterialMap_HeaderFile |
15 | #define _RWGltf_GltfMaterialMap_HeaderFile |
16 | |
17 | #include <RWMesh_MaterialMap.hxx> |
18 | |
19 | class RWGltf_GltfOStreamWriter; |
20 | |
21 | //! Material manager for exporting into glTF format. |
22 | class RWGltf_GltfMaterialMap : public RWMesh_MaterialMap |
23 | { |
24 | public: |
25 | |
26 | //! Main constructor. |
27 | Standard_EXPORT RWGltf_GltfMaterialMap (const TCollection_AsciiString& theFile, |
28 | const Standard_Integer theDefSamplerId); |
29 | |
30 | //! Destructor. |
31 | Standard_EXPORT virtual ~RWGltf_GltfMaterialMap(); |
32 | |
33 | //! Add material images. |
34 | Standard_EXPORT void AddImages (RWGltf_GltfOStreamWriter* theWriter, |
35 | const XCAFPrs_Style& theStyle, |
36 | Standard_Boolean& theIsStarted); |
37 | |
38 | //! Add material. |
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); |
46 | |
47 | //! Return extent of images map. |
48 | Standard_Integer NbImages() const { return myImageMap.Extent(); } |
49 | |
50 | //! Return extent of textures map. |
51 | Standard_Integer NbTextures() const { return myTextureMap.Extent(); } |
52 | |
53 | public: |
54 | |
55 | //! Return base color texture. |
56 | Standard_EXPORT static const Handle(Image_Texture)& baseColorTexture (const Handle(XCAFDoc_VisMaterial)& theMat); |
57 | |
58 | protected: |
59 | |
60 | //! Add texture image. |
61 | Standard_EXPORT void addImage (RWGltf_GltfOStreamWriter* theWriter, |
62 | const Handle(Image_Texture)& theTexture, |
63 | Standard_Boolean& theIsStarted); |
64 | |
65 | //! Add texture. |
66 | Standard_EXPORT void addTexture (RWGltf_GltfOStreamWriter* theWriter, |
67 | const Handle(Image_Texture)& theTexture, |
68 | Standard_Boolean& theIsStarted); |
69 | |
70 | //! Add material |
71 | Standard_EXPORT virtual TCollection_AsciiString AddMaterial (const XCAFPrs_Style& theStyle) Standard_OVERRIDE; |
72 | |
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; |
77 | |
78 | protected: |
79 | |
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; |
85 | |
86 | }; |
87 | |
88 | #endif // _RWGltf_GltfMaterialMap_HeaderFile |