source: OGRE/trunk/ogrenew/Samples/ParticleFX/include/ParticleFX.h @ 692

Revision 692, 4.0 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

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-2005 The OGRE Team
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
41        // Rotate fountains
42        mFountainNode->yaw(Degree(evt.timeSinceLastFrame * 30));
43
44        // Call default
45        return ExampleFrameListener::frameStarted(evt);
46
47    }
48};
49
50
51
52class ParticleApplication : public ExampleApplication
53{
54public:
55    ParticleApplication() {}
56
57protected:
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
67       
68        Entity *ent = mSceneMgr->createEntity("head", "ogrehead.mesh");
69
70        // Add entity to the root scene node
71        mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
72
73
74        // Green nimbus around Ogre
75        ParticleSystem* pSys1 = mSceneMgr->createParticleSystem("Nimbus",
76            "Examples/GreenyNimbus");
77        mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pSys1);
78
79
80        // Create shared node for 2 fountains
81        mFountainNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
82
83        // fountain 1
84        ParticleSystem* pSys2 = mSceneMgr->createParticleSystem("fountain1",
85            "Examples/PurpleFountain");
86        // Point the fountain at an angle
87        SceneNode* fNode = mFountainNode->createChildSceneNode();
88        fNode->translate(200,-100,0);
89        fNode->rotate(Vector3::UNIT_Z, Degree(20));
90        fNode->attachObject(pSys2);
91
92        // fountain 2
93        ParticleSystem* pSys3 = mSceneMgr->createParticleSystem("fountain2",
94            "Examples/PurpleFountain");
95        // Point the fountain at an angle
96        fNode = mFountainNode->createChildSceneNode();
97        fNode->translate(-200,-100,0);
98        fNode->rotate(Vector3::UNIT_Z, Degree(-20));
99        fNode->attachObject(pSys3);
100
101
102
103
104        // Create a rainstorm
105        ParticleSystem* pSys4 = mSceneMgr->createParticleSystem("rain",
106            "Examples/Rain");
107        SceneNode* rNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
108        rNode->translate(0,1000,0);
109        rNode->attachObject(pSys4);
110        // Fast-forward the rain so it looks more natural
111        pSys4->fastForward(5);
112
113
114        // Aureola around Ogre perpendicular to the ground
115        ParticleSystem* pSys5 = mSceneMgr->createParticleSystem("Aureola",
116            "Examples/Aureola");
117        mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pSys5);
118
119                // Set nonvisible timeout
120                ParticleSystem::setDefaultNonVisibleUpdateTimeout(5);
121    }
122
123    // Create new frame listener
124    void createFrameListener(void)
125    {
126        mFrameListener= new ParticleFrameListener(mWindow, mCamera, mFountainNode);
127        mRoot->addFrameListener(mFrameListener);
128    }
129
130
131};
132
Note: See TracBrowser for help on using the repository browser.