source: trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h @ 99

Revision 99, 4.1 KB checked in by mattausch, 19 years ago (diff)
Line 
1/**
2    \file
3        TestCullingTerrainApplication.h
4*/
5#include "CEGUIForwardRefs.h"
6#include "ExampleApplication.h"
7#include "TerrainContentGenerator.h"
8#include "VisibilityEnvironment.h"
9#include <OgreRenderTargetListener.h>
10
11Real timeDelay = 0;
12#define KEY_PRESSED(_key,_timeDelay, _macro) \
13{ \
14    if (mInputDevice->isKeyDown(_key) && timeDelay <= 0) \
15{ \
16    timeDelay = _timeDelay; \
17    _macro ; \
18} \
19}
20
21String mCurrentAlgorithmCaptions[GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS] =
22{
23    "View Frustum Culling",
24        "Stop and Wait Culling",
25        "Coherent Hierarchical Culling"
26};
27
28class VisualizationRenderTargetListener: public RenderTargetListener
29{
30public:
31        VisualizationRenderTargetListener(SceneManager *sceneMgr);
32
33protected:
34        void preViewportUpdate (const RenderTargetViewportEvent &evt);
35        void postRenderTargetUpdate (const RenderTargetEvent &evt);
36
37        SceneManager *mSceneMgr;
38};
39
40class MouseQueryListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener
41{
42public:
43
44    MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,
45                CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera *vizCamera);
46
47    ~MouseQueryListener();
48
49        bool frameStarted(const FrameEvent& evt);
50        bool frameEnded(const FrameEvent& evt);
51
52    /* MouseListener callbacks. */
53    virtual void mouseClicked(MouseEvent* e) { }
54    virtual void mouseEntered(MouseEvent* e) { }
55    virtual void mouseExited(MouseEvent* e)  { }
56
57    // This is when the mouse button goes DOWN.
58    virtual void mousePressed(MouseEvent* e);
59
60    // This is when the mouse button is let UP.
61    virtual void mouseReleased(MouseEvent* e);
62
63    /* MouseMotionListener callbacks */
64    virtual void mouseMoved (MouseEvent *e);
65   
66    // This is when the mouse is clicked, held and dragged.
67    virtual void mouseDragged (MouseEvent *e);
68
69    void keyPressed(KeyEvent* e);
70
71        void keyReleased(KeyEvent* e);
72        void keyClicked(KeyEvent* e);
73
74        void nextAlgorithm();
75        void setAlgorithm(int algorithm);
76        void changeThreshold(int incr);
77        void updateStats();
78        void toggleUseOptimization();
79        void toggleShowOctree();
80        void toggleUseVisibilityCulling();
81        void toggleShowViz();
82        void FixVizCamera();
83
84protected:
85        void clamp2Terrain(Camera *cam);
86
87    bool mLMouseDown, mRMouseDown;     // True if the mouse buttons are down
88    SceneManager *mSceneMgr;           // A pointer to the scene manager
89   
90        CEGUI::Renderer *mGUIRenderer;     // cegui renderer
91       
92        bool mShutdownRequested;
93        int mCurrentAlgorithm;
94        int mVisibilityThreshold;
95
96        OverlayElement *mAlgorithmInfo;
97        OverlayElement *mThresholdInfo;
98        OverlayElement *mFrustumCulledNodesInfo;
99        OverlayElement *mQueryCulledNodesInfo;
100    OverlayElement *mTraversedNodesInfo;
101        OverlayElement *mHierarchyNodesInfo;
102        OverlayElement *mUseOptimizationInfo;
103        OverlayElement *mRenderedNodesInfo;
104        OverlayElement *mObjectsInfo;
105        OverlayElement *mQueriesIssuedInfo;
106
107        SceneNode *mCurrentObject;         // The newly created object
108        int mCount;                        // The number of robots on the screen
109
110        RayQueryExecutor *mRayQueryExecutor;
111        TerrainContentGenerator *mTerrainContentGenerator;
112
113        bool mUseOptimization;
114        bool mShowOctree;
115        bool mUseVisibilityCulling;
116        bool mShowVisualization;
117
118        Camera *mVisualizationCamera;
119};
120
121
122class TestCullingTerrainApplication : public ExampleApplication
123{
124public:
125        ~TestCullingTerrainApplication();
126
127protected:
128        //-- inherited from ExampleApplication
129        bool setup();
130        void createScene();
131        void createFrameListener();
132        void createCamera();
133        //void createViewports();
134       
135        virtual void createRenderTargetListener();
136
137        /** cegui setup */
138        void setupGui();
139
140        CEGUI::OgreCEGUIRenderer *mGUIRenderer;
141        CEGUI::System *mGUISystem;
142
143        Vector3 mMinTranslation;
144        Vector3 mMaxTranslation;
145
146        Vector3 mMinAngle;
147        Vector3 mMaxAngle;
148
149        TerrainContentGenerator *mTerrainContentGenerator;
150       
151        Camera *mVisualizationCamera;
152        VisualizationRenderTargetListener *mRenderTargetListener;
153
154private:
155        void chooseSceneManager(void);
156};
Note: See TracBrowser for help on using the repository browser.