#ifndef _TestCullingTerrainApplication_H__ #define _TestCullingTerrainApplication_H__ #include "CEGUIForwardRefs.h" #include #include "ExampleApplication.h" #include "OgreTerrainContentGenerator.h" #include "TerrainFrameListener.h" #include #include // z order index of visualizaion viewport #define VIZ_VIEWPORT_Z_ORDER 10 class IVReader; //-- constants for animation const float walk_duration = 10.0f; const float wait_duration = 2.0f; const float rotate_factor = 0.7f; const float move_factor = 0.03; /** Rendertarget listener which shows a visualization. */ class VisualizationRenderTargetListener: public RenderTargetListener { public: VisualizationRenderTargetListener(SceneManager *sceneMgr); protected: void preViewportUpdate (const RenderTargetViewportEvent &evt); void postRenderTargetUpdate (const RenderTargetEvent &evt); SceneManager *mSceneMgr; ShadowTechnique mSavedShadowTechnique; ColourValue mSavedAmbientLight; }; /** Class storing the current state of an entity. */ class EntityState { public: enum State {STOP, WAITING, MOVING}; EntityState(Entity *ent, State entityState, Real speed); ~EntityState(); /** Update the entity state. */ void update(Real timeSinceLastFrame); /** Returns entity. */ Entity *GetEntity(); /** Returns entity state index. */ EntityState::State GetState(); static bool OutOfBounds(SceneNode *node); static Vector3 msMinPos; static Vector3 msMaxPos; protected: void SetAnimationState(String stateStr, bool loop); AnimationState *mAnimationState; Entity *mEntity; State mState; Real mAnimationSpeed; Real mTimeElapsed; }; typedef std::vector EntityStates; class TestCullingTerrainApplication: public ExampleApplication { public: TestCullingTerrainApplication(); ~TestCullingTerrainApplication(); /** Generates a scene using num entities of a type. @param num the number of objects @parma objectType the type of objects */ void generateScene(int num, int objectType); /** Returns the caption of the given id of a scene object type. */ String getCurrentObjectCaption(int id); /** Returns state vector of scene entities. */ EntityStates &getEntityStates(); /** Updates all animations according to time elapsed since last frame. */ void updateAnimations(Real timeSinceLastFrame); /** Deletes vector of scene entity states. */ void deleteEntityStates(); // object types enum {ROBOT, TREE, NINJA}; /** Clamps scene node to terrain. @param sceneNode the node to be clamped @param terrainOffs the offset of the node over the terrain @returns if clamping was successful (i.e., the ray hit the terrain) */ bool Clamp2Terrain(SceneNode *node, int terrainOffs); /** Clamps camera to floor plane: used for vienna set. */ bool Clamp2FloorPlane(); /** Loads iv geometry. */ bool LoadSceneIV(const String &filename, SceneNode *root, const int index); bool LoadSceneCollada(const String &filename, SceneNode *root, const int index); bool LoadScene(const String &filename); bool LoadViewCells(const String &filename); /** Loads configuration from disc. */ void loadConfig(const String& filename); /// if hilly terrain should be loaded static bool msShowHillyTerrain; String mFilename; String mViewCellsFilename; /// name of the visibility environment file String mEnvironmentFilename; protected: //-- inherited from ExampleApplication bool setup(); void createScene(); void createFrameListener(); void createCamera(); //void createViewports(); virtual void createRenderTargetListener(); void BakeSceneIntoStaticGeometry(const String &staticGeomName, const String &nodeName); std::vector mEntityStates; /** cegui setup */ void setupGui(); CEGUI::OgreCEGUIRenderer *mGUIRenderer; CEGUI::System *mGUISystem; Vector3 mMinTranslation; Vector3 mMaxTranslation; Vector3 mMinAngle; Vector3 mMaxAngle; TerrainContentGenerator *mTerrainContentGenerator; Camera *mVizCamera; SceneNode *mCamNode; Light *mSunLight; TerrainFrameListener *mTerrainFrameListener; ColourValue mAmbientLight; RayQueryExecutor *mRayQueryExecutor; Vector3 mTerrainMinPos; Vector3 mTerrainMaxPos; IVReader *mIVReader; StaticGeometry *mStaticGeometry; private: void chooseSceneManager(void); }; #endif // TestCullingTerrainApplication