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

Revision 103, 4.3 KB checked in by mattausch, 19 years ago (diff)

fixed bug with shadow maps

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
90protected:
91        void clamp2Terrain();
92
93    bool mLMouseDown, mRMouseDown;     // True if the mouse buttons are down
94    SceneManager *mSceneMgr;           // A pointer to the scene manager
95   
96        CEGUI::Renderer *mGUIRenderer;     // cegui renderer
97       
98        bool mShutdownRequested;
99        int mCurrentAlgorithm;
100        int mVisibilityThreshold;
101
102        OverlayElement *mAlgorithmInfo;
103        OverlayElement *mThresholdInfo;
104        OverlayElement *mFrustumCulledNodesInfo;
105        OverlayElement *mQueryCulledNodesInfo;
106    OverlayElement *mTraversedNodesInfo;
107        OverlayElement *mHierarchyNodesInfo;
108        OverlayElement *mUseOptimizationInfo;
109        OverlayElement *mRenderedNodesInfo;
110        OverlayElement *mObjectsInfo;
111        OverlayElement *mQueriesIssuedInfo;
112
113        SceneNode *mCurrentObject;         // The newly created object
114        int mCount;                        // The number of robots on the screen
115
116        RayQueryExecutor *mRayQueryExecutor;
117        TerrainContentGenerator *mTerrainContentGenerator;
118
119        bool mUseOptimization;
120        bool mShowOctree;
121        bool mUseVisibilityCulling;
122        bool mShowVisualization;
123        bool mRenderNodesForViz;
124        bool mCullCamera;
125
126        Real mVizCameraHeight;
127
128        Camera *mVizCamera;
129        SceneNode *mCamNode;
130
131};
132
133
134class TestCullingTerrainApplication : public ExampleApplication
135{
136public:
137        ~TestCullingTerrainApplication();
138
139protected:
140        //-- inherited from ExampleApplication
141        bool setup();
142        void createScene();
143        void createFrameListener();
144        void createCamera();
145        //void createViewports();
146       
147        virtual void createRenderTargetListener();
148
149        /** cegui setup */
150        void setupGui();
151
152        CEGUI::OgreCEGUIRenderer *mGUIRenderer;
153        CEGUI::System *mGUISystem;
154
155        Vector3 mMinTranslation;
156        Vector3 mMaxTranslation;
157
158        Vector3 mMinAngle;
159        Vector3 mMaxAngle;
160
161        TerrainContentGenerator *mTerrainContentGenerator;
162       
163        Camera *mVizCamera;
164        SceneNode *mCamNode;
165        VisualizationRenderTargetListener *mRenderTargetListener;
166
167private:
168        void chooseSceneManager(void);
169};
Note: See TracBrowser for help on using the repository browser.