Version 2 (modified by landauf, 17 years ago) (diff) |
---|
Lightmanager
This is an archived page! This page is very old and the content is not up to date. Not everything (if any) which is written here will be in the final game! |
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.