00001
00002
00003
00004 #ifndef LIGHT_H_IS_INCLUDED
00005 #define LIGHT_H_IS_INCLUDED
00006
00007 #include "disp/color.H"
00008 #include "mlib/points.H"
00009
00010
00011
00012 class Light {
00013 public:
00014
00015
00016
00017 Light() :
00018 _is_enabled(false),
00019 _is_in_cam_space(true),
00020 _is_positional(false),
00021 _ambient_color (COLOR::black),
00022 _diffuse_color (COLOR::white),
00023 _specular_color(COLOR::white),
00024 _coords(mlib::Wvec(0,0,1)),
00025 _spot_direction(0,0,-1),
00026 _spot_exponent(0),
00027 _spot_cutoff(180),
00028 _k0(1),
00029 _k1(0),
00030 _k2(0) {}
00031
00032
00033 Light(mlib::CWvec& dir,
00034 bool is_enabled = false,
00035 bool is_in_cam_space = true,
00036 CCOLOR& ambient = COLOR::black,
00037 CCOLOR& diffuse = COLOR::white,
00038 CCOLOR& specular = COLOR::white
00039 ) :
00040 _is_enabled(is_enabled),
00041 _is_in_cam_space(is_in_cam_space),
00042 _is_positional(false),
00043 _ambient_color (ambient),
00044 _diffuse_color (diffuse),
00045 _specular_color(specular),
00046 _coords(dir),
00047 _spot_direction(0,0,-1),
00048 _spot_exponent(0),
00049 _spot_cutoff(180),
00050 _k0(1),
00051 _k1(0),
00052 _k2(0) {}
00053
00054
00055 Light(mlib::CWpt& loc,
00056 bool is_enabled = false,
00057 bool is_in_cam_space = true,
00058 CCOLOR& ambient = COLOR::black,
00059 CCOLOR& diffuse = COLOR::white,
00060 CCOLOR& specular = COLOR::white,
00061 mlib::CWvec& spot_dir = mlib::Wvec(0,0,-1),
00062 float spot_exponent = 0,
00063 float spot_cutoff = 180,
00064 float k0 = 1,
00065 float k1 = 0,
00066 float k2 = 0) :
00067 _is_enabled(is_enabled),
00068 _is_in_cam_space(is_in_cam_space),
00069 _is_positional(true),
00070 _ambient_color (ambient),
00071 _diffuse_color (diffuse),
00072 _specular_color(specular),
00073 _coords(loc[0],loc[1],loc[2]),
00074 _spot_direction(spot_dir),
00075 _spot_exponent(spot_exponent),
00076 _spot_cutoff(spot_cutoff),
00077 _k0(k0),
00078 _k1(k1),
00079 _k2(k2) {}
00080
00081
00082 mlib::Wvec get_direction() const { return _coords.normalized(); }
00083
00084 mlib::Wpt get_position() const {
00085 return mlib::Wpt(_coords[0],_coords[1],_coords[2]);
00086 }
00087
00088 void set_position(mlib::CWpt& p) {
00089 _coords = mlib::Wvec(p[0],p[1],p[2]);
00090 _is_positional = true;
00091 }
00092 void set_direction(mlib::CWvec& v) {
00093 _coords = v;
00094 _is_positional = false;
00095 }
00096
00097
00098
00099
00100
00101
00102 bool _is_enabled;
00103 bool _is_in_cam_space;
00104 bool _is_positional;
00105 COLOR _ambient_color;
00106 COLOR _diffuse_color;
00107 COLOR _specular_color;
00108 mlib::Wvec _coords;
00109 mlib::Wvec _spot_direction;
00110 float _spot_exponent;
00111 float _spot_cutoff;
00112 float _k0;
00113 float _k1;
00114 float _k2;
00115 };
00116
00117 #endif // LIGHT_H_IS_INCLUDED
00118
00119