00001
00008 #ifndef _LIGHT_H_
00009 #define _LIGHT_H_
00010 #include "globals.h"
00011 #include "mat.h"
00012 #include "object.h"
00013
00016 class TLight
00017 {
00018 private:
00019 TVector pos;
00020 TVector ambient, diffuse, specular;
00021 float radius;
00022 GLint light;
00023 bool shadow;
00024
00025
00026 GLint shadow_size;
00027 GLfloat shadow_intensity;
00028
00029 GLUquadricObj *q;
00030
00031 public:
00033 GLuint fbo;
00035 TMatrix lightProjectionMatrix;
00037 TMatrix lightViewMatrix;
00039 TMatrix cameraProjectionMatrix;
00041 TMatrix cameraViewMatrix;
00043 TMatrix biasMatrix;
00045 TMatrix textureMatrix;
00046
00047 TLight();
00048 ~TLight();
00058 TLight(GLint lights, TVector amb, TVector diff, TVector spec, TVector lpos, float radius)
00059 { Set(lights,amb,diff,spec,lpos,radius); }
00060
00062 void Move(TVector w)
00063 { pos = w; glLightfv(light + GL_LIGHT0, GL_POSITION, w); }
00064
00066 void KeepPos()
00067 { glLightfv(light + GL_LIGHT0, GL_POSITION, pos); }
00068
00069 void DrawLight(TMatrix &transformMatrix);
00070
00071
00072 void ChangeColor(GLint component, TVector color);
00073
00074 void Set(GLint lights, TVector amb, TVector diff, TVector spec, TVector lpos, float radius);
00075
00076 void SetShadow(GLint shadow_size, GLfloat _shadow_intensity, bool shadow);
00078 void SetRadius(float value)
00079 { radius = value; }
00080
00082 bool HasShadow()
00083 { return shadow; }
00085 GLint ShadowSize()
00086 { return shadow_size; }
00088 GLfloat ShadowIntensity()
00089 { return shadow_intensity; }
00090
00091 string GetShadowCache();
00092
00093
00095 TVector GetPos()
00096 { return pos; }
00098 GLint GetOrd()
00099 { return light; }
00101 float GetRadius()
00102 { return radius; }
00103
00104 };
00105
00106 #endif