00001 #include "Light.h"
00002
00003 Light::Light ()
00004 {
00005 ambient[0] = 0.0f;
00006 ambient[1] = 0.0f;
00007 ambient[2] = 0.0f;
00008 ambient[3] = 0.0f;
00009
00010 diffuse[0] = 1.0f;
00011 diffuse[1] = 1.0f;
00012 diffuse[2] = 1.0f;
00013 diffuse[3] = 1.0f;
00014
00015 specular[0] = 1.0f;
00016 specular[1] = 1.0f;
00017 specular[2] = 1.0f;
00018 specular[3] = 1.0f;
00019
00020 position = new PositionPath ();
00021 }
00022
00023 Light::~Light ()
00024 {
00025
00026 }
00027
00028 void Light::SetAmbient (float red, float green, float blue, float alpha)
00029 {
00030 ambient[0] = red;
00031 ambient[1] = green;
00032 ambient[2] = blue;
00033 ambient[3] = alpha;
00034 }
00035
00036 void Light::SetDiffuse (float red, float green, float blue, float alpha)
00037 {
00038 diffuse[0] = red;
00039 diffuse[1] = green;
00040 diffuse[2] = blue;
00041 diffuse[3] = alpha;
00042 }
00043
00044 void Light::SetSpecular (float red, float green, float blue, float alpha)
00045 {
00046 specular[0] = red;
00047 specular[1] = green;
00048 specular[2] = blue;
00049 specular[3] = alpha;
00050 }
00051
00052 void Light::Bind (int id_)
00053 {
00054 id = id_;
00055 }
00056
00057 void Light::Apply (int time)
00058 {
00059 Position pos;
00060 float pos_[4];
00061
00062 pos = position->GetPosition (time);
00063
00064 pos_[0] = pos.x;
00065 pos_[1] = pos.y;
00066 pos_[2] = pos.z;
00067 pos_[3] = 1.0f;
00068
00069 glEnable (id);
00070 glLightfv (id, GL_AMBIENT, ambient);
00071 glLightfv (id, GL_DIFFUSE, diffuse);
00072 glLightfv (id, GL_SPECULAR, specular);
00073 glLightfv (id, GL_POSITION, pos_);
00074 }
00075
00076