source: GTP/trunk/App/Demos/Illum/Ogre/src/ReflectionTest/include/ReflectionTest.h @ 1720

Revision 1720, 5.1 KB checked in by szirmay, 18 years ago (diff)
Line 
1
2
3
4/*
5-----------------------------------------------------------------------------
6This source file is part of OGRE
7    (Object-oriented Graphics Rendering Engine)
8For the latest info, see http://www.ogre3d.org/
9
10Copyright (c) 2000-2005 The OGRE Team
11Also see acknowledgements in Readme.html
12
13You may use this sample code for anything you like, it is not covered by the
14LGPL like the rest of the engine.
15-----------------------------------------------------------------------------
16*/
17
18/**
19    \file
20        Lighting.h
21    \brief
22        Shows lighting support in OGRE. Also demonstrates the use of billboards
23        and controllers for automatic time-relative behaviour.
24*/
25
26
27#include "ExampleApplication.h"
28#include "OgreIlluminationManager.h"
29#include "SpriteParticleRenderer.h"
30
31
32// Listener class for frame updates
33class RaytraceDemoListener : public ExampleFrameListener
34{
35protected:
36        unsigned long framecount;
37       
38public:
39    RaytraceDemoListener(RenderWindow* window, Camera* maincam)
40        :ExampleFrameListener(window, maincam)
41                                 
42    {
43                this->mMoveSpeed = 2.0;
44                framecount = 0;         
45    }
46        bool processUnbufferedKeyInput(const FrameEvent& evt)
47    {
48                return ExampleFrameListener::processUnbufferedKeyInput(evt);
49        }
50    bool frameStarted(const FrameEvent& evt)
51    {
52                bool result = ExampleFrameListener::frameStarted(evt);
53                framecount++;
54                return result;     
55    }
56};
57
58/** Application class */
59class RaytraceDemoApplication : public ExampleApplication
60{
61
62public:
63
64
65protected:
66
67        SceneNode* objectNode;
68
69        void createScene(void)
70    {
71
72                OgreIlluminationManager::getSingleton().setMainCamera(mCamera);
73                OgreIlluminationManager::getSingleton().setMainViewport(mWindow->getViewport(0));
74               
75                OgreIlluminationManager::getSingleton().setMaxJoinRadius(420);         
76
77                Root::getSingleton()._setCurrentSceneManager(mSceneMgr);
78
79                mCamera->setPosition(0,1,0);           
80                mCamera->setFOVy(Radian(Degree(80)));
81                mCamera->setFarClipDistance(200);
82                mCamera->setNearClipDistance(0.1);
83
84                OgreIlluminationManager::getSingleton().setFocusingSM(false);
85           OgreIlluminationManager::getSingleton().setShadowMapSize(512);
86           OgreIlluminationManager::getSingleton().setBlurShadowMap(true);
87           OgreIlluminationManager::getSingleton().setShadowMapMaterialName("GameTools/ShadowMapDistance");
88            mSceneMgr->setAmbientLight(ColourValue(0.505 * 0.2, 0.897 * 0.2, 0.914 * 0.2));
89               
90                SceneNode* rootNode = mSceneMgr->getRootSceneNode();
91
92        Entity* object = mSceneMgr->createEntity("object", "teapot.mesh");
93                object->setMaterialName("EnvMetals/Gold");
94                objectNode = rootNode->createChildSceneNode();
95                objectNode->attachObject(object);
96                objectNode->scale(0.5,0.5,0.5);
97                objectNode->rotate(Vector3(0,1,0),Radian(Math::PI));
98                objectNode->setPosition(0,1.2,0);
99                objectNode->_updateBounds();
100
101                Entity* room = mSceneMgr->createEntity("scene", "difflab.mesh");
102                //room->setMaterialName("GameTools/Phong");
103                SceneNode* roomNode = rootNode->createChildSceneNode();
104                roomNode->attachObject(room);
105                roomNode->_updateBounds();             
106
107                mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE);
108                Light* redLight1 = mSceneMgr->createLight("RedLight1");
109                redLight1->setType(Light::LT_POINT);
110                redLight1->setCastShadows(false);
111        redLight1->setDiffuseColour(ColourValue(1,0.055, 0.0));
112                redLight1->setPowerScale(1.6);
113                SceneNode* redLightNode1 = rootNode->createChildSceneNode();
114                redLightNode1->setPosition(0.05,2.361,-1.07);
115                redLightNode1->attachObject(redLight1);
116
117                Light* greenLight1 = mSceneMgr->createLight("GreenLight1");
118                greenLight1->setType(Light::LT_POINT);
119                greenLight1->setCastShadows(false);
120        greenLight1->setDiffuseColour(ColourValue(0.362,0.783, 0.685));
121                greenLight1->setPowerScale(2.0);
122                SceneNode* greenLightNode1 = rootNode->createChildSceneNode();
123                greenLightNode1->setPosition(1.312,1.313,0);
124                greenLightNode1->attachObject(greenLight1);
125
126                Light* mainBlueLight = mSceneMgr->createLight("MainBlueLight");
127                mainBlueLight->setType(Light::LT_SPOTLIGHT);
128                mainBlueLight->setCastShadows(true);
129        mainBlueLight->setDiffuseColour(ColourValue(0.395,0.766, 1.0));
130                mainBlueLight->setPowerScale(5.0);
131                mainBlueLight->setSpotlightRange(Degree(0),Degree(160));
132                mainBlueLight->setAttenuation(2.5, 0, 1, 0);
133                SceneNode* mainBlueLightNode = rootNode->createChildSceneNode();
134                mainBlueLightNode->setPosition(-0.546,2.095,1.035);
135                //mainBlueLightNode->rotate(Vector3::UNIT_X, Degree(161.396));
136                //mainBlueLightNode->rotate(Vector3::UNIT_Y, Degree(53.955));
137                //mainBlueLightNode->rotate(Vector3::UNIT_Z, Degree(-145.065));
138                mainBlueLight->setDirection(-1.5,-2.0,1.0);
139                mainBlueLightNode->attachObject(mainBlueLight);
140
141                OgreIlluminationManager::getSingleton().initTechniques();
142
143   }
144
145        void createFrameListener(void)
146    {
147                // This is where we instantiate our own frame listener
148                mFrameListener= new RaytraceDemoListener(mWindow, mCamera);
149                mFrameListener->setPriority(1);
150                OgreIlluminationManager::getSingleton().setPriority(2);
151                mRoot->addFrameListener(mFrameListener);
152                mRoot->addFrameListener(&OgreIlluminationManager::getSingleton());
153
154    }
155
156};
157
Note: See TracBrowser for help on using the repository browser.