1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://www.ogre3d.org/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | You may use this sample code for anything you like, it is not covered by the
|
---|
11 | LGPL like the rest of the engine.
|
---|
12 | -----------------------------------------------------------------------------
|
---|
13 | */
|
---|
14 |
|
---|
15 | /**
|
---|
16 | \file
|
---|
17 | Lighting.h
|
---|
18 | \brief
|
---|
19 | Shows lighting support in OGRE. Also demonstrates the use of billboards
|
---|
20 | and controllers for automatic time-relative behaviour.
|
---|
21 | */
|
---|
22 |
|
---|
23 |
|
---|
24 | #include "ExampleApplication.h"
|
---|
25 | #include "OgreIlluminationManager.h"
|
---|
26 | #include "SceneSerializer.h"
|
---|
27 |
|
---|
28 | bool capture = false;
|
---|
29 | SceneNode* CharacterGroupOrigo;
|
---|
30 | AnimationState* mAnimState = 0;
|
---|
31 |
|
---|
32 | bool PP_glowON = false;
|
---|
33 | bool PP_tonemapON = false;
|
---|
34 | bool PP_dofON = false;
|
---|
35 |
|
---|
36 | Real lightpower = 32.0;
|
---|
37 | Real glowCut = 50.6;
|
---|
38 | Real glowTimeBlur = 0.6;
|
---|
39 | Real glowStrech = 1.8;
|
---|
40 | Real glowCombine = 0.5;
|
---|
41 | // Listener class for frame updates
|
---|
42 | class MoriaDemoFrameListener : public ExampleFrameListener
|
---|
43 | {
|
---|
44 | protected:
|
---|
45 |
|
---|
46 | unsigned long framecount;
|
---|
47 | SceneNode* mainLightNode;
|
---|
48 | Light* light;
|
---|
49 | SceneNode* sysNode;
|
---|
50 |
|
---|
51 | public:
|
---|
52 | MoriaDemoFrameListener(RenderWindow* window, Camera* maincam, SceneNode* lightNode, Light* l, SceneNode* sysNode)
|
---|
53 | :ExampleFrameListener(window, maincam)
|
---|
54 |
|
---|
55 | {
|
---|
56 | mainLightNode = lightNode;
|
---|
57 | light = l;
|
---|
58 | framecount = 0;
|
---|
59 | mMoveSpeed /= 5.0;
|
---|
60 | this->sysNode = sysNode;
|
---|
61 |
|
---|
62 | mStatsOn = false;
|
---|
63 | showDebugOverlay(mStatsOn);
|
---|
64 |
|
---|
65 | }
|
---|
66 |
|
---|
67 | bool frameStarted(const FrameEvent& evt)
|
---|
68 | {
|
---|
69 | if(framecount == 20)//some initialization problem
|
---|
70 | {
|
---|
71 | PP_tonemapON = true;
|
---|
72 | PP_glowON = true;
|
---|
73 | PP_dofON = true;
|
---|
74 | CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
|
---|
75 | "GTP/Moria/PostProc/Glow", true);
|
---|
76 | CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
|
---|
77 | "GTP/Moria/PostProc/ToneMap", true);
|
---|
78 | CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
|
---|
79 | "GTP/Moria/PostProc/DoF", true);
|
---|
80 | }
|
---|
81 |
|
---|
82 | float thisTime = (float) Root::getSingleton().getTimer()->getMilliseconds() / 2000.0f;
|
---|
83 | thisTime= 0;
|
---|
84 | //mainLightNode->setPosition(Vector3(2*cos(thisTime), 2, 2 * sin(thisTime)) + Vector3(5, 0, 5));
|
---|
85 | Vector3 pos = light->getDerivedPosition();
|
---|
86 | pos.normalise();
|
---|
87 | pos *= -1;
|
---|
88 | //light->setDirection( pos);
|
---|
89 |
|
---|
90 | framecount++;
|
---|
91 |
|
---|
92 | // mAnimState->addTime(evt.timeSinceLastFrame * 1.0);
|
---|
93 |
|
---|
94 |
|
---|
95 | //sysNode->setPosition(mCamera->getPosition() - Vector3(0,1.5,0));
|
---|
96 | //sysNode->setPosition(FPSPlayer::thePlayer->getPosition() - Vector3(0,1.5,0));
|
---|
97 |
|
---|
98 | return ExampleFrameListener::frameStarted(evt);
|
---|
99 | }
|
---|
100 |
|
---|
101 | bool processUnbufferedKeyInput(const FrameEvent& evt)
|
---|
102 | {
|
---|
103 | if(capture)
|
---|
104 | {
|
---|
105 | if (mInputDevice->isKeyDown(KC_F2) && mTimeUntilNextToggle <= 0)
|
---|
106 | {
|
---|
107 | TexturePtr tex = TextureManager::getSingleton().getByName("SCREENSHOT");
|
---|
108 | for(int i = 0; i< 30; i++)
|
---|
109 | tex->getBuffer()->getRenderTarget()->update();
|
---|
110 | tex->getBuffer()->getRenderTarget()->writeContentsToFile(String("screen") + StringConverter::toString(framecount) + ".tga");
|
---|
111 | mTimeUntilNextToggle = 0.5;
|
---|
112 | }
|
---|
113 | }
|
---|
114 | if (mInputDevice->isKeyDown(KC_F3) && mTimeUntilNextToggle <= 0)
|
---|
115 | {
|
---|
116 | TexturePtr tex = TextureManager::getSingleton().getByName("Troll_SE_0_COLORCUBEMAP");
|
---|
117 | for (int i = 0; i < 6; i++)
|
---|
118 | tex->getBuffer(i)->getRenderTarget()->writeContentsToFile(String("face") + StringConverter::toString(i) + ".tga");
|
---|
119 | mTimeUntilNextToggle = 0.5;
|
---|
120 | }
|
---|
121 |
|
---|
122 |
|
---|
123 | if (mInputDevice->isKeyDown(KC_ADD) && mTimeUntilNextToggle <= 0)
|
---|
124 | {
|
---|
125 | if (mInputDevice->isKeyDown(KC_RSHIFT))
|
---|
126 | lightpower /= 1.2;
|
---|
127 | else
|
---|
128 | lightpower *= 1.2;
|
---|
129 | light->setPowerScale(lightpower);
|
---|
130 | mTimeUntilNextToggle = 0.2;
|
---|
131 | mWindow->setDebugText(String("LightPower ") + StringConverter::toString(lightpower));
|
---|
132 | }
|
---|
133 | if (mInputDevice->isKeyDown(KC_SUBTRACT) && mTimeUntilNextToggle <= 0)
|
---|
134 | {
|
---|
135 | if (mInputDevice->isKeyDown(KC_RSHIFT))
|
---|
136 | CharacterGroupOrigo->translate(0,0,-evt.timeSinceLastFrame);
|
---|
137 | else
|
---|
138 | CharacterGroupOrigo->translate(0,0,evt.timeSinceLastFrame);
|
---|
139 | }
|
---|
140 | if (mInputDevice->isKeyDown(KC_MULTIPLY) && mTimeUntilNextToggle <= 0)
|
---|
141 | {
|
---|
142 | if (mInputDevice->isKeyDown(KC_RSHIFT))
|
---|
143 | glowTimeBlur /= 1.2;
|
---|
144 | else
|
---|
145 | glowTimeBlur *= 1.2;
|
---|
146 | Ogre::Material* m = (Ogre::Material*) MaterialManager::getSingleton().getByName("GTP/Moria/PostProc/GlowCut").getPointer();
|
---|
147 | m->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("timeBlur", glowTimeBlur);
|
---|
148 | mTimeUntilNextToggle = 0.2;
|
---|
149 | mWindow->setDebugText(String("GlowTimeBlur ") + StringConverter::toString(glowTimeBlur));
|
---|
150 | }
|
---|
151 | if (mInputDevice->isKeyDown(KC_M))
|
---|
152 | {
|
---|
153 | if (mInputDevice->isKeyDown(KC_RSHIFT))
|
---|
154 | glowStrech -= 0.01;
|
---|
155 | else
|
---|
156 | glowStrech += 0.01;
|
---|
157 | Ogre::Material* m = (Ogre::Material*) MaterialManager::getSingleton().getByName("GTP/Moria/PostProc/GlowBlurH").getPointer();
|
---|
158 | m->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("Stretch", glowStrech);
|
---|
159 | m = (Ogre::Material*) MaterialManager::getSingleton().getByName("GTP/Moria/PostProc/GlowBlurV").getPointer();
|
---|
160 | m->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("Stretch", glowStrech);
|
---|
161 | mWindow->setDebugText(String("GlowStretch ") + StringConverter::toString(glowStrech));
|
---|
162 | }
|
---|
163 | if (mInputDevice->isKeyDown(KC_N))
|
---|
164 | {
|
---|
165 | if (mInputDevice->isKeyDown(KC_RSHIFT))
|
---|
166 | glowCombine -= 0.01;
|
---|
167 | else
|
---|
168 | glowCombine += 0.01;
|
---|
169 | Ogre::Material* m = (Ogre::Material*) MaterialManager::getSingleton().getByName("GTP/Moria/GlowFinalCombine").getPointer();
|
---|
170 | m->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("weight2", glowCombine);
|
---|
171 | mTimeUntilNextToggle = 0.2;
|
---|
172 | mWindow->setDebugText(String("GlowCombine ") + StringConverter::toString(glowCombine));
|
---|
173 | }
|
---|
174 |
|
---|
175 | if (mInputDevice->isKeyDown(KC_3) && mTimeUntilNextToggle <= 0)
|
---|
176 | {
|
---|
177 | PP_glowON = !PP_glowON;
|
---|
178 | CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
|
---|
179 | "GTP/Moria/PostProc/Glow", PP_glowON);
|
---|
180 | mTimeUntilNextToggle = 0.2;
|
---|
181 | }
|
---|
182 | if (mInputDevice->isKeyDown(KC_4) && mTimeUntilNextToggle <= 0)
|
---|
183 | {
|
---|
184 | PP_tonemapON = !PP_tonemapON;
|
---|
185 |
|
---|
186 | CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
|
---|
187 | "GTP/PostProc/ToneMap", PP_tonemapON);
|
---|
188 |
|
---|
189 | mTimeUntilNextToggle = 0.2;
|
---|
190 | }
|
---|
191 | if (mInputDevice->isKeyDown(KC_5) && mTimeUntilNextToggle <= 0)
|
---|
192 | {
|
---|
193 | PP_dofON = !PP_dofON;
|
---|
194 | CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
|
---|
195 | "GTP/Moria/PostProc/DoF", PP_dofON);
|
---|
196 | mTimeUntilNextToggle = 0.2;
|
---|
197 | }
|
---|
198 |
|
---|
199 | if (mInputDevice->isKeyDown(KC_I))
|
---|
200 | {
|
---|
201 | light->getParentSceneNode()->setPosition(
|
---|
202 | light->getParentSceneNode()->getPosition()
|
---|
203 | + Vector3(10*evt.timeSinceLastFrame,0,0));
|
---|
204 | }
|
---|
205 | if (mInputDevice->isKeyDown(KC_K))
|
---|
206 | {
|
---|
207 | light->getParentSceneNode()->setPosition(
|
---|
208 | light->getParentSceneNode()->getPosition()
|
---|
209 | + Vector3(-10*evt.timeSinceLastFrame,0,0));
|
---|
210 | }
|
---|
211 | if (mInputDevice->isKeyDown(KC_J))
|
---|
212 | {
|
---|
213 | light->getParentSceneNode()->setPosition(
|
---|
214 | light->getParentSceneNode()->getPosition()
|
---|
215 | + Vector3(0,0,10*evt.timeSinceLastFrame));
|
---|
216 | }
|
---|
217 | if (mInputDevice->isKeyDown(KC_L))
|
---|
218 | {
|
---|
219 | light->getParentSceneNode()->setPosition(
|
---|
220 | light->getParentSceneNode()->getPosition()
|
---|
221 | + Vector3(0,0,-10*evt.timeSinceLastFrame));
|
---|
222 | }
|
---|
223 |
|
---|
224 |
|
---|
225 |
|
---|
226 | return ExampleFrameListener::processUnbufferedKeyInput(evt);
|
---|
227 | }
|
---|
228 |
|
---|
229 | bool processUnbufferedMouseInput(const FrameEvent& evt)
|
---|
230 | {
|
---|
231 | return ExampleFrameListener::processUnbufferedMouseInput(evt);
|
---|
232 | }
|
---|
233 | };
|
---|
234 |
|
---|
235 | /** Application class */
|
---|
236 | class MoriaDemoApplication : public ExampleApplication
|
---|
237 | {
|
---|
238 |
|
---|
239 |
|
---|
240 |
|
---|
241 |
|
---|
242 | protected:
|
---|
243 | SceneNode* mainLightNode;
|
---|
244 | Light* mainLight;
|
---|
245 | SceneNode *pSysNode;
|
---|
246 |
|
---|
247 | void setupResources(void)
|
---|
248 | {
|
---|
249 | // Load resource paths from config file
|
---|
250 | ConfigFile cf;
|
---|
251 | cf.load("resources_moriaScene.cfg");
|
---|
252 |
|
---|
253 | // Go through all sections & settings in the file
|
---|
254 | ConfigFile::SectionIterator seci = cf.getSectionIterator();
|
---|
255 |
|
---|
256 | String secName, typeName, archName;
|
---|
257 | while (seci.hasMoreElements())
|
---|
258 | {
|
---|
259 | secName = seci.peekNextKey();
|
---|
260 | ConfigFile::SettingsMultiMap *settings = seci.getNext();
|
---|
261 | ConfigFile::SettingsMultiMap::iterator i;
|
---|
262 | for (i = settings->begin(); i != settings->end(); ++i)
|
---|
263 | {
|
---|
264 | typeName = i->first;
|
---|
265 | archName = i->second;
|
---|
266 | ResourceGroupManager::getSingleton().addResourceLocation(
|
---|
267 | archName, typeName, secName);
|
---|
268 | }
|
---|
269 | }
|
---|
270 | }
|
---|
271 | void loadResources(void)
|
---|
272 | {
|
---|
273 | // Initialise, parse scripts etc
|
---|
274 | ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");
|
---|
275 | ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Basic");
|
---|
276 | ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
|
---|
277 | ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_EnvMap");
|
---|
278 | ResourceGroupManager::getSingleton().initialiseResourceGroup("PostProc");
|
---|
279 | ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Particles");
|
---|
280 | ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_PathMap");
|
---|
281 | ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_MoriaScene");
|
---|
282 | //ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Diffuse");
|
---|
283 | //ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Caustic");
|
---|
284 | }
|
---|
285 |
|
---|
286 | void createPostproc()
|
---|
287 | {
|
---|
288 | if(!capture)
|
---|
289 | {
|
---|
290 | CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0),
|
---|
291 | "FireHeatCompositor");
|
---|
292 | CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
|
---|
293 | "FireHeatCompositor", true);
|
---|
294 |
|
---|
295 | CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0),
|
---|
296 | "GTP/Moria/PostProc/DoF");
|
---|
297 | CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
|
---|
298 | "GTP/Moria/PostProc/DoF", PP_dofON);
|
---|
299 |
|
---|
300 | CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0),
|
---|
301 | "GTP/Moria/PostProc/Glow");
|
---|
302 | CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
|
---|
303 | "GTP/Moria/PostProc/Glow", PP_glowON);
|
---|
304 |
|
---|
305 |
|
---|
306 | CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0),
|
---|
307 | "GTP/PostProc/ToneMap");
|
---|
308 | CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
|
---|
309 | "GTP/PostProc/ToneMap", PP_tonemapON);
|
---|
310 |
|
---|
311 | /*CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0),
|
---|
312 | "GTP/PostProc/MotionBlur");
|
---|
313 | CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
|
---|
314 | "GTP/PostProc/MotionBlur", false);*/
|
---|
315 | }
|
---|
316 | else
|
---|
317 | {
|
---|
318 | TexturePtr tex = TextureManager::getSingleton().getByName("SCREENSHOT");
|
---|
319 | Viewport* vp = tex->getBuffer()->getRenderTarget()->getViewport(0);
|
---|
320 |
|
---|
321 | CompositorManager::getSingleton().addCompositor(vp,
|
---|
322 | "FireHeatCompositor");
|
---|
323 | CompositorManager::getSingleton().setCompositorEnabled(vp,
|
---|
324 | "FireHeatCompositor", true);
|
---|
325 |
|
---|
326 | CompositorManager::getSingleton().addCompositor(vp,
|
---|
327 | "GTP/Moria/PostProc/DoF");
|
---|
328 | CompositorManager::getSingleton().setCompositorEnabled(vp,
|
---|
329 | "GTP/Moria/PostProc/DoF", true);
|
---|
330 |
|
---|
331 | CompositorManager::getSingleton().addCompositor(vp,
|
---|
332 | "GTP/Moria/PostProc/Glow");
|
---|
333 | CompositorManager::getSingleton().setCompositorEnabled(vp,
|
---|
334 | "GTP/Moria/PostProc/Glow", true);
|
---|
335 |
|
---|
336 |
|
---|
337 | CompositorManager::getSingleton().addCompositor(vp,
|
---|
338 | "GTP/PostProc/ToneMap");
|
---|
339 | CompositorManager::getSingleton().setCompositorEnabled(vp,
|
---|
340 | "GTP/PostProc/ToneMap", true);
|
---|
341 | }
|
---|
342 |
|
---|
343 | }
|
---|
344 |
|
---|
345 | void chooseSceneManager()
|
---|
346 | {
|
---|
347 | mSceneMgr = mRoot->createSceneManager("OctreeSceneManager");
|
---|
348 | }
|
---|
349 |
|
---|
350 | void createScene(void) ///TOWERS
|
---|
351 | {
|
---|
352 |
|
---|
353 |
|
---|
354 | //Overlay* mainOverlay = OverlayManager::getSingleton().getByName("MORIA/MainOverlay");
|
---|
355 | //mainOverlay->show();
|
---|
356 | if(capture)
|
---|
357 | {
|
---|
358 | TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual( "SCREENSHOT",
|
---|
359 | "default",
|
---|
360 | TEX_TYPE_2D,
|
---|
361 | 2048,
|
---|
362 | 1536,
|
---|
363 | 0,
|
---|
364 | 0,
|
---|
365 | PF_R8G8B8,
|
---|
366 | TU_RENDERTARGET);
|
---|
367 | Texture* screenTexture = texPtr.getPointer();
|
---|
368 | RenderTexture* rt = screenTexture->getBuffer()->getRenderTarget();
|
---|
369 | Viewport* vp = rt->addViewport(mCamera);
|
---|
370 | rt->setAutoUpdated(false);
|
---|
371 | vp->setOverlaysEnabled(false);
|
---|
372 | }
|
---|
373 |
|
---|
374 | createPostproc();
|
---|
375 |
|
---|
376 | OgreIlluminationManager::getSingleton().setMainCamera(mCamera);
|
---|
377 | OgreIlluminationManager::getSingleton().setMainViewport(mWindow->getViewport(0));
|
---|
378 | OgreIlluminationManager::getSingleton().setFocusingSM(false);
|
---|
379 | OgreIlluminationManager::getSingleton().setShadowMapSize(128);
|
---|
380 | OgreIlluminationManager::getSingleton().setBlurShadowMap(true);
|
---|
381 | OgreIlluminationManager::getSingleton().setShadowMapMaterialName(Light::LT_SPOTLIGHT, "GTP/Basic/Distance_Normalized");//GameTools/ShadowMapDistance
|
---|
382 | OgreIlluminationManager::getSingleton().setShadowMapMaterialName(Light::LT_POINT, "GTP/Basic/Distance_Normalized");
|
---|
383 | OgreIlluminationManager::getSingleton().setUseLISPSM(false);
|
---|
384 | OgreIlluminationManager::getSingleton().joinSharedRuns(false);
|
---|
385 |
|
---|
386 | Root::getSingleton()._setCurrentSceneManager(mSceneMgr);
|
---|
387 | mCamera->setPosition(0,12,20);
|
---|
388 | //mCamera->setPosition(0,100,0);
|
---|
389 | mCamera->lookAt(15,5,0);
|
---|
390 | mCamera->setFOVy(Radian(Degree(65)));
|
---|
391 | mCamera->setNearClipDistance(0.1);
|
---|
392 | mCamera->setFarClipDistance(500);
|
---|
393 | // Set ambient light
|
---|
394 | mSceneMgr->setAmbientLight(ColourValue(0.1, 0.1, 0.1));
|
---|
395 | mSceneMgr->setSkyBox(true, "Examples/EveningSkyBox", 500);
|
---|
396 |
|
---|
397 | SceneNode* rootNode = mSceneMgr->getRootSceneNode();
|
---|
398 |
|
---|
399 | SceneSerializer s(mSceneMgr);
|
---|
400 | DataStreamPtr inputStream;
|
---|
401 | inputStream = ResourceGroupManager::getSingleton().openResource("MoriaScene.level"); //towers2.level
|
---|
402 | s.parseScript(inputStream, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
|
---|
403 | s.parseEntryPoints("MoriaSceneEntryPoints.text");
|
---|
404 |
|
---|
405 |
|
---|
406 | mainLight = mSceneMgr->createLight("MainLight");
|
---|
407 | mainLight->setType(Light::LT_POINT);
|
---|
408 | //mainLight->setCastShadows(true);
|
---|
409 | mainLight->setDiffuseColour(ColourValue::White);
|
---|
410 | mainLight->setSpecularColour(ColourValue::White);
|
---|
411 | mainLightNode = rootNode->createChildSceneNode();
|
---|
412 |
|
---|
413 | mainLightNode->setPosition(0,9,-190);
|
---|
414 | mainLight->setPowerScale(30000);
|
---|
415 | //mainLight->setDirection(1,0, 0);
|
---|
416 | mainLightNode->attachObject(mainLight);
|
---|
417 | //mainLight->setSpotlightRange(Degree(0),Degree(120));
|
---|
418 | mainLight->setAttenuation(1000.0, 0, 0, 3);
|
---|
419 |
|
---|
420 | CharacterGroupOrigo = rootNode->createChildSceneNode("CharactersOrigo");
|
---|
421 | ParticleSystem* mFireBall = mSceneMgr->createParticleSystem("FPS_PLAYER_FIREBALL", "Moria/FireBall");
|
---|
422 |
|
---|
423 | Light* mFireBallLight = mSceneMgr->createLight("FireBallLight");
|
---|
424 | mFireBallLight->setType(Light::LT_POINT);
|
---|
425 | mFireBallLight->setCastShadows(true);
|
---|
426 | mFireBallLight->setDiffuseColour(ColourValue(0.95,0.98,0.8));
|
---|
427 | mFireBallLight->setPowerScale(1000);
|
---|
428 | mFireBallLight->setAttenuation(1000.0, 0, 0, 6);
|
---|
429 | mFireBallLight->setPosition(0,1,0);
|
---|
430 | SceneNode* fireballNode = CharacterGroupOrigo ->createChildSceneNode("fireBallNode");
|
---|
431 | fireballNode->setPosition(-0.55, 8.74, -2.37 + 10);
|
---|
432 | fireballNode->attachObject(mFireBallLight);
|
---|
433 | fireballNode->attachObject(mFireBall);
|
---|
434 |
|
---|
435 |
|
---|
436 | BillboardSet* bbs = mSceneMgr->createBillboardSet("bb", 1);
|
---|
437 | bbs->setDefaultDimensions(2.3, 2.3);
|
---|
438 | bbs->createBillboard(Vector3::ZERO, ColourValue::White);
|
---|
439 | bbs->setMaterialName("Flare");
|
---|
440 | mainLightNode->attachObject(bbs);
|
---|
441 |
|
---|
442 | Entity* troll = mSceneMgr->createEntity("Troll", "trollMed.mesh");
|
---|
443 | troll->setCastShadows(true);
|
---|
444 | SceneNode* trollNode = CharacterGroupOrigo ->createChildSceneNode("trollNode");
|
---|
445 | trollNode->setPosition(0,0,10);
|
---|
446 | trollNode->attachObject(troll);
|
---|
447 |
|
---|
448 | //troll->setMaterialName("MoriaScene/Troll");
|
---|
449 | //trollNode->setScale(0.3,0.3,0.3);
|
---|
450 |
|
---|
451 | Entity* guard = mSceneMgr->createEntity("Guard", "guard.mesh");
|
---|
452 | guard->setCastShadows(true);
|
---|
453 | SceneNode* guardNode = CharacterGroupOrigo ->createChildSceneNode("guardNode");
|
---|
454 | guardNode->setPosition(0,0,10);
|
---|
455 | guardNode->attachObject(guard);
|
---|
456 |
|
---|
457 |
|
---|
458 | OgreIlluminationManager::getSingleton().initTechniques();
|
---|
459 | }
|
---|
460 |
|
---|
461 | void createPlane(Ogre::String _name, Ogre::String _material, Ogre::Vector3 _pos, Ogre::Vector2 _size, Ogre::Vector2 _subdivisions = Ogre::Vector2(1,1))
|
---|
462 | {
|
---|
463 | Plane _plane;
|
---|
464 | _plane.normal = Vector3::UNIT_Y;
|
---|
465 | _plane.d = 0;
|
---|
466 |
|
---|
467 |
|
---|
468 | MeshManager::getSingleton().createPlane(_name + ".plane",
|
---|
469 | ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
---|
470 | _plane,_size.x,_size.y,1,1,true,1,_subdivisions.x,_subdivisions.y,Vector3::UNIT_Z);
|
---|
471 |
|
---|
472 | Entity *_entity = mSceneMgr->createEntity(_name + ".entity", _name + ".plane");
|
---|
473 | _entity->setMaterialName(_material);
|
---|
474 |
|
---|
475 | SceneNode* _node = mSceneMgr->getRootSceneNode()->createChildSceneNode(_name + ".node");
|
---|
476 | _node->attachObject(_entity);
|
---|
477 | _node->setPosition(_pos);
|
---|
478 |
|
---|
479 | }
|
---|
480 |
|
---|
481 | void createFrameListener(void)
|
---|
482 | {
|
---|
483 | // This is where we instantiate our own frame listener
|
---|
484 | mFrameListener= new MoriaDemoFrameListener(mWindow,
|
---|
485 | mCamera, mainLightNode, mainLight, pSysNode );
|
---|
486 | mFrameListener->setPriority(10);
|
---|
487 | mRoot->addFrameListener(mFrameListener);
|
---|
488 | OgreIlluminationManager::getSingleton().setPriority(100);
|
---|
489 | mRoot->addFrameListener(&OgreIlluminationManager::getSingleton());
|
---|
490 |
|
---|
491 | }
|
---|
492 |
|
---|
493 | };
|
---|
494 |
|
---|