Image Component Library (ICL)
SceneLight.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLGeom/src/ICLGeom/SceneLight.h **
10 ** Module : ICLGeom **
11 ** Authors: Christof Elbrechter, Matthias Esau **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #ifndef ICL_HAVE_OPENGL
34  #ifdef WIN32
35  #pragma WARNING("this header must not be included if ICL_HAVE_OPENGL is not defined")
36  #else
37  #warning "this header must not be included if ICL_HAVE_OPENGL is not defined"
38  #endif
39 #else
40 
41 #include <ICLUtils/CompatMacros.h>
42 #include <ICLGeom/GeomDefs.h>
43 #include <ICLUtils/Uncopyable.h>
44 
45 namespace icl{
46  namespace qt{
48  class GLImg;
50  }
51  namespace geom{
52 
54  class SceneObject;
55  class Scene;
56  class Camera;
57  class SceneLightObject;
60 
74 
76  void setupGL(const Scene &scene, const Camera &cam) const;
77 
78  void updatePositions(const Scene &scene, const Camera &cam) const;
79 
81  const int index;
82 
84  bool on;
85 
88 
90  bool ambientOn;
91 
93  bool diffuseOn;
94 
96  bool specularOn;
97 
98  //flag whether the light casts a shadow
99  bool shadowOn;
100 
101  //flag whether light projects texture
103 
104  //flag whether the light is twosided
106 
109 
112 
115 
118 
120 
122 
124 
126  float spotCutoff;
127 
129 
131 
133  enum Anchor{
136  ObjectAnchor
137  } anchor;
138 
141 
144 
146 
149 
152 
154  SceneLight(Scene *parent, int index);
155 
157 
158  SceneLight(const SceneLight &other);
159 
160 
161  public:
162 
164  ~SceneLight();
165 
167  inline SceneLightObject *getLightObject(){ return lightObject; }
168 
170  inline const SceneLightObject *getLightObject() const { return lightObject; }
171 
173  void setObjectSize(float size);
174 
176  friend class Scene;
177 
179 
180  void setOn(bool on=true);
181 
183  void setAnchorToWorld();
184 
186 
189  void setAnchor(SceneObject *sceneObject);
190 
192 
194  void setCameraAnchor(int cameraIndex=-1);
195 
197 
206  void setPosition(const Vec &position);
207 
209  void setAmbient(const GeomColor &color);
210 
212  void setDiffuse(const GeomColor &color);
213 
215  void setSpecular(const GeomColor &color);
216 
218  void setAmbientEnabled(bool on=true);
219 
221  void setDiffuseEnabled(bool on=true);
222 
224  void setSpecularEnabled(bool on=true);
225 
227  void setSpotDirection(const Vec &vec=Vec(0,0,-1,1));
228 
230  void setSpotExponent(float value=0);
231 
233  void setSpotCutoff(float value=180);
234 
236  void setAttenuation(float constant=1, float linear=0, float quadratic=0);
237 
239  void setShadowEnabled(bool on=true);
240 
242  void setProjectionEnabled(bool on=true);
243 
245  void setTwoSidedEnabled(bool on=true);
246 
248  bool isOn() const;
249 
251  bool getShadowEnabled() const;
252 
254  bool getProjectionEnabled() const;
255 
257  bool getTwoSidedEnabled() const;
258 
260  const Camera* getShadowCam() const;
261 
263  Camera* getShadowCam();
264 
266  void setShadowCam(Camera* cam);
267 
269  void setProjectionImage(qt::GLImg* img);
270 
272  qt::GLImg* getProjectionImage() const;
273 
275  void reset();
276  };
277  } // namespace geom
278 }
279 
280 #endif
GeomColor specular
specular light color
Definition: SceneLight.h:114
bool twoSidedOn
Definition: SceneLight.h:105
GeomColor diffuse
diffuse light color
Definition: SceneLight.h:111
undocument this line if you encounter any issues!
Definition: Any.h:37
Class interface for un-copyable classes.
Definition: Uncopyable.h:64
bool projectionOn
Definition: SceneLight.h:102
float spotExponent
defines the intensity distribution of the light
Definition: SceneLight.h:121
#define ICLGeom_API
Definition: CompatMacros.h:179
bool diffuseOn
flag whether diffuse light component is enabled
Definition: SceneLight.h:93
SceneLightObject * getLightObject()
returns the associated light object
Definition: SceneLight.h:167
int camAnchor
for camera anchor-mode
Definition: SceneLight.h:140
qt::GLImg * projectionImage
Definition: SceneLight.h:145
SceneObject * objectAnchor
for the object anchor mode
Definition: SceneLight.h:148
bool shadowOn
Definition: SceneLight.h:99
Camera class.
Definition: Camera.h:132
light's position is relative to the world
Definition: SceneLight.h:134
OpenGL Texture Map Image class.
Definition: GLImg.h:81
float spotCutoff
defines the cutoff for spot-lights
Definition: SceneLight.h:126
bool ambientOn
flag whether ambient light component is enabled
Definition: SceneLight.h:90
Scene Implementation that is used to handle a list of objects and cameras.
Definition: Scene.h:138
Vec spotDirection
direction vector for directed light (0,0,-1) at default
Definition: SceneLight.h:117
Anchor
internally used anchor mode
Definition: SceneLight.h:133
Vec4D32f Vec
Short typedef for 4D float vectors.
Definition: GeomDefs.h:87
GeomColor ambient
ambient light color
Definition: SceneLight.h:108
ICLQt_API void color(float r, float g=-1, float b=-1, float alpha=255)
sets the current color to given r,g,b,alpha value
The scene light object looks like a light bulb and represents an OpenGL light.
Definition: SceneLightObject.h:42
bool specularOn
flag whether specular light component is enabled
Definition: SceneLight.h:96
Camera * shadowCam
Shadow Camera for rendering ShadowMaps.
Definition: SceneLight.h:143
Wrapper class for OpenGL lights.
Definition: SceneLight.h:72
Vec attenuation
special factor for light attenuation
Definition: SceneLight.h:130
light's position is relative to a camera
Definition: SceneLight.h:135
bool on
flag that is used to swith off/on the light entirely
Definition: SceneLight.h:84
const int index
wrapped opengl light index
Definition: SceneLight.h:81
const SceneLightObject * getLightObject() const
returns the associated light object (const)
Definition: SceneLight.h:170
The SceneObject class defines visible objects in scenes or scene graph nodes.
Definition: SceneObject.h:140
Vec position
the light's position
Definition: SceneLight.h:87
SceneLightObject * lightObject
associated scene light Object
Definition: SceneLight.h:151