Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sglLight.hpp

00001 /*****************************************************************************
00002  * SGL: A Scene Graph Library
00003  *
00004  * Copyright (C) 1997-2001  Scott McMillan   All Rights Reserved.
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the Free
00018  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *****************************************************************************
00020  *     File: sglLight.hpp
00021  *   Author: Scott McMillan
00022  *  Created: 28 November 2000
00023  *  Summary: abstract base class for all types of SGL lights.  Derived from
00024  *           sglNode, it is a leaf node of the scene graph, equivalent to
00025  *           sglGeode or sglText.
00026  *****************************************************************************/
00027 
00028 #ifndef __SGL_LIGHT_HPP
00029 #define __SGL_LIGHT_HPP
00030 
00031 #include <sgl.h>
00032 #include <sglNode.hpp>
00033 
00034 //----------------------------------------------------------------------------
00035 
00065 class SGL_DLL_API sglLight : public sglNode
00066 {
00067 public:
00069    sglLight();
00071    virtual ~sglLight();
00072 
00076    void setOn(bool on);  // true = on; false = off
00077 
00081    bool getOn() const { return m_on_flag; }
00082 
00086    void setAmbient(const sglVec4f &color) { m_ambient = color; }
00087 
00094    void setAmbient(float r, float g, float b, float a)
00095       { m_ambient.set(r,g,b,a); }
00096 
00100    const sglVec4f &getAmbient() const { return m_ambient; }
00101 
00105    void setDiffuse(const sglVec4f &color) { m_diffuse = color; }
00106 
00113    void setDiffuse(float r, float g, float b, float a)
00114       { m_diffuse.set(r,g,b,a); }
00115 
00119    const sglVec4f &getDiffuse() const { return m_diffuse; }
00120 
00124    void setSpecular(const sglVec4f &color) { m_specular = color; }
00125 
00132    void setSpecular(float r, float g, float b, float a)
00133       { m_specular.set(r,g,b,a); }
00134 
00138    const sglVec4f &getSpecular() const { return m_specular; }
00139 
00144    virtual void setup(GLenum gl_light_number) const;
00145 
00146    // See sglObject::printInfo() for details.
00147    virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00148 
00149    // I am not sure what to do with these yet.  I can leave them here, and they
00150    // affect all scene graphs at once, or I can put them as a traversal mode
00151    // or I can leave it up to the user (external to SGL).
00152    //
00153    //static void setGlobalAmbient(const sglVec4f &color);
00154    //static const sglVec4f &getGlobalAmbient() { return s_global_ambient; }
00155    //static void enableLocal(bool on);
00156    //static bool getLocal() { return s_local_flag; }
00157    //static void enableTwoSided(bool on);
00158    //static bool getTwoSided() { return s_two_sided; }
00159 
00160 protected:
00161    virtual void cull(sglCull<float> &trav_state,
00162                      unsigned int cull_flags) const;
00163    virtual void cull(sglCull<double> &trav_state,
00164                      unsigned int cull_flags) const;
00165 
00166    void copyTo(sglLight *dst, unsigned int mode) const;
00167 
00168 private: // methods - not implemented
00169    sglLight(const sglLight &);
00170    sglLight &operator=(const sglLight &);
00171 
00172 protected: // variables
00173    bool     m_on_flag;
00174 
00175    sglVec4f m_ambient;
00176    sglVec4f m_diffuse;
00177    sglVec4f m_specular;
00178 };
00179 
00180 #endif

Generated at Mon Jul 1 18:00:05 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001