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 | Filename: ParticleApplication.cpp
|
---|
17 | Description: Specialisation of OGRE's framework application to show the
|
---|
18 | environment mapping feature.
|
---|
19 | -----------------------------------------------------------------------------
|
---|
20 | */
|
---|
21 |
|
---|
22 |
|
---|
23 | #include "ExampleApplication.h"
|
---|
24 |
|
---|
25 |
|
---|
26 | // Event handler to add ability to alter curvature
|
---|
27 | class ParticleFrameListener : public ExampleFrameListener
|
---|
28 | {
|
---|
29 | protected:
|
---|
30 | SceneNode* mFountainNode;
|
---|
31 | public:
|
---|
32 | ParticleFrameListener(RenderWindow* win, Camera* cam, SceneNode* fountainNode)
|
---|
33 | : ExampleFrameListener(win, cam)
|
---|
34 | {
|
---|
35 | mFountainNode = fountainNode;
|
---|
36 | }
|
---|
37 |
|
---|
38 | bool frameStarted(const FrameEvent& evt)
|
---|
39 | {
|
---|
40 |
|
---|
41 | // Rotate fountains
|
---|
42 | // mFountainNode->yaw(evt.timeSinceLastFrame * 30);
|
---|
43 |
|
---|
44 | // Call default
|
---|
45 | return ExampleFrameListener::frameStarted(evt);
|
---|
46 |
|
---|
47 | }
|
---|
48 | };
|
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 | class ParticleApplication : public ExampleApplication
|
---|
53 | {
|
---|
54 | public:
|
---|
55 | ParticleApplication() {}
|
---|
56 |
|
---|
57 | protected:
|
---|
58 | SceneNode* mFountainNode;
|
---|
59 |
|
---|
60 | // Just override the mandatory create scene method
|
---|
61 | void createScene(void)
|
---|
62 | {
|
---|
63 | // Set ambient light
|
---|
64 | mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
|
---|
65 |
|
---|
66 | // Create a skydome
|
---|
67 | mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8);
|
---|
68 |
|
---|
69 |
|
---|
70 | // Create shared node for 2 fountains
|
---|
71 | mFountainNode = static_cast<SceneNode*>(mSceneMgr->getRootSceneNode()->createChild());
|
---|
72 |
|
---|
73 | // smoke
|
---|
74 | ParticleSystem* pSys2 = mSceneMgr->createParticleSystem("fountain1",
|
---|
75 | "Examples/Smoke");
|
---|
76 | // Point the fountain at an angle
|
---|
77 | SceneNode* fNode = static_cast<SceneNode*>(mFountainNode->createChild());
|
---|
78 | fNode->attachObject(pSys2);
|
---|
79 |
|
---|
80 | }
|
---|
81 |
|
---|
82 | // Create new frame listener
|
---|
83 | void createFrameListener(void)
|
---|
84 | {
|
---|
85 | mFrameListener= new ParticleFrameListener(mWindow, mCamera, mFountainNode);
|
---|
86 | mRoot->addFrameListener(mFrameListener);
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 | };
|
---|
91 |
|
---|