00001 //////////////////////////////////////////////////////////////////////////////// 00002 // Scorched3D (c) 2000-2009 00003 // 00004 // This file is part of Scorched3D. 00005 // 00006 // Scorched3D is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation; either version 2 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // Scorched3D is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with Scorched3D; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 //////////////////////////////////////////////////////////////////////////////// 00020 00021 #if !defined(__INCLUDE_Landscapeh_INCLUDE__) 00022 #define __INCLUDE_Landscapeh_INCLUDE__ 00023 00024 #include <image/ImageHandle.h> 00025 #include <GLEXT/GLTexture.h> 00026 #include <GLEXT/GLShadowFrameBuffer.h> 00027 00028 class Wall; 00029 class ShadowMap; 00030 class Smoke; 00031 class ProgressCounter; 00032 class Water; 00033 class LandscapePoints; 00034 class Sky; 00035 class GLSLShaderSetup; 00036 class Landscape 00037 { 00038 public: 00039 static Landscape *instance(); 00040 00041 enum LandscapeTextureType 00042 { 00043 eDefault, 00044 eOther 00045 }; 00046 00047 void generate(ProgressCounter *counter = 0); 00048 void recalculate(); 00049 void restoreLandscapeTexture(); 00050 void reset(ProgressCounter *counter = 0); 00051 00052 // Access to internal objects 00053 Smoke &getSmoke() { return *smoke_; } 00054 ShadowMap &getShadowMap(); 00055 Wall &getWall() { return *wall_; } 00056 Sky &getSky() { return *sky_; } 00057 Water &getWater() { return *water_; } 00058 LandscapePoints &getPoints() { return *points_; } 00059 00060 // Textures created during landscape texturing 00061 Image &getMainMap() { return mainMap_; } 00062 Image &getScorchMap() { return scorchMap_; } 00063 GLTexture &getMainTexture() { return texture_; } 00064 GLTexture &getMagTexture() { return magTexture_; } 00065 GLTexture &getPlanATexture() { return planAlphaTexture_; } 00066 GLTexture &getPlanTexture() { return planTexture_; } 00067 GLTexture &getLandscapeTexture1() { return landTex1_; } 00068 GLTexture &getGroundTexture() { return groundTexture_; } 00069 GLTexture &getDetailTexture() { return detailTexture_; } 00070 GLTexture &getRoofTexture() { return roofTexture_; } 00071 GLTexture &getArenaMainTexture() { return arenaMainTexture_; } 00072 00073 LandscapeTextureType getTextureType() { return textureType_; } 00074 void setTextureType(LandscapeTextureType type) { textureType_ = type; } 00075 00076 float *getShadowTextureMatrix() { return shadowTextureMatrix_; } 00077 GLShadowFrameBuffer &getShadowFrameBuffer() { return shadowFrameBuffer_; } 00078 00079 void updatePlanTexture(); 00080 void updatePlanATexture(); 00081 void drawGraphicalShadowMap(); 00082 void drawGraphicalReflectionMap(); 00083 int getPlanTexSize(); 00084 int getMapTexSize(); 00085 00086 unsigned int getChangeCount() { return changeCount_; } 00087 00088 void drawTearDown(); 00089 void drawSetup(); 00090 void drawLand(); 00091 void drawWater(); 00092 void drawObjects(); 00093 void drawShadows(); 00094 00095 void simulate(float frameTime); 00096 00097 protected: 00098 static Landscape *instance_; 00099 00100 // All objects that are used to draw the scene 00101 Wall *wall_; 00102 Sky *sky_; 00103 Smoke *smoke_; 00104 Water *water_; 00105 LandscapeTextureType textureType_; 00106 LandscapePoints *points_; 00107 00108 // Textures used for landscape 00109 GLTexture texture_; 00110 GLTexture magTexture_; 00111 GLTexture planTexture_; 00112 GLTexture planAlphaTexture_; 00113 GLTexture detailTexture_; 00114 GLTexture roofTexture_; 00115 GLTexture landTex1_; 00116 GLTexture groundTexture_; 00117 GLTexture splatMaskTexture1_; 00118 GLTexture splatMaskTexture2_; 00119 GLTexture splatMaskTextureBorder1_; 00120 GLTexture splatMaskTextureBorder2_; 00121 GLTexture splatTextures_; 00122 GLTexture arenaMainTexture_; 00123 GLTexture arenaSurroundTexture_; 00124 ImageHandle splatMap_; 00125 ImageHandle mainMap_; 00126 ImageHandle scorchMap_; 00127 ImageHandle bitmapPlanAlphaAlpha_; 00128 ImageHandle bitmapPlanAlpha_; 00129 ImageHandle bitmapPlan_; 00130 00131 // Shadow map 00132 float shadowTextureMatrix_[16]; 00133 float lightModelMatrix_[16]; 00134 float lightProjMatrix_[16]; 00135 GLShadowFrameBuffer shadowFrameBuffer_; 00136 GLSLShaderSetup *landShader_; 00137 GLTexture colorDepthMap_; 00138 00139 // Variables used to set when the water is refreshed 00140 bool resetLandscape_; 00141 float resetLandscapeTimer_; 00142 unsigned int changeCount_; 00143 00144 void savePlan(); 00145 void actualDrawLandTextured(); 00146 void actualDrawLandReflection(); 00147 void actualDrawLandShader(); 00148 void createShadowMatrix(); 00149 00150 // Nasty, we really need some kind of viewport/rendering context 00151 // that the current rendering state for the scene can be stored. 00152 // Useful for things that relate to each drawn scene rather than 00153 // global. e.g. camera window vs main window 00154 struct CameraContext 00155 { 00156 CameraContext(); 00157 00158 ShadowMap *shadowMap_; 00159 } cameraContexts_[2]; 00160 00161 private: 00162 Landscape(); 00163 virtual ~Landscape(); 00164 }; 00165 00166 00167 #endif
1.5.3