Image Component Library (ICL)
|
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, Matthias Esau ** 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.LGPL ** 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 ICL_HAVE_OPENGL 00034 #ifdef WIN32 00035 #pragma WARNING("this header must not be included if ICL_HAVE_OPENGL is not defined") 00036 #else 00037 #warning "this header must not be included if ICL_HAVE_OPENGL is not defined" 00038 #endif 00039 #else 00040 00041 #include <ICLUtils/CompatMacros.h> 00042 #include <ICLGeom/GeomDefs.h> 00043 #include <ICLUtils/Uncopyable.h> 00044 00045 namespace icl{ 00046 namespace geom{ 00047 00049 class SceneObject; 00050 class Scene; 00051 class Camera; 00052 class SceneLightObject; 00055 00056 00067 class ICLGeom_API SceneLight : public utils::Uncopyable{ 00069 00071 void setupGL(const Scene &scene, const Camera &cam) const; 00072 00073 void updatePositions(const Scene &scene, const Camera &cam) const; 00074 00076 const int index; 00077 00079 bool on; 00080 00082 Vec position; 00083 00085 bool ambientOn; 00086 00088 bool diffuseOn; 00089 00091 bool specularOn; 00092 00093 //flag weather the light casts a shadow 00094 bool shadowOn; 00095 00096 //flag weather the light casts a shadow 00097 bool twoSidedOn; 00098 00100 GeomColor ambient; 00101 00103 GeomColor diffuse; 00104 00106 GeomColor specular; 00107 00109 Vec spotDirection; 00110 00112 00113 float spotExponent; 00114 00116 00118 float spotCutoff; 00119 00121 00122 Vec attenuation; 00123 00125 enum Anchor{ 00126 WorldAnchor, 00127 CamAnchor, 00128 ObjectAnchor 00129 } anchor; 00130 00132 int camAnchor; 00133 00135 Camera *shadowCam; 00136 00138 SceneObject *objectAnchor; 00139 00141 SceneLightObject *lightObject; 00142 00144 SceneLight(Scene *parent, int index); 00145 00147 00148 SceneLight(const SceneLight &other); 00149 00150 00151 public: 00152 00154 ~SceneLight(); 00155 00157 inline SceneLightObject *getLightObject(){ return lightObject; } 00158 00160 inline const SceneLightObject *getLightObject() const { return lightObject; } 00161 00163 void setObjectSize(float size); 00164 00166 friend class Scene; 00167 00169 00170 void setOn(bool on=true); 00171 00173 void setAnchorToWorld(); 00174 00176 00179 void setAnchor(SceneObject *sceneObject); 00180 00182 00184 void setCameraAnchor(int cameraIndex=-1); 00185 00187 00196 void setPosition(const Vec &position); 00197 00199 void setAmbient(const GeomColor &color); 00200 00202 void setDiffuse(const GeomColor &color); 00203 00205 void setSpecular(const GeomColor &color); 00206 00208 void setAmbientEnabled(bool on=true); 00209 00211 void setDiffuseEnabled(bool on=true); 00212 00214 void setSpecularEnabled(bool on=true); 00215 00217 void setSpotDirection(const Vec &vec=Vec(0,0,-1,1)); 00218 00220 void setSpotExponent(float value=0); 00221 00223 void setSpotCutoff(float value=180); 00224 00226 void setAttenuation(float constant=1, float linear=0, float quadratic=0); 00227 00229 void setShadowEnabled(bool on=true); 00230 00232 void setTwoSidedEnabled(bool on=true); 00233 00235 bool isOn() const; 00236 00238 bool getShadowEnabled() const; 00239 00241 bool getTwoSidedEnabled() const; 00242 00244 const Camera* getShadowCam() const; 00245 00247 Camera* getShadowCam(); 00248 00250 void setShadowCam(Camera* cam); 00251 00253 void reset(); 00254 }; 00255 } // namespace geom 00256 } 00257 00258 #endif