Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 1 (modified by bknecht, 17 years ago) (diff)

Lightmanager

A class that handles Lights.

A Light is a source that emits light rays (photons)

Usage

First you have to get the Light Manager up and running by using LightManager::getInstance. This automatically initiates the GL_LIGHTING, and sets some default stuff about the light. Then you will create a new light using:

  • int addLight(void);
  • int addLight(int lightNumber);

now you can operate on the light as follows:

  • void setPosition(Vector position);
  • void setPosition(GLfloat x, GLfloat y, GLfloat z);
  • void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
  • void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
  • void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
  • void setSpotDirection(Vector direction);
  • void setSpotCutoff(GLfloat cutoff);

These functions are preatty selv-explaining, but you can read about them below. If you want to fetch info, or the a Light use:

  • Vector getPosition(void) const;
  • Vector getPosition(int lightNumber) const;
  • Light* getLight(int lightNumber) const;

To redraw the light use

  • void draw();

and to delete one just use

  • void deleteLight(void);

for some nice output just use:

  • void debug(void) const;

You can also operate on the single Lights themselves, by first retreaving them with

  • Light* getLight(int lightNumber);

and then using the same functions to change settings.