Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/textEngine/src/lib/graphics/light.h @ 3736

Last change on this file since 3736 was 3681, checked in by bensch, 20 years ago

orxonox/branches/textEngine: merged trunk here.
merged with command:
svn merge ../trunk textEngine -r 3467:HEAD
no conflicts

File size: 4.7 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 class that handles Lights. The LightManager operates on this.
23class Light : public WorldEntity
24{
25 public:
26  Light(int lightNumber);
27  virtual ~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  Vector getPosition() const;
38  /** \returns the lightNumber*/
39  int getLightNumber(void) const {return this->lightNumber;}
40 
41  virtual void draw();
42
43  void debug(void) const;
44
45  // attributes
46 private:
47  int lightNumber;            //!< The number of this Light.
48  GLfloat lightPosition[4];   //!< The Position of this Light.
49  GLfloat diffuseColor[4];    //!< The Diffuse Color this Light emmits.
50  GLfloat specularColor[4];   //!< The specular Color of this Light.
51  float constantAttenuation;  //!< The Factor of the the Constant Attenuation.
52  float linearAttenuation;    //!< The Factor of the the Linear Attenuation.
53  float quadraticAttenuation; //!< The Factor of the the Quadratic Attenuation.
54  GLfloat spotDirection[4];   //!< The direction of the Spot Light.
55  GLfloat spotCutoff;         //!< The cutoff Angle of the Light Source
56};
57
58//! A class that handles Lights
59/**
60   A Light is a source that emits light rays (photons)
61
62   <b>Usage:</b>\n
63   First you have to get the Light Manager up and running by using LightManager::getInstance.
64   This automatically initiates the GL_LIGHTING, and sets some default stuff about the light.\n
65   Then you will create a new light using:
66   \li int addLight(void);
67   \li int addLight(int lightNumber);
68
69   now you can operate on the light as follows:
70   \li void setPosition(Vector position);
71   \li void setPosition(GLfloat x, GLfloat y, GLfloat z);
72   \li void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
73   \li void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
74   \li void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
75   \li void setSpotDirection(Vector direction);
76   \li void setSpotCutoff(GLfloat cutoff);
77
78   These functions are preatty selv-explaining, but you can read about them below.\n
79   If you want to fetch info, or the a Light use:
80   \li Vector getPosition(void) const;
81   \li Vector getPosition(int lightNumber) const;
82   \li Light* getLight(int LightNumber) const;
83
84   To redraw the light use
85   \li void draw();
86   
87   and to delete one just use
88   \li void deleteLight(void);
89
90   for some nice output just use:
91   \li void debug(void) const;
92
93   You can also operate on the single Lights themselves, by first retreaving them with
94   \li Light* getLight(int LightNumber);
95   \n
96   and then using the same functions on this to change settings.
97*/
98class LightManager : public BaseObject
99{
100 private:
101  LightManager(void);
102  void initLight(int LightNumber);
103 
104  static LightManager* singletonRef;    //!< This is the LightHandlers Reference.
105  GLfloat ambientColor[4];       //!< The ambient Color of the scene.
106
107  Light** lights;                //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues.
108  Light* currentLight;           //!< The current Light, we are working with.
109 
110 public:
111  static LightManager* getInstance();
112  virtual ~LightManager(void);
113
114  // set Attributes
115  int addLight(void);
116  int addLight(int lightNumber);
117  void editLightNumber(int lightNumber);
118  void deleteLight(void);
119  void deleteLight(int lightNumber);
120
121  void setAmbientColor(GLfloat r, GLfloat g, GLfloat b);
122
123  void draw();
124
125  //set Attributes
126  void setPosition(Vector position);
127  void setPosition(GLfloat x, GLfloat y, GLfloat z);
128  void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
129  void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
130  void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
131  void setSpotDirection(Vector direction);
132  void setSpotCutoff(GLfloat cutoff);
133
134  // get Attributes
135  Vector getPosition(void) const;
136  Vector getPosition(int lightNumber) const;
137 
138  Light* getLight(int lightNumber) const;
139 
140  void debug(void) const;
141};
142
143#endif /* _LIGHT_H */
Note: See TracBrowser for help on using the repository browser.