Free Electron
Material.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __surface_Sphere_h__
8 #define __surface_Sphere_h__
9 
10 FE_ATTRIBUTE("surf:emissive", "");
11 FE_ATTRIBUTE("surf:ambient", "");
12 FE_ATTRIBUTE("surf:diffuse", "");
13 FE_ATTRIBUTE("surf:specular", "");
14 FE_ATTRIBUTE("surf:shininess", "");
15 
16 namespace fe
17 {
18 namespace ext
19 {
20 
21 /**************************************************************************//**
22  @brief Material RecordView
23 
24  @ingroup surface
25 *//***************************************************************************/
26 class FE_DL_EXPORT Material: virtual public RecordView
27 {
28  public:
29  Functor<Color> emissive;
30  Functor<Color> ambient;
31  Functor<Color> diffuse;
32  Functor<Color> specular;
33  Functor<F32> shininess;
34 
35  Material(void) { setName("Material"); }
36 virtual void addFunctors(void)
37  {
38  add(emissive, FE_USE("surf:emissive"));
39  add(ambient, FE_USE("surf:ambient"));
40  add(diffuse, FE_USE("surf:diffuse"));
41  add(specular, FE_USE("surf:specular"));
42  add(shininess, FE_USE("surf:shininess"));
43  }
44 virtual void initializeRecord(void)
45  {
46  set(emissive());
47  set(ambient());
48  set(diffuse(),1.0f,1.0f,1.0f,1.0f);
49  set(specular());
50  shininess()=1.0f;
51  }
52 virtual void finalizeRecord(void)
53  {
54  if(diffuse()[3]==Real(0) &&
55  magnitudeSquared(diffuse())>Real(0))
56  {
57  diffuse()[3]=1.0;
58  }
59  }
60 };
61 
62 } /* namespace ext */
63 } /* namespace fe */
64 
65 #endif /* __surface_Sphere_h__ */
66 
virtual void initializeRecord(void)
Called at instantiation to initialize attributes.
Definition: Material.h:44
kernel
Definition: namespace.dox:3
Bound accessor in a RecordView.
Definition: RecordView.h:147
Material RecordView.
Definition: Material.h:26
virtual void finalizeRecord(void)
Called right after instantiation to finalize complex attributes.
Definition: Material.h:52
Bindable collection of accessor Functors.
Definition: RecordView.h:106
virtual void addFunctors(void)
Called at instantiation to add functors.
Definition: Material.h:36