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

Light.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Lamp : Open source game middleware
00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library 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 GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //------------------------------------------------------------------------------
00019 
00020 /** @file
00021  * ライトヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef LIGHT_H_
00026 #define LIGHT_H_
00027 
00028 #include <Graphics/SceneNode/SceneLeaf.h>
00029 
00030 namespace Lamp{
00031 
00032 class GlobalLight;
00033 class LocalLight;
00034 class AmbientLight;
00035 class DirectionalLight;
00036 class PointLight;
00037 
00038 //------------------------------------------------------------------------------
00039 /**
00040  * ライト
00041  */
00042 class Light : public SceneLeaf{
00043 friend class SceneObjectManagerTemplate<Light>;
00044 friend class LightManager;
00045 public:
00046     //--------------------------------------------------------------------------
00047     /**
00048      * コピー
00049      * @return コピーされたライト
00050      */
00051     virtual Light* copyLight() const = 0;
00052 
00053     /**
00054      * 破棄
00055      * @param light 破棄するライト
00056      * @return 破棄したオブジェクト数
00057      */
00058     static int destroy(Light* light);
00059 
00060     //--------------------------------------------------------------------------
00061     /**
00062      * ライト色の設定
00063      * @param color ライト色
00064      */
00065     virtual void setColor(const Color3f& color) = 0;
00066 
00067     /**
00068      * ライト色の取得
00069      * @return ライト色
00070      */
00071     virtual Color3f getColor() const = 0;
00072 
00073     //--------------------------------------------------------------------------
00074     /**
00075      * 輝度の取得
00076      * @return 輝度
00077      */
00078     virtual float getLuminance() const{ return getColor().getLuminance(); }
00079 
00080     //--------------------------------------------------------------------------
00081     /**
00082      * ライトマスクの設定
00083      * @param lightMask ライトマスク
00084      */
00085     virtual void setLightMask(u_int lightMask){ lightMask_ = lightMask; }
00086 
00087     /**
00088      * ライトマスクの取得
00089      * @return ライトマスク
00090      */
00091     virtual u_int getLightMask() const{ return lightMask_; }
00092 
00093     //--------------------------------------------------------------------------
00094     // RTTI
00095     //--------------------------------------------------------------------------
00096     /**
00097      * ライトかどうか
00098      * @return ライトならtrue
00099      */
00100     virtual bool isLight() const{ return true; }
00101 
00102     //--------------------------------------------------------------------------
00103     /**
00104      * グローバルライトかどうか
00105      * @return グローバルライトならtrue
00106      */
00107     virtual bool isGlobalLight() const{ return false; }
00108 
00109     /**
00110      * グローバルライトへのキャスト
00111      * @return グローバルライト。型が違えばNULLを返す。
00112      */
00113     virtual GlobalLight* castGlobalLight() const{
00114         if(isGlobalLight()){ return (GlobalLight*)this; }
00115         return NULL;
00116     }
00117 
00118     //--------------------------------------------------------------------------
00119     /**
00120      * ローカルライトかどうか
00121      * @return ローカルライトならtrue
00122      */
00123     virtual bool isLocalLight() const{ return false; }
00124 
00125     /**
00126      * ローカルライトへのキャスト
00127      * @return ローカルライト。型が違えばNULLを返す。
00128      */
00129     virtual LocalLight* castLocalLight() const{
00130         if(isLocalLight()){ return (LocalLight*)this; }
00131         return NULL;
00132     }
00133 
00134     //--------------------------------------------------------------------------
00135     /**
00136      * アンビエントライトかどうか
00137      * @return アンビエントライトならtrue
00138      */
00139     virtual bool isAmbientLight() const{ return false; }
00140 
00141     /**
00142      * アンビエントライトへのキャスト
00143      * @return アンビエントライト。型が違えばNULLを返す。
00144      */
00145     virtual AmbientLight* castAmbientLight() const{
00146         if(isAmbientLight()){ return (AmbientLight*)this; }
00147         return NULL;
00148     }
00149 
00150     //--------------------------------------------------------------------------
00151     /**
00152      * ディレクショナルライトかどうか
00153      * @return ディレクショナルライトならtrue
00154      */
00155     virtual bool isDirectionalLight() const{ return false; }
00156 
00157     /**
00158      * ディレクショナルライトへのキャスト
00159      * @return ディレクショナルライト。型が違えばNULLを返す。
00160      */
00161     virtual DirectionalLight* castDirectionalLight() const{
00162         if(isDirectionalLight()){ return (DirectionalLight*)this; }
00163         return NULL;
00164     }
00165 
00166     //--------------------------------------------------------------------------
00167     /**
00168      * ポイントライトかどうか
00169      * @return ポイントライトならtrue
00170      */
00171     virtual bool isPointLight() const{ return false; }
00172 
00173     /**
00174      * ポイントライトへのキャスト
00175      * @return ポイントライト。型が違えばNULLを返す。
00176      */
00177     virtual PointLight* castPointLight() const{
00178         if(isPointLight()){ return (PointLight*)this; }
00179         return NULL;
00180     }
00181 
00182     //--------------------------------------------------------------------------
00183 protected:
00184     /**
00185      * コンストラクタ
00186      * @param name 名前
00187      * @param scene シーン
00188      */
00189     Light(const String& name, Scene* scene);
00190 
00191     /**
00192      * デストラクタ
00193      */
00194     virtual ~Light();
00195 
00196     /**
00197      * ライトの値コピー
00198      * @param destination コピー先ライト
00199      */
00200     virtual void copyLightValue(Light* destination) const;
00201 
00202     //--------------------------------------------------------------------------
00203 private:
00204     // ライトマスク
00205     u_int lightMask_;
00206 
00207 };
00208 
00209 //------------------------------------------------------------------------------
00210 } // End of namespace Lamp
00211 #endif // End of LIGHT_H_
00212 //------------------------------------------------------------------------------
00213 

Generated on Wed Mar 16 10:29:31 2005 for Lamp by doxygen 1.3.2