1 | /*! |
---|
2 | \file light.h |
---|
3 | \brief Handles Lights. |
---|
4 | |
---|
5 | A Light is one of the more important things in a 3D-environment, |
---|
6 | without it one sees nothing :) |
---|
7 | It is here for diffuse-, specular- and Bump-Mappings. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifndef _LIGHT_H |
---|
11 | #define _LIGHT_H |
---|
12 | |
---|
13 | #include "world_entity.h" |
---|
14 | #include "glincl.h" |
---|
15 | |
---|
16 | #define NUMBEROFLIGHTS GL_MAX_LIGHTS |
---|
17 | |
---|
18 | enum AttenuationType {CONSTANT, LINEAR, QUADRATIC}; |
---|
19 | |
---|
20 | // FORWARD DEFINITIONS // |
---|
21 | class Vector; |
---|
22 | |
---|
23 | //! A class that handles Lights |
---|
24 | /** |
---|
25 | A Light is a source that emits light rays (photons) |
---|
26 | */ |
---|
27 | class Light : public WorldEntity |
---|
28 | { |
---|
29 | private: |
---|
30 | //! A struct that holds information about a Light |
---|
31 | struct LightValue |
---|
32 | { |
---|
33 | int lightNumber; //!< The number of this Light. |
---|
34 | GLfloat lightPosition[4]; //!< The Position of this Light. |
---|
35 | GLfloat lmodelAmbient[4]; //!< The general Ambient Color. |
---|
36 | GLfloat diffuseColor[4]; //!< The Diffuse Color this Light emmits. |
---|
37 | GLfloat specularColor[4]; //!< The specular Color of this Light. |
---|
38 | AttenuationType attenuationType;//!< The AttenuationType of this Light. |
---|
39 | float attenuationFactor; //!< the Factor the attenuation should have. |
---|
40 | }; |
---|
41 | |
---|
42 | static Light* singletonRef; //!< This is the LightHandlers Reference. |
---|
43 | GLfloat ambientColor[4]; //!< The ambient Color of the scene. |
---|
44 | |
---|
45 | |
---|
46 | Light(void); |
---|
47 | |
---|
48 | void init(int LightNumber); |
---|
49 | LightValue** lights; |
---|
50 | LightValue* currentLight; |
---|
51 | |
---|
52 | public: |
---|
53 | static Light* getInstance(); |
---|
54 | ~Light(void); |
---|
55 | |
---|
56 | // set Attributes |
---|
57 | int addLight(void); |
---|
58 | int addLight(int lightNumber); |
---|
59 | void editLightNumber(int lightNumber); |
---|
60 | void deleteLight(void); |
---|
61 | void deleteLight(int lightNumber); |
---|
62 | |
---|
63 | void setPosition(Vector position); |
---|
64 | void setPosition(GLfloat x, GLfloat y, GLfloat z); |
---|
65 | void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b); |
---|
66 | void setSpecularColor(GLfloat r, GLfloat g, GLfloat b); |
---|
67 | void setAttenuation(AttenuationType type, float factor); |
---|
68 | void setAmbientColor(GLfloat r, GLfloat g, GLfloat b); |
---|
69 | // get Attributes |
---|
70 | Vector getPosition(void); |
---|
71 | |
---|
72 | void debug(void); |
---|
73 | }; |
---|
74 | |
---|
75 | #endif /* _LIGHT_H */ |
---|