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

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