~scrawl-deactivatedaccount/+junk/StuntRally

« back to all changes in this revision

Viewing changes to editor/BaseApp.h

  • Committer: Jannik Heller
  • Date: 2011-01-30 12:41:18 UTC
  • Revision ID: scrawl@scrawl-desktop-20110130124118-v5euo5nkmhjqqd9s
First commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _BaseApp_h_
 
2
#define _BaseApp_h_
 
3
#include <OgreRenderTargetListener.h>
 
4
#include "../ogre/QTimer.h"
 
5
 
 
6
 
 
7
class BaseApp :
 
8
                public Ogre::FrameListener, public Ogre::WindowEventListener,
 
9
                public OIS::KeyListener, public OIS::MouseListener
 
10
                //public Ogre::RenderTargetListener
 
11
{
 
12
public:
 
13
        BaseApp();      virtual ~BaseApp();
 
14
        virtual void Run( bool showDialolg );
 
15
 
 
16
        class SplineRoad* road; //-
 
17
 
 
18
        //AppThr appThr;
 
19
        HANDLE hpr;  QTimer timer;
 
20
        void OnTimer(double dTime);
 
21
        bool mShutDown;
 
22
protected:
 
23
        bool mShowDialog;//, mShutDown;
 
24
        bool setup(), configure();  void updateStats();
 
25
 
 
26
        ///  create
 
27
        virtual void createScene() = 0;
 
28
        virtual void destroyScene();
 
29
 
 
30
        void createCamera(), createFrameListener();
 
31
        void setupResources(), createResourceListener(), loadResources();
 
32
        SceneNode* ndSky; //-
 
33
 
 
34
        ///  frame events
 
35
        virtual bool frameStarted(const FrameEvent& evt);
 
36
        virtual bool frameRenderingQueued(const FrameEvent& evt);
 
37
        virtual bool frameEnded(const FrameEvent& evt);
 
38
        virtual void processMouse() { }
 
39
        
 
40
        ///  input events
 
41
        /*virtual*/
 
42
        virtual bool keyPressed(const OIS::KeyEvent &arg);
 
43
        virtual bool keyReleased(const OIS::KeyEvent &arg);
 
44
 
 
45
        bool mouseMoved(const OIS::MouseEvent &arg);
 
46
        bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
 
47
        bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
 
48
        void windowResized(RenderWindow* rw), windowClosed(RenderWindow* rw);
 
49
 
 
50
        ///  input event queues  for gui  ------------------------------------
 
51
        struct CmdKey {  public:
 
52
                //OIS::KeyEvent key;
 
53
                OIS::KeyCode key;
 
54
                unsigned int text;  bool gui;
 
55
                CmdKey() : key(OIS::KC_UNASSIGNED), text(0) {  }
 
56
                CmdKey(const OIS::KeyEvent& k) : key(k.key), text(k.text) {  }
 
57
        };
 
58
        struct CmdMouseMove {  public:
 
59
                OIS::MouseState ms;
 
60
                CmdMouseMove() {  }
 
61
                CmdMouseMove(const OIS::MouseEvent& m) : ms(m.state) {  }
 
62
        };
 
63
        struct CmdMouseBtn  {  public:
 
64
                OIS::MouseState ms;  OIS::MouseButtonID btn;
 
65
                CmdMouseBtn() {  }
 
66
                CmdMouseBtn(const OIS::MouseEvent& m, OIS::MouseButtonID b) : ms(m.state),btn(b) {  }
 
67
        };
 
68
        #define cmd_Max 1024
 
69
        //std::deque<CmdKey> cmdKeyPress, cmdKeyRel;
 
70
        //std::deque<CmdMouseMove> cmdMouseMove;
 
71
        //std::deque<CmdMouseBtn> cmdMousePress, cmdMouseRel;
 
72
        CmdKey* cmdKeyPress, *cmdKeyRel;  int i_cmdKeyPress, i_cmdKeyRel;
 
73
        CmdMouseMove* cmdMouseMove;  int i_cmdMouseMove;
 
74
        CmdMouseBtn* cmdMousePress, *cmdMouseRel;  int i_cmdMousePress, i_cmdMouseRel;
 
75
 
 
76
 
 
77
        ///  Ogre
 
78
        Root *mRoot;  SceneManager* mSceneMgr;
 
79
        Viewport* mViewport;  RenderWindow* mWindow;
 
80
        Camera* mCamera, *mCameraT;
 
81
        Vector3 /*mCamPosPrv,mCamDirPrv,*/mCamPosOld,mCamDirOld;
 
82
        
 
83
        ///  input
 
84
        OIS::InputManager* mInputManager;
 
85
        OIS::Mouse* mMouse;  OIS::Keyboard* mKeyboard;
 
86
 
 
87
 
 
88
        ///  ovelay
 
89
        Overlay* mDebugOverlay;
 
90
        OverlayElement* ovFps, *ovTri, *ovBat,  *ovSt,
 
91
                *ovPos, *ovDbg, *ovInfo, *ovStat, *ovFocus, *ovFocBck;  Real fStFade;
 
92
 
 
93
        bool alt, ctrl, shift;  // key modifiers
 
94
        bool mbLeft, mbRight, mbMiddle;  // mouse buttons
 
95
        String  mDebugText, mFilText;   // info texts
 
96
        bool mbWireFrame, mShowCamPos, mStatsOn;
 
97
        char s[512];
 
98
 
 
99
 
 
100
        ///  camera upd
 
101
        bool bMoveCam;  int mx,my,mz;  double mDTime;
 
102
        Real mRotX, mRotY,  mRotKX, mRotKY,  moveMul, rotMul;
 
103
        Vector3 mTrans;
 
104
        enum ED_MODE {  ED_Deform=0, ED_Smooth, /*ED_Paint,*/ ED_Road, ED_Start, ED_PrvCam, ED_ALL  }
 
105
                edMode,edModeOld;
 
106
 
 
107
 
 
108
        ///  Gui
 
109
        bool bGuiFocus;  // gui shown
 
110
        MyGUI::Gui* mGUI;       MyGUI::OgrePlatform* mPlatform;
 
111
        MyGUI::WidgetPtr mWndOpts, mWndBrush, mWndCam,
 
112
                mWndRoadCur, mWndRoadNew, mWndRoadStats;  // gui windows
 
113
        MyGUI::TabPtr mWndTabs;
 
114
        
 
115
public:
 
116
        inline bool bCam()  {  return  bMoveCam && !bGuiFocus;  }
 
117
        inline bool bEdit() {  return !bMoveCam && !bGuiFocus;  }
 
118
        
 
119
};
 
120
#endif
 
 
b'\\ No newline at end of file'