TAPs 0.7.7.3
TAPsOpenGLLightModel.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsOpenGLLightModel.hpp
00003 
00004 Light Model for OpenGL
00005 
00006 SUKITTI PUNAK   (05/12/2006)
00007 UPDATE          (05/14/2006)
00008 ******************************************************************************/
00009 #ifndef TAPs_OPENGL_LIGHT_MODEL_HPP
00010 #define TAPs_OPENGL_LIGHT_MODEL_HPP
00011 
00012 #include "TAPsOpenGLFns.hpp"
00013 
00014 BEGIN_NAMESPACE_TAPs__OpenGL
00015 //=============================================================================
00016 template <typename T>
00017 class OpenGLLightModel {
00018 //-----------------------------------------------------------------------------
00019 public:
00020     static int GetNumberOfLights ();
00021     static int GetMaxinumNumberOfLightsAllowed ();
00022     //-------------------------------------------------------------------------
00023     // Constructor and Destructor
00024     OpenGLLightModel ();
00025     OpenGLLightModel ( 
00026             T lightNumber,                                      // light#
00027             T ambientR,  T ambientG,  T ambientB,  T ambientA,  // ambient
00028             T diffuseR,  T diffuseG,  T diffuseB,  T diffuseA,  // diffuse
00029             T specularR, T specularG, T specularB, T specularA, // specular
00030             T positionX, T positionY, T positionZ, T positionW, // position
00031             T spotDirectionX = 0,       // spot direction x
00032             T spotDirectionY = 0,       // spot direction y
00033             T spotDirectionZ = -1,      // spot direction z
00034             T spotExponent = 0,         // spot exponent
00035             T spotCutoff = 180,         // spot cutoff
00036             T constantAttenuation = 1,  // constant attenuation
00037             T linearAttenuation = 0,    // linear attenuation
00038             T QuadraticAttenuation = 0  // quadratic attenuation
00039     );
00040     ~OpenGLLightModel ();
00041     //---------------------------------------------------------------
00042     // Get/Set Function(s)
00043     inline void Enable ();
00044     inline void Disable ();
00045     inline void Switch ( bool on );
00046     inline void ToggleSwitch ();
00047     inline bool IsOn () const;
00048     inline bool IsEnabled () const;
00049     //-------------------------------------------
00050     inline void SetGLLightNumber ( int n );
00051     inline void SetGLLightNumber ( GLenum eGL );
00052     inline int  GetGLLightNumber () const;
00053     //-------------------------------------------
00054     inline void SetAmbient ( const Vector4<T> & v );
00055     inline void SetAmbient ( const Vector3<T> & v );
00056     inline void SetAmbient ( T r, T g, T b, T a );
00057     inline void SetAmbient ( T r, T g, T b );
00058     inline const Vector4<T> & GetAmbient () const;
00059     //-------------------------------------------
00060     inline void SetDiffuse ( const Vector4<T> & v );
00061     inline void SetDiffuse ( const Vector3<T> & v );
00062     inline void SetDiffuse ( T r, T g, T b, T a );
00063     inline void SetDiffuse ( T r, T g, T b );
00064     inline const Vector4<T> & GetDiffuse () const;
00065     //-------------------------------------------
00066     inline void SetSpecular ( const Vector4<T> & v );
00067     inline void SetSpecular ( const Vector3<T> & v );
00068     inline void SetSpecular ( T r, T g, T b, T a );
00069     inline void SetSpecular ( T r, T g, T b );
00070     inline const Vector4<T> & GetSpecular () const;
00071     //-------------------------------------------
00072     inline void SetPosition ( const Vector4<T> & v );
00073     inline void SetPosition ( const Vector3<T> & v );
00074     inline void SetPosition ( T x, T y, T z, T w );
00075     inline void SetPosition ( T x, T y, T z );
00076     inline const Vector4<T> & GetPosition () const;
00077     //-------------------------------------------
00078     inline void SetSpotDirection ( const Vector3<T> & v );
00079     inline void SetSpotDirection ( T x, T y, T z );
00080     inline const Vector3<T> & GetSpotDirection () const;
00081     //-------------------------------------------
00082     inline void SetSpotExponent ( T t );
00083     inline T GetSpotExponent () const;
00084     //-------------------------------------------
00085     inline void SetSpotCutoff ( T t );
00086     inline T GetSpotCutoff () const;
00087     //-------------------------------------------
00088     inline void SetAttenuationConstant ( T t );
00089     inline T GetAttenuationConstant () const;
00090     //-------------------------------------------
00091     inline void SetAttenuationLinear( T t );
00092     inline T GetAttenuationLinear () const;
00093     //-------------------------------------------
00094     inline void SetAttenuationQuadratic ( T t );
00095     inline T GetAttenuationQuadratic () const;
00096     //---------------------------------------------------------------
00097     /*
00098     // Shadow
00099     void GenerateShadowMap ( 
00100         //void (*DrawModels)( Enum::DrawMode DM ), 
00101         void (*DrawModels)(), 
00102         //OpenGLModelManager<T> obj, 
00103         //void (OpenGLModelManager<T>::*DrawModels)(), 
00104                 T tDistance = 100, int shadowSize = 512 );
00105     //*/
00106     //---------------------------------------------------------------
00107     // Operation(s)
00108     //---------------------------------------------------------------
00109     // Drawing(s)
00110     void Draw ();
00111 //-----------------------------------------------------------------------------
00112 private:
00113     //---------------------------------------------------------------
00114     static void SetGLMaxLights ();
00115     //---------------------------------------------------------------
00116     void SetDefaultValues ();
00117     //-------------------------------------------------------------------------
00118     // Data Member(s)
00119     GLenum          m_eGLLightNumber;   // GL_LIGHTi; 0 <= i < GL_MAX_LIGHTS
00120     bool            m_bOn;              // On/Off (enable/disable) light
00121     Vector4<T>      m_v4Ambient;        // Light Ambient    [-1,1]
00122                                         //   (Default: (0,0,0,1))
00123     Vector4<T>      m_v4Diffuse;        // Light Diffuse    [-1,1]
00124                                         //   (Default: (1,1,1,1)) for GL_LIGHT0
00125                                         //   (Default: (0,0,0,0)) for other
00126     Vector4<T>      m_v4Specular;       // Light Specular   [-1,1]
00127                                         //   (Default: (1,1,1,1)) for GL_LIGHT0
00128                                         //   (Default: (0,0,0,0)) for other
00129     Vector4<T>      m_v4Position;       // Light Position   (Default: (0,0,1,0))
00130     //-------------------------------------------
00131     Vector3<T>      m_v3SpotDirection;  // Light Spot Direction (Default: (0,0,-1))
00132     T       m_tSpotExponent;            // Light Spot Exponent [0,128] (Default: 0)
00133     T       m_tSpotCutoff;              // Light Spot Cutoff [0,90] & 180 (Default: 180)
00134     T       m_tConstantAttenuation;     // Light Constant Attenuation  (Default: 1)
00135     T       m_tLinearAttenuation;       // Light Linear Attenuation    (Default: 0)
00136     T       m_tQuadraticAttenuation;    // Light Quadratic Attenuation (Default: 0)
00137     //---------------------------------------------------------------
00138     // Shadow
00139     //void SetRelatedInfoForShadow ();
00140     //===============================================================
00141     //---------------------------------------------------------------
00142     // Static Data Member(s)
00143     static GLint    g_iGLMaxLights;     // GL_MAX_LIGHTS
00144     static GLuint   g_uiGLDisplayList;  // display list for light models
00145     static int      g_iTotalLights;     // Number of lights created
00146     //-------------------------------------------------------------------------
00147 };  // END CLASS OpenGLLightModel
00148 
00149 //=============================================================================
00150 END_NAMESPACE_TAPs__OpenGL
00151 //-----------------------------------------------------------------------------
00152 // Include definition if TAPs_USE_EXPORT is not defined
00153 //#if !defined( TAPs_USE_EXPORT )
00154     #include "TAPsOpenGLLightModel.cpp"
00155 //#endif
00156 //-----------------------------------------------------------------------------
00157 #endif
00158 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00159 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines