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

Revision 1003, 4.5 KB checked in by mattausch, 18 years ago (diff)

added collada importer

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