1 |
|
---|
2 |
|
---|
3 |
|
---|
4 | /*
|
---|
5 | -----------------------------------------------------------------------------
|
---|
6 | This source file is part of OGRE
|
---|
7 | (Object-oriented Graphics Rendering Engine)
|
---|
8 | For the latest info, see http://www.ogre3d.org/
|
---|
9 |
|
---|
10 | Copyright (c) 2000-2005 The OGRE Team
|
---|
11 | Also see acknowledgements in Readme.html
|
---|
12 |
|
---|
13 | You may use this sample code for anything you like, it is not covered by the
|
---|
14 | LGPL 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 | #include "FrameCapture.h"
|
---|
31 |
|
---|
32 | float refIndex = 0.77;
|
---|
33 | int scene = 3;
|
---|
34 | FrameCapture* capture;
|
---|
35 |
|
---|
36 | bool multiplebounce = true;
|
---|
37 |
|
---|
38 | int currentMaterial = 2;
|
---|
39 | int currentObject = 2;
|
---|
40 | String objectNames[] = {String("sphere.mesh"),
|
---|
41 | String("teapot.mesh"),
|
---|
42 | String("buddha.mesh")};
|
---|
43 |
|
---|
44 | String materialNames[] = {String("GTP/MultiBounce/Reflector"),
|
---|
45 | String("GTP/MultiBounce/Refractor"),
|
---|
46 | String("GTP/MultiBounce/CausticRefractor"),
|
---|
47 | String("GTP/MultiBounce/Reflector_MinMax"),
|
---|
48 | String("GTP/MultiBounce/Refractor_MinMax"),
|
---|
49 | String("GTP/MultiBounce/CausticRefractor_MinMax")};
|
---|
50 |
|
---|
51 | String resourceGroupName[] = { String("GTP_MultipleReflection"),
|
---|
52 | String("GTP_MultipleRefraction"),
|
---|
53 | String("GTP_MultipleRefraction"),
|
---|
54 | String("GTP_MultipleReflection_MinMax"),
|
---|
55 | String("GTP_MultipleRefraction_MinMax"),
|
---|
56 | String("GTP_MultipleRefraction_MinMax")};
|
---|
57 |
|
---|
58 | // Listener class for frame updates
|
---|
59 | class RaytraceDemoListener : public ExampleFrameListener
|
---|
60 | {
|
---|
61 | protected:
|
---|
62 | unsigned long framecount;
|
---|
63 | SceneNode* objectNode;
|
---|
64 |
|
---|
65 | public:
|
---|
66 | void setMoveSpeed(float speed){mMoveSpeed = speed;}
|
---|
67 | RaytraceDemoListener(RenderWindow* window, Camera* maincam, SceneNode* objectNode)
|
---|
68 | :ExampleFrameListener(window, maincam)
|
---|
69 |
|
---|
70 | {
|
---|
71 | this->mMoveSpeed = 0.1;
|
---|
72 | if(scene == 2)
|
---|
73 | this->mMoveSpeed = 1.0;
|
---|
74 | if(scene == 3)
|
---|
75 | this->mMoveSpeed = 10.0;
|
---|
76 | mStatsOn = false;
|
---|
77 | showDebugOverlay(mStatsOn);
|
---|
78 |
|
---|
79 | framecount = 0;
|
---|
80 | this->objectNode = objectNode;
|
---|
81 |
|
---|
82 | }
|
---|
83 |
|
---|
84 | void moveCamera()
|
---|
85 | {/*
|
---|
86 | mCamera->yaw(mRotX);
|
---|
87 | mCamera->pitch(mRotY);
|
---|
88 | mCamera->moveRelative(mTranslateVector);*/
|
---|
89 |
|
---|
90 | mCamera->getParentSceneNode()->yaw(mRotX, Node::TransformSpace::TS_WORLD);
|
---|
91 | mCamera->getParentSceneNode()->pitch(mRotY, Node::TransformSpace::TS_LOCAL);
|
---|
92 | mCamera->getParentSceneNode()->translate(mTranslateVector, Node::TransformSpace::TS_LOCAL);
|
---|
93 |
|
---|
94 | }
|
---|
95 |
|
---|
96 | bool processUnbufferedKeyInput(const FrameEvent& evt)
|
---|
97 | {
|
---|
98 | static float lastTime = 0.0;
|
---|
99 | float thisTime = (float) Root::getSingleton().getTimer()->getMilliseconds() / 1000.0f;
|
---|
100 | float elapsed = thisTime - lastTime;
|
---|
101 | float move = elapsed * 0.25;
|
---|
102 | if(scene == 3)
|
---|
103 | move *= 10;
|
---|
104 | float rotate = 80.0 * move;
|
---|
105 |
|
---|
106 | if (mInputDevice->isKeyDown(KC_J))
|
---|
107 | {
|
---|
108 | refIndex -= 0.001;
|
---|
109 |
|
---|
110 | MaterialPtr mat1 = MaterialManager::getSingleton().getByName(materialNames[currentMaterial]);
|
---|
111 | if(!mat1.isNull())
|
---|
112 | {
|
---|
113 | GpuProgramParameters* Fparams1 = mat1->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer();
|
---|
114 | Fparams1->setNamedConstant("refIndex", refIndex);
|
---|
115 | }
|
---|
116 | MaterialPtr mat2 = MaterialManager::getSingleton().getByName("GTP/MultiBounce/PhotonMap");
|
---|
117 | if(!mat2.isNull())
|
---|
118 | {
|
---|
119 | GpuProgramParameters* Fparams2 = mat2->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer();
|
---|
120 | Fparams2->setNamedConstant("refIndex", refIndex);
|
---|
121 | }
|
---|
122 | }
|
---|
123 | if (mInputDevice->isKeyDown(KC_K))
|
---|
124 | {
|
---|
125 | refIndex += 0.001;
|
---|
126 |
|
---|
127 | MaterialPtr mat1 = MaterialManager::getSingleton().getByName(materialNames[currentMaterial]);
|
---|
128 | if(!mat1.isNull())
|
---|
129 | {
|
---|
130 | GpuProgramParameters* Fparams1 = mat1->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer();
|
---|
131 | Fparams1->setNamedConstant("refIndex", refIndex);
|
---|
132 | }
|
---|
133 | MaterialPtr mat2 = MaterialManager::getSingleton().getByName("GTP/MultiBounce/PhotonMap");
|
---|
134 | if(!mat2.isNull())
|
---|
135 | {
|
---|
136 | GpuProgramParameters* Fparams2 = mat2->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer();
|
---|
137 | Fparams2->setNamedConstant("refIndex", refIndex);
|
---|
138 | }
|
---|
139 | }
|
---|
140 |
|
---|
141 | if (mInputDevice->isKeyDown(KC_UP))
|
---|
142 | {
|
---|
143 | objectNode->translate(0,0,move);
|
---|
144 | }
|
---|
145 | if (mInputDevice->isKeyDown(KC_MULTIPLY))
|
---|
146 | {
|
---|
147 | //objectNode->scale(1.1,1.1,1.1);
|
---|
148 | objectNode->rotate(Vector3(0,0,1), Degree(rotate));
|
---|
149 |
|
---|
150 | }
|
---|
151 | if (mInputDevice->isKeyDown(KC_DIVIDE))
|
---|
152 | {
|
---|
153 | //objectNode->scale(1.0/1.1,1.0/1.1,1.0/1.1);
|
---|
154 | objectNode->rotate(Vector3(1,0,0), Degree(rotate));
|
---|
155 |
|
---|
156 | }
|
---|
157 | if (mInputDevice->isKeyDown(KC_ADD))
|
---|
158 | {
|
---|
159 | objectNode->rotate(Vector3(0,1,0), Degree(rotate));
|
---|
160 | }
|
---|
161 | if (mInputDevice->isKeyDown(KC_HOME))
|
---|
162 | {
|
---|
163 | objectNode->translate(0,move,0);
|
---|
164 | }
|
---|
165 | if (mInputDevice->isKeyDown(KC_END))
|
---|
166 | {
|
---|
167 | objectNode->translate(0,-move,0);
|
---|
168 | }
|
---|
169 | if (mInputDevice->isKeyDown(KC_DOWN))
|
---|
170 | {
|
---|
171 | objectNode->translate(0,0,-move);
|
---|
172 | }
|
---|
173 | if (mInputDevice->isKeyDown(KC_RIGHT))
|
---|
174 | {
|
---|
175 | objectNode->translate(-move,0,0);
|
---|
176 | }
|
---|
177 | if (mInputDevice->isKeyDown(KC_LEFT))
|
---|
178 | {
|
---|
179 | objectNode->translate(move,0,0);
|
---|
180 | }
|
---|
181 |
|
---|
182 | if (mInputDevice->isKeyDown(KC_A))
|
---|
183 | {
|
---|
184 | // Move camera left
|
---|
185 | mTranslateVector.x = -mMoveScale;
|
---|
186 | }
|
---|
187 |
|
---|
188 | if (mInputDevice->isKeyDown(KC_D))
|
---|
189 | {
|
---|
190 | // Move camera RIGHT
|
---|
191 | mTranslateVector.x = mMoveScale;
|
---|
192 | }
|
---|
193 |
|
---|
194 | /* Move camera forward by keypress. */
|
---|
195 | if ( mInputDevice->isKeyDown(KC_W) )
|
---|
196 | {
|
---|
197 | mTranslateVector.z = -mMoveScale;
|
---|
198 | }
|
---|
199 |
|
---|
200 | /* Move camera backward by keypress. */
|
---|
201 | if (mInputDevice->isKeyDown(KC_S) )
|
---|
202 | {
|
---|
203 | mTranslateVector.z = mMoveScale;
|
---|
204 | }
|
---|
205 |
|
---|
206 | if (mInputDevice->isKeyDown(KC_PGUP))
|
---|
207 | {
|
---|
208 | // Move camera up
|
---|
209 | mTranslateVector.y = mMoveScale;
|
---|
210 | }
|
---|
211 |
|
---|
212 | if (mInputDevice->isKeyDown(KC_PGDOWN))
|
---|
213 | {
|
---|
214 | // Move camera down
|
---|
215 | mTranslateVector.y = -mMoveScale;
|
---|
216 | }
|
---|
217 | if (mInputDevice->isKeyDown(KC_N) && mTimeUntilNextToggle <= 0)
|
---|
218 | {
|
---|
219 | capture->playEvent();
|
---|
220 | mTimeUntilNextToggle = 1;
|
---|
221 | }
|
---|
222 | if (mInputDevice->isKeyDown(KC_B) && mTimeUntilNextToggle <= 0)
|
---|
223 | {
|
---|
224 | capture->recordEvent();
|
---|
225 | mTimeUntilNextToggle = 1;
|
---|
226 | }
|
---|
227 | if (mInputDevice->isKeyDown(KC_M) && mTimeUntilNextToggle <= 0)
|
---|
228 | {
|
---|
229 | capture->setSaving();
|
---|
230 | capture->playEvent();
|
---|
231 | mTimeUntilNextToggle = 1;
|
---|
232 | }
|
---|
233 |
|
---|
234 | if( mInputDevice->isKeyDown( KC_ESCAPE) )
|
---|
235 | {
|
---|
236 | return false;
|
---|
237 | }
|
---|
238 |
|
---|
239 | // see if switching is on, and you want to toggle
|
---|
240 | if (mInputTypeSwitchingOn && mInputDevice->isKeyDown(KC_M) && mTimeUntilNextToggle <= 0)
|
---|
241 | {
|
---|
242 | switchMouseMode();
|
---|
243 | mTimeUntilNextToggle = 1;
|
---|
244 | }
|
---|
245 |
|
---|
246 | if (mInputTypeSwitchingOn && mInputDevice->isKeyDown(KC_K) && mTimeUntilNextToggle <= 0)
|
---|
247 | {
|
---|
248 | // must be going from immediate keyboard to buffered keyboard
|
---|
249 | switchKeyMode();
|
---|
250 | mTimeUntilNextToggle = 1;
|
---|
251 | }
|
---|
252 | if (mInputDevice->isKeyDown(KC_F) && mTimeUntilNextToggle <= 0)
|
---|
253 | {
|
---|
254 | mStatsOn = !mStatsOn;
|
---|
255 | showDebugOverlay(mStatsOn);
|
---|
256 |
|
---|
257 | mTimeUntilNextToggle = 1;
|
---|
258 | }
|
---|
259 |
|
---|
260 | if (mInputDevice->isKeyDown(KC_SYSRQ) && mTimeUntilNextToggle <= 0)
|
---|
261 | {
|
---|
262 | char tmp[20];
|
---|
263 | sprintf(tmp, "screenshot_%d.png", ++mNumScreenShots);
|
---|
264 | mWindow->writeContentsToFile(tmp);
|
---|
265 | mTimeUntilNextToggle = 0.5;
|
---|
266 | mWindow->setDebugText(String("Wrote ") + tmp);
|
---|
267 | }
|
---|
268 |
|
---|
269 | static bool displayCameraDetails = false;
|
---|
270 | if (mInputDevice->isKeyDown(KC_P) && mTimeUntilNextToggle <= 0)
|
---|
271 | {
|
---|
272 | displayCameraDetails = !displayCameraDetails;
|
---|
273 | mTimeUntilNextToggle = 0.5;
|
---|
274 | if (!displayCameraDetails)
|
---|
275 | mWindow->setDebugText("");
|
---|
276 | }
|
---|
277 | if (displayCameraDetails)
|
---|
278 | {
|
---|
279 | // Print camera details
|
---|
280 | mWindow->setDebugText("P: " + StringConverter::toString(mCamera->getDerivedPosition()) + " " +
|
---|
281 | "O: " + StringConverter::toString(mCamera->getDerivedOrientation()));
|
---|
282 | }
|
---|
283 | lastTime = thisTime;
|
---|
284 | // Return true to continue rendering
|
---|
285 | return true;
|
---|
286 | }
|
---|
287 | bool frameStarted(const FrameEvent& evt)
|
---|
288 | {
|
---|
289 | bool result = ExampleFrameListener::frameStarted(evt);
|
---|
290 | framecount++;
|
---|
291 | return result;
|
---|
292 | }
|
---|
293 | };
|
---|
294 |
|
---|
295 | /** Application class */
|
---|
296 | class RaytraceDemoApplication : public ExampleApplication
|
---|
297 | {
|
---|
298 |
|
---|
299 | public:
|
---|
300 |
|
---|
301 |
|
---|
302 | protected:
|
---|
303 |
|
---|
304 | SceneNode* objectNode;
|
---|
305 |
|
---|
306 | void createCamera(void)
|
---|
307 | {
|
---|
308 | // Create the camera
|
---|
309 | mCamera = mSceneMgr->createCamera("PlayerCam");
|
---|
310 |
|
---|
311 | SceneNode* camNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("mainCameraNode");
|
---|
312 | camNode->attachObject(mCamera);
|
---|
313 | //camNode->setPosition(Vector3(0,1,0));
|
---|
314 | // Position it at 500 in Z direction
|
---|
315 | //mCamera->setPosition(Vector3(0,0,500));
|
---|
316 | // Look back along -Z
|
---|
317 | //mCamera->lookAt(Vector3(0,0,-300));
|
---|
318 | mCamera->setNearClipDistance(5);
|
---|
319 |
|
---|
320 | }
|
---|
321 |
|
---|
322 | void loadResources(void)
|
---|
323 | {
|
---|
324 | // Initialise, parse scripts etc
|
---|
325 | ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");
|
---|
326 | ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
|
---|
327 | ResourceGroupManager::getSingleton().initialiseResourceGroup("PostProc");
|
---|
328 | ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Basic");
|
---|
329 | ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_EnvMap");
|
---|
330 | ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Caustic");
|
---|
331 | ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_MultiBounce_Shared");
|
---|
332 | ResourceGroupManager::getSingleton().initialiseResourceGroup(resourceGroupName[currentMaterial]);
|
---|
333 | if(currentMaterial == 2)
|
---|
334 | ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_MultipleCausticRefraction");
|
---|
335 | if(currentMaterial == 5)
|
---|
336 | ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_MultipleCausticRefraction_MinMax");
|
---|
337 | }
|
---|
338 |
|
---|
339 | void createScene(void)
|
---|
340 | {
|
---|
341 |
|
---|
342 | OgreIlluminationManager::getSingleton().setMainCamera(mCamera);
|
---|
343 | OgreIlluminationManager::getSingleton().setMainViewport(mWindow->getViewport(0));
|
---|
344 |
|
---|
345 | OgreIlluminationManager::getSingleton().setMaxJoinRadius(420);
|
---|
346 |
|
---|
347 | Root::getSingleton()._setCurrentSceneManager(mSceneMgr);
|
---|
348 |
|
---|
349 | mCamera->setFOVy(Radian(Degree(80 * mWindow->getHeight() / mWindow->getWidth())));
|
---|
350 | mCamera->setFarClipDistance(200);
|
---|
351 | mCamera->setNearClipDistance(0.1);
|
---|
352 |
|
---|
353 | SceneNode* cn = mCamera->getParentSceneNode();
|
---|
354 |
|
---|
355 | OgreIlluminationManager::getSingleton().setFocusingSM(false);
|
---|
356 | OgreIlluminationManager::getSingleton().setShadowMapSize(512);
|
---|
357 | OgreIlluminationManager::getSingleton().setBlurShadowMap(true);
|
---|
358 | OgreIlluminationManager::getSingleton().setShadowMapMaterialName("GameTools/ShadowMapDistance");
|
---|
359 | mSceneMgr->setAmbientLight(ColourValue(0.505 * 0.2, 0.897 * 0.2, 0.914 * 0.2));
|
---|
360 |
|
---|
361 | capture = new FrameCapture(mWindow);
|
---|
362 | if(scene == 1) createScene1();
|
---|
363 | if(scene == 2) createScene2();
|
---|
364 | if(scene == 3) createScene3();
|
---|
365 |
|
---|
366 | OgreIlluminationManager::getSingleton().initTechniques();
|
---|
367 | }
|
---|
368 | void createScene1(void)
|
---|
369 | {
|
---|
370 | SceneNode* rootNode = mSceneMgr->getRootSceneNode();
|
---|
371 |
|
---|
372 | mCamera->getParentSceneNode()->translate(1.1,0.8,1.0);
|
---|
373 | //mCamera->lookAt(Vector3(0,1.2,0.0));
|
---|
374 |
|
---|
375 | Entity* object;
|
---|
376 | object = mSceneMgr->createEntity("object", objectNames[currentObject]);
|
---|
377 |
|
---|
378 | object->setMaterialName(materialNames[currentMaterial]);
|
---|
379 | objectNode = rootNode->createChildSceneNode("objectNode");
|
---|
380 | objectNode->attachObject(object);
|
---|
381 |
|
---|
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);
|
---|
387 |
|
---|
388 | objectNode->setPosition(0,1.2,0);
|
---|
389 | objectNode->_updateBounds();
|
---|
390 |
|
---|
391 | capture->addAnimableNode(objectNode);
|
---|
392 | capture->addAnimableNode(mCamera->getParentSceneNode());
|
---|
393 |
|
---|
394 | Entity* room = mSceneMgr->createEntity("scene", "difflab.mesh");
|
---|
395 | //room->setMaterialName("GameTools/Phong");
|
---|
396 | SceneNode* roomNode = rootNode->createChildSceneNode();
|
---|
397 | roomNode->attachObject(room);
|
---|
398 | roomNode->_updateBounds();
|
---|
399 |
|
---|
400 | mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE);
|
---|
401 | Light* redLight1 = mSceneMgr->createLight("RedLight1");
|
---|
402 | redLight1->setType(Light::LT_POINT);
|
---|
403 | redLight1->setCastShadows(false);
|
---|
404 | redLight1->setDiffuseColour(ColourValue(1,0.055, 0.0));
|
---|
405 | redLight1->setPowerScale(1.6);
|
---|
406 | SceneNode* redLightNode1 = rootNode->createChildSceneNode();
|
---|
407 | redLightNode1->setPosition(0.05,2.361,-1.07);
|
---|
408 | redLightNode1->attachObject(redLight1);
|
---|
409 |
|
---|
410 | Light* greenLight1 = mSceneMgr->createLight("GreenLight1");
|
---|
411 | greenLight1->setType(Light::LT_POINT);
|
---|
412 | greenLight1->setCastShadows(false);
|
---|
413 | greenLight1->setDiffuseColour(ColourValue(0.362,0.783, 0.685));
|
---|
414 | greenLight1->setPowerScale(2.0);
|
---|
415 | SceneNode* greenLightNode1 = rootNode->createChildSceneNode();
|
---|
416 | greenLightNode1->setPosition(1.312,1.313,0);
|
---|
417 | greenLightNode1->attachObject(greenLight1);
|
---|
418 |
|
---|
419 | Light* mainBlueLight = mSceneMgr->createLight("MainBlueLight");
|
---|
420 | mainBlueLight->setType(Light::LT_SPOTLIGHT);
|
---|
421 | mainBlueLight->setCastShadows(true);
|
---|
422 | mainBlueLight->setDiffuseColour(ColourValue(0.395,0.766, 1.0));
|
---|
423 | mainBlueLight->setPowerScale(5.0);
|
---|
424 | mainBlueLight->setSpotlightRange(Degree(0),Degree(160));
|
---|
425 | mainBlueLight->setAttenuation(2.5, 0, 1, 0);
|
---|
426 | SceneNode* mainBlueLightNode = rootNode->createChildSceneNode();
|
---|
427 | mainBlueLightNode->setPosition(-0.546,2.095,1.035);
|
---|
428 | //mainBlueLightNode->rotate(Vector3::UNIT_X, Degree(161.396));
|
---|
429 | //mainBlueLightNode->rotate(Vector3::UNIT_Y, Degree(53.955));
|
---|
430 | //mainBlueLightNode->rotate(Vector3::UNIT_Z, Degree(-145.065));
|
---|
431 | mainBlueLight->setDirection(-1.5,-2.0,1.0);
|
---|
432 | mainBlueLightNode->attachObject(mainBlueLight);
|
---|
433 | }
|
---|
434 |
|
---|
435 | void createScene2(void)
|
---|
436 | {
|
---|
437 | SceneNode* rootNode = mSceneMgr->getRootSceneNode();
|
---|
438 |
|
---|
439 | mCamera->setPosition(2.3,7.0,2.3);
|
---|
440 | //mCamera->lookAt(Vector3(0,5.75,0.0));
|
---|
441 |
|
---|
442 | Entity* object = mSceneMgr->createEntity("object", "teapot.mesh");
|
---|
443 | object->setMaterialName("MetalTeapotMultipleBounce");
|
---|
444 | objectNode = rootNode->createChildSceneNode();
|
---|
445 | objectNode->attachObject(object);
|
---|
446 | //objectNode->scale(0.5,0.5,0.5);
|
---|
447 | //objectNode->scale(0.005,0.005,0.005);
|
---|
448 | objectNode->setPosition(0,5.75,0.0);
|
---|
449 | objectNode->_updateBounds();
|
---|
450 |
|
---|
451 | Entity* room = mSceneMgr->createEntity("scene", "terito.mesh");
|
---|
452 | //room->setMaterialName("GameTools/Phong");
|
---|
453 | SceneNode* roomNode = rootNode->createChildSceneNode();
|
---|
454 | roomNode->attachObject(room);
|
---|
455 | roomNode->_updateBounds();
|
---|
456 |
|
---|
457 | mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE);
|
---|
458 | Light* Light1 = mSceneMgr->createLight("Light1");
|
---|
459 | Light1->setType(Light::LT_POINT);
|
---|
460 | Light1->setCastShadows(false);
|
---|
461 | Light1->setDiffuseColour(ColourValue(1,1, 1));
|
---|
462 | Light1->setPowerScale(1.0);
|
---|
463 | SceneNode* LightNode1 = rootNode->createChildSceneNode();
|
---|
464 | LightNode1->setPosition(1.5,10.3,0);
|
---|
465 | LightNode1->attachObject(Light1);
|
---|
466 | }
|
---|
467 |
|
---|
468 | void createScene3(void)
|
---|
469 | {
|
---|
470 | SceneNode* rootNode = mSceneMgr->getRootSceneNode();
|
---|
471 |
|
---|
472 | //mCamera->getParentSceneNode()->translate(Vector3(6.564,4.328,0.059));
|
---|
473 | //mCamera->setPosition(4.0,4.2,-3.5);
|
---|
474 | //mCamera->getParentSceneNode()->translate(7.0,2.6,-0.5);
|
---|
475 | mCamera->setPosition(7.0,2.6,-0.5);
|
---|
476 | mCamera->lookAt(Vector3(1.0, 0.0,0.6));
|
---|
477 | Entity* object;
|
---|
478 |
|
---|
479 | object = mSceneMgr->createEntity("object", objectNames[currentObject]);
|
---|
480 |
|
---|
481 | object->setMaterialName(materialNames[currentMaterial]);
|
---|
482 | objectNode = rootNode->createChildSceneNode();
|
---|
483 | objectNode->attachObject(object);
|
---|
484 |
|
---|
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 |
|
---|
496 | objectNode->_updateBounds();
|
---|
497 |
|
---|
498 | Entity* room = mSceneMgr->createEntity("scene", "colorcube.mesh");
|
---|
499 | //room->setMaterialName("GameTools/Phong");
|
---|
500 | SceneNode* roomNode = rootNode->createChildSceneNode();
|
---|
501 | roomNode->attachObject(room);
|
---|
502 | roomNode->setScale(2,2,2);
|
---|
503 | roomNode->_updateBounds();
|
---|
504 |
|
---|
505 | mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE);
|
---|
506 | Light* Light1 = mSceneMgr->createLight("Light1");
|
---|
507 | Light1->setType(Light::LT_SPOTLIGHT);
|
---|
508 | Light1->setCastShadows(true);
|
---|
509 | Light1->setDiffuseColour(ColourValue(1,1, 1));
|
---|
510 | Light1->setPowerScale(1.0);
|
---|
511 | SceneNode* LightNode1 = rootNode->createChildSceneNode();
|
---|
512 | LightNode1->setPosition(3,3,3);
|
---|
513 | Light1->setDirection(-1,-1,-1);
|
---|
514 | Light1->setSpotlightRange(Degree(0),Degree(120));
|
---|
515 | LightNode1->attachObject(Light1);
|
---|
516 | /*
|
---|
517 | BillboardSet* bbs = mSceneMgr->createBillboardSet("bb", 1);
|
---|
518 | bbs->setDefaultDimensions(0.2, 0.2);
|
---|
519 | bbs->createBillboard(Vector3::ZERO, ColourValue::White);
|
---|
520 | bbs->setMaterialName("Flare");
|
---|
521 | LightNode1->attachObject(bbs);*/
|
---|
522 | }
|
---|
523 |
|
---|
524 | void createFrameListener(void)
|
---|
525 | {
|
---|
526 | // This is where we instantiate our own frame listener
|
---|
527 | mFrameListener= new RaytraceDemoListener(mWindow, mCamera, objectNode);
|
---|
528 | mFrameListener->setPriority(1);
|
---|
529 | OgreIlluminationManager::getSingleton().setPriority(3);
|
---|
530 | capture->setPriority(2);
|
---|
531 | mRoot->addFrameListener(capture);
|
---|
532 | mRoot->addFrameListener(mFrameListener);
|
---|
533 | mRoot->addFrameListener(&OgreIlluminationManager::getSingleton());
|
---|
534 |
|
---|
535 | }
|
---|
536 |
|
---|
537 | };
|
---|
538 |
|
---|