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

PointLight.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 POINT_LIHGT_H_
00026 #define POINT_LIHGT_H_
00027 
00028 #include <Graphics/Light/LocalLight.h>
00029 
00030 namespace Lamp{
00031 
00032 //------------------------------------------------------------------------------
00033 /**
00034  * ポイントライト
00035  */
00036 class PointLight : public LocalLight{
00037 friend class LightManager;
00038 public:
00039     //--------------------------------------------------------------------------
00040     /**
00041      * コピー
00042      * @param copyMask コピーマスク
00043      * @return コピーされたシーンリーフ
00044      */
00045     virtual SceneLeaf* copy(u_int copyMask = 0) const{
00046         return copyPointLight();
00047     }
00048 
00049     /**
00050      * コピー
00051      * @return コピーされたライト
00052      */
00053     virtual Light* copyLight() const{ return copyPointLight(); }
00054 
00055     /**
00056      * ポイントライトのコピー
00057      * @return コピーされたモデル
00058      */
00059     virtual PointLight* copyPointLight() const;
00060 
00061     //--------------------------------------------------------------------------
00062     /**
00063      * ライト色の設定
00064      * @param color ライト色
00065      */
00066     virtual void setColor(const Color3f& color){
00067         diffuseColor_ = specularColor_ = color;
00068     }
00069 
00070     /**
00071      * ライト色の取得
00072      * @return ライト色
00073      */
00074     virtual Color3f getColor() const{
00075         Color3f result(Math::maximum(diffuseColor_.r, specularColor_.r),
00076             Math::maximum(diffuseColor_.g, specularColor_.g),
00077             Math::maximum(diffuseColor_.b, specularColor_.b));
00078         return result;
00079     }
00080 
00081     //--------------------------------------------------------------------------
00082     /**
00083      * ディフューズライト色の設定
00084      * @param color ディフューズライト色
00085      */
00086     virtual void setDiffuseColor(const Color3f& color){ diffuseColor_ = color; }
00087 
00088     /**
00089      * ディフューズライト色の取得
00090      * @return ディフューズライト色
00091      */
00092     virtual const Color3f& getDiffuseColor() const{ return diffuseColor_; }
00093 
00094     //--------------------------------------------------------------------------
00095     /**
00096      * スペキュラライト色の設定
00097      * @param color スペキュラライト色
00098      */
00099     virtual void setSpecularColor(const Color3f& color){
00100         specularColor_ = color;
00101     }
00102 
00103     /**
00104      * スペキュラライト色の取得
00105      * @return スペキュラライト色
00106      */
00107     virtual const Color3f& getSpecularColor() const{ return specularColor_; }
00108 
00109     //--------------------------------------------------------------------------
00110     /**
00111      * ライトの位置設定
00112      * @param position ライトの位置
00113      */
00114     virtual void setPosition(const Vector3& position){ position_ = position; }
00115 
00116     /**
00117      * ライトのワールド位置取得
00118      * @return ライトのワールド位置
00119      */
00120     virtual const Vector3& getPosition() const{ return position_; }
00121 
00122     /**
00123      * ライトのワールド位置取得
00124      * @return ライトのワールド位置
00125      */
00126     virtual const Vector3& getWorldPosition() const{
00127         Assert(getParent() != NULL);
00128         return worldPosition_;
00129     }
00130 
00131     //--------------------------------------------------------------------------
00132     /**
00133      * レンジの設定
00134      * @param range レンジ
00135      */
00136     virtual void setRange(float range){ range_ = range; }
00137 
00138     /**
00139      * レンジの取得
00140      * @return レンジ
00141      */
00142     virtual float getRange() const{ return range_; }
00143 
00144     /**
00145      * グローバルレンジの取得
00146      * @return グローバルレンジ
00147      */
00148     virtual float getGlobalRange() const{ return globalRange_; }
00149 
00150     //--------------------------------------------------------------------------
00151     /**
00152      * 減衰係数の設定
00153      * @param attenuation0 減衰係数0
00154      * @param attenuation1 減衰係数1
00155      * @param attenuation2 減衰係数2
00156      */
00157     virtual void setAttenuation(
00158         float attenuation0, float attenuation1, float attenuation2){
00159         attenuation0_ = attenuation0;
00160         attenuation1_ = attenuation1;
00161         attenuation2_ = attenuation2;
00162     }
00163 
00164     //--------------------------------------------------------------------------
00165     /**
00166      * 減衰係数0の設定
00167      * @param attenuation0 減衰係数0
00168      */
00169     virtual void setAttenuation0(float attenuation0){
00170         attenuation0_ = attenuation0;
00171     }
00172 
00173     /**
00174      * 減衰係数0の取得
00175      * @return 減衰係数0
00176      */
00177     virtual float getAttenuation0() const{ return attenuation0_; }
00178 
00179     //--------------------------------------------------------------------------
00180     /**
00181      * 減衰係数1の設定
00182      * @param attenuation1 減衰係数1
00183      */
00184     virtual void setAttenuation1(float attenuation1){
00185         attenuation1_ = attenuation1;
00186     }
00187 
00188     /**
00189      * 減衰係数1の取得
00190      * @return 減衰係数1
00191      */
00192     virtual float getAttenuation1() const{ return attenuation1_; }
00193 
00194     //--------------------------------------------------------------------------
00195     /**
00196      * 減衰係数2の設定
00197      * @param attenuation2 減衰係数2
00198      */
00199     virtual void setAttenuation2(float attenuation2){
00200         attenuation2_ = attenuation2;
00201     }
00202 
00203     /**
00204      * 減衰係数2の取得
00205      * @return 減衰係数2
00206      */
00207     virtual float getAttenuation2() const{ return attenuation2_; }
00208 
00209     //--------------------------------------------------------------------------
00210     /**
00211      * カメラとの距離の2乗の設定
00212      * @param squaredCameraDistance カメラとの距離の2乗
00213      */
00214     virtual void setSquaredCameraDistance(float squaredCameraDistance){
00215         squaredCameraDistance_ = squaredCameraDistance;
00216     }
00217 
00218     /**
00219      * カメラとの距離の2乗の取得
00220      * @return カメラとの距離の2乗
00221      */
00222     virtual float getSquaredCameraDistance() const{
00223         return squaredCameraDistance_;
00224     }
00225 
00226     //--------------------------------------------------------------------------
00227     /**
00228      * ポイントライトかどうか
00229      * @return ポイントライトならtrue
00230      */
00231     virtual bool isPointLight() const{ return true; }
00232 
00233 protected:
00234     //--------------------------------------------------------------------------
00235     /**
00236      * コンストラクタ
00237      * @param name 名前
00238      * @param scene シーン
00239      */
00240     PointLight(const String& name, Scene* scene);
00241 
00242     /**
00243      * デストラクタ
00244      */
00245     virtual ~PointLight();
00246 
00247     //--------------------------------------------------------------------------
00248     /**
00249      * 走査
00250      * @param parentMatrix 親行列
00251      * @param parentEnabled 親が有効か
00252      * @param parentScaled 親がスケールを使用しているか
00253      * @param parentChanged 親に変更があったか
00254      */
00255     virtual void traverse(const Matrix34& parentMatrix, bool parentEnabled,
00256         bool parentScaled, bool parentChanged);
00257 
00258     //--------------------------------------------------------------------------
00259 private:
00260     // ディフューズカラー
00261     Color3f diffuseColor_;
00262     // スペキュラカラー
00263     Color3f specularColor_;
00264     // 位置
00265     Vector3 position_;
00266     // ワールド位置
00267     Vector3 worldPosition_;
00268     // レンジ
00269     float range_;
00270     // グローバルレンジ
00271     float globalRange_;
00272     // 減衰係数0
00273     float attenuation0_;
00274     // 減衰係数1
00275     float attenuation1_;
00276     // 減衰係数2
00277     float attenuation2_;
00278     // カメラとの距離の2乗
00279     float squaredCameraDistance_;
00280 
00281 };
00282 
00283 //------------------------------------------------------------------------------
00284 } // End of namespace Lamp
00285 #endif // End of POINT_LIHGT_H_
00286 //------------------------------------------------------------------------------
00287 

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