[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 |
|
---|
| 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 |
|
---|
[1163] | 25 | class KdTreeApp : public ExampleApplication
|
---|
| 26 | {
|
---|
| 27 | public:
|
---|
| 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);
|
---|
[1296] | 50 | void createTerrainScene(Real max_x, Real max_y, Real max_z);
|
---|
| 51 | Vector3 clampToGround(const Vector3& vect, Real offset, Real cap);
|
---|
[1300] | 52 |
|
---|
| 53 | const String& getViewCellsFileName() const { return mViewCells; }
|
---|
[1163] | 54 | protected:
|
---|
| 55 | KdTreeAppListener *mFrameListener;
|
---|
[1195] | 56 | KdTreeAppRenderTargetListener *mRenderTargerListener;
|
---|
[1204] | 57 | SceneNode *mCamNode;
|
---|
| 58 | SceneNode *mMoveNode;
|
---|
| 59 | Camera *mTopCam;
|
---|
| 60 | //Camera *mFollowCam;
|
---|
[1163] | 61 |
|
---|
[1204] | 62 | // scene options
|
---|
[1296] | 63 | String mSceneFiles;
|
---|
| 64 | String mViewCells;
|
---|
[1163] | 65 | Real mRotationRadius;
|
---|
| 66 | int mModelSpacing;
|
---|
| 67 | int mModelCount;
|
---|
| 68 | int mRandomCount;
|
---|
| 69 | Real mPlaneDim;
|
---|
| 70 | bool mShadowsEnabled;
|
---|
| 71 | int mSelectEntities;
|
---|
| 72 |
|
---|
[1204] | 73 | KdTreeAppListener::Options mOptions;
|
---|
[1202] | 74 |
|
---|
[1163] | 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 |
|
---|
[1202] | 90 | /** load scene from file **/
|
---|
[1163] | 91 | bool loadScene(const String& filename);
|
---|
| 92 | bool loadSceneIV(const String &filename, SceneNode *root, const int index);
|
---|
[1285] | 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);
|
---|
[1202] | 97 |
|
---|
[1285] | 98 | typedef std::list<SceneNode *> NodeList;
|
---|
| 99 | void addNodesToList(SceneNode* node, NodeList& list);
|
---|
| 100 |
|
---|
[1202] | 101 | void createMaterials(void);
|
---|
[1273] | 102 | void createSimpleScene(void);
|
---|
[1274] | 103 |
|
---|
| 104 | RaySceneQuery* mRaySceneQuery;
|
---|
[1163] | 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 |
---|