/** \file TestCullingTerrainApplication.h */ #include "CEGUIForwardRefs.h" #include "ExampleApplication.h" #include "OgreOcclusionCullingSceneTraverser.h" #include "TerrainContentGenerator.h" Real timeDelay = 0; #define KEY_PRESSED(_key,_timeDelay, _macro) \ { \ if (mInputDevice->isKeyDown(_key) && timeDelay <= 0) \ { \ timeDelay = _timeDelay; \ _macro ; \ } \ } String mCurrentAlgorithmCaptions[OcclusionCullingSceneTraverser::NUM_RENDERMODES] = { "Cull Frustum", "Stop and Wait", "Coherent Occlusion Culling" }; class MouseQueryListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener { public: MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer, RayQueryExecutor *rqe); ~MouseQueryListener( ); bool frameStarted(const FrameEvent& evt); bool frameEnded(const FrameEvent& evt); /* MouseListener callbacks. */ virtual void mouseClicked(MouseEvent* e) { } virtual void mouseEntered(MouseEvent* e) { } virtual void mouseExited(MouseEvent* e) { } // This is when the mouse button goes DOWN. virtual void mousePressed(MouseEvent* e); // This is when the mouse button is let UP. virtual void mouseReleased(MouseEvent* e); /* MouseMotionListener callbacks */ virtual void mouseMoved (MouseEvent *e); // This is when the mouse is clicked, held and dragged. virtual void mouseDragged (MouseEvent *e); void keyPressed(KeyEvent* e); void keyReleased(KeyEvent* e); void keyClicked(KeyEvent* e); void changeAlgorithm(); void changeThreshold(int incr); void changeStats(); protected: bool mLMouseDown, mRMouseDown; // True if the mouse buttons are down SceneManager *mSceneMgr; // A pointer to the scene manager CEGUI::Renderer *mGUIRenderer; // cegui renderer bool mShutdownRequested; int mCurrentAlgorithm; int mThreshold; OverlayElement *mAlgorithmInfo; OverlayElement *mThresholdInfo; OverlayElement *mFrustumCulledNodesInfo; OverlayElement *mQueryCulledNodesInfo; OverlayElement *mTraversedNodesInfo; OverlayElement *mHierarchyNodesInfo; OverlayElement *mSceneNodesInfo; OverlayElement *mRenderedNodesInfo; SceneNode *mCurrentObject; // The newly created object RaySceneQuery *mRaySceneQuery; // The ray scene query pointer int mCount; // The number of robots on the screen RayQueryExecutor *mRayQueryExecutor; }; class TestCullingTerrainApplication : public ExampleApplication { public: ~TestCullingTerrainApplication(); protected: void createScene(void); void createFrameListener(void); void setupGui(void); virtual void createCamera(void); /** generates a new scene object @param tranlationRatio ratio between minimal and maximal possible translation @param rotationRatio ratio between minimal and maximal possible rotation @idx the index of the new object @entName the name of the object entity */ void generateSceneObject(const Vector3 &translationRatio, const Vector3 &rotationRatio, const int idx, const String &entName); CEGUI::OgreCEGUIRenderer *mGUIRenderer; CEGUI::System *mGUISystem; RayQueryExecutor *mRayQueryExecutor; TerrainContentGenerator *mTerrainContentGenerator; Vector3 mMinTranslation; Vector3 mMaxTranslation; Vector3 mMinAngle; Vector3 mMaxAngle; private: void chooseSceneManager(void); };