Changeset 1840 for GTP/trunk/App/Demos
- Timestamp:
- 12/01/06 19:01:08 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Geom/Demo_LodTrees
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Geom/Demo_LodTrees/Demo_LodTrees.vcproj
r1321 r1840 21 21 Optimization="0" 22 22 ImproveFloatingPointConsistency="TRUE" 23 AdditionalIncludeDirectories="..\OgreStuff\include;..\..\..\..\Lib\Geom\shared\GTGeometry\include "23 AdditionalIncludeDirectories="..\OgreStuff\include;..\..\..\..\Lib\Geom\shared\GTGeometry\include;..\OgreStuff\include\opt" 24 24 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS" 25 25 MinimalRebuild="TRUE" … … 35 35 <Tool 36 36 Name="VCLinkerTool" 37 AdditionalDependencies="OgreMain_d.lib GTGeometry_d.lib "37 AdditionalDependencies="OgreMain_d.lib GTGeometry_d.lib Plugin_OctreeSceneManager.lib" 38 38 OutputFile="$(OutDir)/Demo_LodTrees.exe" 39 39 LinkIncremental="2" 40 AdditionalLibraryDirectories="..\OgreStuff\lib;..\..\..\..\Lib\Geom\shared\GTGeometry\build\Debug\ "40 AdditionalLibraryDirectories="..\OgreStuff\lib;..\..\..\..\Lib\Geom\shared\GTGeometry\build\Debug\;..\OgreStuff\lib\opt\debug\" 41 41 GenerateDebugInformation="TRUE" 42 42 ProgramDatabaseFile="$(OutDir)/Demo_LodTrees.pdb" … … 48 48 Name="VCPostBuildEventTool" 49 49 CommandLine="xcopy /Y ..\OgreStuff\bin\Debug\*.dll build\Debug 50 xcopy /Y ..\OgreStuff\bin\Debug\*.cfg build\Debug"/> 50 xcopy /Y ..\OgreStuff\bin\Debug\*.cfg build\Debug 51 "/> 51 52 <Tool 52 53 Name="VCPreBuildEventTool"/> … … 74 75 <Tool 75 76 Name="VCCLCompilerTool" 76 AdditionalIncludeDirectories="..\OgreStuff\include;..\..\..\..\Lib\Geom\shared\GTGeometry\include "77 AdditionalIncludeDirectories="..\OgreStuff\include;..\..\..\..\Lib\Geom\shared\GTGeometry\include;..\OgreStuff\include\opt" 77 78 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" 78 79 RuntimeLibrary="4" … … 85 86 <Tool 86 87 Name="VCLinkerTool" 87 AdditionalDependencies="OgreMain.lib GTGeometry.lib "88 AdditionalDependencies="OgreMain.lib GTGeometry.lib Plugin_OctreeSceneManager.lib" 88 89 OutputFile="$(OutDir)/Demo_LodTrees.exe" 89 90 LinkIncremental="1" 90 AdditionalLibraryDirectories="..\OgreStuff\lib;..\..\..\..\Lib\Geom\shared\GTGeometry\build\Release\ "91 AdditionalLibraryDirectories="..\OgreStuff\lib;..\..\..\..\Lib\Geom\shared\GTGeometry\build\Release\;..\OgreStuff\lib\opt\debug\" 91 92 IgnoreDefaultLibraryNames="" 92 93 GenerateDebugInformation="TRUE" … … 100 101 Name="VCPostBuildEventTool" 101 102 CommandLine="xcopy /Y ..\OgreStuff\bin\Release\*.dll build\Release 102 xcopy /Y ..\OgreStuff\bin\Release\*.cfg build\Release"/> 103 xcopy /Y ..\OgreStuff\bin\Release\*.cfg build\Release 104 "/> 103 105 <Tool 104 106 Name="VCPreBuildEventTool"/> -
GTP/trunk/App/Demos/Geom/Demo_LodTrees/main.cpp
r1813 r1840 21 21 #define dist_max 800 22 22 23 #define ENABLE_TERRAIN_SHADOWS 24 #define TERRAIN_SHADOW_SIZE 2048 25 23 26 //Global variables 24 27 Geometry::GeoMeshLoader *meshloader=NULL; … … 35 38 OverlayElement* mInfo2; 36 39 OverlayElement* mHelp; 40 Ogre::Light *theLight = NULL; 41 Ogre::Viewport *shadowViewport = NULL; 42 RenderTarget *render_target = NULL; 37 43 38 44 char HelpString[]="(F1) Quit Help\n" … … 78 84 bool frameStarted(const FrameEvent& evt) 79 85 { 80 static bool firstFrame=true;81 if (firstFrame)82 {83 CalculateShadowMap();84 firstFrame=false;85 }86 87 86 // Move upto 80 units/second 88 87 Real MoveFactor = 120.0 * evt.timeSinceLastFrame; … … 133 132 lodfactor=1.0f; 134 133 135 if (fabsf(lodfactorBefore[i]-lodfactor)>0. 1f)134 if (fabsf(lodfactorBefore[i]-lodfactor)>0.05f) 136 135 { 137 136 lod_tree_types[i]->GoToLod(lodfactor); … … 216 215 return true; 217 216 } 218 219 void CalculateShadowMap(void)220 {221 }222 217 }; 223 218 … … 253 248 254 249 255 class LodTreeApplication : public ExampleApplication 250 #include "OgreTerrainSceneManager.h" 251 252 class LodTreeApplication : public ExampleApplication, public RenderTargetListener 256 253 { 257 254 protected: … … 270 267 void chooseSceneManager(void) 271 268 { 272 // Get the SceneManager, in this case a generic one273 // mSceneMgr = mRoot->getSceneManager(Ogre::ST_EXTERIOR_CLOSE);274 269 mSceneMgr = mRoot->createSceneManager("TerrainSceneManager"); 275 270 } 271 272 // render target events 273 void preRenderTargetUpdate(const RenderTargetEvent& evt) 274 { 275 if (render_target) 276 { 277 (static_cast<TerrainSceneManager*>(mSceneMgr))->getTerrainRootNode()->setVisible(false); 278 mSceneMgr->setSkyBox(false, "Examples/CloudyNoonSkyBox"); 279 mSceneMgr->setFog(FOG_EXP, Ogre::ColourValue(0.5f,0.5f,0.5f), 1000 ); 280 mInfo2->hide(); 281 } 282 } 283 void postRenderTargetUpdate(const RenderTargetEvent& evt) 284 { 285 if (render_target) 286 { 287 (static_cast<TerrainSceneManager*>(mSceneMgr))->getTerrainRootNode()->setVisible(true); 288 mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox"); 289 mSceneMgr->setFog( FOG_EXP, Ogre::ColourValue(0.4f,0.5f,0.6f), 0.001 ); 290 mInfo2->show(); 291 // render_target->removeAllListeners(); 292 // render_target->removeAllViewports(); 293 render_target->setAutoUpdated(false); 294 } 295 } 276 296 277 297 … … 285 305 theCam->setNearClipDistance(0.1f); 286 306 287 mSceneMgr->setFog( FOG_EXP, Ogre::ColourValue(0.4f,0.5f,0.6f), 0.001 );307 // mSceneMgr->setFog( FOG_EXP, Ogre::ColourValue(0.4f,0.5f,0.6f), 0.001 ); 288 308 289 309 // Create a directional light 290 Light* l= mSceneMgr->createLight("MainLight");291 l->setType(Light::LT_DIRECTIONAL);292 l->setDirection(0.1,-1.0,-0.2);310 theLight = mSceneMgr->createLight("MainLight"); 311 theLight->setType(Light::LT_DIRECTIONAL); 312 theLight->setDirection(0.1,-1.0,-0.2); 293 313 294 314 // terrain 295 315 mSceneMgr->setWorldGeometry( "terrain.cfg" ); 296 297 316 298 317 mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox"); 299 318 … … 343 362 mInfo->setCaption("\nMaintain F2 to disable LOD"); 344 363 364 #ifdef ENABLE_TERRAIN_SHADOWS 365 345 366 // create the shadow texture 346 367 TexturePtr shadow_map = Ogre::TextureManager::getSingleton().createManual("TheShadowMap", 347 368 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,TEX_TYPE_2D, 348 256,256,0,PF_R8G8B8,TU_STATIC_WRITE_ONLY|TU_RENDERTARGET); 349 350 /* // en vez de crear la textura aqui se puee intentar cargar de fichero una y modificarla 369 TERRAIN_SHADOW_SIZE,TERRAIN_SHADOW_SIZE,0,PF_R8G8B8,TU_RENDERTARGET); 370 351 371 HardwarePixelBufferSharedPtr shadowBuffer = shadow_map->getBuffer(); 352 RenderTarget *render_target = shadowBuffer->getRenderTarget();*/ 353 354 HardwarePixelBufferSharedPtr shadowBuffer = shadow_map->getBuffer(); 355 RenderTarget *render_target = shadowBuffer->getRenderTarget(); 356 357 358 // RenderTarget *rttTex = shadow_map->getBuffer()->getRenderTarget(); 359 // mSceneMgr->createCamera("lightCam"); 360 361 362 372 render_target = shadowBuffer->getRenderTarget(); 373 374 Ogre::Camera *lightCam = mSceneMgr->createCamera("lightCam"); 375 lightCam->setProjectionType(Ogre::PT_ORTHOGRAPHIC); 376 lightCam->setAspectRatio(1.0); 377 lightCam->setFOVy(Degree(164)); 378 lightCam->rotate(Vector3(1,0,0),Degree(-90)); 379 lightCam->move(BS_center+Ogre::Vector3(-50,400,78)); 380 381 shadowViewport = render_target->addViewport(lightCam); 382 shadowViewport->setClearEveryFrame(true); 383 shadowViewport->setBackgroundColour(ColourValue::White); 384 385 render_target->addListener(this); 386 387 MaterialPtr terrainMat = MaterialManager::getSingleton().getByName("Demos/TerrainMixed"); 388 Ogre::Pass *thePass = terrainMat->getTechnique(0)->createPass(); 389 thePass->setSceneBlending(Ogre::SBT_MODULATE); 390 Ogre::TextureUnitState *texState = thePass->createTextureUnitState(); 391 texState->setTextureName("TheShadowMap"); 392 thePass->_load(); 393 394 terrainMat->compile(); 395 terrainMat->load(); 396 397 #endif 363 398 } 364 399
Note: See TracChangeset
for help on using the changeset viewer.