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

RevLine 
[1163]1#ifndef __KdTreeApp_H__
2#define __KdTreeApp_H__
3
[1187]4#include <OgreRenderTargetListener.h>
5#include <ExampleApplication.h>
6#include <ivreader.h>
[1163]7#include "TestKdTreeAppListener.h"
8
[1195]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
[1163]25class KdTreeApp : public ExampleApplication
26{
27public:
28
[1204]29        KdTreeApp() :
30        mFrameListener(0),
31        mRenderTargerListener(0)
32        {
[1202]33        }
[1163]34
[1204]35        KdTreeApp(const KdTreeAppListener::Options& options) :
36        mFrameListener(0),
37        mRenderTargerListener(0),
38        mOptions(options)
39        {
[1202]40        }
41
[1163]42        ~KdTreeApp()
43        {
[1195]44                delete mRenderTargerListener;
[1163]45                delete mFrameListener;
46        }
47
[1285]48        // save entities to ascii file
49        bool saveSceneASCII(const String& filename, SceneNode *entityroot);
[1163]50protected:
51        KdTreeAppListener *mFrameListener;
[1195]52        KdTreeAppRenderTargetListener *mRenderTargerListener;
[1204]53        SceneNode *mCamNode;
54        SceneNode *mMoveNode;
55        Camera *mTopCam;
56        //Camera *mFollowCam;
[1163]57
[1204]58        // scene options
[1273]59        //String  mSceneFiles;
[1163]60        Real    mRotationRadius;
61        int             mModelSpacing;
62        int             mModelCount;
63        int             mRandomCount;
64        Real    mPlaneDim;
65        bool    mShadowsEnabled;
66        int             mSelectEntities;
67
[1204]68        KdTreeAppListener::Options mOptions;
[1202]69
[1163]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
[1202]85        /** load scene from file **/
[1163]86        bool loadScene(const String& filename);
87        bool loadSceneIV(const String &filename, SceneNode *root, const int index);
[1285]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);
[1202]92
[1285]93        typedef std::list<SceneNode *> NodeList;
94        void addNodesToList(SceneNode* node, NodeList& list);
95
[1202]96        void createMaterials(void);
[1273]97        void createSimpleScene(void);
[1274]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;
[1163]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.