Changeset 37 for trunk/VUT/OcclusionCullingSceneManager/TestCullingDotScene
- Timestamp:
- 04/01/05 17:28:57 (20 years ago)
- Location:
- trunk/VUT/OcclusionCullingSceneManager/TestCullingDotScene
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/OcclusionCullingSceneManager/TestCullingDotScene/TestCullingDotScene.vcproj
r36 r37 13 13 <Configuration 14 14 Name="Debug|Win32" 15 OutputDirectory=" Debug"16 IntermediateDirectory=" Debug"15 OutputDirectory="..\bin\$(ConfigurationName)" 16 IntermediateDirectory="..\obj\$(ConfigurationName)" 17 17 ConfigurationType="1" 18 18 CharacterSet="2"> … … 21 21 Optimization="0" 22 22 AdditionalIncludeDirectories=""$(OGRE_PATH)\Dependencies\include";"$(OGRE_PATH)\OgreMain\include";"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\Dependencies\include\CEGUI";"$(OGRE_PATH)\PlugIns\OctreeSceneManager\include";"$(OGRE_ADDONS_PATH)\dotsceneoctree\PlugIns\DotSceneManager\include";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include";../include" 23 PreprocessorDefinitions=" WIN32;_DEBUG;_WINDOWS"23 PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_DEBUG;WIN32;_STLP_DEBUG" 24 24 MinimalRebuild="TRUE" 25 25 BasicRuntimeChecks="3" 26 RuntimeLibrary=" 5"26 RuntimeLibrary="2" 27 27 UsePrecompiledHeader="0" 28 28 WarningLevel="3" … … 34 34 Name="VCLinkerTool" 35 35 AdditionalDependencies="Plugin_OctreeSceneManager.lib OGREMain_d.LIB CEGUIBase_d.lib OgreGUIRenderer_d.lib Plugin_DotSceneManager.lib" 36 OutputFile="$(O utDir)/TestCullingDotScene.exe"36 OutputFile="$(OGRE_PATH)/Samples/Common/bin/Debug/TestCullingDotScene.exe" 37 37 LinkIncremental="2" 38 38 AdditionalLibraryDirectories=""$(OGRE_PATH)\Dependencies\Lib\Debug";"$(OGRE_ADDONS_PATH)\dotsceneoctree\PlugIns\DotSceneManager\bin\debug";"$(OGRE_PATH)\OgreMain\Lib\Debug";"$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\debug";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib"" … … 133 133 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"> 134 134 </Filter> 135 <Filter 136 Name="tinyxml" 137 Filter=""> 138 <File 139 RelativePath="..\tinyxml\tinystr.cpp"> 140 </File> 141 <File 142 RelativePath="..\tinyxml\tinystr.h"> 143 </File> 144 <File 145 RelativePath="..\tinyxml\tinyxml.cpp"> 146 </File> 147 <File 148 RelativePath="..\tinyxml\tinyxml.h"> 149 </File> 150 <File 151 RelativePath="..\tinyxml\tinyxmlerror.cpp"> 152 </File> 153 <File 154 RelativePath="..\tinyxml\tinyxmlparser.cpp"> 155 </File> 156 </Filter> 135 157 </Files> 136 158 <Globals> -
trunk/VUT/OcclusionCullingSceneManager/TestCullingDotScene/TestCullingDotSceneApplication.cpp
r36 r37 14 14 15 15 #include "Ogre.h" 16 #include "TestCullingApplication.h" 16 #include "OgreLight.h" 17 #include "tinyxml.h" 18 #include "TestCullingDotSceneApplication.h" 17 19 #include "OgreOcclusionCullingSceneTraverser.h" 18 20 … … 20 22 #include "windows.h" 21 23 22 RaySceneQuery* raySceneQuery = 0;23 24 24 /***********************************************/ 25 /* TestCulling Application implementation */25 /* TestCullingDotSceneApplication implementation */ 26 26 /***********************************************/ 27 TestCullingApplication::~TestCullingApplication() 28 { 29 delete raySceneQuery; 30 } 31 32 void TestCullingApplication::parseDotScene( const String &SceneName, const String& groupName ) 27 void TestCullingDotSceneApplication::ParseDotScene( const String &SceneName, const String& groupName ) 33 28 { 34 29 TiXmlDocument *XMLDoc; … … 254 249 } 255 250 256 Light* LoadLight( TiXmlElement *XMLLight )251 Light* TestCullingDotSceneApplication::LoadLight( TiXmlElement *XMLLight ) 257 252 { 258 253 TiXmlElement *XMLDiffuse, *XMLSpecular, *XMLAttentuation, *XMLPosition; 259 254 260 255 // Create a light (point | directional | spot | radPoint) 261 Light* l = mSceneMgr->createLight( XMLLight->Attribute("name") );256 Light* light = mSceneMgr->createLight( XMLLight->Attribute("name") ); 262 257 if( !XMLLight->Attribute("type") || String(XMLLight->Attribute("type")) == "point" ) 263 l ->setType( Light::LT_POINT );258 light->setType( Light::LT_POINT ); 264 259 else if( String(XMLLight->Attribute("type")) == "directional") 265 l ->setType( Light::LT_DIRECTIONAL );260 light->setType( Light::LT_DIRECTIONAL ); 266 261 else if( String(XMLLight->Attribute("type")) == "spot") 267 l ->setType( Light::LT_SPOTLIGHT );262 light->setType( Light::LT_SPOTLIGHT ); 268 263 else if( String(XMLLight->Attribute("type")) == "radPoint") 269 l ->setType( Light::LT_POINT );264 light->setType( Light::LT_POINT ); 270 265 271 266 XMLDiffuse = XMLLight->FirstChildElement("colourDiffuse"); … … 277 272 Diffuse.b = Ogre::StringConverter::parseReal( XMLDiffuse->Attribute("b") ); 278 273 Diffuse.a = 1; 279 l ->setDiffuseColour(Diffuse);274 light->setDiffuseColour(Diffuse); 280 275 } 281 276 … … 289 284 Specular.b = Ogre::StringConverter::parseReal( XMLSpecular->Attribute("b") ); 290 285 Specular.a = 1; 291 l ->setSpecularColour(Specular);286 light->setSpecularColour(Specular); 292 287 } 293 288 … … 297 292 //get defaults incase not all values specified 298 293 Real range, constant, linear, quadratic; 299 range = l ->getAttenuationRange();300 constant = l ->getAttenuationConstant();301 linear = l ->getAttenuationLinear();302 quadratic = l ->getAttenuationQuadric();294 range = light->getAttenuationRange(); 295 constant = light->getAttenuationConstant(); 296 linear = light->getAttenuationLinear(); 297 quadratic = light->getAttenuationQuadric(); 303 298 304 299 if( XMLAttentuation->Attribute("range") ) … … 310 305 if( XMLAttentuation->Attribute("quadratic") ) 311 306 quadratic = StringConverter::parseReal( XMLAttentuation->Attribute("quadratic") ); 312 l ->setAttenuation( range, constant, linear, quadratic );307 light->setAttenuation( range, constant, linear, quadratic ); 313 308 } 314 309 … … 324 319 p.z = StringConverter::parseReal( XMLPosition->Attribute("z") ); 325 320 326 l ->setPosition( p );321 light->setPosition( p ); 327 322 } 328 323 329 324 //castShadows (true | false) "true" 330 l ->setCastShadows( true );325 light->setCastShadows( true ); 331 326 if( XMLLight->Attribute("visible") ) 332 327 if( String(XMLLight->Attribute("visible")) == "false" ) 333 l ->setCastShadows( false );328 light->setCastShadows( false ); 334 329 335 330 //visible (true | false) "true" 336 l ->setVisible( true );331 light->setVisible( true ); 337 332 if( XMLLight->Attribute("visible") ) 338 333 if( String(XMLLight->Attribute("visible")) == "false" ) 339 l->setVisible( false ); 340 341 return l; 342 } 343 //----------------------------------------------------------------------- 344 void TestCullingApplication::createCamera( void ) 345 { 346 // Create the camera 347 mCamera = mSceneMgr->createCamera("PlayerCam"); 348 349 // Position it at 500 in Z direction 350 mCamera->setPosition(Vector3(128,25,128)); 351 352 // Look back along -Z 353 mCamera->lookAt(Vector3(0,0,-300)); 354 mCamera->setNearClipDistance( 1 ); 355 mCamera->setFarClipDistance( 1000 ); 356 } 357 //----------------------------------------------------------------------- 358 void TestCullingApplication::createScene(void) 359 { 360 Plane waterPlane; 361 // Set ambient light 362 mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); 363 364 // Create a light 365 Light* l = mSceneMgr->createLight("MainLight"); 366 // Accept default settings: point light, white diffuse, just set position 367 // NB I could attach the light to a SceneNode if I wanted it to move automatically with 368 // other objects, but I don't 369 l->setPosition(20,80,50); 370 371 // Fog 372 // NB it's VERY important to set this before calling setWorldGeometry 373 // because the vertex program picked will be different 374 ColourValue fadeColour(0.93, 0.86, 0.76); 375 mSceneMgr->setFog( FOG_LINEAR, fadeColour, .001, 500, 1000); 376 mWindow->getViewport(0)->setBackgroundColour(fadeColour); 377 378 std::string terrain_cfg("terrain.cfg"); 379 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE 380 terrain_cfg = mResourcePath + terrain_cfg; 381 #endif 382 mSceneMgr -> setWorldGeometry( terrain_cfg ); 383 // Infinite far plane? 384 if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE)) 385 { 386 mCamera->setFarClipDistance(0); 387 } 388 389 // Define the required skyplane 390 Plane plane; 391 // 5000 world units from the camera 392 plane.d = 5000; 393 // Above the camera, facing down 394 plane.normal = -Vector3::UNIT_Y; 395 396 // Set a nice viewpoint 397 mCamera->setPosition(707,2500,528); 398 mCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 399 400 raySceneQuery = mSceneMgr->createRayQuery( 401 Ray(mCamera->getPosition(), Vector3::NEGATIVE_UNIT_Y)); 402 403 // Create a skybox 404 // mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox"); 405 406 // CEGUI setup 407 setupGui(); 408 } 409 //----------------------------------------------------------------------- 410 void TestCullingApplication::setupGui( void ) 411 { 412 mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, ST_EXTERIOR_CLOSE); 334 light->setVisible( false ); 335 336 return light; 337 } 338 //----------------------------------------------------------------------- 339 void TestCullingDotSceneApplication::createScene(void) 340 { 341 mSceneMgr->setAmbientLight(ColourValue(0.09f, 0.09f, 0.09f)); 342 mSceneMgr->setSkyBox(true, "Examples/MorningSkyBox" ); 343 344 //This is default, though, set it anyway :) 345 ResourceGroupManager::getSingleton().setWorldResourceGroupName("General"); 346 mSceneMgr->setWorldGeometry( "MyScene.scene" ); 347 //mSceneMgr->SetOctreeVisible( 1 ); 348 349 ParseDotScene( "MyScene.scene", "General" ); 350 // CEGUI setup 351 setupGui(); 352 } 353 //----------------------------------------------------------------------- 354 void TestCullingDotSceneApplication::setupGui( void ) 355 { 356 mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, ST_GENERIC); 413 357 mGUISystem = new CEGUI::System(mGUIRenderer); 414 358 … … 428 372 } 429 373 //----------------------------------------------------------------------- 430 void TestCulling Application::createFrameListener(void)374 void TestCullingDotSceneApplication::createFrameListener(void) 431 375 { 432 376 mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr, mGUIRenderer); … … 435 379 } 436 380 //----------------------------------------------------------------------- 437 void TestCullingApplication::chooseSceneManager(void) 438 { 439 //mSceneMgr = mRoot->getSceneManager(ST_GENERIC); 440 mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_CLOSE); 381 void TestCullingDotSceneApplication::chooseSceneManager(void) 382 { 383 mSceneMgr = mRoot->getSceneManager(ST_GENERIC); 384 385 } 386 //----------------------------------------------------------------------- 387 void TestCullingDotSceneApplication::createViewports(void) 388 { 389 // Create one viewport, entire window 390 Viewport* vp = mWindow->addViewport(mCamera); 391 // Look back along -Z 392 mCamera->lookAt(Vector3(0, 0, -300)); 393 mCamera->setPosition(0 , 100, 600); 441 394 } 442 395 … … 544 497 } 545 498 //----------------------------------------------------------------------- 546 bool MouseQueryListener::frameStarted(const FrameEvent &evt)547 {548 // clamp to terrain549 static Ray updateRay;550 updateRay.setOrigin(mCamera->getPosition());551 updateRay.setDirection(Vector3::NEGATIVE_UNIT_Y);552 raySceneQuery->setRay(updateRay);553 RaySceneQueryResult& qryResult = raySceneQuery->execute();554 RaySceneQueryResult::iterator i = qryResult.begin();555 556 if (i != qryResult.end() && i->worldFragment)557 {558 SceneQuery::WorldFragment* wf = i->worldFragment;559 mCamera->setPosition(mCamera->getPosition().x,560 i->worldFragment->singleIntersection.y + 10,561 mCamera->getPosition().z);562 }563 564 return ExampleFrameListener::frameStarted(evt);565 }566 //-----------------------------------------------------------------------567 499 bool MouseQueryListener::frameEnded(const FrameEvent& evt) 568 500 { … … 575 507 KEY_PRESSED(KC_SPACE, 0.3, changeAlgorithm()); 576 508 577 KEY_PRESSED(KC_SUBTRACT, 0. 3, changeThreshold(-10));509 KEY_PRESSED(KC_SUBTRACT, 0.0, changeThreshold(-10)); 578 510 KEY_PRESSED(KC_ADD, 0, changeThreshold(10)); 579 511 //KEY_PRESSED(KC_T, 1, change); … … 646 578 { 647 579 // Create application object 648 TestCulling Application app;580 TestCullingDotSceneApplication app; 649 581 650 582 try -
trunk/VUT/OcclusionCullingSceneManager/TestCullingDotScene/TestCullingDotSceneApplication.h
r36 r37 5 5 #include "CEGUIForwardRefs.h" 6 6 #include "ExampleApplication.h" 7 //#include "OgreOcclusionCullingSceneManager.h"7 #include "OgreLight.h" 8 8 #include "OgreOcclusionCullingSceneTraverser.h" 9 9 … … 36 36 } 37 37 38 bool frameStarted(const FrameEvent& evt);38 // bool frameStarted(const FrameEvent& evt); 39 39 bool frameEnded(const FrameEvent& evt); 40 40 … … 83 83 84 84 85 class TestCulling Application : public ExampleApplication85 class TestCullingDotSceneApplication : public ExampleApplication 86 86 { 87 87 public: 88 ~TestCullingApplication();88 //~TestCullingDotSceneApplication(); 89 89 90 90 protected: … … 92 92 void createFrameListener(void); 93 93 void setupGui(void); 94 void parseDotScene( const String &SceneName, const String& groupName );95 voidLight* LoadLight( TiXmlElement *XMLLight );94 void ParseDotScene( const String &SceneName, const String& groupName ); 95 Light* LoadLight( TiXmlElement *XMLLight ); 96 96 97 virtual void create Camera(void);97 virtual void createViewports(void); 98 98 99 99 CEGUI::OgreCEGUIRenderer *mGUIRenderer; … … 103 103 void chooseSceneManager(void); 104 104 105 //SceneManager* mSceneMgr; 105 106 //Entity* mShip; 106 107 //SceneNode* mShipNode;
Note: See TracChangeset
for help on using the changeset viewer.