HyperspaceExplorer 0.7.1
Light.h
00001 /*
00002 Hyperspace Explorer - visualizing higher-dimensional geometry
00003 Copyright (C) 2010  Lene Preuss <lene.preuss@gmail.com>
00004 
00005 This program is free software; you can redistribute it and/or modify
00006 it under the terms of the GNU General Public License as published by
00007 the Free Software Foundation; either version 2 of the License, or
00008 (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License along
00016 with this program; if not, write to the Free Software Foundation, Inc.,
00017 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018 
00019 */
00020 
00021 #ifndef LIGHT_H
00022 #define LIGHT_H
00023 
00024 #include "Vector.h"
00025 #include "Color.h"
00026 
00028 
00034 class LightSource {
00035     public:
00037         LightSource():
00038             _position(0.,0.,0.,0.),
00039             _ambient(0.,0.,0.,0.),
00040             _diffuse(0.,0.,0.,0.),
00041             _specular(0.,0.,0.,0.) { }
00042 
00044 
00049         LightSource(const VecMath::Vector<4> &pos,
00050                     const Color &a, const Color &d, const Color &s):
00051             _position(pos), _ambient(a), _diffuse(d), _specular(s) { }
00052 
00054         virtual ~LightSource() { }
00055 
00057         virtual const VecMath::Vector<4> &getPosition() const { return _position; }
00059         virtual void setPosition(const VecMath::Vector<4> &pos) { _position = pos; }
00060 
00062         virtual const Color &getAmbient() const { return _ambient; }
00064         virtual void setAmbient(const Color &col) { _ambient = col; }
00065 
00067         virtual const Color &getDiffuse() const { return _diffuse; }
00069         virtual void setDiffuse(const Color &col) { _diffuse = col; }
00070 
00072         virtual const Color &getSpecular() const { return _specular; }
00074         virtual void setSpecular(const Color &col) { _specular = col; }
00075 
00076     private:
00078         VecMath::Vector<4> _position;
00079         Color _ambient;     
00080         Color _diffuse;     
00081         Color _specular;    
00082 };
00083 
00085 
00091 class Light {
00092     public:
00093 
00095         Light(const LightSource &s): _lightSource(s) { }
00096 
00098 
00103         Light(const VecMath::Vector<4> &pos,
00104               const Color &a, const Color &d, const Color &s):
00105             _lightSource(pos, a, d, s) { }
00106 
00108 
00111         virtual void render() const = 0;
00112 
00113     protected:
00114 
00116         virtual const VecMath::Vector<4> &getPosition() const {
00117             return _lightSource.getPosition();
00118         }
00120         virtual const Color &getAmbient() const {
00121             return _lightSource.getAmbient();
00122         }
00124         virtual const Color &getDiffuse() const {
00125             return _lightSource.getDiffuse();
00126         }
00128         virtual const Color &getSpecular() const {
00129             return _lightSource.getSpecular();
00130         }
00131 
00132     private:
00134         LightSource _lightSource;
00135 };
00136 
00138 class LightOpenGL: public Light {
00139     public:
00141         LightOpenGL(const LightSource &s): Light(s) { }
00142 
00144         virtual void render() const;
00145 };
00146 
00147 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends

Generated on Mon Apr 9 2012 20:25:14 for HyperspaceExplorer 0.7.1 by doxygen 1.7.4  -  Hosted bySourceForge.net Logo