Changeset 1598 for GTP/trunk/App/Demos/Illum/Ogre/src/DiffuseTest/include
- Timestamp:
- 10/10/06 11:13:58 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/src/DiffuseTest/include/DiffuseTest.h
r1590 r1598 225 225 }; 226 226 227 228 class FloorRenderTargetListener : public RenderTargetListener 229 { 230 public: 231 Entity* scene; 232 FloorRenderTargetListener(Entity* scene) 233 { 234 this->scene = scene; 235 } 236 void preRenderTargetUpdate(const RenderTargetEvent& evt) 237 { 238 scene->getSubEntity(0)->setVisible(false); 239 scene->getSubEntity(17)->setVisible(false); 240 scene->getSubEntity(35)->setVisible(false); 241 scene->getSubEntity(52)->setVisible(false); 242 } 243 void postRenderTargetUpdate(const RenderTargetEvent& evt) 244 { 245 scene->getSubEntity(0)->setVisible(true); 246 scene->getSubEntity(17)->setVisible(true); 247 scene->getSubEntity(35)->setVisible(true); 248 scene->getSubEntity(52)->setVisible(true); 249 } 250 251 }; 252 253 class CeilRenderTargetListener : public RenderTargetListener 254 { 255 public: 256 Entity* scene; 257 CeilRenderTargetListener(Entity* scene) 258 { 259 this->scene = scene; 260 } 261 void preRenderTargetUpdate(const RenderTargetEvent& evt) 262 { 263 scene->getSubEntity(1)->setVisible(false); 264 scene->getSubEntity(18)->setVisible(false); 265 scene->getSubEntity(36)->setVisible(false); 266 scene->getSubEntity(53)->setVisible(false); 267 } 268 void postRenderTargetUpdate(const RenderTargetEvent& evt) 269 { 270 scene->getSubEntity(1)->setVisible(true); 271 scene->getSubEntity(18)->setVisible(true); 272 scene->getSubEntity(36)->setVisible(true); 273 scene->getSubEntity(53)->setVisible(true); 274 } 275 276 }; 277 278 class ReflectionCameraFrameListener : public FrameListener 279 { 280 public: 281 Camera* floorReflCam; 282 Camera* ceilReflCam; 283 Camera* mainCamera; 284 ReflectionCameraFrameListener(Camera* floorcam, Camera* ceilCam, Camera* mainCam) 285 { 286 floorReflCam = floorcam; 287 ceilReflCam = ceilCam; 288 mainCamera = mainCam; 289 } 290 bool frameStarted(const FrameEvent& evt) 291 { 292 floorReflCam->setOrientation(mainCamera->getOrientation()); 293 floorReflCam->setPosition(mainCamera->getPosition()); 294 295 // ceilReflCam->setOrientation(mainCamera->getOrientation()); 296 // ceilReflCam->setPosition(mainCamera->getPosition()); 297 298 return true; 299 } 300 }; 227 301 /** Application class */ 228 302 class RaytraceDemoApplication : public ExampleApplication … … 258 332 mCamera->setPosition(0,10,10); 259 333 mCamera->setFOVy(Radian(Degree(80))); 260 mCamera->setFarClipDistance( 100);334 mCamera->setFarClipDistance(200); 261 335 mCamera->setNearClipDistance(0.1); 262 // Set ambient light 336 337 //createScene1(); 338 createScene2(); 339 340 OgreIlluminationManager::getSingleton().initTechniques(); 341 342 343 } 344 345 void createScene1() 346 { 347 263 348 mSceneMgr->setAmbientLight(ColourValue(0.1, 0.0537, 0.0)); 264 349 //mSceneMgr->setAmbientLight(ColourValue(0.0, 0.0, 0.0)); … … 355 440 redlight2Node->setPosition(18.689,7.743,-10.838); 356 441 redlight2Node->attachObject(redlight2); 357 358 OgreIlluminationManager::getSingleton().initTechniques();359 360 361 442 } 443 444 Camera* mReflectCamFloor; 445 Camera* mReflectCamCeil; 446 ReflectionCameraFrameListener* reflListener; 447 void createScene2() 448 { 449 mCamera->setPosition(0,5,10); 450 MovablePlane *floorPlane = new MovablePlane("ReflectPlaneFloor"); 451 floorPlane->d = 0; 452 floorPlane->normal = Vector3::UNIT_Y; 453 454 RenderTexture* rttTexFloor = mRoot->getRenderSystem()->createRenderTexture( "FloorReflection", 512, 512, TEX_TYPE_2D, PF_R8G8B8 ); 455 { 456 mReflectCamFloor = mSceneMgr->createCamera("ReflectCamFloor"); 457 mReflectCamFloor->setNearClipDistance(mCamera->getNearClipDistance()); 458 mReflectCamFloor->setFarClipDistance(mCamera->getFarClipDistance()); 459 /* mReflectCamFloor->setAspectRatio( 460 (Real)mWindow->getViewport(0)->getActualWidth() / 461 (Real)mWindow->getViewport(0)->getActualHeight());*/ 462 mReflectCamFloor->setFOVy(mCamera->getFOVy()); 463 mReflectCamFloor->setAspectRatio(mCamera->getAspectRatio()); 464 465 Viewport *v = rttTexFloor->addViewport( mReflectCamFloor ); 466 v->setClearEveryFrame( true ); 467 v->setBackgroundColour( ColourValue::Black ); 468 469 470 // set up linked reflection 471 mReflectCamFloor->enableReflection(floorPlane); 472 // Also clip 473 mReflectCamFloor->enableCustomNearClipPlane(floorPlane); 474 } 475 /* MovablePlane *ceilPlane = new MovablePlane("ReflectPlaneCeil"); 476 ceilPlane->d = -8; 477 ceilPlane->normal = Vector3::NEGATIVE_UNIT_Y; 478 RenderTexture* rttTexCeil = mRoot->getRenderSystem()->createRenderTexture( "CeilReflection", 512, 512, TEX_TYPE_2D, PF_R8G8B8 ); 479 { 480 mReflectCamCeil = mSceneMgr->createCamera("ReflectCamCeil"); 481 mReflectCamCeil->setNearClipDistance(mCamera->getNearClipDistance()); 482 mReflectCamCeil->setFarClipDistance(mCamera->getFarClipDistance()); 483 mReflectCamCeil->setAspectRatio( 484 (Real)mWindow->getViewport(0)->getActualWidth() / 485 (Real)mWindow->getViewport(0)->getActualHeight()); 486 487 Viewport *v = rttTexCeil->addViewport( mReflectCamCeil ); 488 v->setClearEveryFrame( true ); 489 v->setBackgroundColour( ColourValue::Black ); 490 491 492 // set up linked reflection 493 mReflectCamCeil->enableReflection(floorPlane); 494 // Also clip 495 mReflectCamCeil->enableCustomNearClipPlane(floorPlane); 496 } 497 */ 498 reflListener = new ReflectionCameraFrameListener(mReflectCamFloor, mReflectCamCeil, mCamera); 499 reflListener->setPriority(2); 500 501 // mSceneMgr->setAmbientLight(ColourValue(0.1, 0.0537, 0.0)); 502 mSceneMgr->setAmbientLight(ColourValue(0.0, 0.0, 0.0)); 503 504 SceneNode* rootNode = mSceneMgr->getRootSceneNode(); 505 506 Entity* object = mSceneMgr->createEntity("object", "athene.mesh"); 507 object->setMaterialName("GameTools/Diffuse/use"); 508 //object->setMaterialName("GameTools/Diffuse2"); 509 objectNode = rootNode->createChildSceneNode(); 510 objectNode->attachObject(object); 511 objectNode->scale(0.05,0.05,0.05); 512 objectNode->setPosition(0,4,0); 513 objectNode->_updateBounds(); 514 515 Entity* room = mSceneMgr->createEntity("scene", "uvegfolyoso2.mesh"); 516 //room->setMaterialName("GameTools/Phong"); 517 SceneNode* roomNode = rootNode->createChildSceneNode(); 518 roomNode->attachObject(room); 519 roomNode->_updateBounds(); 520 rttTexFloor->addListener(new FloorRenderTargetListener(room)); 521 //rttTexCeil->addListener(new CeilRenderTargetListener(room)); 522 523 Light* light1 = mSceneMgr->createLight("Light1"); 524 light1->setType(Light::LT_POINT); 525 light1->setDiffuseColour(ColourValue(0.526,0.535, 0.974)); 526 light1->setPowerScale(3); 527 SceneNode* lightNode1 = rootNode->createChildSceneNode(); 528 lightNode1->setPosition(-1.266,4.131,-4.438); 529 lightNode1->attachObject(light1); 530 531 Light* light2 = mSceneMgr->createLight("Light2"); 532 light2->setType(Light::LT_POINT); 533 light2->setDiffuseColour(ColourValue(0.391,0.781, 0.974)); 534 light2->setPowerScale(3); 535 SceneNode* lightNode2 = rootNode->createChildSceneNode(); 536 lightNode2->setPosition(-33.537,4.131,-4.438); 537 lightNode2->attachObject(light2); 538 539 Light* light3 = mSceneMgr->createLight("Light3"); 540 light3->setType(Light::LT_POINT); 541 light3->setDiffuseColour(ColourValue(0.391,0.781, 0.974)); 542 light3->setPowerScale(3); 543 SceneNode* lightNode3 = rootNode->createChildSceneNode(); 544 lightNode3->setPosition(-97.446,4.131,-4.438); 545 lightNode3->attachObject(light3); 546 547 Light* light4 = mSceneMgr->createLight("Light4"); 548 light4->setType(Light::LT_POINT); 549 light4->setDiffuseColour(ColourValue(0.304,0.974, 0.770)); 550 light4->setPowerScale(3); 551 SceneNode* lightNode4 = rootNode->createChildSceneNode(); 552 lightNode4->setPosition(-63.277,4.131,-4.438); 553 lightNode4->attachObject(light4); 554 555 556 557 558 559 } 560 362 561 void createPlane(Ogre::String _name, Ogre::String _material, Ogre::Vector3 _pos, Ogre::Vector2 _size, Ogre::Vector2 _subdivisions = Ogre::Vector2(1,1)) { 363 562 … … 389 588 ); 390 589 mFrameListener->setPriority(1); 391 OgreIlluminationManager::getSingleton().setPriority( 2);590 OgreIlluminationManager::getSingleton().setPriority(10); 392 591 mRoot->addFrameListener(&OgreIlluminationManager::getSingleton()); 393 592 mRoot->addFrameListener(mFrameListener); 593 mRoot->addFrameListener(reflListener); 394 594 395 595 } … … 397 597 }; 398 598 599
Note: See TracChangeset
for help on using the changeset viewer.