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

Revision 111, 5.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"
[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
[85]89        void nextAlgorithm();
[61]90        void changeThreshold(int incr);
[87]91        void updateStats();
[107]92
[86]93        void toggleUseOptimization();
94        void toggleShowOctree();
[99]95        void toggleUseVisibilityCulling();
96        void toggleShowViz();
[103]97        void toggleRenderNodesForViz();
[107]98        void toggleRecord();
99
[100]100        void zoomVizCamera(int zoom);
[107]101       
102        void addFrameInfo(SceneNode *camNode, Real timeElapsed);
103        void setCurrentFrameInfo(Real timeElapsed);
[61]104
[107]105        void setAppState(int state);
106        void nextAppState();
[104]107
[107]108        void setAlgorithm(int algorithm);
[106]109
[107]110        void moveCamera();
111       
112        void writeFrames();
113        void loadFrames();
114
[111]115        void toggleUseShadows();
116
[61]117protected:
[104]118        void Clamp2Terrain();
[106]119       
[61]120    bool mLMouseDown, mRMouseDown;     // True if the mouse buttons are down
121    SceneManager *mSceneMgr;           // A pointer to the scene manager
122   
123        CEGUI::Renderer *mGUIRenderer;     // cegui renderer
124       
125        bool mShutdownRequested;
126        int mCurrentAlgorithm;
[85]127        int mVisibilityThreshold;
[106]128       
[61]129        OverlayElement *mAlgorithmInfo;
130        OverlayElement *mThresholdInfo;
131        OverlayElement *mFrustumCulledNodesInfo;
132        OverlayElement *mQueryCulledNodesInfo;
133    OverlayElement *mTraversedNodesInfo;
134        OverlayElement *mHierarchyNodesInfo;
[86]135        OverlayElement *mUseOptimizationInfo;
[61]136        OverlayElement *mRenderedNodesInfo;
[87]137        OverlayElement *mObjectsInfo;
138        OverlayElement *mQueriesIssuedInfo;
[61]139
[107]140        SceneNode *mCurrentObject;    // the newly created object
141        int mObjectCount;             // The number of objects on the screen
[61]142
143        RayQueryExecutor *mRayQueryExecutor;
[82]144        TerrainContentGenerator *mTerrainContentGenerator;
[86]145
146        bool mUseOptimization;
147        bool mShowOctree;
[99]148        bool mUseVisibilityCulling;
149        bool mShowVisualization;
[103]150        bool mRenderNodesForViz;
[100]151        bool mCullCamera;
[93]152
[100]153        Real mVizCameraHeight;
154
155        Camera *mVizCamera;
156        SceneNode *mCamNode;
[106]157       
[105]158        //std::deque<Vector3> mWalkList;   // The list of points we are walking to
[107]159        std::vector<frame_info> mFrameInfo;
[106]160               
161        int mCurrentFrame;
162        // the current application state
[107]163        int mAppState;
164        bool mRecord;
165        Real mTimeElapsed;
[111]166        bool mUseShadows;
[61]167};
168
169
170class TestCullingTerrainApplication : public ExampleApplication
171{
172public:
173        ~TestCullingTerrainApplication();
174
175protected:
[99]176        //-- inherited from ExampleApplication
177        bool setup();
[85]178        void createScene();
179        void createFrameListener();
[99]180        void createCamera();
181        //void createViewports();
182       
183        virtual void createRenderTargetListener();
184
185        /** cegui setup */
[85]186        void setupGui();
[61]187
188        CEGUI::OgreCEGUIRenderer *mGUIRenderer;
189        CEGUI::System *mGUISystem;
190
[87]191        Vector3 mMinTranslation;
192        Vector3 mMaxTranslation;
193
194        Vector3 mMinAngle;
[61]195        Vector3 mMaxAngle;
196
[82]197        TerrainContentGenerator *mTerrainContentGenerator;
[99]198       
[100]199        Camera *mVizCamera;
200        SceneNode *mCamNode;
[109]201        Light *mSunLight;
[99]202        VisualizationRenderTargetListener *mRenderTargetListener;
[75]203
[61]204private:
205        void chooseSceneManager(void);
[99]206};
Note: See TracBrowser for help on using the repository browser.