1 // Copyright (c) 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 _XCAFDoc_VisMaterialCommon_HeaderFile
15 #define _XCAFDoc_VisMaterialCommon_HeaderFile
17 #include <Graphic3d_AlphaMode.hxx>
18 #include <Graphic3d_Vec.hxx>
19 #include <Image_Texture.hxx>
20 #include <Quantity_ColorRGBA.hxx>
21 #include <Standard_Dump.hxx>
23 class Graphic3d_Aspects;
24 class Graphic3d_MaterialAspect;
26 //! Common (obsolete) material definition.
27 struct XCAFDoc_VisMaterialCommon
29 Handle(Image_Texture) DiffuseTexture; //!< image defining diffuse color
30 Quantity_Color AmbientColor; //!< ambient color
31 Quantity_Color DiffuseColor; //!< diffuse color
32 Quantity_Color SpecularColor; //!< specular color
33 Quantity_Color EmissiveColor; //!< emission color
34 Standard_ShortReal Shininess; //!< shininess value
35 Standard_ShortReal Transparency; //!< transparency value within [0, 1] range with 0 meaning opaque
36 Standard_Boolean IsDefined; //!< defined flag; FALSE by default
38 //! Empty constructor.
39 XCAFDoc_VisMaterialCommon()
40 : AmbientColor (0.1, 0.1, 0.1, Quantity_TOC_RGB),
41 DiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_RGB),
42 SpecularColor(0.2, 0.2, 0.2, Quantity_TOC_RGB),
43 EmissiveColor(0.0, 0.0, 0.0, Quantity_TOC_RGB),
46 IsDefined (Standard_False) {}
48 //! Compare two materials.
49 Standard_Boolean IsEqual (const XCAFDoc_VisMaterialCommon& theOther) const
51 if (&theOther == this)
55 else if (theOther.IsDefined != IsDefined)
64 return theOther.DiffuseTexture == DiffuseTexture
65 && theOther.AmbientColor == AmbientColor
66 && theOther.DiffuseColor == DiffuseColor
67 && theOther.SpecularColor == SpecularColor
68 && theOther.EmissiveColor == EmissiveColor
69 && theOther.Shininess == Shininess
70 && theOther.Transparency == Transparency;
73 //! Dumps the content of me into the stream
74 void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const
76 OCCT_DUMP_CLASS_BEGIN (theOStream, XCAFDoc_VisMaterialCommon)
78 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, DiffuseTexture.get())
80 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &AmbientColor)
81 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &DiffuseColor)
82 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &SpecularColor)
83 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &EmissiveColor)
85 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Shininess)
86 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Transparency)
87 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsDefined)
91 #endif // _XCAFDoc_VisMaterialCommon_HeaderFile