/*****************************************************************************

File: ClipmapSceneManager.h
Desc: The scenemanager for planetary terrains

Date: 2005/01/01

Author: Wim Lemkens

*****************************************************************************/

#ifndef __CLIPMAPSCENEMANAGER_H
#define __CLIPMAPSCENEMANAGER_H

#include <OgreSceneManager.h>

#include "ClipmapPatchManager.h"
#include "SeperateCubemappedPlanetReader.h"

namespace Ogre
{
	//----------------------------------------------------------------------------
	/// Factory for ClipmapSceneManager
	class ClipmapSceneManagerFactory : public SceneManagerFactory
	{
	protected:
		void initMetaData(void) const;
	public:
		ClipmapSceneManagerFactory() {}
		~ClipmapSceneManagerFactory() {}
		/// Factory type name
		static const String FACTORY_TYPE_NAME;
		SceneManager* createInstance(const String& instanceName);
		void destroyInstance(SceneManager* instance);
	};

	//----------------------------------------------------------------------------
	class ClipmapSceneManager : public SceneManager
	{
	public:
		/**
		* The constructor of the scenemanager itself
		*/
		ClipmapSceneManager(const String &name);

		/**
		* The destructor of the scenemanager
		*/
		virtual ~ClipmapSceneManager();

		/**
		* Setup the world
		* @param	const String &filename
		* 			The filename of the configuration file
		*/
		void setWorldGeometry(const String &filename);

		/**
		* Display the visible objects
		*/
		virtual void _renderVisibleObjects();

		/**
		* Clear the scene
		*/
		void clearScene(void);

		const String& getTypeName(void) const
		{
			return ClipmapSceneManagerFactory::FACTORY_TYPE_NAME;
		}

	private:
		///	The root of the scene to which everything will be attached
		SceneNode	    *mClipmapRoot;

		// Passthrough call to allow queries to access parent protected entity list
		//EntityList& getEntities() { return mEntities; }

		/**
		* Clear the world
		*/
		void flushWorldGeometry(void);

		///	The manager that updates the 6 sides of the cubemap
		ClipmapPatchManager* mClipmapPatchManager;

		/// The geometry reader to query the vertex-data from
		SeperateCubemappedPlanetReader *geometryReader;
	};

} // namespace Ogre


#endif
