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

DrawRequest.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 DRAW_REQUEST_H_
00026 #define DRAW_REQUEST_H_
00027 
00028 #include <Core/Container/ArrayList.h>
00029 
00030 namespace Lamp{
00031 
00032 class Fog;
00033 class Camera;
00034 class SceneNode;
00035 class Model;
00036 class Mesh;
00037 class MeshData;
00038 class Material;
00039 class LocalLight;
00040 class AmbientLight;
00041 class DirectionalLight;
00042 
00043 //------------------------------------------------------------------------------
00044 /**
00045  * 描画リクエスト
00046  */
00047 class DrawRequest{
00048 friend class Renderer;
00049 public:
00050     //--------------------------------------------------------------------------
00051     // メッシュ情報
00052     //--------------------------------------------------------------------------
00053     /**
00054      * メッシュの取得
00055      * @return メッシュ
00056      */
00057     virtual Mesh* getMesh() const{ return mesh_; }
00058 
00059     /**
00060      * メッシュに変更があったか
00061      * @return メッシュに変更があればtrue
00062      */
00063     virtual bool isMeshChanged() const{ return (mesh_ != preMesh_); }
00064 
00065     /**
00066      * シーンノードの取得
00067      * @return シーンノード
00068      */
00069     virtual SceneNode* getSceneNode() const{ return sceneNode_; }
00070 
00071     /**
00072      * シーンノードに変更があったか
00073      * @return シーンノードに変更があればtrue
00074      */
00075     virtual bool isSceneNodeChanged() const{
00076         return (sceneNode_ != preSceneNode_);
00077     }
00078 
00079     /**
00080      * モデルの取得
00081      * @return モデル
00082      */
00083     virtual Model* getModel() const{ return model_; }
00084 
00085     /**
00086      * モデルに変更があったか
00087      * @return モデルに変更があればtrue
00088      */
00089     virtual bool isModelChanged() const{ return (model_ != preModel_); }
00090 
00091     /**
00092      * メッシュデータの取得
00093      * @return メッシュデータ
00094      */
00095     virtual MeshData* getMeshData() const{ return meshData_; }
00096 
00097     /**
00098      * メッシュデータに変更があったか
00099      * @return メッシュデータに変更があればtrue
00100      */
00101     virtual bool isMeshDataChanged() const{
00102         return (meshData_ != preMeshData_);
00103     }
00104 
00105     /**
00106      * マテリアルの取得
00107      * @return マテリアル
00108      */
00109     virtual Material* getMaterial() const{ return material_; }
00110 
00111     /**
00112      * 前のマテリアルの取得
00113      * @return 前のマテリアル
00114      */
00115     virtual Material* getPreMaterial() const{ return preMaterial_; }
00116 
00117     /**
00118      * マテリアルに変更があったか
00119      * @return マテリアルに変更があればtrue
00120      */
00121     virtual bool isMaterialChanged() const{
00122         return (material_ != preMaterial_);
00123     }
00124 
00125     /**
00126      * 正規化を必要とするか
00127      * @return 正規化を必要とするならtrue
00128      */
00129     virtual bool requireNormalize() const;
00130 
00131     /**
00132      * パイプラインモードに変更があったか
00133      * @return パイプラインモードに変更があればtrue
00134      */
00135     virtual bool isPipelineModeChanged() const;
00136 
00137     //--------------------------------------------------------------------------
00138     // フォグ
00139     //--------------------------------------------------------------------------
00140     /**
00141      * フォグの取得
00142      * @return フォグ
00143      */
00144     virtual Fog* getFog() const{ return fog_; }
00145 
00146     //--------------------------------------------------------------------------
00147     // カメラ
00148     //--------------------------------------------------------------------------
00149     /**
00150      * カメラの取得
00151      * @return カメラ
00152      */
00153     virtual Camera* getCamera() const{ return camera_; }
00154 
00155     //--------------------------------------------------------------------------
00156     // アンビエントライト
00157     //--------------------------------------------------------------------------
00158     /**
00159      * アンビエントライト数の取得
00160      * @return アンビエントライト数
00161      */
00162     virtual int getAmbientLightCount() const{
00163         return ambientLights_.getCount();
00164     }
00165 
00166     /**
00167      * アンビエントライトの取得
00168      */
00169     virtual AmbientLight* getAmbientLight(int index) const{
00170         return ambientLights_.get(index);
00171     }
00172 
00173     /**
00174      * アンビエント色の取得
00175      * @return アンビエント色
00176      */
00177     Color3f getAmbientColor() const;
00178 
00179     //--------------------------------------------------------------------------
00180     // ディレクショナルライト
00181     //--------------------------------------------------------------------------
00182     /**
00183      * ディレクショナルライト数の取得
00184      * @return ディレクショナルライト数
00185      */
00186     virtual int getDirectionalLightCount() const{
00187         return directionalLights_.getCount();
00188     }
00189 
00190     /**
00191      * ディレクショナルライトの取得
00192      */
00193     virtual DirectionalLight* getDirectionalLight(int index) const{
00194         return directionalLights_.get(index);
00195     }
00196 
00197     //--------------------------------------------------------------------------
00198     // ローカルライト
00199     //--------------------------------------------------------------------------
00200     /**
00201      * ローカルライトの追加
00202      * @param localLight 追加するライト
00203      */
00204     virtual void addLocalLight(LocalLight* localLight);
00205 
00206     /**
00207      * ローカルライトのクリア
00208      */
00209     virtual void clearLocalLights(){ localLights_.clear(); }
00210 
00211     /**
00212      * ローカルライト数の取得
00213      * @return ローカルライト数
00214      */
00215     virtual int getLocalLightCount() const{ return localLights_.getCount(); }
00216 
00217     /**
00218      * ローカルライトの取得
00219      */
00220     virtual LocalLight* getLocalLight(int index) const{
00221         return localLights_.get(index);
00222     }
00223 
00224     /**
00225      * ローカルライトのソート
00226      */
00227     virtual void sortLocalLights(){
00228         localLights_.sort(sortLocalLightsCallback);
00229     }
00230 
00231     //--------------------------------------------------------------------------
00232     /**
00233      * ローカルライトのソート用コールバック
00234      * @param left 左辺値
00235      * @param right 右辺値
00236      * @return 左辺値が右辺値より大きいときは1以上
00237      */
00238     static int sortLocalLightsCallback(
00239         LocalLight* const* left, LocalLight* const* right);
00240 
00241 protected:
00242     //--------------------------------------------------------------------------
00243     // レンダラから使用されるインターフェース
00244     //--------------------------------------------------------------------------
00245     /**
00246      * コンストラクタ
00247      */
00248     DrawRequest();
00249 
00250     /**
00251      * デストラクタ
00252      */
00253     virtual ~DrawRequest();
00254 
00255     //--------------------------------------------------------------------------
00256     /**
00257      * クリア
00258      */
00259     virtual void clear();
00260 
00261     //--------------------------------------------------------------------------
00262     /**
00263      * ブレンドが有効になった
00264      * @return ブレンドが有効になったのならtrue
00265      */
00266     virtual bool isBlendEnabled() const;
00267 
00268     //--------------------------------------------------------------------------
00269     /**
00270      * メッシュの設定
00271      * @param mesh メッシュ
00272      */
00273     virtual void setMesh(Mesh* mesh);
00274 
00275     //--------------------------------------------------------------------------
00276     /**
00277      * フォグの設定
00278      * @param fog フォグ
00279      */
00280     virtual void setFog(Fog* fog){ fog_ = fog; }
00281 
00282     //--------------------------------------------------------------------------
00283     /**
00284      * カメラの設定
00285      * @param camera カメラ
00286      */
00287     virtual void setCamera(Camera* camera){ camera_ = camera; }
00288 
00289     //--------------------------------------------------------------------------
00290     /**
00291      * アンビエントライトの追加
00292      * @param ambientLight 追加するライト
00293      */
00294     virtual void addAmbientLight(AmbientLight* ambientLight);
00295 
00296     /**
00297      * ディレクショナルライトの追加
00298      * @param directionalLight 追加するライト
00299      */
00300     virtual void addDirectionalLight(DirectionalLight* directionalLight);
00301 
00302     //--------------------------------------------------------------------------
00303     /**
00304      * ローカルライトのソート実装
00305      */
00306     virtual int sortLocalLightsImprement(LocalLight* left, LocalLight* right);
00307 
00308 private:
00309     //--------------------------------------------------------------------------
00310     // コピーコンストラクタの隠蔽
00311     DrawRequest(const DrawRequest& copy);
00312 
00313     // 代入コピーの隠蔽
00314     void operator =(const DrawRequest& copy);
00315 
00316     // インスタンス
00317     static DrawRequest* instance_;
00318     // アンビエントライト
00319     ArrayList<AmbientLight*> ambientLights_;
00320     // ディレクショナルライト
00321     ArrayList<DirectionalLight*> directionalLights_;
00322     // ローカルライト
00323     ArrayList<LocalLight*> localLights_;
00324     // フォグ
00325     Fog* fog_;
00326     // カメラ
00327     Camera* camera_;
00328     // メッシュ
00329     Mesh* mesh_;
00330     // シーンノード
00331     SceneNode* sceneNode_;
00332     // モデル
00333     Model* model_;
00334     // メッシュデータ
00335     MeshData* meshData_;
00336     // マテリアル
00337     Material* material_;
00338     // 前のメッシュ
00339     Mesh* preMesh_;
00340     // 前のシーンノード
00341     SceneNode* preSceneNode_;
00342     // 前のモデル
00343     Model* preModel_;
00344     // 前のメッシュデータ
00345     MeshData* preMeshData_;
00346     // 前のマテリアル
00347     Material* preMaterial_;
00348 
00349 };
00350 
00351 //------------------------------------------------------------------------------
00352 } // End of namespace Lamp
00353 #endif // End of DRAW_REQUEST_H_
00354 //------------------------------------------------------------------------------

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