/*! \file light.h \brief Handles Lights. A Light is one of the more important things in a 3D-environment, without it one sees nothing :) It is here for diffuse-, specular- and Bump-Mappings. */ #ifndef _LIGHT_H #define _LIGHT_H #include "world_entity.h" #include "glincl.h" //! The maximum number of Lights this OpenGL-implementation supports #define NUMBEROFLIGHTS GL_MAX_LIGHTS // FORWARD DEFINITIONS // class Vector; //! A struct that holds information about a Light class Light : public WorldEntity { public: Light(int lightNumber); ~Light(void); void setPosition(Vector position); void setPosition(GLfloat x, GLfloat y, GLfloat z); void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b); void setSpecularColor(GLfloat r, GLfloat g, GLfloat b); void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation); void setSpotDirection(Vector direction); void setSpotCutoff(GLfloat cutoff); virtual void draw(); // attributes int lightNumber; //!< The number of this Light. GLfloat lightPosition[4]; //!< The Position of this Light. GLfloat diffuseColor[4]; //!< The Diffuse Color this Light emmits. GLfloat specularColor[4]; //!< The specular Color of this Light. float constantAttenuation; //!< The Factor of the the Constant Attenuation. float linearAttenuation; //!< The Factor of the the Linear Attenuation. float quadraticAttenuation; //!< The Factor of the the Quadratic Attenuation. GLfloat spotDirection[4]; //!< The direction of the Spot Light. GLfloat spotCutoff; //!< The cutoff Angle of the Light Source void debug(void); }; //! A class that handles Lights /** A Light is a source that emits light rays (photons) */ class LightManager : public BaseObject { private: LightManager(void); void initLight(int LightNumber); static LightManager* singletonRef; //!< This is the LightHandlers Reference. GLfloat ambientColor[4]; //!< The ambient Color of the scene. Light** lights; //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues. Light* currentLight; //!< The current Light, we are working with. public: static LightManager* getInstance(); virtual ~LightManager(void); // set Attributes int addLight(void); int addLight(int lightNumber); void editLightNumber(int lightNumber); void deleteLight(void); void deleteLight(int lightNumber); void setAmbientColor(GLfloat r, GLfloat g, GLfloat b); //set Attributes void setPosition(Vector position); void setPosition(GLfloat x, GLfloat y, GLfloat z); void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b); void setSpecularColor(GLfloat r, GLfloat g, GLfloat b); void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation); void setSpotDirection(Vector direction); void setSpotCutoff(GLfloat cutoff); // get Attributes Vector getPosition(void); /** \returns the Position of Light \param lightNumber lightnumber */ inline Vector getPosition(int lightNumber) { if (!this->lights[lightNumber]) return Vector(.0,.0,.0); return Vector(this->lights[lightNumber]->lightPosition[0], this->lights[lightNumber]->lightPosition[1], this->lights[lightNumber]->lightPosition[2]); } void debug(void); }; #endif /* _LIGHT_H */