Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SceneLight.h
Go to the documentation of this file.
00001 /********************************************************************
00002 **                Image Component Library (ICL)                    **
00003 **                                                                 **
00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld          **
00005 **                         Neuroinformatics Group                  **
00006 ** Website: www.iclcv.org and                                      **
00007 **          http://opensource.cit-ec.de/projects/icl               **
00008 **                                                                 **
00009 ** File   : ICLGeom/src/ICLGeom/SceneLight.h                       **
00010 ** Module : ICLGeom                                                **
00011 ** Authors: Christof Elbrechter                                    **
00012 **                                                                 **
00013 **                                                                 **
00014 ** GNU LESSER GENERAL PUBLIC LICENSE                               **
00015 ** This file may be used under the terms of the GNU Lesser General **
00016 ** Public License version 3.0 as published by the                  **
00017 **                                                                 **
00018 ** Free Software Foundation and appearing in the file LICENSE.GPL  **
00019 ** included in the packaging of this file.  Please review the      **
00020 ** following information to ensure the license requirements will   **
00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt                **
00022 **                                                                 **
00023 ** The development of this software was supported by the           **
00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology.    **
00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche       **
00026 ** Forschungsgemeinschaft (DFG) in the context of the German       **
00027 ** Excellence Initiative.                                          **
00028 **                                                                 **
00029 ********************************************************************/
00030 
00031 #pragma once
00032 
00033 #ifndef HAVE_OPENGL
00034 #warning "this header must not be included if HAVE_OPENGL is not defined"
00035 #else
00036 
00037 #include <ICLGeom/GeomDefs.h>
00038 #include <ICLUtils/Uncopyable.h>
00039 
00040 namespace icl{
00041   namespace geom{
00042     
00044     class SceneObject;
00045     class Scene;
00046     class Camera;
00047     class SceneLightObject;
00050 
00051 
00054     class SceneLight : public utils::Uncopyable{
00056 
00058       void setupGL(const Scene &scene, const Camera &cam) const;
00059       
00060       void updatePositions(const Scene &scene, const Camera &cam) const;
00061       
00063       const int index;
00064       
00066       bool on;
00067       
00069       Vec position;
00070       
00072       bool ambientOn;
00073   
00075       bool diffuseOn;
00076   
00078       bool specularOn;
00079       
00080       //flag weather the light casts a shadow
00081       bool shadowOn;
00082       
00084       GeomColor ambient;
00085       
00087       GeomColor diffuse;
00088       
00090       GeomColor specular;
00091       
00093       Vec spotDirection;
00094       
00096 
00097       float spotExponent;
00098       
00100 
00102       float spotCutoff;
00103       
00105 
00106       Vec attenuation;
00107   
00109       enum Anchor{
00110         WorldAnchor, 
00111         CamAnchor,   
00112         ObjectAnchor 
00113       } anchor; 
00114       
00116       int camAnchor;
00117       
00119       Camera *shadowCam;
00120       
00122       SceneObject *objectAnchor;
00123   
00125       SceneLightObject *lightObject;
00126       
00128       SceneLight(Scene *parent, int index);
00129       
00131 
00132       SceneLight(const SceneLight &other);
00133      
00134 
00135       public:
00136   
00138       ~SceneLight();
00139       
00141       inline SceneLightObject *getLightObject(){ return lightObject; }
00142 
00144       inline const SceneLightObject *getLightObject() const { return lightObject; }
00145 
00147       void setObjectSize(float size);
00148       
00150       friend class Scene;
00151   
00153 
00154       void setOn(bool on=true);
00155       
00157       void setAnchorToWorld();
00158   
00160 
00163       void setAnchor(SceneObject *sceneObject);
00164       
00166 
00168       void setCameraAnchor(int cameraIndex=-1);
00169   
00171 
00180       void setPosition(const Vec &position);
00181       
00183       void setAmbient(const GeomColor &color);
00184   
00186       void setDiffuse(const GeomColor &color);
00187       
00189       void setSpecular(const GeomColor &color);
00190       
00192       void setAmbientEnabled(bool on=true);
00193   
00195       void setDiffuseEnabled(bool on=true);
00196   
00198       void setSpecularEnabled(bool on=true);
00199       
00201       void setSpotDirection(const Vec &vec=Vec(0,0,-1,1));
00202   
00204       void setSpotExponent(float value=0);
00205   
00207       void setSpotCutoff(float value=180);
00208   
00210       void setAttenuation(float constant=1, float linear=0, float quadratic=0);
00211       
00213       void setShadowEnabled(bool on=true);
00214       
00216       const Camera& getShadowCam() const;
00217       
00219       Camera& getShadowCam();
00220       
00222       void reset();
00223     };
00224   } // namespace geom
00225 }
00226 
00227 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines