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

Revision 114, 5.3 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"
[107]7#include "OgreTerrainContentGenerator.h"
[74]8#include "VisibilityEnvironment.h"
[99]9#include <OgreRenderTargetListener.h>
[106]10#include <vector>
[61]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
[74]22String mCurrentAlgorithmCaptions[GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS] =
[61]23{
[74]24    "View Frustum Culling",
25        "Stop and Wait Culling",
26        "Coherent Hierarchical Culling"
[61]27};
[106]28
29/** The information about camera position and orienation per frame */
30typedef struct
[105]31{
[106]32        Vector3 position;
33        Quaternion orientation;
[107]34        Real timeElapsed;
[106]35} frame_info;
[61]36
[106]37
[99]38class VisualizationRenderTargetListener: public RenderTargetListener
39{
40public:
41        VisualizationRenderTargetListener(SceneManager *sceneMgr);
42
43protected:
44        void preViewportUpdate (const RenderTargetViewportEvent &evt);
45        void postRenderTargetUpdate (const RenderTargetEvent &evt);
46
47        SceneManager *mSceneMgr;
48};
49
[61]50class MouseQueryListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener
51{
52public:
[106]53       
[61]54    MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,
[100]55                CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera *vizCamera,
56                SceneNode *camNode);
[61]57
[80]58    ~MouseQueryListener();
[61]59
60        bool frameStarted(const FrameEvent& evt);
61        bool frameEnded(const FrameEvent& evt);
[100]62        bool processUnbufferedKeyInput(const FrameEvent& evt);
63   
[61]64
65    /* MouseListener callbacks. */
66    virtual void mouseClicked(MouseEvent* e) { }
67    virtual void mouseEntered(MouseEvent* e) { }
68    virtual void mouseExited(MouseEvent* e)  { }
69
70    // This is when the mouse button goes DOWN.
71    virtual void mousePressed(MouseEvent* e);
72
73    // This is when the mouse button is let UP.
74    virtual void mouseReleased(MouseEvent* e);
75
76    /* MouseMotionListener callbacks */
77    virtual void mouseMoved (MouseEvent *e);
78   
79    // This is when the mouse is clicked, held and dragged.
80    virtual void mouseDragged (MouseEvent *e);
81
82    void keyPressed(KeyEvent* e);
83
84        void keyReleased(KeyEvent* e);
85        void keyClicked(KeyEvent* e);
86
[107]87        enum  {WALKTHROUGH, REPLAY, STATE_NUM};
88
[113]89        // visualization modes for scene nodes
[114]90        //enum {NODEVIZ_NONE, NODEVIZ_RENDER_NODES,
91        //        NODEVIZ_RENDER_NODES_AND_CONTENT, NODEVIZ_MODES_NUM};
92        enum {NODEVIZ_NONE, NODEVIZ_RENDER_GEOMETRY, NODEVIZ_MODES_NUM};
[113]93
[85]94        void nextAlgorithm();
[61]95        void changeThreshold(int incr);
[87]96        void updateStats();
[107]97
[86]98        void toggleUseOptimization();
99        void toggleShowOctree();
[99]100        void toggleUseVisibilityCulling();
101        void toggleShowViz();
[113]102        void nextNodeVizMode();
[107]103        void toggleRecord();
104
[100]105        void zoomVizCamera(int zoom);
[107]106       
107        void addFrameInfo(SceneNode *camNode, Real timeElapsed);
108        void setCurrentFrameInfo(Real timeElapsed);
[61]109
[107]110        void setAppState(int state);
111        void nextAppState();
[104]112
[107]113        void setAlgorithm(int algorithm);
[106]114
[107]115        void moveCamera();
116       
117        void writeFrames();
118        void loadFrames();
119
[111]120        void toggleUseShadows();
121
[61]122protected:
[104]123        void Clamp2Terrain();
[106]124       
[61]125    bool mLMouseDown, mRMouseDown;     // True if the mouse buttons are down
126    SceneManager *mSceneMgr;           // A pointer to the scene manager
127   
128        CEGUI::Renderer *mGUIRenderer;     // cegui renderer
129       
130        bool mShutdownRequested;
131        int mCurrentAlgorithm;
[85]132        int mVisibilityThreshold;
[106]133       
[61]134        OverlayElement *mAlgorithmInfo;
135        OverlayElement *mThresholdInfo;
136        OverlayElement *mFrustumCulledNodesInfo;
137        OverlayElement *mQueryCulledNodesInfo;
138    OverlayElement *mTraversedNodesInfo;
139        OverlayElement *mHierarchyNodesInfo;
[86]140        OverlayElement *mUseOptimizationInfo;
[61]141        OverlayElement *mRenderedNodesInfo;
[87]142        OverlayElement *mObjectsInfo;
143        OverlayElement *mQueriesIssuedInfo;
[61]144
[107]145        SceneNode *mCurrentObject;    // the newly created object
146        int mObjectCount;             // The number of objects on the screen
[61]147
148        RayQueryExecutor *mRayQueryExecutor;
[82]149        TerrainContentGenerator *mTerrainContentGenerator;
[86]150
151        bool mUseOptimization;
152        bool mShowOctree;
[99]153        bool mUseVisibilityCulling;
154        bool mShowVisualization;
[113]155        int mNodeVizMode;
[100]156        bool mCullCamera;
[93]157
[100]158        Real mVizCameraHeight;
159
160        Camera *mVizCamera;
161        SceneNode *mCamNode;
[106]162       
[105]163        //std::deque<Vector3> mWalkList;   // The list of points we are walking to
[107]164        std::vector<frame_info> mFrameInfo;
[106]165               
166        int mCurrentFrame;
167        // the current application state
[107]168        int mAppState;
169        bool mRecord;
170        Real mTimeElapsed;
[111]171        bool mUseShadows;
[112]172
173        bool mVisualizeCulledNodes;
[61]174};
175
176
177class TestCullingTerrainApplication : public ExampleApplication
178{
179public:
180        ~TestCullingTerrainApplication();
181
182protected:
[99]183        //-- inherited from ExampleApplication
184        bool setup();
[85]185        void createScene();
186        void createFrameListener();
[99]187        void createCamera();
188        //void createViewports();
189       
190        virtual void createRenderTargetListener();
191
192        /** cegui setup */
[85]193        void setupGui();
[61]194
195        CEGUI::OgreCEGUIRenderer *mGUIRenderer;
196        CEGUI::System *mGUISystem;
197
[87]198        Vector3 mMinTranslation;
199        Vector3 mMaxTranslation;
200
201        Vector3 mMinAngle;
[61]202        Vector3 mMaxAngle;
203
[82]204        TerrainContentGenerator *mTerrainContentGenerator;
[99]205       
[100]206        Camera *mVizCamera;
207        SceneNode *mCamNode;
[109]208        Light *mSunLight;
[99]209        VisualizationRenderTargetListener *mRenderTargetListener;
[75]210
[61]211private:
212        void chooseSceneManager(void);
[99]213};
Note: See TracBrowser for help on using the repository browser.