Changeset 2140 for GTP/trunk/App/Demos/Illum/Ogre/src/ReflectionTest
- Timestamp:
- 02/20/07 14:14:46 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/src/ReflectionTest/include/ReflectionTest.h
r2095 r2140 29 29 #include "SpriteParticleRenderer.h" 30 30 #include "FrameCapture.h" 31 32 float refIndex = 0.77; 33 int scene = 3; 31 #include "OgreCausticCubeMapRenderingRun.h" 32 33 float worldSizeVar = 0.002; 34 float refIndex = 0.995; 35 int scene = 1; 34 36 FrameCapture* capture; 35 37 36 38 bool multiplebounce = true; 37 38 int currentMaterial = 2; 39 int currentObject = 2; 39 bool useCauInt = true; 40 41 int currentMaterial = 3; 42 int currentObject = 1; 40 43 String objectNames[] = {String("sphere.mesh"), 41 44 String("teapot.mesh"), 42 String("buddha.mesh")}; 45 String("buddha.mesh"), 46 String("head.mesh")}; 47 48 float objectscales[] = {0.01,1,1,0.1}; 49 float scenescales[] = {0.3,1, 2.7}; 43 50 44 51 String materialNames[] = {String("GTP/MultiBounce/Reflector"), … … 47 54 String("GTP/MultiBounce/Reflector_MinMax"), 48 55 String("GTP/MultiBounce/Refractor_MinMax"), 49 String("GTP/MultiBounce/CausticRefractor_MinMax")}; 56 String("GTP/MultiBounce/CausticRefractor_MinMax"), 57 String("semmi") 58 }; 50 59 51 60 String resourceGroupName[] = { String("GTP_MultipleReflection"), … … 54 63 String("GTP_MultipleReflection_MinMax"), 55 64 String("GTP_MultipleRefraction_MinMax"), 56 String("GTP_MultipleRefraction_MinMax")}; 65 String("GTP_MultipleRefraction_MinMax"), 66 String("GTP_Basic")}; 57 67 58 68 // Listener class for frame updates … … 62 72 unsigned long framecount; 63 73 SceneNode* objectNode; 74 Entity *object; 64 75 65 76 public: 66 77 void setMoveSpeed(float speed){mMoveSpeed = speed;} 67 RaytraceDemoListener(RenderWindow* window, Camera* maincam, SceneNode* objectNode )78 RaytraceDemoListener(RenderWindow* window, Camera* maincam, SceneNode* objectNode, Entity* object) 68 79 :ExampleFrameListener(window, maincam) 69 80 70 81 { 71 this->mMoveSpeed = 0.1; 82 this->object = object; 83 this->mMoveSpeed = 1; 72 84 if(scene == 2) 73 85 this->mMoveSpeed = 1.0; … … 99 111 float thisTime = (float) Root::getSingleton().getTimer()->getMilliseconds() / 1000.0f; 100 112 float elapsed = thisTime - lastTime; 101 float move = elapsed * 0. 25;102 if(scene == 3 )113 float move = elapsed * 0.5; 114 if(scene == 3 ) 103 115 move *= 10; 104 116 float rotate = 80.0 * move; 105 117 if (mInputDevice->isKeyDown(KC_G)) 118 { 119 worldSizeVar -= 0.002; 120 if(worldSizeVar < 0.002)worldSizeVar = 0.002; 121 MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/MultiBounce/CauCube_Trianglesobject_SE_0_clone"); 122 if(!mat.isNull()) 123 { 124 GpuProgramParameters* Vparams = mat->getTechnique(0)->getPass(0)->getVertexProgramParameters().getPointer(); 125 Vparams->setNamedConstant("WorldSize", worldSizeVar); 126 } 127 } 128 if (mInputDevice->isKeyDown(KC_H)) 129 { 130 worldSizeVar += 0.002; 131 MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/MultiBounce/CauCube_Trianglesobject_SE_0_clone"); 132 if(!mat.isNull()) 133 { 134 GpuProgramParameters* Vparams = mat->getTechnique(0)->getPass(0)->getVertexProgramParameters().getPointer(); 135 Vparams->setNamedConstant("WorldSize", worldSizeVar); 136 } 137 } 138 if (mInputDevice->isKeyDown(KC_I) && mTimeUntilNextToggle <= 0) 139 { 140 useCauInt = !useCauInt; 141 142 MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/MultiBounce/CauCube_Trianglesobject_SE_0_clone"); 143 if(!mat.isNull()) 144 { 145 GpuProgramParameters* Vparams = mat->getTechnique(0)->getPass(0)->getVertexProgramParameters().getPointer(); 146 Vparams->setNamedConstant("notUseIntensity", !useCauInt); 147 if(useCauInt) 148 { 149 mat->getTechnique(0)->getPass(0)->setPolygonMode(PM_SOLID); 150 OgreTechniqueGroup* tg = (OgreTechniqueGroup*) object->getSubEntity(0)->getRenderTechniqueGroup(); 151 OgreCausticCubeMapRenderingRun* rr = (OgreCausticCubeMapRenderingRun*) 152 tg->getSharedRuns()->getRun(ILLUMRUN_CAUSTIC_CUBEMAP) 153 ->asOgreRenderingRun(); 154 rr->setBlurMap(true); 155 } 156 else 157 { 158 mat->getTechnique(0)->getPass(0)->setPolygonMode(PM_POINTS); 159 OgreTechniqueGroup* tg = (OgreTechniqueGroup*) object->getSubEntity(0)->getRenderTechniqueGroup(); 160 OgreCausticCubeMapRenderingRun* rr = (OgreCausticCubeMapRenderingRun*) 161 tg->getSharedRuns()->getRun(ILLUMRUN_CAUSTIC_CUBEMAP) 162 ->asOgreRenderingRun(); 163 rr->setBlurMap(false); 164 } 165 } 166 mTimeUntilNextToggle = 1; 167 } 106 168 if (mInputDevice->isKeyDown(KC_J)) 107 169 { … … 114 176 Fparams1->setNamedConstant("refIndex", refIndex); 115 177 } 116 MaterialPtr mat2 = MaterialManager::getSingleton().getByName("GTP/MultiBounce/PhotonMap"); 178 //MaterialPtr mat2 = MaterialManager::getSingleton().getByName("GTP/MultiBounce/PhotonMap"); 179 MaterialPtr mat2 = MaterialManager::getSingleton().getByName("GTP/Caustic/PhotonMap_HitEnv"); 117 180 if(!mat2.isNull()) 118 181 { … … 131 194 Fparams1->setNamedConstant("refIndex", refIndex); 132 195 } 133 MaterialPtr mat2 = MaterialManager::getSingleton().getByName("GTP/MultiBounce/PhotonMap"); 196 //MaterialPtr mat2 = MaterialManager::getSingleton().getByName("GTP/MultiBounce/PhotonMap"); 197 MaterialPtr mat2 = MaterialManager::getSingleton().getByName("GTP/Caustic/PhotonMap_HitEnv"); 134 198 if(!mat2.isNull()) 135 199 { … … 336 400 ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_MultipleCausticRefraction_MinMax"); 337 401 } 402 Entity* object; 403 404 void createPostproc() 405 { 406 CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0), 407 "GTP/PostProc/Glow"); 408 CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), 409 "GTP/PostProc/Glow", true); 410 /* 411 CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0), 412 "GTP/PostProc/ToneMap"); 413 CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), 414 "GTP/PostProc/ToneMap", true); */ 415 } 338 416 339 417 void createScene(void) 340 418 { 419 createPostproc(); 341 420 342 421 OgreIlluminationManager::getSingleton().setMainCamera(mCamera); … … 372 451 mCamera->getParentSceneNode()->translate(1.1,0.8,1.0); 373 452 //mCamera->lookAt(Vector3(0,1.2,0.0)); 374 375 Entity* object; 453 376 454 object = mSceneMgr->createEntity("object", objectNames[currentObject]); 377 455 … … 380 458 objectNode->attachObject(object); 381 459 382 if(currentObject == 1) 383 objectNode->scale(0.5,0.5,0.5); 384 if(currentObject == 0) 385 objectNode->scale(0.005,0.005,0.005); 386 //objectNode->scale(0.005,0.005,0.005); 460 float scale = objectscales[currentObject] * scenescales[scene-1]; 461 objectNode->scale(scale, scale, scale); 387 462 388 463 objectNode->setPosition(0,1.2,0); … … 395 470 //room->setMaterialName("GameTools/Phong"); 396 471 SceneNode* roomNode = rootNode->createChildSceneNode(); 397 roomNode->attachObject(room); 472 roomNode->attachObject(room); 398 473 roomNode->_updateBounds(); 399 474 400 475 mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE); 476 401 477 Light* redLight1 = mSceneMgr->createLight("RedLight1"); 402 478 redLight1->setType(Light::LT_POINT); … … 421 497 mainBlueLight->setCastShadows(true); 422 498 mainBlueLight->setDiffuseColour(ColourValue(0.395,0.766, 1.0)); 423 mainBlueLight->setPowerScale( 5.0);499 mainBlueLight->setPowerScale(3.0); 424 500 mainBlueLight->setSpotlightRange(Degree(0),Degree(160)); 425 501 mainBlueLight->setAttenuation(2.5, 0, 1, 0); … … 431 507 mainBlueLight->setDirection(-1.5,-2.0,1.0); 432 508 mainBlueLightNode->attachObject(mainBlueLight); 509 /* 510 Light* mainLight = mSceneMgr->createLight("MainLight"); 511 mainLight->setType(Light::LT_SPOTLIGHT); 512 mainLight->setSpotlightRange(Degree(0),Degree(160)); 513 mainLight->setCastShadows(false); 514 mainLight->setDiffuseColour(ColourValue(0.995,0.996, 0.80)); 515 mainLight->setPowerScale(1.0); 516 mainLight->setAttenuation(3, 0, 1, 0); 517 SceneNode* mainLightNode = rootNode->createChildSceneNode(); 518 mainLightNode->setPosition(0,2.5,0); 519 mainLight->setDirection(0,-1.0,0); 520 mainLightNode->attachObject(mainLight);*/ 521 /* 522 BillboardSet* bbs = mSceneMgr->createBillboardSet("bb", 1); 523 bbs->setDefaultDimensions(0.2, 0.2); 524 bbs->createBillboard(Vector3::ZERO, ColourValue::White); 525 bbs->setMaterialName("Flare"); 526 mainLightNode->attachObject(bbs);*/ 433 527 } 434 528 … … 440 534 //mCamera->lookAt(Vector3(0,5.75,0.0)); 441 535 442 Entity*object = mSceneMgr->createEntity("object", "teapot.mesh");536 object = mSceneMgr->createEntity("object", "teapot.mesh"); 443 537 object->setMaterialName("MetalTeapotMultipleBounce"); 444 538 objectNode = rootNode->createChildSceneNode(); … … 465 559 LightNode1->attachObject(Light1); 466 560 } 467 561 468 562 void createScene3(void) 469 563 { … … 475 569 mCamera->setPosition(7.0,2.6,-0.5); 476 570 mCamera->lookAt(Vector3(1.0, 0.0,0.6)); 477 Entity* object;478 571 479 572 object = mSceneMgr->createEntity("object", objectNames[currentObject]); … … 483 576 objectNode->attachObject(object); 484 577 485 if(currentObject == 1) 486 { 487 objectNode->scale(2.7,2.7,2.7); 488 objectNode->setPosition(0,0.7,0.0); 489 } 490 if(currentObject == 0) 491 { 492 objectNode->scale(0.027,0.027,0.027); 493 objectNode->setPosition(1,0.0,1.0); 494 } 495 578 float scale = objectscales[currentObject] * scenescales[scene-1]; 579 objectNode->scale(scale, scale, scale); 580 496 581 objectNode->_updateBounds(); 497 582 … … 525 610 { 526 611 // This is where we instantiate our own frame listener 527 mFrameListener= new RaytraceDemoListener(mWindow, mCamera, objectNode );612 mFrameListener= new RaytraceDemoListener(mWindow, mCamera, objectNode, object); 528 613 mFrameListener->setPriority(1); 529 614 OgreIlluminationManager::getSingleton().setPriority(3);
Note: See TracChangeset
for help on using the changeset viewer.