#ifndef __KdTreeApp_H__ #define __KdTreeApp_H__ #include #include #include #include "TestKdTreeAppListener.h" class KdTreeAppRenderTargetListener : public RenderTargetListener { public: KdTreeAppRenderTargetListener(SceneManager *sceneMgr); protected: void preViewportUpdate (const RenderTargetViewportEvent &evt); void postRenderTargetUpdate (const RenderTargetEvent &evt); SceneManager *mSceneMgr; ShadowTechnique mSavedShadowTechnique; ColourValue mSavedAmbientLight; }; class KdTreeApp : public ExampleApplication { public: KdTreeApp() : mFrameListener(0), mRenderTargerListener(0) { } KdTreeApp(const KdTreeAppListener::Options& options) : mFrameListener(0), mRenderTargerListener(0), mOptions(options) { } ~KdTreeApp() { delete mRenderTargerListener; delete mFrameListener; } // save entities to ascii file bool saveSceneASCII(const String& filename, SceneNode *entityroot); protected: KdTreeAppListener *mFrameListener; KdTreeAppRenderTargetListener *mRenderTargerListener; SceneNode *mCamNode; SceneNode *mMoveNode; Camera *mTopCam; //Camera *mFollowCam; // scene options //String mSceneFiles; Real mRotationRadius; int mModelSpacing; int mModelCount; int mRandomCount; Real mPlaneDim; bool mShadowsEnabled; int mSelectEntities; KdTreeAppListener::Options mOptions; virtual void setupResources(void); virtual void createScene(void); virtual void createFrameListener(void); virtual void chooseSceneManager(void); virtual void createCamera(void); virtual void createViewports(void); /** Configures the application - returns false if the user chooses to abandon configuration. */ virtual bool configure(void); /** load scene from file **/ bool loadScene(const String& filename); bool loadSceneIV(const String &filename, SceneNode *root, const int index); // loadding world geometry from cfg file - for terrain bool loadSceneCfg(const String &filename, SceneNode *root, const int index); // load entities from ascii file bool loadSceneASCII(const String &filename, SceneNode *root, const int index); typedef std::list NodeList; void addNodesToList(SceneNode* node, NodeList& list); void createMaterials(void); void createSimpleScene(void); void createTerrainScene(Real max_x, Real max_y, Real max_z); Vector3 clampToGround(const Vector3& vect, Real offset, Real cap); RaySceneQuery* mRaySceneQuery; private: std::string cat(std::string name, int x, int z) { std::stringstream s; s.fill('0'); s << name; s.width(2); s << x; s.width(2); s << z; return s.str(); } }; #endif