source: trunk/VUT/work/TestCulling/TestCullingApplication.h @ 100

Revision 100, 3.2 KB checked in by mattausch, 20 years ago (diff)

added visualization for octree culling
camera in terrainexample is now attached to camera node => can see correct camera
in visualization

Line 
1/**
2    \file
3        TestCullingApplication.h
4*/
5#include "CEGUIForwardRefs.h"
6#include "ExampleApplication.h"
7#include "VisibilityEnvironment.h"
8#include "SceneContentGenerator.h"
9
10Real timeDelay = 0;
11#define KEY_PRESSED(_key,_timeDelay, _macro) \
12{ \
13    if (mInputDevice->isKeyDown(_key) && timeDelay <= 0) \
14{ \
15    timeDelay = _timeDelay; \
16    _macro ; \
17} \
18}
19
20String mCurrentAlgorithmCaptions[GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS] =
21{
22    "View Frustum Culling",
23        "Stop and Wait Culling",
24        "Coherent Hierarchical Culling"
25};
26
27class MouseQueryListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener
28{
29public:
30
31    MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager,
32                        CEGUI::Renderer *renderer, SceneContentGenerator *sceneContentGenerator);
33
34
35    ~MouseQueryListener( );
36
37        bool frameStarted(const FrameEvent& evt);
38        bool frameEnded(const FrameEvent& evt);
39
40    /* MouseListener callbacks. */
41    virtual void mouseClicked(MouseEvent* e) { }
42    virtual void mouseEntered(MouseEvent* e) { }
43    virtual void mouseExited(MouseEvent* e)  { }
44
45    // This is when the mouse button goes DOWN.
46    virtual void mousePressed(MouseEvent* e);
47
48    // This is when the mouse button is let UP.
49    virtual void mouseReleased(MouseEvent* e);
50
51    /* MouseMotionListener callbacks */
52    virtual void mouseMoved (MouseEvent *e);
53   
54    // This is when the mouse is clicked, held and dragged.
55    virtual void mouseDragged (MouseEvent *e);
56
57    void keyPressed(KeyEvent* e);
58
59        void keyReleased(KeyEvent* e);
60        void keyClicked(KeyEvent* e);
61
62        void nextAlgorithm();
63        void setAlgorithm(int algorithm);
64        void changeThreshold(int incr);
65        void updateStats();
66        void toggleUseOptimization();
67        void toggleShowOctree();
68        void toggleUseVisibilityCulling();
69        void toggleShowViz();
70
71protected:
72    bool mLMouseDown, mRMouseDown;     // True if the mouse buttons are down
73    SceneManager *mSceneMgr;           // A pointer to the scene manager
74   
75        CEGUI::Renderer *mGUIRenderer;     // cegui renderer
76       
77        bool mShutdownRequested;
78        int mCurrentAlgorithm;
79        int mVisibilityThreshold;
80
81        OverlayElement *mAlgorithmInfo;
82        OverlayElement *mThresholdInfo;
83        OverlayElement *mFrustumCulledNodesInfo;
84        OverlayElement *mQueryCulledNodesInfo;
85    OverlayElement *mTraversedNodesInfo;
86        OverlayElement *mHierarchyNodesInfo;
87        OverlayElement *mRenderedNodesInfo;
88        OverlayElement *mObjectsInfo;
89        OverlayElement *mUseOptimizationInfo;
90        OverlayElement *mQueriesIssuedInfo;
91
92        SceneContentGenerator *mSceneContentGenerator;
93
94        bool mUseOptimization;
95        bool mShowOctree;
96        bool mUseVisibilityCulling;
97        bool mShowVisualization;
98
99        Camera *mVizCamera;
100};
101
102
103class TestCullingApplication : public ExampleApplication
104{
105public:
106        ~TestCullingApplication();
107
108protected:
109        void createScene();
110        void createFrameListener();
111        void setupGui();
112       
113        //virtual void createCamera(void);
114
115        CEGUI::OgreCEGUIRenderer *mGUIRenderer;
116        CEGUI::System *mGUISystem;
117
118        Vector3 mMinTranslation;
119        Vector3 mMaxTranslation;
120
121        Vector3 mMinAngle;
122        Vector3 mMaxAngle;
123
124        SceneContentGenerator *mSceneContentGenerator;
125
126private:
127        void chooseSceneManager(void);
128};
129
Note: See TracBrowser for help on using the repository browser.