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

Revision 99, 4.1 KB checked in by mattausch, 19 years ago (diff)
RevLine 
[61]1/**
2    \file
3        TestCullingTerrainApplication.h
4*/
5#include "CEGUIForwardRefs.h"
6#include "ExampleApplication.h"
7#include "TerrainContentGenerator.h"
[74]8#include "VisibilityEnvironment.h"
[99]9#include <OgreRenderTargetListener.h>
[61]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
[74]21String mCurrentAlgorithmCaptions[GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS] =
[61]22{
[74]23    "View Frustum Culling",
24        "Stop and Wait Culling",
25        "Coherent Hierarchical Culling"
[61]26};
27
[99]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
[61]40class MouseQueryListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener
41{
42public:
43
44    MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,
[94]45                CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera *vizCamera);
[61]46
[80]47    ~MouseQueryListener();
[61]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
[85]74        void nextAlgorithm();
75        void setAlgorithm(int algorithm);
[61]76        void changeThreshold(int incr);
[87]77        void updateStats();
[86]78        void toggleUseOptimization();
79        void toggleShowOctree();
[99]80        void toggleUseVisibilityCulling();
81        void toggleShowViz();
[94]82        void FixVizCamera();
[61]83
84protected:
[94]85        void clamp2Terrain(Camera *cam);
86
[61]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;
[85]94        int mVisibilityThreshold;
[61]95
96        OverlayElement *mAlgorithmInfo;
97        OverlayElement *mThresholdInfo;
98        OverlayElement *mFrustumCulledNodesInfo;
99        OverlayElement *mQueryCulledNodesInfo;
100    OverlayElement *mTraversedNodesInfo;
101        OverlayElement *mHierarchyNodesInfo;
[86]102        OverlayElement *mUseOptimizationInfo;
[61]103        OverlayElement *mRenderedNodesInfo;
[87]104        OverlayElement *mObjectsInfo;
105        OverlayElement *mQueriesIssuedInfo;
[61]106
107        SceneNode *mCurrentObject;         // The newly created object
108        int mCount;                        // The number of robots on the screen
109
110        RayQueryExecutor *mRayQueryExecutor;
[82]111        TerrainContentGenerator *mTerrainContentGenerator;
[86]112
113        bool mUseOptimization;
114        bool mShowOctree;
[99]115        bool mUseVisibilityCulling;
116        bool mShowVisualization;
[93]117
[94]118        Camera *mVisualizationCamera;
[61]119};
120
121
122class TestCullingTerrainApplication : public ExampleApplication
123{
124public:
125        ~TestCullingTerrainApplication();
126
127protected:
[99]128        //-- inherited from ExampleApplication
129        bool setup();
[85]130        void createScene();
131        void createFrameListener();
[99]132        void createCamera();
133        //void createViewports();
134       
135        virtual void createRenderTargetListener();
136
137        /** cegui setup */
[85]138        void setupGui();
[61]139
140        CEGUI::OgreCEGUIRenderer *mGUIRenderer;
141        CEGUI::System *mGUISystem;
142
[87]143        Vector3 mMinTranslation;
144        Vector3 mMaxTranslation;
145
146        Vector3 mMinAngle;
[61]147        Vector3 mMaxAngle;
148
[82]149        TerrainContentGenerator *mTerrainContentGenerator;
[99]150       
151        Camera *mVisualizationCamera;
152        VisualizationRenderTargetListener *mRenderTargetListener;
[75]153
[61]154private:
155        void chooseSceneManager(void);
[99]156};
Note: See TracBrowser for help on using the repository browser.