a4815d55 |
1 | // Copyright (c) 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 _XCAFDoc_VisMaterialCommon_HeaderFile |
15 | #define _XCAFDoc_VisMaterialCommon_HeaderFile |
16 | |
17 | #include <Graphic3d_AlphaMode.hxx> |
18 | #include <Graphic3d_Vec.hxx> |
19 | #include <Image_Texture.hxx> |
20 | #include <Quantity_ColorRGBA.hxx> |
bc73b006 |
21 | #include <Standard_Dump.hxx> |
a4815d55 |
22 | |
23 | class Graphic3d_Aspects; |
24 | class Graphic3d_MaterialAspect; |
25 | |
26 | //! Common (obsolete) material definition. |
27 | struct XCAFDoc_VisMaterialCommon |
28 | { |
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 |
37 | |
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), |
44 | Shininess (1.0f), |
45 | Transparency (0.0f), |
46 | IsDefined (Standard_False) {} |
47 | |
48 | //! Compare two materials. |
49 | Standard_Boolean IsEqual (const XCAFDoc_VisMaterialCommon& theOther) const |
50 | { |
51 | if (&theOther == this) |
52 | { |
53 | return true; |
54 | } |
55 | else if (theOther.IsDefined != IsDefined) |
56 | { |
57 | return false; |
58 | } |
59 | else if (!IsDefined) |
60 | { |
61 | return true; |
62 | } |
63 | |
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; |
71 | } |
bc73b006 |
72 | |
73 | //! Dumps the content of me into the stream |
74 | void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const |
75 | { |
76 | OCCT_DUMP_CLASS_BEGIN (theOStream, XCAFDoc_VisMaterialCommon) |
77 | |
78 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, DiffuseTexture.get()) |
79 | |
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) |
84 | |
85 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Shininess) |
86 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Transparency) |
87 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsDefined) |
88 | } |
89 | }; |
a4815d55 |
90 | |
91 | #endif // _XCAFDoc_VisMaterialCommon_HeaderFile |