source: GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTree.h @ 1285

Revision 1285, 2.7 KB checked in by szydlowski, 18 years ago (diff)

saving and loading entities to file

Line 
1#ifndef __KdTreeApp_H__
2#define __KdTreeApp_H__
3
4#include <OgreRenderTargetListener.h>
5#include <ExampleApplication.h>
6#include <ivreader.h>
7#include "TestKdTreeAppListener.h"
8
9
10class KdTreeAppRenderTargetListener : public RenderTargetListener
11{
12public:
13        KdTreeAppRenderTargetListener(SceneManager *sceneMgr);
14
15protected:
16        void preViewportUpdate (const RenderTargetViewportEvent &evt);
17        void postRenderTargetUpdate (const RenderTargetEvent &evt);
18
19        SceneManager *mSceneMgr;
20
21        ShadowTechnique mSavedShadowTechnique;
22        ColourValue mSavedAmbientLight;
23};
24
25class KdTreeApp : public ExampleApplication
26{
27public:
28
29        KdTreeApp() :
30        mFrameListener(0),
31        mRenderTargerListener(0)
32        {
33        }
34
35        KdTreeApp(const KdTreeAppListener::Options& options) :
36        mFrameListener(0),
37        mRenderTargerListener(0),
38        mOptions(options)
39        {
40        }
41
42        ~KdTreeApp()
43        {
44                delete mRenderTargerListener;
45                delete mFrameListener;
46        }
47
48        // save entities to ascii file
49        bool saveSceneASCII(const String& filename, SceneNode *entityroot);
50protected:
51        KdTreeAppListener *mFrameListener;
52        KdTreeAppRenderTargetListener *mRenderTargerListener;
53        SceneNode *mCamNode;
54        SceneNode *mMoveNode;
55        Camera *mTopCam;
56        //Camera *mFollowCam;
57
58        // scene options
59        //String  mSceneFiles;
60        Real    mRotationRadius;
61        int             mModelSpacing;
62        int             mModelCount;
63        int             mRandomCount;
64        Real    mPlaneDim;
65        bool    mShadowsEnabled;
66        int             mSelectEntities;
67
68        KdTreeAppListener::Options mOptions;
69
70        virtual void setupResources(void);
71
72        virtual void createScene(void);
73
74        virtual void createFrameListener(void);
75       
76        virtual void chooseSceneManager(void);
77
78    virtual void createCamera(void);
79
80        virtual void createViewports(void);
81
82    /** Configures the application - returns false if the user chooses to abandon configuration. */
83    virtual bool configure(void);
84
85        /** load scene from file **/
86        bool loadScene(const String& filename);
87        bool loadSceneIV(const String &filename, SceneNode *root, const int index);
88        // loadding world geometry from cfg file - for terrain
89        bool loadSceneCfg(const String &filename, SceneNode *root, const int index);
90        // load entities from ascii file
91        bool loadSceneASCII(const String &filename, SceneNode *root, const int index);
92
93        typedef std::list<SceneNode *> NodeList;
94        void addNodesToList(SceneNode* node, NodeList& list);
95
96        void createMaterials(void);
97        void createSimpleScene(void);
98        void createTerrainScene(Real max_x, Real max_y, Real max_z);
99        Vector3 clampToGround(const Vector3& vect, Real offset, Real cap);
100
101        RaySceneQuery* mRaySceneQuery;
102private:
103        std::string cat(std::string name, int x, int z)
104        {
105                std::stringstream s;
106                s.fill('0');
107                s << name;
108                s.width(2);
109                s << x;
110                s.width(2);
111                s << z;
112                return s.str();
113        }
114};
115
116#endif
Note: See TracBrowser for help on using the repository browser.