Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Light.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2015 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OMNI_VISUAL_LIGHT_H_
21 #define OMNI_VISUAL_LIGHT_H_
22 
23 #include <array>
24 #include <QColor>
25 #include <QOpenGLFunctions>
26 #include "Tracker.h"
27 
28 namespace omni {
29  namespace visual {
30  /// A light with position and phong shader attributes
31  struct Light : Tracker
32  {
33  public:
34  Light(const Tracker& _tracker = Tracker(),
35  qreal const& _intensity = 1.0);
36 
37  Light(const Tracker& _tracker,
38  const QColor& _ambient,
39  const QColor& _diffuse,
40  const QColor& _specular,
41  const qreal& _intensity = 1.0);
42 
43 
44  /// Setup light in OpenGL
45  void setup(GLuint _index = GL_LIGHT0);
46 
47  /// Return color for ambient
48  QColor ambient() const;
49 
50  /// Set new ambient color
51  void setAmbient(QColor);
52 
53  /// Return diffuse color
54  QColor diffuse() const;
55 
56  /// Set new diffuse color
57  void setDiffuse(QColor);
58 
59  /// Return specular color
60  QColor specular() const;
61 
62  /// Set new specular color
63  void setSpecular(QColor);
64 
65  /// Return intensity value
66  qreal intensity() const;
67 
68  /// Set new intensity value
69  void setIntensity(qreal);
70 
71  /// Deserialize from stream
72  void fromStream(QDataStream&);
73 
74  /// Serialize to stream
75  void toStream(QDataStream&) const;
76 
77  /// Test for equality. ScreenSetup is ignored
78  friend bool operator==(Light const&,
79  Light const&);
80 
81  private:
82  typedef std::array<GLfloat, 4>param_type;
83  param_type colorParam(QColor) const;
84  param_type eye4() const;
85 
87  qreal intensity_;
88  };
89  }
90 }
91 
93 
94 #endif /* OMNI_VISUAL_LIGHT_H_ */
Light(const Tracker &_tracker=Tracker(), qreal const &_intensity=1.0)
Definition: Light.cpp:45
QColor specular() const
Return specular color.
Definition: Light.cpp:102
void setIntensity(qreal)
Set new intensity value.
Definition: Light.cpp:117
QColor ambient_
Definition: Light.h:86
A light with position and phong shader attributes.
Definition: Light.h:31
QColor diffuse_
Definition: Light.h:86
std::array< GLfloat, 4 > param_type
Definition: Light.h:82
void setup(GLuint _index=GL_LIGHT0)
Setup light in OpenGL.
Definition: Light.cpp:67
Tracker()
Definition: Tracker.cpp:27
#define OMNI_DECL_STREAM_OPERATORS(CLASS)
Definition: Interface.h:53
void toStream(QDataStream &) const
Serialize to stream.
Definition: Light.cpp:146
friend bool operator==(Light const &, Light const &)
Test for equality. ScreenSetup is ignored.
Definition: Light.cpp:152
param_type eye4() const
Definition: Light.cpp:132
qreal intensity() const
Return intensity value.
Definition: Light.cpp:112
QColor diffuse() const
Return diffuse color.
Definition: Light.cpp:92
Definition: Tracker.h:27
void setAmbient(QColor)
Set new ambient color.
Definition: Light.cpp:87
void fromStream(QDataStream &)
Deserialize from stream.
Definition: Light.cpp:140
QColor ambient() const
Return color for ambient.
Definition: Light.cpp:82
QColor specular_
Definition: Light.h:86
void setDiffuse(QColor)
Set new diffuse color.
Definition: Light.cpp:97
void setSpecular(QColor)
Set new specular color.
Definition: Light.cpp:107
qreal intensity_
Definition: Light.h:87
param_type colorParam(QColor) const
Definition: Light.cpp:122