source: GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.h @ 2555

Revision 2555, 4.6 KB checked in by mattausch, 17 years ago (diff)

added partial implementation of chc++. problem: bounding box rendering in Ogre is VERY slow

RevLine 
[115]1#ifndef _TestCullingTerrainApplication_H__
2#define _TestCullingTerrainApplication_H__
3
[61]4#include "CEGUIForwardRefs.h"
[139]5#include <OgreRenderTargetListener.h>
[61]6#include "ExampleApplication.h"
[139]7
[107]8#include "OgreTerrainContentGenerator.h"
[133]9#include "TerrainFrameListener.h"
[61]10
[161]11#include <OgreEntity.h>
[723]12#include <string>
[161]13
[173]14// z order index of visualizaion viewport
15#define VIZ_VIEWPORT_Z_ORDER 10
16
[866]17class IVReader;
[173]18
19//-- constants for animation
20const float walk_duration = 10.0f;
21const float wait_duration = 2.0f;
22const float rotate_factor = 0.7f;
23const float move_factor = 0.03;
24
25
26/** Rendertarget listener which shows a visualization.
27*/
[99]28class VisualizationRenderTargetListener: public RenderTargetListener
29{
30public:
[1604]31       
[99]32        VisualizationRenderTargetListener(SceneManager *sceneMgr);
33
34protected:
35        void preViewportUpdate (const RenderTargetViewportEvent &evt);
36        void postRenderTargetUpdate (const RenderTargetEvent &evt);
37
38        SceneManager *mSceneMgr;
[139]39       
40        ShadowTechnique mSavedShadowTechnique;
41        ColourValue mSavedAmbientLight;
[99]42};
43
[161]44/** Class storing the current state of an entity.
45*/
46class EntityState
47{
48public:
49        enum State {STOP, WAITING, MOVING};
[61]50
[161]51        EntityState(Entity *ent, State entityState, Real speed);
[164]52        ~EntityState();
[161]53        /** Update the entity state.
54        */
55        void update(Real timeSinceLastFrame);
56
57        /** Returns entity.
58        */
59        Entity *GetEntity();
60
61        /** Returns entity state index.
62        */
63        EntityState::State GetState();
64
[164]65        static bool OutOfBounds(SceneNode *node);
66
67        static Vector3 msMinPos;
68        static Vector3 msMaxPos;
69
[161]70protected:
71
72        void SetAnimationState(String stateStr, bool loop);
73
74        AnimationState *mAnimationState;
75        Entity *mEntity;
76
77        State mState;
78        Real mAnimationSpeed;
79        Real mTimeElapsed;
80};
81
82typedef std::vector<EntityState *> EntityStates;
83
[160]84class TestCullingTerrainApplication: public ExampleApplication
[61]85{
86public:
[145]87        TestCullingTerrainApplication();
[61]88        ~TestCullingTerrainApplication();
89
[161]90        /** Generates a scene using num entities of a type.
91                @param num the number of objects
92                @parma objectType the type of objects
93        */
[160]94        void generateScene(int num, int objectType);
95
[161]96        /** Returns the caption of the given id of a scene object type.
97        */
[160]98        String getCurrentObjectCaption(int id);
99
[161]100        /** Returns state vector of scene entities.
101        */
102        EntityStates &getEntityStates();
[160]103
[161]104        /** Updates all animations according to time elapsed since last frame.
105        */
106    void updateAnimations(Real timeSinceLastFrame);
107
108        /** Deletes vector of scene entity states.
109        */
110        void deleteEntityStates();
111
112        // object types
[915]113        enum {ROBOT, TREE, NINJA};
[161]114
115       
116        /** Clamps scene node to terrain.
117                @param sceneNode the node to be clamped
118                @param terrainOffs the offset of the node over the terrain
119                @returns if clamping was successful (i.e., the ray hit the terrain)
120        */
121        bool Clamp2Terrain(SceneNode *node, int terrainOffs);
122
[1607]123        /** Clamps camera to floor plane: used e.g., for vienna set.
[866]124        */
[1607]125        bool Clamp2FloorPlane(const float dist);
[866]126
[924]127        /** Loads iv geometry.
[866]128        */
[924]129        bool LoadSceneIV(const String &filename, SceneNode *root, const int index);
[866]130
[1003]131        bool LoadSceneCollada(const String &filename, SceneNode *root, const int index);
132
[937]133        bool LoadScene(const String &filename);
[924]134
[937]135        bool LoadViewCells(const String &filename);
[924]136
137        /** Loads configuration from disc.
138        */
139        void loadConfig(const String& filename);
[1271]140
141
[932]142        /// if hilly terrain should be loaded
[866]143        static bool msShowHillyTerrain;
144
[937]145        String mFilename;
146        String mViewCellsFilename;
[973]147        /// name of the visibility environment file
[937]148        String mEnvironmentFilename;
[1271]149       
[2555]150        //int mAlgorithm;
[937]151
[1609]152        Vector3 mInitialPosition;
[1271]153
[61]154protected:
[160]155
[1609]156        ////////////////
[99]157        //-- inherited from ExampleApplication
[1609]158
[99]159        bool setup();
[85]160        void createScene();
161        void createFrameListener();
[99]162        void createCamera();
163        //void createViewports();
164       
165        virtual void createRenderTargetListener();
166
[901]167        void BakeSceneIntoStaticGeometry(const String &staticGeomName,
168                                                                         const String &nodeName);
169
[161]170        std::vector<EntityState *> mEntityStates;
[160]171
[161]172        /** cegui setup
173        */
[85]174        void setupGui();
[61]175
176        CEGUI::OgreCEGUIRenderer *mGUIRenderer;
177        CEGUI::System *mGUISystem;
178
[87]179        Vector3 mMinTranslation;
180        Vector3 mMaxTranslation;
181
182        Vector3 mMinAngle;
[61]183        Vector3 mMaxAngle;
184
[82]185        TerrainContentGenerator *mTerrainContentGenerator;
[99]186       
[100]187        Camera *mVizCamera;
188        SceneNode *mCamNode;
[109]189        Light *mSunLight;
[75]190
[133]191        TerrainFrameListener *mTerrainFrameListener;
[139]192        ColourValue mAmbientLight;
[161]193        RayQueryExecutor *mRayQueryExecutor;
194
[164]195        Vector3 mTerrainMinPos;
196        Vector3 mTerrainMaxPos;
[183]197
[866]198        IVReader *mIVReader;
[901]199       
200        StaticGeometry *mStaticGeometry;
[1271]201   
[1816]202private:
[924]203
[61]204        void chooseSceneManager(void);
[115]205};
206
207#endif // TestCullingTerrainApplication
Note: See TracBrowser for help on using the repository browser.