Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/light.h @ 3597

Last change on this file since 3597 was 3597, checked in by bensch, 19 years ago

orxonox/trunk: Light is now a World-entity.

File size: 3.3 KB
Line 
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//! The maximum number of Lights this OpenGL-implementation supports
17#define NUMBEROFLIGHTS GL_MAX_LIGHTS
18
19// FORWARD DEFINITIONS //
20class Vector;
21
22//! A struct that holds information about a Light
23class Light : public WorldEntity
24{
25 public:
26  Light(int lightNumber);
27  ~Light(void);
28
29  void setPosition(Vector position);
30  void setPosition(GLfloat x, GLfloat y, GLfloat z);
31  void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
32  void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
33  void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
34  void setSpotDirection(Vector direction);
35  void setSpotCutoff(GLfloat cutoff);
36
37  virtual void draw();
38
39  // attributes
40
41  int lightNumber;            //!< The number of this Light.
42  GLfloat lightPosition[4];   //!< The Position of this Light.
43  GLfloat diffuseColor[4];    //!< The Diffuse Color this Light emmits.
44  GLfloat specularColor[4];   //!< The specular Color of this Light.
45  float constantAttenuation;  //!< The Factor of the the Constant Attenuation.
46  float linearAttenuation;    //!< The Factor of the the Linear Attenuation.
47  float quadraticAttenuation; //!< The Factor of the the Quadratic Attenuation.
48  GLfloat spotDirection[4];   //!< The direction of the Spot Light.
49  GLfloat spotCutoff;         //!< The cutoff Angle of the Light Source
50
51  void debug(void);
52};
53
54//! A class that handles Lights
55/**
56   A Light is a source that emits light rays (photons)
57*/
58class LightManager : public BaseObject
59{
60 private:
61  LightManager(void);
62  void initLight(int LightNumber);
63 
64  static LightManager* singletonRef;    //!< This is the LightHandlers Reference.
65  GLfloat ambientColor[4];       //!< The ambient Color of the scene.
66
67  Light** lights;                //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues.
68  Light* currentLight;           //!< The current Light, we are working with.
69 
70 public:
71  static LightManager* getInstance();
72  virtual ~LightManager(void);
73
74  // set Attributes
75  int addLight(void);
76  int addLight(int lightNumber);
77  void editLightNumber(int lightNumber);
78  void deleteLight(void);
79  void deleteLight(int lightNumber);
80
81  void setAmbientColor(GLfloat r, GLfloat g, GLfloat b);
82
83  //set Attributes
84  void setPosition(Vector position);
85  void setPosition(GLfloat x, GLfloat y, GLfloat z);
86  void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
87  void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
88  void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
89  void setSpotDirection(Vector direction);
90  void setSpotCutoff(GLfloat cutoff);
91
92  // get Attributes
93  Vector getPosition(void);
94  /**
95     \returns the Position of Light
96     \param lightNumber lightnumber
97  */
98  inline Vector getPosition(int lightNumber)
99    {
100      if (!this->lights[lightNumber])
101        return Vector(.0,.0,.0);
102      return Vector(this->lights[lightNumber]->lightPosition[0],
103                    this->lights[lightNumber]->lightPosition[1],
104                    this->lights[lightNumber]->lightPosition[2]);
105    }
106
107  void debug(void);
108};
109
110#endif /* _LIGHT_H */
Note: See TracBrowser for help on using the repository browser.