Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: some more classes now destroy themselves via virtual-destructors and call to predecessing destroy-function
also made
#include "stdincl.h" out of unnecessary h-files, so we got faster compile time.

File size: 2.9 KB
RevLine 
[3245]1/*!
[3436]2    \file light.h
3    \brief Handles Lights.
[3329]4
[3436]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.
[3245]8*/
[1853]9
[3436]10#ifndef _LIGHT_H
11#define _LIGHT_H
[1853]12
[3436]13#include "world_entity.h"
14#include "glincl.h"
[1853]15
[3446]16//! The maximum number of Lights this OpenGL-implementation supports
[3437]17#define NUMBEROFLIGHTS GL_MAX_LIGHTS
18
[3446]19//! Enumerator for the attenuation-Type.
20/**
21   CONSTANT means GL_CONSTANT_ATTENUATION
22   LINEAR means   GL_LINEAR_ATTENUATION
23   QUADRATIC means GL_QUADRATIC_ATTENUATION
24*/
[3441]25enum AttenuationType {CONSTANT, LINEAR, QUADRATIC};
26
[3436]27// FORWARD DEFINITIONS //
28class Vector;
[2036]29
[3436]30//! A class that handles Lights
[3329]31/**
[3436]32   A Light is a source that emits light rays (photons)
[3329]33*/
[3437]34class Light : public WorldEntity
[3436]35{
[3437]36 private:
37  //! A struct that holds information about a Light
38  struct LightValue
39  {
40    int lightNumber;            //!< The number of this Light.
41    GLfloat lightPosition[4];   //!< The Position of this Light.
42    GLfloat diffuseColor[4];    //!< The Diffuse Color this Light emmits.
43    GLfloat specularColor[4];   //!< The specular Color of this Light.
[3441]44    AttenuationType attenuationType;//!< The AttenuationType of this Light.
[3453]45    float attenuationFactor;    //!< The Factor the attenuation should have.
46    GLfloat spotDirection[4];   //!< The direction of the Spot Light.
47    GLfloat spotCutoff;         //!< The cutoff Angle of the Light Source
[3437]48  };
49
50  static Light* singletonRef;    //!< This is the LightHandlers Reference.
[3440]51  GLfloat ambientColor[4];       //!< The ambient Color of the scene.
52
53
[3437]54  Light(void);
55
56  void init(int LightNumber); 
[3446]57  LightValue** lights;           //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues.
58  LightValue* currentLight;      //!< The current Light, we are working with.
[3436]59 
[1904]60 public:
[3437]61  static Light* getInstance();
[3543]62  virtual ~Light(void);
63  void destroy(void);
[1853]64
[3543]65
[3436]66  // set Attributes
[3437]67  int addLight(void);
68  int addLight(int lightNumber);
69  void editLightNumber(int lightNumber);
70  void deleteLight(void);
71  void deleteLight(int lightNumber);
72
[3436]73  void setPosition(Vector position);
[3437]74  void setPosition(GLfloat x, GLfloat y, GLfloat z);
[3436]75  void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
76  void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
[3441]77  void setAttenuation(AttenuationType type, float factor);
[3440]78  void setAmbientColor(GLfloat r, GLfloat g, GLfloat b);
[3453]79  void setSpotDirection(Vector direction);
80  void setSpotCutoff(GLfloat cutoff);
81
[3436]82  // get Attributes
83  Vector getPosition(void);
[3446]84  /**
85     \returns the Position of Light
86     \param lightNumber lightnumber
87  */
[3444]88  inline Vector getPosition(int lightNumber)
89    {
90      if (!this->lights[lightNumber])
91        return Vector(.0,.0,.0);
92      return Vector(this->lights[lightNumber]->lightPosition[0],
93                    this->lights[lightNumber]->lightPosition[1],
94                    this->lights[lightNumber]->lightPosition[2]);
95    }
[3442]96
97  void debug(void);
[1853]98};
99
[3436]100#endif /* _LIGHT_H */
Note: See TracBrowser for help on using the repository browser.