Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogreode/demos/SimpleScenes/include/SimpleScenesApplication.h @ 21

Last change on this file since 21 was 21, checked in by nicolasc, 16 years ago

added ogreode and Colladaplugin

File size: 3.7 KB
Line 
1/*
2SimpleScenesApplication.h
3------------------------
4Defintion of the class responsible for running the OgreOde
5demo scenes. Wrangles input and the various different test
6scenes into a single application. Extends the ExampleApplication
7and ExampleFrameListener classes.
8*/
9#ifndef _SIMPLESCENESAPPLICATION_H_
10#define _SIMPLESCENESAPPLICATION_H_
11
12// Include the OgreOde interface which includes Ogre itself
13#include "OgreOde_Core.h"
14#include "ExampleApplication.h"
15
16#if !(OGRE_VERSION_MINOR < 4)
17    using namespace OIS;
18#endif //OGRE_VERSION not heihort
19
20// Our framework class for the different tests
21#include "SimpleScenes.h"
22
23class SimpleScenesApplication;
24
25/*
26A frame listener that does default processing before deferring to the main application
27*/
28class SimpleScenesFrameListener:public ExampleFrameListener
29{
30public:
31        // Standard example constructor with one additional parameter
32        SimpleScenesFrameListener(SimpleScenesApplication* demo,RenderWindow* win,Camera* cam) : 
33      ExampleFrameListener(win,cam),
34      _demo(demo)
35        {
36                mMoveSpeed = 15.0;
37        }
38        ~SimpleScenesFrameListener(){}
39
40        bool frameStarted(const FrameEvent& evt);
41        bool frameEnded(const FrameEvent& evt);
42
43protected:
44        // Keep track of the application that created us
45        SimpleScenesApplication* _demo;
46};
47
48/*
49The test application, based on the Ogre example application for consistency
50*/
51class SimpleScenesApplication: public ExampleApplication
52{
53        // The frame listener gets access to some special things
54        friend class SimpleScenesFrameListener;
55
56public:
57        // Standard constructor/destructor
58    SimpleScenesApplication() : 
59      ExampleApplication()
60        {
61                _test = 0;
62                _plane = 0;
63                _stepper = 0;   
64                _world = 0;
65
66                _time_elapsed = 0.0;
67                _time_step = SimpleScenes::STEP_RATE;
68                _looking = _chasing = false;
69                _paused = false;
70        }
71    ~SimpleScenesApplication();
72
73protected:
74        // Override stuff from the base class
75    void createScene(void);     
76    void createFrameListener(void)
77    {
78        mFrameListener= new SimpleScenesFrameListener(this,mWindow,mCamera);
79        mRoot->addFrameListener(mFrameListener);
80    }
81    void chooseSceneManager(void)
82    {
83        mSceneMgr = mRoot->createSceneManager( ST_GENERIC, "basicsm" );
84    }
85
86        // Add the standard resources, plus our own pack
87        void setupResources(void)
88    {
89                ExampleApplication::setupResources(); 
90                ResourceGroupManager *rsm = ResourceGroupManager::getSingletonPtr();
91                StringVector groups = rsm->getResourceGroups();       
92                if (std::find(groups.begin(), groups.end(), String("OgreOde")) == groups.end())
93                {
94                        FileInfoListPtr finfo =  ResourceGroupManager::getSingleton().findResourceFileInfo (
95                                "Bootstrap", "axes.mesh");
96
97                        const bool isSDK =  (!finfo->empty()) && 
98                                StringUtil::startsWith (finfo->begin()->archive->getName(), "../../media/packs/ogrecore.zip", true);
99
100                        rsm->createResourceGroup("OgreOde");
101                        if (isSDK)
102                        {
103                                rsm->addResourceLocation("../../../ogreode/demos/Media","FileSystem", "OgreOde");
104                        }
105                        else
106                        {
107                                rsm->addResourceLocation("../../../../../ogreaddons/ogreode/demos/Media","FileSystem", "OgreOde");
108                        }
109                }
110        }
111
112    // The frame listener will call these       
113
114#if (OGRE_VERSION_MINOR < 4)
115    void frameStarted(const FrameEvent& evt,InputReader* mInputDevice);
116    void frameEnded(const FrameEvent& evt,InputReader* mInputDevice);
117#else
118    void frameStarted(const FrameEvent& evt, OIS::Keyboard* input, OIS::Mouse* mouse);
119    void frameEnded(const FrameEvent& evt, OIS::Keyboard* input, OIS::Mouse* mouse);
120#endif //OGRE_VERSION not heihort
121
122
123       
124protected:
125        OgreOde::World*                                 _world;
126        OgreOde::StepHandler*                   _stepper;
127        OgreOde::InfinitePlaneGeometry* _plane;
128        SimpleScenes*                                   _test;
129
130        Real    _delay,_time_elapsed,_time_step;
131        Light*  _spot;
132        bool    _looking,_chasing,_paused;
133};
134
135#endif
Note: See TracBrowser for help on using the repository browser.