/** \file TestCullingTerrainApplication.h */ #include "CEGUIForwardRefs.h" #include "ExampleApplication.h" #include "TerrainContentGenerator.h" #include "VisibilityEnvironment.h" #include Real timeDelay = 0; #define KEY_PRESSED(_key,_timeDelay, _macro) \ { \ if (mInputDevice->isKeyDown(_key) && timeDelay <= 0) \ { \ timeDelay = _timeDelay; \ _macro ; \ } \ } String mCurrentAlgorithmCaptions[GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS] = { "View Frustum Culling", "Stop and Wait Culling", "Coherent Hierarchical Culling" }; class VisualizationRenderTargetListener: public RenderTargetListener { public: VisualizationRenderTargetListener(SceneManager *sceneMgr); protected: void preViewportUpdate (const RenderTargetViewportEvent &evt); void postRenderTargetUpdate (const RenderTargetEvent &evt); SceneManager *mSceneMgr; }; class MouseQueryListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener { public: MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera *vizCamera, SceneNode *camNode); ~MouseQueryListener(); bool frameStarted(const FrameEvent& evt); bool frameEnded(const FrameEvent& evt); bool processUnbufferedKeyInput(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 nextAlgorithm(); void setAlgorithm(int algorithm); void changeThreshold(int incr); void updateStats(); void toggleUseOptimization(); void toggleShowOctree(); void toggleUseVisibilityCulling(); void toggleShowViz(); void toggleRenderNodesForViz(); void zoomVizCamera(int zoom); void moveCamera(); protected: void Clamp2Terrain(); bool NextLocation(); 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 mVisibilityThreshold; OverlayElement *mAlgorithmInfo; OverlayElement *mThresholdInfo; OverlayElement *mFrustumCulledNodesInfo; OverlayElement *mQueryCulledNodesInfo; OverlayElement *mTraversedNodesInfo; OverlayElement *mHierarchyNodesInfo; OverlayElement *mUseOptimizationInfo; OverlayElement *mRenderedNodesInfo; OverlayElement *mObjectsInfo; OverlayElement *mQueriesIssuedInfo; SceneNode *mCurrentObject; // The newly created object int mCount; // The number of robots on the screen RayQueryExecutor *mRayQueryExecutor; TerrainContentGenerator *mTerrainContentGenerator; bool mUseOptimization; bool mShowOctree; bool mUseVisibilityCulling; bool mShowVisualization; bool mRenderNodesForViz; bool mCullCamera; Real mVizCameraHeight; Camera *mVizCamera; SceneNode *mCamNode; Real mWalkSpeed; Real mDistance; Vector3 mDestination; Vector3 mDirection; std::deque mWalkList; // The list of points we are walking to }; class TestCullingTerrainApplication : public ExampleApplication { public: ~TestCullingTerrainApplication(); protected: //-- inherited from ExampleApplication bool setup(); void createScene(); void createFrameListener(); void createCamera(); //void createViewports(); virtual void createRenderTargetListener(); /** cegui setup */ void setupGui(); CEGUI::OgreCEGUIRenderer *mGUIRenderer; CEGUI::System *mGUISystem; Vector3 mMinTranslation; Vector3 mMaxTranslation; Vector3 mMinAngle; Vector3 mMaxAngle; TerrainContentGenerator *mTerrainContentGenerator; Camera *mVizCamera; SceneNode *mCamNode; VisualizationRenderTargetListener *mRenderTargetListener; private: void chooseSceneManager(void); };