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 |
|
---|
10 | class KdTreeAppRenderTargetListener : public RenderTargetListener
|
---|
11 | {
|
---|
12 | public:
|
---|
13 | KdTreeAppRenderTargetListener(SceneManager *sceneMgr);
|
---|
14 |
|
---|
15 | protected:
|
---|
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 |
|
---|
25 | class KdTreeApp : public ExampleApplication
|
---|
26 | {
|
---|
27 | public:
|
---|
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);
|
---|
50 | void createTerrainScene(Real max_x, Real max_y, Real max_z);
|
---|
51 | Vector3 clampToGround(const Vector3& vect, Real offset, Real cap);
|
---|
52 |
|
---|
53 | const String& getViewCellsFileName() const { return mViewCells; }
|
---|
54 | protected:
|
---|
55 | KdTreeAppListener *mFrameListener;
|
---|
56 | KdTreeAppRenderTargetListener *mRenderTargerListener;
|
---|
57 | SceneNode *mCamNode;
|
---|
58 | SceneNode *mMoveNode;
|
---|
59 | Camera *mTopCam;
|
---|
60 | //Camera *mFollowCam;
|
---|
61 |
|
---|
62 | // scene options
|
---|
63 | String mSceneFiles;
|
---|
64 | String mViewCells;
|
---|
65 | Real mRotationRadius;
|
---|
66 | int mModelSpacing;
|
---|
67 | int mModelCount;
|
---|
68 | int mRandomCount;
|
---|
69 | Real mPlaneDim;
|
---|
70 | bool mShadowsEnabled;
|
---|
71 | int mSelectEntities;
|
---|
72 |
|
---|
73 | KdTreeAppListener::Options mOptions;
|
---|
74 |
|
---|
75 | virtual void setupResources(void);
|
---|
76 |
|
---|
77 | virtual void createScene(void);
|
---|
78 |
|
---|
79 | virtual void createFrameListener(void);
|
---|
80 |
|
---|
81 | virtual void chooseSceneManager(void);
|
---|
82 |
|
---|
83 | virtual void createCamera(void);
|
---|
84 |
|
---|
85 | virtual void createViewports(void);
|
---|
86 |
|
---|
87 | /** Configures the application - returns false if the user chooses to abandon configuration. */
|
---|
88 | virtual bool configure(void);
|
---|
89 |
|
---|
90 | /** load scene from file **/
|
---|
91 | bool loadScene(const String& filename);
|
---|
92 | bool loadSceneIV(const String &filename, SceneNode *root, const int index);
|
---|
93 | // loadding world geometry from cfg file - for terrain
|
---|
94 | bool loadSceneCfg(const String &filename, SceneNode *root, const int index);
|
---|
95 | // load entities from ascii file
|
---|
96 | bool loadSceneASCII(const String &filename, SceneNode *root, const int index);
|
---|
97 |
|
---|
98 | typedef std::list<SceneNode *> NodeList;
|
---|
99 | void addNodesToList(SceneNode* node, NodeList& list);
|
---|
100 |
|
---|
101 | void createMaterials(void);
|
---|
102 | void createSimpleScene(void);
|
---|
103 |
|
---|
104 | RaySceneQuery* mRaySceneQuery;
|
---|
105 | private:
|
---|
106 | std::string cat(std::string name, int x, int z)
|
---|
107 | {
|
---|
108 | std::stringstream s;
|
---|
109 | s.fill('0');
|
---|
110 | s << name;
|
---|
111 | s.width(2);
|
---|
112 | s << x;
|
---|
113 | s.width(2);
|
---|
114 | s << z;
|
---|
115 | return s.str();
|
---|
116 | }
|
---|
117 | };
|
---|
118 |
|
---|
119 | #endif |
---|