Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: Light faster getPosition algorythm

File size: 2.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#define NUMBEROFLIGHTS GL_MAX_LIGHTS
17
18enum AttenuationType {CONSTANT, LINEAR, QUADRATIC};
19
20// FORWARD DEFINITIONS //
21class Vector;
22
23//! A class that handles Lights
24/**
25   A Light is a source that emits light rays (photons)
26*/
27class 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  //! \returns the Position of Light \param lightNumber lightnumber
72  inline Vector getPosition(int lightNumber)
73    {
74      if (!this->lights[lightNumber])
75        return Vector(.0,.0,.0);
76      return Vector(this->lights[lightNumber]->lightPosition[0],
77                    this->lights[lightNumber]->lightPosition[1],
78                    this->lights[lightNumber]->lightPosition[2]);
79    }
80
81  void debug(void);
82};
83
84#endif /* _LIGHT_H */
Note: See TracBrowser for help on using the repository browser.