00001 00002 /* 00003 TEDDY - General graphics application library 00004 Copyright (C) 1999-2002 Timo Suoranta 00005 tksuoran@cc.helsinki.fi 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2.1 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 00021 $Id: Light.h,v 1.6 2002/02/16 12:41:39 tksuoran Exp $ 00022 */ 00023 00024 00025 #ifndef TEDDY__MATERIALS__LIGHT__H 00026 #define TEDDY__MATERIALS__LIGHT__H 00027 00028 00029 #include "Teddy/Maths/Vector.h" 00030 #include "Teddy/Models/Model.h" 00031 #include "Teddy/Graphics/Color.h" 00032 00033 00034 // Forward declarations 00035 namespace Teddy { 00036 namespace PhysicalComponents { class Projection; }; 00037 }; 00038 00039 00040 00041 namespace Teddy { 00042 namespace Materials { 00043 00044 00058 class Light : public Teddy::Models::Model { 00059 public: 00060 static const unsigned long TYPE_DIRECTIONAL; 00061 static const unsigned long TYPE_POSITIONAL; 00062 public: 00063 Light( const std::string &name ); 00064 00065 void setType ( const unsigned long type ); 00066 void setAmbient ( const Teddy::Graphics::Color &a ); 00067 void setDiffuse ( const Teddy::Graphics::Color &d ); 00068 void setSpecular ( const Teddy::Graphics::Color &s ); 00069 void setAttenuation ( const float constant, const float linear, const float quadratic ); 00070 void setSpotCutOff ( const float cutoff_angle ); 00071 void setSpotExponent ( const float exponent ); 00072 void setSpotDirection( Teddy::Maths::Vector spot_direction ); 00073 void enable (); 00074 void disable (); 00075 virtual void applyLight ( Teddy::PhysicalComponents::Projection *p ); 00076 00077 // Light special tick 00078 void orbit ( float radius, float speed, int axis ); 00079 00080 protected: 00081 unsigned long type; 00082 int id; 00083 Teddy::Graphics::Color ambient; 00084 Teddy::Graphics::Color diffuse; 00085 Teddy::Graphics::Color specular; 00086 unsigned int flags; 00087 00088 float constant_attenuation; 00089 float linear_attenuation; 00090 float quadratic_attenuation; 00091 float spot_cutoff_angle; 00092 float spot_exponent; 00093 Teddy::Maths::TVector<float> spot_direction; 00094 00095 bool orbit_active; 00096 float orbit_radius; 00097 float orbit_speed; 00098 int orbit_axis; 00099 00100 static unsigned int light_id [8]; // FIX (query number of available lights from OpenGL) 00101 static int light_status[8]; 00102 }; 00103 00104 00105 }; // namespace Materials 00106 }; // namespace Teddy 00107 00108 00109 #endif // TEDDY__MATERIALS__LIGHT__H 00110