Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

CLightSource.h

Go to the documentation of this file.
00001 /*
00002  * CLightSource.h
00003  * $Id: CLightSource.h,v 1.9 2001/11/23 02:03:35 mjanich 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  * As a special exception to the GPL, the QGLViewer authors (Markus
00022  * Janich, Michael Meissner, Richard Guenther, Alexander Buck and Thomas
00023  * Woerner) give permission to link this program with Qt (non-)commercial
00024  * edition, and distribute the resulting executable, without including
00025  * the source code for the Qt (non-)commercial edition in the source
00026  * distribution.
00027  *
00028  */
00029 
00030 //  Description : Definition of the CLightSource class 
00031 //  Purpose     : Managment of class providing the interface to a linked
00032 //                list of objects.
00033 
00034 
00035 #ifndef __CLIGHTSOURCE_H
00036 #define __CLIGHTSOURCE_H
00037 
00038 
00039 // Own
00041 #include "CV3D.h"
00042 #include "CP3D.h"
00043 #include "GeoGeneric.h"
00044 
00045 
00046 // defines
00048 
00049 
00055 class CLightSource
00056 /*************************/
00057 {
00058   public:
00059       enum LightStatus {
00060          ON,
00061          OFF
00062       };
00063 
00064       enum LightSourceType {
00065          DIRECTIONAL,
00066          POINT,
00067          CONE,
00068          CONE_DIFFUSE
00069       };
00070 
00071     //constructors
00072 
00077       CLightSource() 
00078         : m_LightSourceType(POINT),
00079           m_LightStatus(ON),
00080           m_Point(CP3D(0,0,0)),
00081           m_Direction(CV3D(0,0,-1)),
00082           m_rfIntensity(1.0),
00083           m_rfAngle(180.0),
00084           m_rfExponent(0.0),
00085           m_rfConstantAttenuation(1.0),
00086           m_rfLinearAttenuation(0.0),
00087           m_rfQuadraticAttenuation(0.0)
00088 
00089       {
00090          setColor(1.0, 1.0, 1.0);
00091       };
00092 
00094       CLightSource(const CLightSource &);
00095 
00097       CLightSource(LightSourceType nType);
00098 
00100       CLightSource(const CV3D &direction, float rfIntensity=1.0);
00101 
00103       CLightSource(const CP3D &point, float rfIntensity=1.0);
00104 
00106       CLightSource(const CP3D &point, const CV3D &direction, 
00107                    float rfAngle, float rfIntensity=1.0);
00108 
00110       CLightSource(const CP3D &point, const CV3D &direction, float rfAngle, 
00111                    float rfExponent=50.0, float rfIntensity=1.0);
00112 
00113      // the default copy constructor should be ok, also the = operator
00114 
00115     //destructors
00116       virtual ~CLightSource() { ;};
00117 
00118   
00119     //methods
00121       LightSourceType getType() const { return m_LightSourceType; };
00122 
00124       LightStatus getStatus() const { return m_LightStatus; };
00125 
00127       const float* getColor() const { return m_arfColor; };
00128 
00130       const CP3D &getPosition() const { return m_Point; };
00131 
00133       CV3D getDirection(const CP3D &point) const;
00134 
00136       const CV3D &getDirection() const { return m_Direction; };
00137 
00139       CV3D getDirectionToLight() const { return -1 * m_Direction; };
00140 
00142       float getIntensity() const { return m_rfIntensity; };
00143 
00145       float getIntensity(const CP3D &point) const;
00146 
00150       float getExponent() const { return m_rfExponent; };
00151 
00153       float getAngle() const { return m_rfAngle; };
00154 
00156       float getConstantAttenuation() const { return m_rfConstantAttenuation; };
00157 
00159       float getLinearAttenuation() const { return m_rfLinearAttenuation; };
00160 
00162       float getQuadraticAttenuation() const { return m_rfQuadraticAttenuation; };
00163 
00165       void setType(LightSourceType nType) { m_LightSourceType = nType; };
00166 
00168       int setStatus(LightStatus status) { m_LightStatus = status; return 1; };
00169 
00171       int setPosition(const CP3D &point);
00172 
00174       int setDirection(const CV3D &direction);
00175 
00177       int setAngle(float rfAngle);
00178 
00182       int setExponent(float rfExponent);
00183 
00185       int setIntensity(float rfIntensity);
00186 
00188       void setColor(float rfRed, float rfGreen, float rfBlue);
00189 
00191       void setConstantAttenuation(float rfValue) { m_rfConstantAttenuation = rfValue; };
00192 
00194       void setLinearAttenuation(float rfValue) { m_rfLinearAttenuation = rfValue; };
00195 
00197       void setQuadraticAttenuation(float rfValue) { m_rfQuadraticAttenuation = rfValue; };
00198 
00199   protected:
00200     //methods
00201 
00202   private:
00203     //data
00204       LightSourceType m_LightSourceType;
00205       LightStatus     m_LightStatus;
00206 
00207       CP3D m_Point;
00208       CV3D m_Direction;
00209 
00210       float m_arfColor[3];
00211       float m_rfIntensity;
00212       float m_rfAngle;
00213       float m_rfExponent;
00214       float m_rfConstantAttenuation;
00215       float m_rfLinearAttenuation;
00216       float m_rfQuadraticAttenuation;
00217 };
00218 #endif

Generated on Mon Oct 20 09:04:48 2003 for QGLViewer by doxygen 1.3.4