Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/Samples/ParticleFX/include/ParticleFX.h @ 3

Last change on this file since 3 was 3, checked in by anonymous, 17 years ago

=update

File size: 4.1 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2006 Torus Knot Software Ltd
8Also see acknowledgements in Readme.html
9
10You may use this sample code for anything you like, it is not covered by the
11LGPL like the rest of the engine.
12-----------------------------------------------------------------------------
13*/
14/*
15-----------------------------------------------------------------------------
16Filename:    ParticleApplication.cpp
17Description: 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
27class ParticleFrameListener : public ExampleFrameListener
28{
29protected:
30    SceneNode* mFountainNode;
31public:
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        if( ExampleFrameListener::frameStarted(evt) == false )
41            return false;
42        // Rotate fountains
43        mFountainNode->yaw(Degree(evt.timeSinceLastFrame * 30));
44
45        // Call default
46        return true;
47
48    }
49};
50
51
52
53class ParticleApplication : public ExampleApplication
54{
55public:
56    ParticleApplication() {}
57
58protected:
59    SceneNode* mFountainNode;
60
61    // Just override the mandatory create scene method
62    void createScene(void)
63    {
64        // Set ambient light
65        mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
66
67
68
69        Entity *ent = mSceneMgr->createEntity("head", "ogrehead.mesh");
70
71        // Add entity to the root scene node
72        mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
73
74
75        // Green nimbus around Ogre
76        //mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(
77        //        mSceneMgr->createParticleSystem("Nimbus", "Examples/GreenyNimbus"));
78
79        // Create some nice fireworks
80        mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(
81                mSceneMgr->createParticleSystem("Fireworks", "Examples/Fireworks"));
82
83        // Create shared node for 2 fountains
84        mFountainNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
85
86        // fountain 1
87        ParticleSystem* pSys2 = mSceneMgr->createParticleSystem("fountain1",
88            "Examples/PurpleFountain");
89        // Point the fountain at an angle
90        SceneNode* fNode = mFountainNode->createChildSceneNode();
91        fNode->translate(200,-100,0);
92        fNode->rotate(Vector3::UNIT_Z, Degree(20));
93        fNode->attachObject(pSys2);
94
95        // fountain 2
96        ParticleSystem* pSys3 = mSceneMgr->createParticleSystem("fountain2",
97            "Examples/PurpleFountain");
98        // Point the fountain at an angle
99        fNode = mFountainNode->createChildSceneNode();
100        fNode->translate(-200,-100,0);
101        fNode->rotate(Vector3::UNIT_Z, Degree(-20));
102        fNode->attachObject(pSys3);
103
104
105
106
107        // Create a rainstorm
108        ParticleSystem* pSys4 = mSceneMgr->createParticleSystem("rain",
109            "Examples/Rain");
110        SceneNode* rNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
111        rNode->translate(0,1000,0);
112        rNode->attachObject(pSys4);
113        // Fast-forward the rain so it looks more natural
114        pSys4->fastForward(5);
115
116
117        // Aureola around Ogre perpendicular to the ground
118        ParticleSystem* pSys5 = mSceneMgr->createParticleSystem("Aureola",
119            "Examples/Aureola");
120        mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pSys5);
121
122                // Set nonvisible timeout
123                ParticleSystem::setDefaultNonVisibleUpdateTimeout(5);
124    }
125
126    // Create new frame listener
127    void createFrameListener(void)
128    {
129        mFrameListener= new ParticleFrameListener(mWindow, mCamera, mFountainNode);
130        mRoot->addFrameListener(mFrameListener);
131    }
132
133
134};
135
Note: See TracBrowser for help on using the repository browser.