Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

CLightSource.h

Go to the documentation of this file.
00001 /*
00002  * CLightSource.h
00003  * $Id: CLightSource.h,v 1.7 2001/10/03 08:15:22 meissner Exp $
00004  *
00005  * Copyright (C) 1999, 2000 Michael Meissner, Michael Guthe
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * This program 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
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  */
00022 
00023 //  Description : Definition of the CLightSource class 
00024 //  Purpose     : Managment of class providing the interface to a linked
00025 //                list of objects.
00026 
00027 
00028 #ifndef __CLIGHTSOURCE_H
00029 #define __CLIGHTSOURCE_H
00030 
00031 
00032 // Own
00034 #include "CV3D.h"
00035 #include "CP3D.h"
00036 #include "GeoGeneric.h"
00037 
00038 
00039 // defines
00041 
00042 
00048 class CLightSource
00049 /*************************/
00050 {
00051   public:
00052       enum LightStatus {
00053          ON,
00054          OFF
00055       };
00056 
00057       enum LightSourceType {
00058          DIRECTIONAL,
00059          POINT,
00060          CONE,
00061          CONE_DIFFUSE
00062       };
00063 
00064     //constructors
00065 
00070       CLightSource() 
00071         : m_LightSourceType(POINT),
00072           m_LightStatus(ON),
00073           m_rfIntensity(1.0),
00074           m_rfAngle(360.0),
00075           m_rfExponent(1.0),
00076           m_rfConstantAttenuation(1.0),
00077           m_rfLinearAttenuation(0.0),
00078           m_rfQuadraticAttenuation(0.0)
00079 
00080       {
00081          setColor(1.0, 1.0, 1.0);
00082       };
00083 
00085       CLightSource(const CLightSource &);
00086 
00088       CLightSource(LightSourceType nType);
00089 
00091       CLightSource(const CV3D &direction, float rfIntensity=1.0);
00092 
00094       CLightSource(const CP3D &point, float rfIntensity=1.0);
00095 
00097       CLightSource(const CP3D &point, const CV3D &direction, 
00098                    float rfAngle, float rfIntensity=1.0);
00099 
00101       CLightSource(const CP3D &point, const CV3D &direction, float rfAngle, 
00102                    float rfExponent=50.0, float rfIntensity=1.0);
00103 
00104      // the default copy constructor should be ok, also the = operator
00105 
00106     //destructors
00107       virtual ~CLightSource() { ;};
00108 
00109   
00110     //methods
00112       LightSourceType getType() const { return m_LightSourceType; };
00113 
00115       LightStatus getStatus() const { return m_LightStatus; };
00116 
00118       const float* getColor() const { return m_arfColor; };
00119 
00121       const CP3D &getPosition() const { return m_Point; };
00122 
00124       CV3D getDirection(const CP3D &point) const;
00125 
00127       const CV3D &getDirection() const { return m_Direction; };
00128 
00130       CV3D getDirectionToLight() const { return -1 * m_Direction; };
00131 
00133       float getIntensity() const { return m_rfIntensity; };
00134 
00136       float getIntensity(const CP3D &point) const;
00137 
00141       float getExponent() const { return m_rfExponent; };
00142 
00144       float getAngle() const { return m_rfAngle; };
00145 
00147       float getConstantAttenuation() const { return m_rfConstantAttenuation; };
00148 
00150       float getLinearAttenuation() const { return m_rfLinearAttenuation; };
00151 
00153       float getQuadraticAttenuation() const { return m_rfQuadraticAttenuation; };
00154 
00156       void setType(LightSourceType nType) { m_LightSourceType = nType; };
00157 
00159       int setStatus(LightStatus status) { m_LightStatus = status; return 1; };
00160 
00162       int setPosition(const CP3D &point);
00163 
00165       int setDirection(const CV3D &direction);
00166 
00168       int setAngle(float rfAngle);
00169 
00173       int setExponent(float rfExponent);
00174 
00176       int setIntensity(float rfIntensity);
00177 
00179       void setColor(float rfRed, float rfGreen, float rfBlue);
00180 
00182       void setConstantAttenuation(float rfValue) { m_rfConstantAttenuation = rfValue; };
00183 
00185       void setLinearAttenuation(float rfValue) { m_rfLinearAttenuation = rfValue; };
00186 
00188       void setQuadraticAttenuation(float rfValue) { m_rfQuadraticAttenuation = rfValue; };
00189 
00190   protected:
00191     //methods
00192 
00193   private:
00194     //data
00195       LightSourceType m_LightSourceType;
00196       LightStatus     m_LightStatus;
00197 
00198       CP3D m_Point;
00199       CV3D m_Direction;
00200 
00201       float m_arfColor[3];
00202       float m_rfIntensity;
00203       float m_rfAngle;
00204       float m_rfExponent;
00205       float m_rfConstantAttenuation;
00206       float m_rfLinearAttenuation;
00207       float m_rfQuadraticAttenuation;
00208 };
00209 #endif

Generated at Thu Oct 4 17:17:25 2001 for QGLViewer by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001