Index: GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTreeAppListener.h
===================================================================
--- GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTreeAppListener.h	(revision 1202)
+++ GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTreeAppListener.h	(revision 1204)
@@ -61,20 +61,127 @@
 class KdTreeAppListener: public FrameListener, public KeyListener
 {
+
+public:
+	// visualization modes for scene nodes
+	enum VizMode
+	{
+		NODEVIZ_NONE, 
+		NODEVIZ_RENDER_NODES, 
+		NODEVIZ_RENDER_NODES_AND_CONTENT, 
+		NODEVIZ_MODES_NUM
+	};
+
+	enum AppState
+	{
+		AS_NORMAL,
+		AS_RECORD,
+		AS_PLAYBACK
+	};
+
+	struct Options
+	{
+		Options():
+		mDemoMode(false),
+		mRotateSpeed(36.0f),
+		mMoveSpeed(100.0f),
+		mRotationPeriod(30.0f),
+		mMaxDepth(12),
+		mKT(2.0f),
+		mKI(1.0f),
+		mRenderMethod("CHC")
+		{
+
+		}
+
+		String mDemoInfileName;
+		String mDemoOutfileName;
+		String mDemoLogfileName;
+		bool mDemoMode;
+		Degree mRotateSpeed;
+		Real mMoveSpeed;
+		Real mRotationPeriod;
+		int mMaxDepth;
+		Real mKT;
+		Real mKI;
+		String mRenderMethod;
+	};
+
+    // Constructor takes a RenderWindow because it uses that to determine input context
+    KdTreeAppListener(RenderWindow* win, SceneManager* sm, const Options& options,  
+		bool useBufferedInputKeys = false, bool useBufferedInputMouse = false);
+
+    virtual ~KdTreeAppListener();
+
+	void initOverlayElement(OverlayElement **elInfo, String ext, 
+		String name, int top, String caption);
+
+	void initStatsOverlay();
+
+	void initKdTreeOverlay();
+
+	void showDebugOverlay(bool show);
+
+	void toggleVizCamera();
+
+    virtual bool processUnbufferedKeyInput(const FrameEvent& evt);
+
+    bool processUnbufferedMouseInput(const FrameEvent& evt);
+
+	void moveCamera();
+
+    // Override frameStarted event to process that (don't care about frameEnded)
+    bool frameStarted(const FrameEvent& evt);
+
+    bool frameEnded(const FrameEvent& evt);
+
+	void switchMouseMode();
+
+	void switchKeyMode();
+
+	void keyClicked(KeyEvent* e);
+
+	void keyPressed(KeyEvent* e) {};
+	void keyReleased(KeyEvent* e) {};
+
+
 protected:
-	int mSceneDetailIndex ;
-    Real mMoveSpeed;
-    Degree mRotateSpeed;
-	Real mRotationPeriod;
+	// basic
+	RenderWindow* mWindow;
+	SceneManager *mSceneMgr;
+	Options mOptions;
+	bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn;
+
+	// elements
+	SceneNode *mCamNode;
+	Camera* mCamera;
+	Camera* mTopCam;
+
+	// toggle
+	bool mStatsOn;
+
+	bool mVizCamera;
 	bool mShowTree;
 	bool mFreeMove;
 	bool mTopCamFollow;
 
+	// counters
+	int mSeqNum;
+	unsigned int mNumScreenShots;
+
+	// rendering/texture options
+	int mSceneDetailIndex;
+	TextureFilterOptions mFiltering;
+	int mAniso;
+
+	// chc stats
 	Real mDelayedQueriesIssued;
 	Real mDelayedTraversedNodes;
 
-	int mSeqNum;
-
-	Overlay* mDebugOverlay;
-	Overlay* mKdTreeOverlay;
+	// overlays
+	Overlay *mDemoOverlay;
+	Overlay *mDebugOverlay;
+	Overlay *mKdTreeOverlay;
+
+	OverlayElement *mDemoStatus;
 
 	OverlayElement *mKdTreeMaxDepthInfo;
@@ -95,50 +202,29 @@
 	OverlayElement *mQueriesIssuedInfo;
 
+	// input
 	EventProcessor* mEventProcessor;
 	InputReader* mInputDevice;
-	SceneNode *mCamNode;
-	Camera* mCamera;
-	Camera* mTopCam;
-	SceneManager *mSceneMgr;
-	Radian mDeathAngle;
-
+
+	// movement
 	Vector3 mTranslateVector;
-	RenderWindow* mWindow;
-	bool mStatsOn;
-	bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn;
-	unsigned int mNumScreenShots;
+	Vector3 mVizCamTransVect;
+	Radian mRotX, mRotY;
 	float mMoveScale;
 	Degree mRotScale;
+	Radian mDeathAngle;
+
 	// just to stop toggles flipping too fast
 	Real mTimeUntilNextToggle ;
-	Radian mRotX, mRotY;
-	TextureFilterOptions mFiltering;
-	int mAniso;
-
-	// stuff for the viz camera
-	bool mVizCamera;
-	Vector3 mVizCamTransVect;
-
-    void updateStats(void);
 
 	// stuff for walkthrough recording/playback
-	String mDemoInfileName;
-	String mDemoOutfileName;
-
-	enum AppState
-	{
-		AS_NORMAL,
-		AS_RECORD,
-		AS_PLAYBACK
-	};
-
+	//std::ofstream mDemoFramesLog;
+	std::list<Real> mDemoFPS;
+	Real mTimeUntilNextLogWrite;
 	FrameList mFrameList;
 	FrameList::iterator mCurrFrame;
 	Real mTimeRemaining;
+	Real mWaitBeforeDemoStart;
 
 	AppState mAppState;
-
-	Overlay * mDemoOverlay;
-	OverlayElement * mDemoStatus;
 
 	void setDemoOverlay();
@@ -148,5 +234,5 @@
 
 	void saveFrameInfo(Real elapsedTime);
-	
+
 	/** save demo frame data to file **/
 	static void saveFrames(const String& filename, FrameList& framelist);
@@ -159,51 +245,5 @@
 	static void loadFramesBinary(const String& filename, FrameList& framelist);
 
-public:
-	// visualization modes for scene nodes
-	enum 
-	{
-		NODEVIZ_NONE, 
-		NODEVIZ_RENDER_NODES, 
-		NODEVIZ_RENDER_NODES_AND_CONTENT, 
-		NODEVIZ_MODES_NUM
-	};
-
-    // Constructor takes a RenderWindow because it uses that to determine input context
-    KdTreeAppListener(RenderWindow* win, SceneManager* sm, Real rs, Real ms, Real rp, 
-		const String& infile, const String& outfile, 
-		bool useBufferedInputKeys = false, bool useBufferedInputMouse = false);
-
-    virtual ~KdTreeAppListener();
-
-	void initOverlayElement(OverlayElement **elInfo, String ext, 
-		String name, int top, String caption);
-
-	void initStatsOverlay();
-
-	void initKdTreeOverlay();
-
-	void showDebugOverlay(bool show);
-
-	void toggleVizCamera();
-
-    virtual bool processUnbufferedKeyInput(const FrameEvent& evt);
-
-    bool processUnbufferedMouseInput(const FrameEvent& evt);
-
-	void moveCamera();
-
-    // Override frameStarted event to process that (don't care about frameEnded)
-    bool frameStarted(const FrameEvent& evt);
-
-    bool frameEnded(const FrameEvent& evt);
-
-	void switchMouseMode();
-
-	void switchKeyMode();
-
-	void keyClicked(KeyEvent* e);
-
-	void keyPressed(KeyEvent* e) {};
-	void keyReleased(KeyEvent* e) {};
+	void updateStats(void);
 };
 
