Index: P/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityTerrainSceneManager.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityTerrainSceneManager.h	(revision 925)
+++ 	(revision )
@@ -1,201 +1,0 @@
-#ifndef _VisibilityTerrainSceneManager_H__
-#define _VisibilityTerrainSceneManager_H__
-
-#include <OgreSceneNode.h>
-#include <OgreTerrainSceneManager.h>
-#include <OgreOctreeNode.h>
-#include <OgreOctreeCamera.h>
-#include <OgrePrerequisites.h>
-
-#include "OgreOctreeHierarchyInterface.h"
-#include "OgrePlatformQueryManager.h"
-#include "VisibilityManager.h"
-
-
-namespace Ogre {
-
-/**
-	This class extends the terrain scene manager,
-	using occlusion queries for visibility culling.
-*/
-class __declspec(dllexport) VisibilityTerrainSceneManager: public TerrainSceneManager
-{
-public:
-	VisibilityTerrainSceneManager(const String& name, GtpVisibility::VisibilityManager *visManager);
-	~VisibilityTerrainSceneManager();
-
-	void _renderVisibleObjects();
-	void _findVisibleObjects(Camera* cam, bool onlyShadowCasters);
-	void _updateSceneGraph(Camera* cam);
-
-	/** Sets the given option for the SceneManager
-		@remarks Options are: "Algorithm", int *;			
-	*/
-	
-	virtual bool setOption(const String &, const void *);
-	/** Gets the given option for the Scene VisibilityManager.
-	    @remarks
-		See setOption
-	*/
-	virtual bool getOption(const String &, void *);
-
-	bool getOptionValues(const String & key, StringVector &refValueList);
-	bool getOptionKeys(StringVector &refKeys);
-
-	/** Sets the visibility manager.
-		@param visManager the visibility manager
-	*/
-	void setVisibilityManager(GtpVisibility::VisibilityManager *visManager);
-	/** See set.
-	*/
-	GtpVisibility::VisibilityManager *getVisibilityManager();
-
-	/** Render a queue group. 
-		Override so we can handle delayed rendering of transparent objects
-	*/
-	void renderBasicQueueGroupObjects(RenderQueueGroup* pGroup, 
-								 QueuedRenderableCollection::OrganisationMode om);
-
-	/** Writes out stats into the Ogre log file.
-	*/
-	void WriteLog();
-
-	/** We override this because we want to include the z-fail pass. 
-	*/
-	const Pass* _setPass(Pass* pass);
-	/** Override from SceneManager so we can skip all but first pass for depth pass. 
-	*/
-	bool validatePassForRendering(Pass* pass);
-	/** This function renders renderables using false color ids.
-	*/
-#ifdef ITEM_BUFFER
-	void RenderItemBuffer(RenderPriorityGroup* pGroup);
-	/** Renders a single object using false color id.
-	*/
-	void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass);
-	/** Overritten from scene manager to include the false color id rendering of the
-		scene objects.
-	*/
-#endif // ITEM_BUFFER
-	void _renderQueueGroupObjects(RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om);
-
-	/** Override from SceneManager so that sub entities can be assigned an id for item buffer.
-	*/
-	Entity* createEntity(const String& entityName, const String& meshName);
-
-	/** Returns pointer to visibility manager.
-	*/
-	GtpVisibility::VisibilityManager *GetVisibilityManager();
-
-	/** Returns hierarchy interface.
-	*/
-	OctreeHierarchyInterface *GetHierarchyInterface();
-
-	/** Inherited from scene manager. Neccesary to draw terrain properly.
-	*/
-	void endFrame();
-
-	/** Override this because we must handle shadows differently.
-	*/
-	void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup,
-		QueuedRenderableCollection::OrganisationMode om);
-	/** Override this because we must handle shadows differently.
-	*/
-	void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup, 
-		QueuedRenderableCollection::OrganisationMode om);
-/// @copydoc SceneManager::getTypeName
-	const String& getTypeName(void) const;
-	static const String FACTORY_TYPE_NAME;
-
-	void setWorldGeometry( DataStreamPtr& stream, const String& typeName );
-
-protected:
-	
-	/** Creates material for depth pass, e.g., a pass that only fills the depth buffer. 
-	*/
-	void InitDepthPass();
-	/** Creates material for item buffer. 
-	*/
-	void InitItemBufferPass();
-	/** Fills render queue so that a visualization can be rendered. 
-	*/
-	void PrepareVisualization(Camera *cam);
-	/** Initialises necessary parameters for hierarchical visibility culling.
-	*/
-	void InitVisibilityCulling(Camera *cam);
-
-
-
-	/// the interface to the scene hierarchy.
-	OctreeHierarchyInterface *mHierarchyInterface;
-	/// manages all visibility options
-	GtpVisibility::VisibilityManager *mVisibilityManager;
-
-	/// if a visualization of the hierarchical culling is shown
-	bool mShowVisualization;
-
-	/// if the culled nodes are indicated in the visualization
-	bool mVisualizeCulledNodes;
-
-	/// if symbols for the nodes are shown in the visualization
-	bool mRenderNodesForViz;
-	/// if content of the nodes is shown in the visualization
-	bool mRenderNodesContentForViz;
-
-	/// if we render transparents after the hierarchical traversal
-	bool mDelayRenderTransparents;
-
-	/// if we use a depth pass (i.e., fill only the depth buffer in the first pass)
-	bool mUseDepthPass;
-	/// if we currently rendering the depth pass
-	bool mIsDepthPassPhase;
-	
-	/// if we use an item buffer for rendering (i.e., object ids as color codes
-	bool mUseItemBuffer;
-	/// if we currently render the item buffer 
-	bool mIsItemBufferPhase;
-
-	/// if depth write should be enabled
-	bool mEnableDepthWrite;
-	/// if transparents are skipped during rendering
-	bool mSkipTransparents;
-
-	/// the depth pass (no lighting, just filling the depth buffer)
-	Pass *mDepthPass;
-	Pass *mItemBufferPass;
-
-	int mCurrentEntityId;
-	/// flag for passes which should not be deleted from queue during first traversal
-	int mLeavePassesInQueue;
-
-
-	/// if transparent object are considered for item buffer visibility
-	bool mRenderTransparentsForItemBuffer;
-	/// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer
-	bool mExecuteVertexProgramForAllPasses;
-
-	bool mIsHierarchicalCulling;
-
-	std::ofstream mDummyLog;
-};
-
-/// Factory for VisibilityTerrainSceneManager
-class VisibilityTerrainSceneManagerFactory : public SceneManagerFactory
-{
-protected:
-	typedef std::vector<TerrainPageSource*> TerrainPageSources;
-	TerrainPageSources mTerrainPageSources;
-	void initMetaData(void) const;
-	GtpVisibility::VisibilityManager *visManager;
-public:
-	VisibilityTerrainSceneManagerFactory(GtpVisibility::VisibilityManager *vm);
-	~VisibilityTerrainSceneManagerFactory();
-	/// Factory type name
-	static const String FACTORY_TYPE_NAME;
-	SceneManager* createInstance(const String& instanceName);
-	void destroyInstance(SceneManager* instance);
-};
-
-} // namespace Ogre
-
-#endif // CullingTerrainSceneManager_H
Index: P/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityOctreeSceneManager.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityOctreeSceneManager.h	(revision 925)
+++ 	(revision )
@@ -1,229 +1,0 @@
-#ifndef _VisibilityOctreeSceneManager_H__
-#define _VisibilityOctreeSceneManager_H__
-
-#include <OgreSceneNode.h>
-#include <OgreOctreeSceneManager.h>
-#include <OgreOctreeNode.h>
-#include <OgreOctreeCamera.h>
-#include <OgrePrerequisites.h>
-#include <OgreMovableObject.h>
-#include "OgreOctreeHierarchyInterface.h"
-#include "OgrePlatformQueryManager.h"
-#include "VisibilityManager.h"
-#include "Containers.h"
-#include "ViewCellsManager.h"
-
-//class GtpVisibilityPreprocessor::ViewCellsManager;
-
-
-namespace Ogre {
-
-/**
-	This class extends the octree scene manager, using 
-	occlusion queries for visibility culling.
-*/
-class __declspec(dllexport) VisibilityOctreeSceneManager: public OctreeSceneManager
-{
-public:
-	VisibilityOctreeSceneManager(const String& name, GtpVisibility::VisibilityManager *visManager);
-	~VisibilityOctreeSceneManager();
-
-	void _renderVisibleObjects();
-	void _findVisibleObjects(Camera* cam, bool onlyShadowCasters);
-	void _updateSceneGraph(Camera* cam );
-
-	/** Sets the given option for the SceneManager
-		@remarks Options are: "Algorithm", int *;			
-	*/
-	
-	virtual bool setOption(const String &, const void *);
-	/** Gets the given option for the Scene VisibilityManager.
-	    @remarks
-		See setOption
-	*/
-	virtual bool getOption(const String &, void *);
-
-	bool getOptionValues(const String & key, StringVector &refValueList);
-	bool getOptionKeys(StringVector &refKeys);
-
-	/** Sets the visibility manager.
-		@param visManager the visibility manager
-	*/
-	void setVisibilityManager(GtpVisibility::VisibilityManager *visManager);
-	/** See set.
-	*/
-	GtpVisibility::VisibilityManager *getVisibilityManager();
-	
-	/** Render a queue group. 
-		Override so we can handle delayed rendering of transparent objects
-	*/
-	void renderBasicQueueGroupObjects(RenderQueueGroup* pGroup, 
-								 QueuedRenderableCollection::OrganisationMode om);
-
-	/** Writes out stats into the Ogre log file.
-	*/
-	void WriteLog();
-
-	/** Override pass so we can do the z-fail pass. 
-	*/
-	const Pass* _setPass(Pass* pass);
-
-	/** Override from SceneManager so we can skip all but first pass for depth pass. 
-	*/
-	bool validatePassForRendering(Pass* pass);
-#ifdef ITEM_BUFFER
-	void RenderItemBuffer(RenderPriorityGroup* pGroup);
-	void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass);
-#endif // ITEM_BUFFER
-	void _renderQueueGroupObjects(RenderQueueGroup* pGroup,
-		QueuedRenderableCollection::OrganisationMode om);
-
-	/** Override from SceneManager so that sub entities can be assigned an id for item buffer.
-	*/
-	Entity* createEntity(const String& entityName, const String& meshName);
-
-	/** Returns pointer to visibility manager.
-	*/
-	GtpVisibility::VisibilityManager *GetVisibilityManager();
-
-	/** Returns hierarchy interface.
-	*/
-	OctreeHierarchyInterface *GetHierarchyInterface();
-
-	void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup, 
-		QueuedRenderableCollection::OrganisationMode om);
-	void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup,
-		QueuedRenderableCollection::OrganisationMode om);
-
-	void loadVisibilityConfig(const String& filename);
-
-
-	/** Loads view cells for this particular scene.
-	*/
-	void LoadViewCells(std::string filename);
-
-protected:
-	
-	/** Creates material for depth pass, e.g., a pass that only fills the depth buffer. 
-	*/
-	void InitDepthPass();
-	/** Creates material for item buffer. 
-	*/
-	void InitItemBufferPass();
-	/** Fills render queue so that a visualization can be rendered. 
-	*/
-	void PrepareVisualization(Camera *cam);
-	/** Initialises necessary parameters for hierarchical visibility culling.
-	*/
-	void InitVisibilityCulling(Camera *cam);
-	
-	/** Finds object corresponding to this bounding box in the scene.
-	*/
-	Entity *FindCorrespondingObject(const AxisAlignedBox &box);
-
-	/** Identifies objects in the scene and gives them unique ids that
-		correspond to preprocessor ids.
-	*/
-	void IdentifyObjects(GtpVisibilityPreprocessor::ObjectContainer &objects);
-
-	/** Loads / unloads pvs of the view cell to set the visibility in the scene.
-	*/
-	void applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, const bool load);
-
-	/** updates pvs in current frame.
-	*/
-	void updatePvs(Camera *cam);
-
-	/** Sets all objects invisible.
-	*/
-	void SetObjectsVisible(const bool visible);
-
-	/// the interface to the scene hierarchy.
-	OctreeHierarchyInterface *mHierarchyInterface;
-	/// manages all visibility options
-	GtpVisibility::VisibilityManager *mVisibilityManager;
-	
-	/// if a visualization of the hierarchical culling is shown
-	bool mShowVisualization;
-
-	/// if the culled nodes are indicated in the visualization
-	bool mVisualizeCulledNodes;
-
-	/// if symbols for the nodes are shown in the visualization
-	bool mRenderNodesForViz;
-	/// if content of the nodes is shown in the visualization
-	bool mRenderNodesContentForViz;
-
-	/// render transparents after the hierarchical traversal
-	bool mDelayRenderTransparents;
-
-	/// use a depth pass (i.e., fill only the depth buffer in the first pass)
-	bool mUseDepthPass;
-	/// flag indicating if we currently render the depth pass
-	bool mIsDepthPassPhase;
-
-	/// if we use an item buffer for rendering (i.e., object ids as color codes
-	bool mUseItemBuffer;
-	/// if we currently render the item buffer 
-	bool mIsItemBufferPhase;
-
-	/// if depth write should be enabled
-	bool mEnableDepthWrite;
-	/// if transparents are skipped during rendering
-	bool mSkipTransparents;
-
-	/// the depth pass (no lighting, just filling the depth buffer)
-	Pass *mDepthPass;
-	Pass *mItemBufferPass;
-
-	int mCurrentEntityId;
-	/// flag for passes which should not be deleted from queue during first traversal
-	int mLeavePassesInQueue;
-	
-
-	/// if transparent object are considered for item buffer visibility
-	bool mRenderTransparentsForItemBuffer;
-	/// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer
-	bool mExecuteVertexProgramForAllPasses;
-
-	/// if hierarchical culling is currently in use
-	bool mIsHierarchicalCulling;
-
-	bool mViewCellsLoaded;
-	GtpVisibilityPreprocessor::ViewCellsManager *mViewCellsManager;
-
-
-	/// Used to assign Ogre meshes to view cell entries.
-	GtpVisibilityPreprocessor::ObjectContainer mObjects;
-
-	GtpVisibilityPreprocessor::ViewCell *mElementaryViewCell;
-	GtpVisibilityPreprocessor::ViewCell *mCurrentViewCell;
-
-	/// If view cells are used.
-	bool mUseViewCells;
-
-	/// if the view cells are filtered
-	bool mUseVisibilityFilter;
-};
-
-/// Factory for VisibilityOctreeSceneManager
-class VisibilityOctreeSceneManagerFactory : public SceneManagerFactory
-{
-protected:
-	void initMetaData(void) const;
-	GtpVisibility::VisibilityManager *visManager;
-public:
-	VisibilityOctreeSceneManagerFactory(GtpVisibility::VisibilityManager *vm)
-	{
-		visManager = vm;
-	}
-	~VisibilityOctreeSceneManagerFactory() {}
-	/// Factory type name
-	static const String FACTORY_TYPE_NAME;
-	SceneManager* createInstance(const String& instanceName);
-	void destroyInstance(SceneManager* instance);
-};
-
-} // namespace Ogre
-
-#endif // VisibilityOctreeSceneManager_H
Index: P/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBspHierarchyInterface.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBspHierarchyInterface.h	(revision 345)
+++ 	(revision )
@@ -1,48 +1,0 @@
-#ifndef _BspHierarchyInterface_H__
-#define _BspHierarchyInterface_H__
-
-#include "OgrePlatformHierarchyInterface.h"
-
-namespace Ogre {
-/**
-	This class implements the hierarchy interface for the Ogre bsp hierarchy.
-*/
-class BspHierarchyInterface : public PlatformHierarchyInterface
-{
-public:
-	BspHierarchyInterface(SceneManager *sm, RenderSystem *rsys);
-
-	/** Gets the given option for the scene traverser.
-	    @remarks
-		See setOption
-	*/
-	//bool getOption( const String &, void * );
-	//bool getOptionKeys( StringVector &refKeys );
-	void PullUpVisibility(GtpVisibility::HierarchyNode *node) const;
-	/** Traverses given node.
-		@param node current node
-		@remark pushes children on the distance queue
-	*/
-	void TraverseNode(GtpVisibility::HierarchyNode *node);
-	void RenderNode(GtpVisibility::HierarchyNode *node);
-	bool IsLeaf(GtpVisibility::HierarchyNode *node) const;
-	bool HasGeometry(GtpVisibility::HierarchyNode *node) const;
-	float GetSquaredDistance(GtpVisibility::HierarchyNode *node) const;
-	
-	void SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible) const;
-	void SetLastVisited(GtpVisibility::HierarchyNode *node, 
-						const unsigned int frameId) const;
-
-	bool IsNodeVisible(GtpVisibility::HierarchyNode *node) const;
-	unsigned int LastVisited(GtpVisibility::HierarchyNode *node) const;
-
-protected:
-	/** Returns pointer to the bounding box of the node.
-		@param node current hierarchy node
-		@returns bounding box of current node
-	*/
-	AxisAlignedBox *GetBoundingBox(GtpVisibility::HierarchyNode *node);
-};
-} // namespace Ogre
-
-#endif // BspHierarchyInterface_H
Index: P/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityBspSceneManager.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityBspSceneManager.h	(revision 59)
+++ 	(revision )
@@ -1,61 +1,0 @@
-#ifndef _VisibilityBspSceneManager_H__
-#define _VisibilityBspSceneManager_H__
-
-#include <OgreSceneNode.h>
-#include <OgreBspSceneManager.h>
-#include <OgreOctreeNode.h>
-#include <OgreOctreeCamera.h>
-#include <OgrePrerequisites.h>
-
-#include "OgreBspHierarchyInterface.h"
-#include "GtpVisibility/Manager.h"
-
-namespace Ogre {
-
-/**
-	This class extends the octree scene manager, using 
-	occlusion queries for visibility culling.
-*/
-class VisibilityBspSceneManager: public BspSceneManager
-{
-public:
-	VisibilityBspSceneManager(GtpVisibility::Manager *visManager);
-	~VisibilityBspSceneManager();
-
-	void _renderVisibleObjects();
-	void _findVisibleObjects(Camera* cam, bool onlyShadowCasters);
-	void _updateSceneGraph(Camera* cam );
-
-	/** Sets the given option for the SceneManager
-			    @remarks
-		Options are:
-		"Algorithm", int *;			
-	*/
-	
-	virtual bool setOption(const String &, const void *);
-	/** Gets the given option for the Scene Manager.
-	    @remarks
-		See setOption
-	*/
-	virtual bool getOption(const String &, void *);
-
-	bool getOptionValues(const String & key, StringVector &refValueList);
-	bool getOptionKeys(StringVector &refKeys);
-
-	/** Sets the visibility manager.
-		@param visManager the visibility manager
-	*/
-	void setVisibilityManager(GtpVisibility::Manager *visManager);
-	/** See set.
-	*/
-	GtpVisibility::Manager *getVisibilityManager( void );
-
-protected:
-	
-	BspHierarchyInterface *mHierarchyInterface;
-	GtpVisibility::Manager *mVisibilityManager;
-};
-
-} // namespace Ogre
-
-#endif // VisibilityBspSceneManager_H
Index: P/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityDotSceneManager.h
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityDotSceneManager.h	(revision 59)
+++ 	(revision )
@@ -1,58 +1,0 @@
-#ifndef _VisibilityDotSceneManager_H__
-#define _VisibilityDotSceneManager_H__
-
-#include <OgreSceneNode.h>
-#include <DotSceneManager.h>
-#include <OgrePrerequisites.h>
-#include "VisibilityManager.h"
-#include "OgreSceneNodeHierarchyInterface.h"
-
-namespace Ogre {
-
-/**
-	This class extends the dot scene manager, using occlusion queries for 
-	visibility culling. 
-	@remark the scene manager can operate on Ogre scene descriptions in 
-	XML defined by the ".scene" format
-*/
-class VisibilityDotSceneManager: public DotSceneManager
-{
-public:
-	VisibilityDotSceneManager(GtpVisibility::VisibilityManager *visManager);
-	~VisibilityDotSceneManager();
-
-	void _renderVisibleObjects();
-	void _findVisibleObjects(Camera* cam, bool onlyShadowCasters);
-	void _updateSceneGraph(Camera* cam);
-
-	/** Sets the given option for the SceneManager
-		@remarks
-		Options are:
-		"Algorithm", int *;			
-	*/
-	virtual bool setOption(const String &, const void *);
-	/** Gets the given option for the Scene VisibilityManager.
-	    @remarks
-		See setOption
-	*/
-	virtual bool getOption(const String &, void *);
-
-	bool getOptionValues(const String & key, StringVector &refValueList);
-	bool getOptionKeys(StringVector &refKeys);
-
-	/** Sets the visibility manager.
-		@param visManager the visibility manager
-	*/
-	void setVisibilityManager(GtpVisibility::VisibilityManager *visManager);
-	/** See set.
-	*/
-	GtpVisibility::VisibilityManager *getVisibilityManager();
-
-protected:
-
-	Ogre::SceneNodeHierarchyInterface *mHierarchyInterface;
-	GtpVisibility::VisibilityManager *mVisibilityManager;
-};
-} // namespace Ogre
-
-#endif // VisibilityDotSceneManager_H
Index: P/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityTerrainSceneManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityTerrainSceneManager.cpp	(revision 925)
+++ 	(revision )
@@ -1,973 +1,0 @@
-#include "OgreVisibilityTerrainSceneManager.h"
-#include "OgreVisibilityOptionsManager.h"
-#include <OgreMath.h>
-#include <OgreIteratorWrappers.h>
-#include <OgreRenderSystem.h>
-#include <OgreCamera.h>
-#include <OgreLogManager.h>
-#include <OgreStringConverter.h>
-#include <OgreEntity.h>
-#include <OgreSubEntity.h>
-#include <OgreConfigFile.h>
-#include <OgreMaterialManager.h>
-#include <OgreHeightmapTerrainPageSource.h>
-
-// normal terrain rendering
-const static int NORMAL_RENDER_HACK = false;
-
-namespace Ogre {
-
-//-----------------------------------------------------------------------
-VisibilityTerrainSceneManager::VisibilityTerrainSceneManager(const String& name, 
-	GtpVisibility::VisibilityManager *visManager):
-TerrainSceneManager(name),
-mVisibilityManager(visManager), 
-mShowVisualization(false),
-mRenderNodesForViz(false),
-mRenderNodesContentForViz(false),
-mVisualizeCulledNodes(false),
-mLeavePassesInQueue(0),
-mDelayRenderTransparents(true),
-mUseDepthPass(false),
-mIsDepthPassPhase(false),
-mUseItemBuffer(false),
-mIsItemBufferPhase(false),
-mCurrentEntityId(1),
-mEnableDepthWrite(true),
-mSkipTransparents(false),
-mRenderTransparentsForItemBuffer(true),
-mExecuteVertexProgramForAllPasses(false),
-mIsHierarchicalCulling(false)
-{
-	mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem);
-	
-	if (0)
-	{
-		mDisplayNodes = true;
-		mShowBoundingBoxes = true;
-		mShowBoxes = true;
-	}
-
-	// TODO: set maxdepth to reasonable value
-	mMaxDepth = 50;
-}
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::InitDepthPass()
-{
-	MaterialPtr depthMat = MaterialManager::getSingleton().getByName("Visibility/DepthPass");
-
-	if (depthMat.isNull())
-    {
-		depthMat = MaterialManager::getSingleton().create(
-                "Visibility/DepthPass",
-                ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
-
-        mDepthPass = depthMat->getTechnique(0)->getPass(0);
-
-		mDepthPass->setColourWriteEnabled(false);
-		mDepthPass->setDepthWriteEnabled(true);
-		mDepthPass->setLightingEnabled(false);
-		//mDepthPass->setDepthCheckEnabled(false);
-	}
-	else
-	{
-		mDepthPass = depthMat->getTechnique(0)->getPass(0);
-	}
-}
-//-----------------------------------------------------------------------
-VisibilityTerrainSceneManager::~VisibilityTerrainSceneManager()
-{
-	OGRE_DELETE(mHierarchyInterface);
-}
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::InitItemBufferPass()
-{
-	MaterialPtr itemBufferMat = MaterialManager::getSingleton().
-		getByName("Visibility/ItemBufferPass");
-
-	if (itemBufferMat.isNull())
-    {
-		// Init
-		itemBufferMat = MaterialManager::getSingleton().create("Visibility/ItemBufferPass",
-                ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
-
-		mItemBufferPass = itemBufferMat->getTechnique(0)->getPass(0);
-		mItemBufferPass->setColourWriteEnabled(true);
-		mItemBufferPass->setDepthWriteEnabled(true);
-		mItemBufferPass->setLightingEnabled(true);
-		//mItemBufferPass->setLightingEnabled(false);
-	}
-	else
-	{
-		mItemBufferPass = itemBufferMat->getTechnique(0)->getPass(0);
-	}
-	//mItemBufferPass->setAmbient(1, 1, 0);
-}
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::PrepareVisualization(Camera *cam)
-{
-	// add player camera for visualization purpose
-	try 
-	{
-		Camera *c;
-		if ((c = getCamera("PlayerCam")) != NULL)
-		{
-			getRenderQueue()->addRenderable(c);
-		}   
-    }
-    catch (...)
-    {
-        // ignore
-    }
-	// add bounding boxes of rendered objects
-	for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it)
-	{
-		getRenderQueue()->addRenderable(*it);
-	}
-	
-	if (mRenderNodesForViz || mRenderNodesContentForViz)
-	{
-		// HACK: change node material so it is better suited for visualization
-		MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial");
-		nodeMat->setAmbient(1, 1, 0);
-		nodeMat->setLightingEnabled(true);
-		nodeMat->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();
-
-		for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it)
-		{
-			if (mRenderNodesForViz)
-			{
-				// render the leaf nodes
-				if (((*it)->numAttachedObjects() > 0) && ((*it)->numChildren() == 0) && 
-					 (*it)->getAttachedObject(0)->getMovableType() == "Entity")
-				{
-					getRenderQueue()->addRenderable((*it));
-				}
-
-				// addbounding boxes instead of node itself
-				//(*it)->_addBoundingBoxToQueue(getRenderQueue());
-			}
-			if (mRenderNodesContentForViz) 
-			{
-				(*it)->_addToRenderQueue(cam, getRenderQueue(), false);
-			}
-		}
-	}	
-}
-//-----------------------------------------------------------------------
-const Pass *VisibilityTerrainSceneManager::_setPass(Pass* pass)
-{
-	if (NORMAL_RENDER_HACK)
-	{
-		return SceneManager::_setPass(pass);
-	}
-
-	// TODO: setting vertex program is not efficient
-	//Pass *usedPass = ((mIsDepthPassPhase && !pass->hasVertexProgram()) ? mDepthPass : pass); 
-	
-	// set depth fill pass if we currently do not make an aabb occlusion query
-	const bool useDepthPass = 
-		(mIsDepthPassPhase && !mHierarchyInterface->IsBoundingBoxQuery());
-
-	Pass *usedPass = useDepthPass ? mDepthPass : pass;
-	
-
-	const IlluminationRenderStage savedStage = mIlluminationStage; 
-	
-	// set illumination stage to NONE so no shadow material is used 
-	// for depth pass or for occlusion query
-	if (mIsDepthPassPhase || mHierarchyInterface->IsBoundingBoxQuery())
-	{
-		mIlluminationStage = IRS_NONE;
-	}
-	
-	// --- set vertex program of current pass in order to set correct depth
-	if (mExecuteVertexProgramForAllPasses && 
-		mIsDepthPassPhase && 
-		pass->hasVertexProgram())
-	{
-		// add vertex program of current pass to depth pass
-		mDepthPass->setVertexProgram(pass->getVertexProgramName());
-
-		if (mDepthPass->hasVertexProgram())
-		{
-			const GpuProgramPtr& prg = mDepthPass->getVertexProgram();
-			// Load this program if not done already
-			if (!prg->isLoaded())
-				prg->load();
-			// Copy params
-			mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters());
-		}
-	}
-	else if (mDepthPass->hasVertexProgram()) // reset vertex program
-	{
-		mDepthPass->setVertexProgram("");
-	}
-	
-	// save old depth write: needed for item buffer
-	const bool IsDepthWrite = usedPass->getDepthWriteEnabled();
-
-	// global option which enables / disables depth writes
-	if (!mEnableDepthWrite)
-	{
-		usedPass->setDepthWriteEnabled(false);
-	}
-	
-
-	//-- set actual pass here
-	const Pass *result = SceneManager::_setPass(usedPass);
-
-
-	// reset depth write
-	if (!mEnableDepthWrite)
-	{
-		usedPass->setDepthWriteEnabled(IsDepthWrite);
-	}
-
-	// reset illumination stage
-	mIlluminationStage = savedStage;
-
-	return result;
-}
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam,
-														bool onlyShadowCasters)
-{
-	if (NORMAL_RENDER_HACK)
-	{
-		TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters);
-		return;
-	}
-
-	//-- show visible scene nodes and octree bounding boxes from last frame
-	if (mShowVisualization)
-    {
-		PrepareVisualization(cam);
-	}
-	else 
-	{	
-		// for hierarchical culling, we interleave identification 
-		// and rendering of objects in _renderVisibibleObjects
-
-		// for the shadow pass we use only standard rendering
-		// because of low occlusion
-		if (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && 
-			mIlluminationStage == IRS_RENDER_TO_TEXTURE)
-		{
-			TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters);
-		}
-
-		// only shadow casters will be rendered in shadow texture pass
-		if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);
-	}
-	
-	
-	// -- delete lists stored for visualization
-	mVisible.clear();
-	mBoxes.clear();
-}
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::_renderVisibleObjects()
-{
-	if (NORMAL_RENDER_HACK)
-	{
-		TerrainSceneManager::_renderVisibleObjects();
-
-		return;
-	}
-
-	InitDepthPass(); 	  // create material for depth pass
-	InitItemBufferPass(); // create material for item buffer pass
-
-	// save ambient light to reset later
-	ColourValue savedAmbient = mAmbientLight;
-
-	//-- apply standard rendering for some modes (e.g., visualization, shadow pass)
-
-	if (mShowVisualization ||
-	   (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && 
-	    mIlluminationStage == IRS_RENDER_TO_TEXTURE))
-	{	
-		IlluminationRenderStage savedStage = mIlluminationStage; 
-	
-		if (mShowVisualization) 
-		{
-			// disable illumination stage to prevent rendering shadows
-			mIlluminationStage = IRS_NONE;
-		}
-
-		// standard rendering for shadow maps because of performance
-		TerrainSceneManager::_renderVisibleObjects();
-
-		mIlluminationStage = savedStage;
-	}
-	else //-- the hierarchical culling algorithm
-	{ 
-		// this is also called in TerrainSceneManager: really
-                // nexessary?
-		mDestRenderSystem -> setLightingEnabled(false);
-
-		// don't render backgrounds for item buffer
-		if (mUseItemBuffer)
-		{
-			clearSpecialCaseRenderQueues();
-			getRenderQueue()->clear();
-		}
-
-		//-- hierarchical culling
-		// the objects of different layers (e.g., background, scene, 
-		// overlay) must be identified and rendered one after another
-
-		//-- render all early skies
-		clearSpecialCaseRenderQueues();
-		addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND);
-		addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY);
-		setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
-
-		OctreeSceneManager::_renderVisibleObjects();
-		/////////////////////////////////////////////////
-
-#ifdef GTP_VISIBILITY_MODIFIED_OGRE
-		// delete previously rendered content
-		_deleteRenderedQueueGroups();
-#endif
-
-		//-- prepare queue for visible objects (i.e., all but overlay and skies late)
-		clearSpecialCaseRenderQueues();
-		addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE);
-		addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY);
-	
-		// exclude this queues from hierarchical rendering
-		setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
-
-
-		// set all necessary parameters for 
-		// hierarchical visibility culling and rendering
-		InitVisibilityCulling(mCameraInProgress);
-
-
-		/** 
-		 * the hierarchical culling algorithm
-		 * for depth pass: we just find objects and update depth buffer
-		 * for "delayed" rendering: we render some passes afterwards
-		 * e.g., transparents, because they need front-to-back sorting
-		**/
-		
-		mVisibilityManager->ApplyVisibilityCulling();
-
-		// delete remaining renderables from queue:
-		// all which are not in mLeavePassesInQueue)
-#ifdef GTP_VISIBILITY_MODIFIED_OGRE
-		_deleteRenderedQueueGroups(mLeavePassesInQueue);
-#endif
-
-		//-- reset parameters
-		mIsDepthPassPhase = false;
-		mIsItemBufferPhase = false;
-		mSkipTransparents = false;
-		mLeavePassesInQueue = 0;
-		
-#if 1	
-		// add visible nodes found by the visibility culling algorithm
-		if (mUseDepthPass)
-		{
-			NodeList::const_iterator it, it_end = mVisible.end();
-
-			//getRenderQueue()->clear();
-			for (it = mVisible.begin(); it != it_end; ++ it)
-			{
-				(*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false);
-			}
-		}
-#endif	
-		//-- now we can render all remaining queue objects
-		//-- used for depth pass, transparents, overlay
-		clearSpecialCaseRenderQueues();
-	
-		OctreeSceneManager::_renderVisibleObjects();
-	
-	} // hierarchical culling
-		
-	// HACK: set the new render level index, important to avoid cracks
-	// in terrain caused by LOD
-	//TerrainRenderable::NextRenderLevelIndex();
-	
-	// reset ambient light
-	setAmbientLight(savedAmbient);
-
-	getRenderQueue()->clear(); // finally clear render queue
-	if (1) OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ...
-
-	if (0) WriteLog(); // write out stats
-}
-
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::_updateSceneGraph(Camera* cam)
-{
-	if (NORMAL_RENDER_HACK)
-	{
-		TerrainSceneManager::_updateSceneGraph(cam);
-		return;
-	}
-
-	mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface);
-	mHierarchyInterface->SetRenderSystem(mDestRenderSystem);
-
-	TerrainSceneManager::_updateSceneGraph(cam);
-}
-//-----------------------------------------------------------------------
-bool VisibilityTerrainSceneManager::setOption(const String & key, const void * val)
-{
-	if (key == "UseDepthPass")
-	{
-		mUseDepthPass = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "PrepareVisualization")
-	{
-		mShowVisualization = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "RenderNodesForViz")
-	{
-		mRenderNodesForViz = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "RenderNodesContentForViz")
-	{
-		mRenderNodesContentForViz = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "SkyBoxEnabled")
-	{
-		mSkyBoxEnabled = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "SkyPlaneEnabled")
-	{
-		mSkyPlaneEnabled = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "SkyDomeEnabled")
-	{
-		mSkyDomeEnabled = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "VisualizeCulledNodes")
-	{
-		mVisualizeCulledNodes = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "DelayRenderTransparents")
-	{
-		mDelayRenderTransparents = (*static_cast<const bool *>(val));
-		return true;
-	}
-
-	if (key == "DepthWrite")
-	{
-		mEnableDepthWrite = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "UseItemBuffer")
-	{
-		mUseItemBuffer = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "ExecuteVertexProgramForAllPasses")
-	{ 
-		mExecuteVertexProgramForAllPasses  = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "RenderTransparentsForItemBuffer")
-	{ 
-		mRenderTransparentsForItemBuffer  = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "NodeVizScale")
-	{ 
-		OctreeNode::setVizScale(*static_cast<const float *>(val));
-		return true;
-	}
-
-	return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
-		setOption(key, val) || TerrainSceneManager::setOption(key, val);
-}
-//-----------------------------------------------------------------------
-bool VisibilityTerrainSceneManager::getOption(const String & key, void *val)
-{
-	if (key == "NumHierarchyNodes")
-	{
-		* static_cast<unsigned int *>(val) = (unsigned int)mNumOctants;
-		return true;
-	}
-	
-	return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
-		getOption(key, val) && TerrainSceneManager::getOption(key, val);
-}
-//-----------------------------------------------------------------------
-bool VisibilityTerrainSceneManager::getOptionValues(const String & key, 
-													StringVector &refValueList)
-{
-	return TerrainSceneManager::getOptionValues( key, refValueList);
-}
-//-----------------------------------------------------------------------
-bool VisibilityTerrainSceneManager::getOptionKeys(StringVector & refKeys)
-{
-	return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
-		getOptionKeys(refKeys) || TerrainSceneManager::getOptionKeys(refKeys);
-}
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::setVisibilityManager(GtpVisibility::
-														 VisibilityManager *visManager)
-{
-	mVisibilityManager = visManager;
-}
-//-----------------------------------------------------------------------
-GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::getVisibilityManager()
-{
-	return mVisibilityManager;
-}
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::WriteLog()
-{
-	std::stringstream d;
-
-	d << "Depth pass: " << StringConverter::toString(mUseDepthPass) << ", "
-	  << "Delay transparents: " << StringConverter::toString(mDelayRenderTransparents) << ", "
-	  << "Use optimization: " << StringConverter::toString(mHierarchyInterface->GetTestGeometryForVisibleLeaves()) << ", "
-	  << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", "
-	  << "Hierarchy nodes: " << mNumOctants << ", " 
-	  << "Traversed nodes: " << mHierarchyInterface->GetNumTraversedNodes() << ", "
-	  << "Rendered nodes: " << mHierarchyInterface->GetNumRenderedNodes() << ", "
-	  << "Query culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumQueryCulledNodes() << ", "
-	  << "Frustum culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumFrustumCulledNodes() << ", "
-      << "Queries issued: " << mVisibilityManager->GetCullingManager()->GetNumQueriesIssued() << ", "
-	  << "Found objects: " << (int)mVisible.size() << "\n";
-
-	LogManager::getSingleton().logMessage(d.str());
-}
-//-----------------------------------------------------------------------
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::renderBasicQueueGroupObjects(RenderQueueGroup* pGroup, 
-																 QueuedRenderableCollection::OrganisationMode om)
-{
-    // Basic render loop
-    // Iterate through priorities
-    RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator();
-
-    while (groupIt.hasMoreElements())
-    {
-        RenderPriorityGroup* pPriorityGrp = groupIt.getNext();
-
-        // Sort the queue first
-        pPriorityGrp->sort(mCameraInProgress);
-
-        // Do solids
-        renderObjects(pPriorityGrp->getSolidsBasic(), om, true);
-
-		// for correct rendering, transparents must be rendered after hierarchical culling
-		// => do nothing
-
-        // Do transparents (always descending)
-		if (NORMAL_RENDER_HACK || !mSkipTransparents)
-		{
-			renderObjects(pPriorityGrp->getTransparents(), 
-			QueuedRenderableCollection::OM_SORT_DESCENDING, true);
-		}
-
-
-    }// for each priority
-}
-//-----------------------------------------------------------------------
-bool VisibilityTerrainSceneManager::validatePassForRendering(Pass* pass)
-{	
-	if (NORMAL_RENDER_HACK)
-	{
-		return SceneManager::validatePassForRendering(pass);
-	}
-
-	// skip all but first pass if we are doing the depth pass
-	if ((mIsDepthPassPhase || mIsItemBufferPhase) && (pass->getIndex() > 0))
-	{
-		return false;
-	}
-	// all but first pass
-	/*else if ((!mIsDepthPassPhase || mIsItemBufferPhase) && (pass->getIndex() != 0))
-	{
-		return false;
-	}*/
-
-	return SceneManager::validatePassForRendering(pass);
-}
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::_renderQueueGroupObjects(
-	RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om)
-{
-	if (NORMAL_RENDER_HACK || !mIsItemBufferPhase)
-	{
-		SceneManager::_renderQueueGroupObjects(pGroup, om);
-		return;
-	}
-#ifdef ITEM_BUFFER
-	//-- item buffer: render objects using false colors
-
-    // Iterate through priorities
-    RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator();
-
-	while (groupIt.hasMoreElements())
-    {
-		RenderItemBuffer(groupIt.getNext());
-	}
-#endif // ITEM_BUFFER
-}
-#ifdef ITEM_BUFFER
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup)
-{
-	// Do solids
-	RenderPriorityGroup::SolidRenderablePassMap solidObjs = pGroup->_getSolidPasses();
-
-	// ----- SOLIDS LOOP -----
-	RenderPriorityGroup::SolidRenderablePassMap::const_iterator ipass, ipassend;
-	ipassend = solidObjs.end();
-
-	for (ipass = solidObjs.begin(); ipass != ipassend; ++ipass)
-	{
-		// Fast bypass if this group is now empty
-		if (ipass->second->empty()) 
-			continue;
-
-		// Render only first pass of renderable as false color
-		if (ipass->first->getIndex() > 0)
-			continue;
-
-		RenderPriorityGroup::RenderableList* rendList = ipass->second;
-		
-		RenderPriorityGroup::RenderableList::const_iterator irend, irendend;
-		irendend = rendList->end();
-			
-		for (irend = rendList->begin(); irend != irendend; ++irend)
-		{
-			if (0)
-			{
-				std::stringstream d; d << "itembuffer, pass name: " << 
-				ipass->first->getParent()->getParent()->getName();
-				
-				LogManager::getSingleton().logMessage(d.str());
-			}
-			
-			RenderSingleObjectForItemBuffer(*irend, ipass->first);
-		}
-	}
-
-	//-- TRANSPARENT LOOP: must be handled differently from solids
-
-	// transparents are treated either as solids or completely discarded
-	if (mRenderTransparentsForItemBuffer)
-	{
-		RenderPriorityGroup::TransparentRenderablePassList transpObjs = 
-			pGroup->_getTransparentPasses();
-		RenderPriorityGroup::TransparentRenderablePassList::const_iterator 
-			itrans, itransend;
-
-		itransend = transpObjs.end();
-		for (itrans = transpObjs.begin(); itrans != itransend; ++itrans)
-		{
-			// like for solids, render only first pass
-			if (itrans->pass->getIndex() == 0)
-			{	
-				RenderSingleObjectForItemBuffer(itrans->renderable, itrans->pass);
-			}
-		}
-	}
-}
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass)
-{
-	static LightList nullLightList;
-	
-	int col[4];
-	
-	// -- create color code out of object id
-	col[0] = (rend->getId() >> 16) & 255;
-	col[1] = (rend->getId() >> 8) & 255;
-	col[2] = rend->getId() & 255;
-//	col[3] = 255;
-
-	//mDestRenderSystem->setColour(col[0], col[1], col[2], col[3]);
-    
-	mItemBufferPass->setAmbient(ColourValue(col[0] / 255.0f,
-										    col[1] / 255.0f, 
-											col[2] / 255.0f, 1));
-
-	// set vertex program of current pass
-	if (mExecuteVertexProgramForAllPasses && pass->hasVertexProgram())
-	{
-		mItemBufferPass->setVertexProgram(pass->getVertexProgramName());
-
-		if (mItemBufferPass->hasVertexProgram())
-		{
-			const GpuProgramPtr& prg = mItemBufferPass->getVertexProgram();
-			// Load this program if not done already
-			if (!prg->isLoaded())
-				prg->load();
-			// Copy params
-			mItemBufferPass->setVertexProgramParameters(pass->getVertexProgramParameters());
-		}
-	}
-	else if (mItemBufferPass->hasVertexProgram())
-	{
-		mItemBufferPass->setVertexProgram("");
-	}
-
-	Pass *usedPass = setPass(mItemBufferPass); 
-
-
-	// render a single object, this will set up auto params if required
-	renderSingleObject(rend, usedPass, false, &nullLightList);
-}
-#endif // ITEM_BUFFER
-//-----------------------------------------------------------------------
-GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::GetVisibilityManager()
-{
-	return mVisibilityManager;
-}
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::InitVisibilityCulling(Camera *cam)
-{
-	// reset culling manager stats
-	mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes);
-
-	// set depth pass flag before rendering
-	mIsDepthPassPhase = mUseDepthPass;
-
-	mIsHierarchicalCulling = true; // during hierarchical culling
-
-	// item buffer needs full ambient lighting to use item colors as unique id
-	if (mUseItemBuffer) 
-	{
-		mIsItemBufferPhase = true;
-		setAmbientLight(ColourValue(1,1,1,1));
-	}
-
-
-	// set passes which are stored in render queue 
-	// for rendering AFTER hierarchical culling, i.e., passes which need 
-	// a special rendering order
-	
-	mLeavePassesInQueue = 0;
-
-	if (!mUseDepthPass && !mUseItemBuffer)
-	{
-		if (mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE)
-		{
-			// TODO: remove this pass because it should be processed during hierarchical culling
-			//mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_NOSHADOW;
-
-			mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_DECAL;
-			mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_DIFFUSE_SPECULAR;
-			mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES;
-
-			// just render ambient stuff
-			/*** msz: no more IRS_AMBIENT, see OgreSceneManager.h ***/
-			// mIlluminationStage = IRS_AMBIENT;
-		}
-	
-		if (mShadowTechnique == SHADOWTYPE_STENCIL_MODULATIVE)
-		{
-			mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_NOSHADOW;
-			mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES;
-		}
-	
-		// transparents should be rendered after hierarchical culling to 
-		// provide front-to-back ordering
-		if (mDelayRenderTransparents)
-		{
-			mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES;
-		}
-	}
-
-	// skip rendering transparents during the hierarchical culling
-	// (because they will be rendered afterwards)
-	mSkipTransparents = 
-		(mIsDepthPassPhase || (mLeavePassesInQueue & RenderPriorityGroup::TRANSPARENT_PASSES));
-
-	// -- initialise interface for rendering traversal of the hierarchy
-	mHierarchyInterface->SetHierarchyRoot(mOctree);
-	
-	// possible two cameras (one for culling, one for rendering)
-	mHierarchyInterface->InitTraversal(mCameraInProgress, 
-									   mCullCamera ? getCamera("CullCamera") : NULL,
-									   mLeavePassesInQueue);
-		
-	//std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue;LogManager::getSingleton().logMessage(d.str());
-}
-//-----------------------------------------------------------------------
-OctreeHierarchyInterface *VisibilityTerrainSceneManager::GetHierarchyInterface()
-{
-	return mHierarchyInterface;
-}
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::endFrame()
-{
-	TerrainRenderable::ResetRenderLevelIndex();
-}
-//-----------------------------------------------------------------------
-Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName, 
-													const String& meshName)
-{
-	Entity *ent = SceneManager::createEntity(entityName, meshName);
-
-	for (int i = 0; i < (int)ent->getNumSubEntities(); ++i)
-	{
-		ent->getSubEntity(i)->setId(mCurrentEntityId);
-	}
-
-	// increase counter of entity id values
-	++ mCurrentEntityId;
-
-	return ent;
-}
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(
-	RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om)
-{
-	// only render solid passes during hierarchical culling
-	if (mIsHierarchicalCulling)
-	{
-		RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator();
-	    LightList lightList;
-
-		while (groupIt.hasMoreElements())
-		{
-			RenderPriorityGroup* pPriorityGrp = groupIt.getNext();
-
-			// Sort the queue first
-			pPriorityGrp->sort(mCameraInProgress);
-
-			// Clear light list
-			lightList.clear();
-
-			// Render all the ambient passes first, no light iteration, no lights
-			/*** msz: no more IRS_AMBIENT, see OgreSceneManager.h ***/
-			// mIlluminationStage = IRS_AMBIENT;
-
-			OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsBasic(), om, false, &lightList);
-			// Also render any objects which have receive shadows disabled
-			OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsNoShadowReceive(), om, true);
-		}
-	}
-	else // render the rest of the passes
-	{
-		OctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(pGroup, om);
-	}
-}
-//-----------------------------------------------------------------------
-void VisibilityTerrainSceneManager::renderModulativeStencilShadowedQueueGroupObjects(
-	RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om)
-{
-   if (mIsHierarchicalCulling)
-   {
-	   // Iterate through priorities
-	   RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator();
-
-	   while (groupIt.hasMoreElements())
-	   {
-		   RenderPriorityGroup* pPriorityGrp = groupIt.getNext();
-
-		   // Sort the queue first
-		   pPriorityGrp->sort(mCameraInProgress);
-
-		   // Do (shadowable) solids
-		   OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsBasic(), om, true);
-	   }
-   }
-   else
-   {
-	   SceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup, om);
-   }
-}
-
-const String& VisibilityTerrainSceneManager::getTypeName(void) const
-{
-	return VisibilityTerrainSceneManagerFactory::FACTORY_TYPE_NAME;
-}
-
-//-------------------------------------------------------------------------
-void VisibilityTerrainSceneManager::setWorldGeometry( DataStreamPtr& stream, const String& typeName )
-{
-    // Clear out any existing world resources (if not default)
-    if (ResourceGroupManager::getSingleton().getWorldResourceGroupName() != 
-        ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME)
-    {
-        ResourceGroupManager::getSingleton().clearResourceGroup(
-            ResourceGroupManager::getSingleton().getWorldResourceGroupName());
-    }
-	destroyLevelIndexes();
-    mTerrainPages.clear();
-    // Load the configuration
-    loadConfig( stream );
-	initLevelIndexes();
-
-    // Resize the octree, allow for 1 page for now
-    float max_x = mOptions.scale.x * mOptions.pageSize;
-    float max_y = mOptions.scale.y;
-    float max_z = mOptions.scale.z * mOptions.pageSize;
-
-	float maxAxis = std::max(max_x, max_y);
-	maxAxis = std::max(maxAxis, max_z);
-	resize( AxisAlignedBox( 0, 0, 0, maxAxis, maxAxis, maxAxis ) );
-    
-    setupTerrainMaterial();
-
-    setupTerrainPages();
-
- }
-
-	//-----------------------------------------------------------------------
-	const String VisibilityTerrainSceneManagerFactory::FACTORY_TYPE_NAME = "VisibilityTerrainSceneManager";
-	//-----------------------------------------------------------------------
-	VisibilityTerrainSceneManagerFactory::VisibilityTerrainSceneManagerFactory(
-		GtpVisibility::VisibilityManager *vm)
-	{
-		visManager = vm;
-	}
-	//-----------------------------------------------------------------------
-	VisibilityTerrainSceneManagerFactory::~VisibilityTerrainSceneManagerFactory()
-	{
-		for (TerrainPageSources::iterator i = mTerrainPageSources.begin();
-			i != mTerrainPageSources.end(); ++i)
-		{
-			delete *i;
-		}
-		mTerrainPageSources.clear();
-	}
-	//-----------------------------------------------------------------------
-	void VisibilityTerrainSceneManagerFactory::initMetaData(void) const
-	{
-		mMetaData.typeName = FACTORY_TYPE_NAME;
-		mMetaData.description = "Scene manager which generally organises the scene on "
-			"the basis of an octree, but also supports terrain world geometry and has awesome (TM) occlusion culling capabilities. ";
-		mMetaData.sceneTypeMask = ST_EXTERIOR_CLOSE; // previous compatiblity
-		mMetaData.worldGeometrySupported = true;
-	}
-	//-----------------------------------------------------------------------
-	SceneManager* VisibilityTerrainSceneManagerFactory::createInstance(
-		const String& instanceName)
-	{
-		VisibilityTerrainSceneManager* tsm = new VisibilityTerrainSceneManager(instanceName, visManager);
-		// Create & register default sources (one per manager)
-		HeightmapTerrainPageSource* ps = new HeightmapTerrainPageSource();
-		mTerrainPageSources.push_back(ps);
-		tsm->registerPageSource("Heightmap", ps);
-
-		return tsm;
-	}
-	//-----------------------------------------------------------------------
-	void VisibilityTerrainSceneManagerFactory::destroyInstance(SceneManager* instance)
-	{
-		delete instance;
-	}
-
-} // namespace Ogre
Index: P/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManager.cpp	(revision 925)
+++ 	(revision )
@@ -1,146 +1,0 @@
-#include <OgreMath.h>
-#include <OgreIteratorWrappers.h>
-#include <OgreRenderSystem.h>
-#include <OgreCamera.h>
-#include "OgreVisibilitySceneManager.h"
-#include "OgreSceneNodeHierarchyInterface.h"
-#include "OgreVisibilityOptionsManager.h"
-
-
-namespace Ogre {
-
-//-----------------------------------------------------------------------
-VisibilitySceneManager::VisibilitySceneManager(const String& name, 
-											   GtpVisibility::VisibilityManager *visManager)
-:SceneManager(name), 
-mVisibilityManager(visManager), 
-mUseDepthPass(false), 
-mShowVisualization(false)
-{
-	mHierarchyInterface = new SceneNodeHierarchyInterface(this, mDestRenderSystem);
-}
-//-----------------------------------------------------------------------
-VisibilitySceneManager::~VisibilitySceneManager()
-{
-	delete mHierarchyInterface;
-}
-//-----------------------------------------------------------------------
-void VisibilitySceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)
-{
-	mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);
-	// does nothing if hierarchical culling is used =>
-	// we interleave identification and rendering of objects 
-	// in _renderVisibibleObjects
-	if (!mUseDepthPass)
-	{
-		SceneManager::_findVisibleObjects(cam, onlyShadowCasters);
-		return;	
-	}
-}
-//-----------------------------------------------------------------------
-void VisibilitySceneManager::_renderVisibleObjects()
-{
-	if (!mShowVisualization)
-	{
-		mHierarchyInterface->SetHierarchyRoot(mSceneRoot);
-		mHierarchyInterface->InitTraversal(mCameraInProgress);
-
-		// reset culling manager stats
-		mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes);
-	}
-
-	// standard terrain scenemanager rendering without hierarchical culling
-	if (!mUseDepthPass || mShowVisualization)
-	{	
-		SceneManager::_renderVisibleObjects();
-	
-		return;
-	} 
-
-	//-- hierarchical culling
-	// the objects of different layers (e.g., background, scene, 
-	// overlay) must be identified and rendered one after another
-
-	//-- render background
-	clearSpecialCaseRenderQueues();
-	addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND);
-	addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY);
-
-	setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
-	SceneManager::_renderVisibleObjects();
-
-#ifdef GTP_VISIBILITY_MODIFIED_OGRE
-	_deleteRenderedQueueGroups();
-#endif
-
-	//-- render visible objects (i.e., all but overlay)
-	clearSpecialCaseRenderQueues();
-	addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY);
-	setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
-
-
-	/** 
-	* the hierarchical culling algorithm
-	**/
-	mVisibilityManager->ApplyVisibilityCulling();
-
-
-#ifdef GTP_VISIBILITY_MODIFIED_OGRE
-	_deleteRenderedQueueGroups();
-#endif
-
-	//-- render overlay
-	clearSpecialCaseRenderQueues();
-	SceneManager::_renderVisibleObjects();
-
-	//WriteLog(); // write out stats
-}
-//-----------------------------------------------------------------------
-void VisibilitySceneManager::_updateSceneGraph(Camera* cam)
-{
-	mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface);
-	mHierarchyInterface->SetRenderSystem(mDestRenderSystem);
-	
-	SceneManager::_updateSceneGraph(cam);
-}
-//-----------------------------------------------------------------------
-bool VisibilitySceneManager::setOption(const String & key, const void * val)
-{
-	return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
-		setOption(key, val) || SceneManager::setOption(key, val);
-}
-//-----------------------------------------------------------------------
-bool VisibilitySceneManager::getOption(const String & key, void *val)
-{
-	if (key == "NumHierarchyNodes")
-	{
-		* static_cast<unsigned int *>(val) = (unsigned int)mSceneNodes.size();
-		return true;
-	}
-	
-	return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
-		getOption(key, val) && SceneManager::getOption(key, val);
-}
-//-----------------------------------------------------------------------
-bool VisibilitySceneManager::getOptionValues(const String & key, StringVector  &refValueList)
-{
-	return SceneManager::getOptionValues(key, refValueList);
-}
-//-----------------------------------------------------------------------
-bool VisibilitySceneManager::getOptionKeys(StringVector & refKeys)
-{
-	return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
-		getOptionKeys(refKeys) || SceneManager::getOptionKeys(refKeys);
-}
-//-----------------------------------------------------------------------
-void VisibilitySceneManager::setVisibilityManager(GtpVisibility::VisibilityManager *visManager)
-{
-	mVisibilityManager = visManager;
-}
-//-----------------------------------------------------------------------
-GtpVisibility::VisibilityManager *VisibilitySceneManager::getVisibilityManager()
-{
-	return mVisibilityManager;
-}
-
-} // namespace Ogre
Index: P/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOctreeSceneManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOctreeSceneManager.cpp	(revision 928)
+++ 	(revision )
@@ -1,1200 +1,0 @@
-#include "OgreVisibilityOctreeSceneManager.h"
-#include "OgreVisibilityOptionsManager.h"
-#include <OgreMath.h>
-#include <OgreIteratorWrappers.h>
-#include <OgreRenderSystem.h>
-#include <OgreCamera.h>
-#include <OgreLogManager.h>
-#include <OgreStringConverter.h>
-#include <OgreEntity.h>
-#include <OgreSubEntity.h>
-#include <OgreMaterialManager.h>
-#include <OgreIteratorWrappers.h>
-#include "VspBspTree.h"
-#include "Containers.h"
-#include "ViewCellsManager.h"
-#include <OgreConfigFile.h>
-#include "OgreTypeConverter.h"
-#include "OgreMeshInstance.h"
-#include "common.h"
-
-// normal terrain rendering
-const static NORMAL_RENDER_HACK = false;
-
-namespace Ogre {
-
-//-----------------------------------------------------------------------
-VisibilityOctreeSceneManager::VisibilityOctreeSceneManager(const String& name, 
-	GtpVisibility::VisibilityManager *visManager)
-:
-OctreeSceneManager(name),
-mVisibilityManager(visManager), 
-mShowVisualization(false),
-mRenderNodesForViz(false),
-mRenderNodesContentForViz(false),
-mVisualizeCulledNodes(false),
-mLeavePassesInQueue(0),
-mDelayRenderTransparents(true),
-mUseDepthPass(false),
-mIsDepthPassPhase(false),
-mUseItemBuffer(false),
-mIsItemBufferPhase(false),
-mCurrentEntityId(1),
-mEnableDepthWrite(true),
-mSkipTransparents(false),
-mRenderTransparentsForItemBuffer(true),
-mExecuteVertexProgramForAllPasses(true),
-mIsHierarchicalCulling(false),
-mViewCellsLoaded(false),
-mUseViewCells(false),
-mUseVisibilityFilter(false),
-mCurrentViewCell(NULL),
-mElementaryViewCell(NULL)
-{
-	mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem);
-		
-	if (0)
-	{
-		mDisplayNodes = true;
-		mShowBoundingBoxes = true;
-		mShowBoxes = true;
-	}
-
-	// TODO: set maxdepth to reasonable value
-	mMaxDepth = 50;
-
-	//loadVisibilityConfig("GtpVisibility.cfg");
-	//LoadViewCells("");
-	//mViewCellsLoaded = true;
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::InitDepthPass()
-{
-	MaterialPtr depthMat = MaterialManager::getSingleton().getByName("Visibility/DepthPass");
-
-	if (depthMat.isNull())
-    {
-		depthMat = MaterialManager::getSingleton().create(
-                "Visibility/DepthPass",
-                ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
-
-		mDepthPass = depthMat->getTechnique(0)->getPass(0);
-		mDepthPass->setColourWriteEnabled(false);
-		mDepthPass->setDepthWriteEnabled(true);
-		mDepthPass->setLightingEnabled(false);
-	}
-	else
-	{
-		mDepthPass = depthMat->getTechnique(0)->getPass(0);
-	}
-}
-//-----------------------------------------------------------------------
-VisibilityOctreeSceneManager::~VisibilityOctreeSceneManager()
-{
-	OGRE_DELETE(mHierarchyInterface);
-	CLEAR_CONTAINER(mObjects);
-	OGRE_DELETE(mCurrentViewCell);
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::InitItemBufferPass()
-{
-	MaterialPtr itemBufferMat = MaterialManager::getSingleton().
-		getByName("Visibility/ItemBufferPass");
-
-	if (itemBufferMat.isNull())
-    {
-		// Init
-		itemBufferMat = MaterialManager::getSingleton().create("Visibility/ItemBufferPass",
-                ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
-
-		mItemBufferPass = itemBufferMat->getTechnique(0)->getPass(0);
-		mItemBufferPass->setColourWriteEnabled(true);
-		mItemBufferPass->setDepthWriteEnabled(true);
-		mItemBufferPass->setLightingEnabled(true);
-		//mItemBufferPass->setLightingEnabled(false);
-	}
-	else
-	{
-		mItemBufferPass = itemBufferMat->getTechnique(0)->getPass(0);
-	}
-	//mItemBufferPass->setAmbient(1, 1, 0);
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::PrepareVisualization(Camera *cam)
-{
-	// add player camera for visualization purpose
-	try 
-	{
-		Camera *c;
-		if ((c = getCamera("PlayerCam")) != NULL)
-		{
-			getRenderQueue()->addRenderable(c);
-		}   
-    }
-    catch(...)
-    {
-        // ignore
-    }
-	// add bounding boxes of rendered objects
-	if (1)
-	for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it)
-{
-		getRenderQueue()->addRenderable(*it);
-	}
-	
-	if (mRenderNodesForViz || mRenderNodesContentForViz)
-	{
-		// HACK: change node material so it is better suited for visualization
-		MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial");
-		nodeMat->setAmbient(1, 1, 0);
-		nodeMat->setLightingEnabled(true);
-		nodeMat->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();
-
-		for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it)
-		{
-			if (mRenderNodesForViz)
-			{
-				// render the leaf nodes
-				if ((*it)->numAttachedObjects() && 
-					!(*it)->numChildren() && 
-					((*it)->getAttachedObject(0)->getMovableType() == "Entity") &&
-					(*it)->getAttachedObject(0)->isVisible())
-				{
-				getRenderQueue()->addRenderable((*it));
-			}
-			}
-			// add renderables itself
-			if (mRenderNodesContentForViz) 
-			{
-				(*it)->_addToRenderQueue(cam, getRenderQueue(), false);
-			}
-		}
-	}
-}
-//-----------------------------------------------------------------------
-const Pass *VisibilityOctreeSceneManager::_setPass(Pass* pass)
-{
-	if (NORMAL_RENDER_HACK)
-	{
-		return SceneManager::_setPass(pass);
-	}
-
-	// TODO: setting vertex program is not efficient
-	//Pass *usedPass = ((mIsDepthPassPhase && !pass->hasVertexProgram()) ? mDepthPass : pass); 
-	
-	// set depth fill pass if we currently do not make an aabb occlusion query
-	const bool useDepthPass = 
-		(mIsDepthPassPhase && !mHierarchyInterface->IsBoundingBoxQuery());
-
-	Pass *usedPass = useDepthPass ? mDepthPass : pass;
-
-	IlluminationRenderStage savedStage = mIlluminationStage; 
-	
-	// set illumination stage to NONE so no shadow material is used 
-	// for depth pass or for occlusion query
-	if (mIsDepthPassPhase || mHierarchyInterface->IsBoundingBoxQuery())
-	{
-		mIlluminationStage = IRS_NONE;
-	}
-
-	// --- set vertex program of current pass in order to set correct depth
-	if (mExecuteVertexProgramForAllPasses && 
-		mIsDepthPassPhase && 
-		pass->hasVertexProgram())
-    {
-		// add vertex program of current pass to depth pass
-		mDepthPass->setVertexProgram(pass->getVertexProgramName());
-
-		if (mDepthPass->hasVertexProgram())
-		{
-			const GpuProgramPtr& prg = mDepthPass->getVertexProgram();
-			// Load this program if not done already
-			if (!prg->isLoaded())
-				prg->load();
-			// Copy params
-			mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters());
-		}
-	}
-	else if (mDepthPass->hasVertexProgram()) // reset vertex program
-	{
-		mDepthPass->setVertexProgram("");
-	}
-
-	// save old depth write: needed for item buffer
-	const bool IsDepthWrite = usedPass->getDepthWriteEnabled();
-
-	// global option which enables / disables depth writes
-	if (!mEnableDepthWrite)
-	{
-		usedPass->setDepthWriteEnabled(false);
-	}
-
-
-	//-- set actual pass here
-	const Pass *result = SceneManager::_setPass(usedPass);
-
-
-	// reset depth write
-	if (!mEnableDepthWrite)
-	{
-		usedPass->setDepthWriteEnabled(IsDepthWrite);
-	}
-
-	// reset illumination stage
-	mIlluminationStage = savedStage;
-
-	return result;
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)
-{
-	if (NORMAL_RENDER_HACK)
-	{
-		OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters);
-		return;
-	}
-	
-
-	//-- show visible scene nodes and octree bounding boxes from last frame
-	if (mShowVisualization)
-    {
-		PrepareVisualization(cam);
-	}
-	else 
-	{	
-		// for hierarchical culling, we interleave identification 
-		// and rendering of objects in _renderVisibibleObjects
-
-		// for the shadow pass we use only standard rendering
-		// because of low occlusion
-		if (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && 
-			mIlluminationStage == IRS_RENDER_TO_TEXTURE)
-		{
-			OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters);
-		}
-
-		// only shadow casters will be rendered in shadow texture pass
-		if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);
-
-
-		//-- apply view cell pvs
-		updatePvs(cam);
-	}
-	
-	
-	// -- delete lists stored for visualization
-	mVisible.clear();
-	mBoxes.clear();
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::_renderVisibleObjects()
-{
-	if (NORMAL_RENDER_HACK)
-	{
-		OctreeSceneManager::_renderVisibleObjects();
-	
-		return;
-	}
-
-	InitDepthPass(); 	  // create material for depth pass
-	InitItemBufferPass(); // create material for item buffer pass
-
-	// save ambient light to reset later
-	ColourValue savedAmbient = mAmbientLight;
-
-	//-- apply standard rendering for some modes (e.g., visualization, shadow pass)
-
-	if (mShowVisualization ||
-	   (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && 
-	    mIlluminationStage == IRS_RENDER_TO_TEXTURE))
-	{
-		IlluminationRenderStage savedStage = mIlluminationStage; 
-	
-		if (mShowVisualization)
-		{
-			// disable illumination stage to prevent rendering shadows
-			mIlluminationStage = IRS_NONE;
-		}
-
-		// standard rendering for shadow maps because of performance
-		OctreeSceneManager::_renderVisibleObjects();
-
-		mIlluminationStage = savedStage;
-	}
-	else //-- the hierarchical culling algorithm
-	{	
-		// this is also called in TerrainSceneManager: really necessary?
-		//mDestRenderSystem -> setLightingEnabled(false);
-
-		// don't render backgrounds for item buffer
-		if (mUseItemBuffer)
-		{
-			clearSpecialCaseRenderQueues();
-			getRenderQueue()->clear();
-		} 	
-
-		//-- hierarchical culling
-		// the objects of different layers (e.g., background, scene, 
-		// overlay) must be identified and rendered one after another
-
-		//-- render all early skies
-		clearSpecialCaseRenderQueues();
-		addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND);
-		addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY);
-		setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
-
-		OctreeSceneManager::_renderVisibleObjects();
-		/////////////////////////////////////////////////
-
-#ifdef GTP_VISIBILITY_MODIFIED_OGRE
-		// delete previously rendered content
-		_deleteRenderedQueueGroups();
-#endif
-
-		//-- prepare queue for visible objects (i.e., all but overlay and skies late)
-		clearSpecialCaseRenderQueues();
-		addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE);
-		addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY);
-		
-		// exclude this queues from hierarchical rendering
-		setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
-	
-
-		// set all necessary parameters for 
-		// hierarchical visibility culling and rendering
-		InitVisibilityCulling(mCameraInProgress);
-	
-		/** 
-		* the hierarchical culling algorithm
-		* for depth pass: we just find objects and update depth buffer
-		* for "delayed" rendering: we render some passes afterwards
-		* e.g., transparents, because they need front-to-back sorting
-		**/
-	
-		mVisibilityManager->ApplyVisibilityCulling();
-	
-		// delete remaining renderables from queue:
-		// all which are not in mLeavePassesInQueue)
-#ifdef GTP_VISIBILITY_MODIFIED_OGRE
-		_deleteRenderedQueueGroups(mLeavePassesInQueue);
-#endif
-
-		//-- reset parameters
-		mIsDepthPassPhase = false;
-		mIsItemBufferPhase = false;
-		mSkipTransparents = false;
-		mIsHierarchicalCulling = false;
-
-		mLeavePassesInQueue = 0;
-
-#if 1	
-		// add visible nodes found by the visibility culling algorithm
-		if (mUseDepthPass)
-		{
-			NodeList::const_iterator it, it_end = mVisible.end();
-
-			//getRenderQueue()->clear();
-			for (it = mVisible.begin(); it != it_end; ++ it)
-			{ 
-				(*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false);
-			}
-		}
-#endif	
-		//-- now we can render all remaining queue objects
-		//-- used for depth pass, transparents, overlay
-
-		clearSpecialCaseRenderQueues();
-	
-		OctreeSceneManager::_renderVisibleObjects();
-	} // hierarchical culling
-
-	// reset ambient light
-	setAmbientLight(savedAmbient);
-
-	getRenderQueue()->clear(); // finally clear render queue
-	if (1) OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ...
-
-	if (0) WriteLog(); // write out stats
-}
-
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::_updateSceneGraph(Camera* cam)
-{
-	if (NORMAL_RENDER_HACK)
-	{
-		OctreeSceneManager::_updateSceneGraph(cam);
-		return;
-	}
-
-	mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface);
-	mHierarchyInterface->SetRenderSystem(mDestRenderSystem);
-
-	OctreeSceneManager::_updateSceneGraph(cam);
-}
-//-----------------------------------------------------------------------
-bool VisibilityOctreeSceneManager::setOption(const String & key, const void * val)
-{
-	if (key == "UseDepthPass")
-	{
-		mUseDepthPass = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "PrepareVisualization")
-	{
-		mShowVisualization = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "RenderNodesForViz")
-	{
-		mRenderNodesForViz = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "RenderNodesContentForViz")
-	{
-		mRenderNodesContentForViz = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "SkyBoxEnabled")
-	{
-		mSkyBoxEnabled = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "SkyPlaneEnabled")
-	{
-		mSkyPlaneEnabled = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "SkyDomeEnabled")
-	{
-		mSkyDomeEnabled = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "VisualizeCulledNodes")
-	{
-		mVisualizeCulledNodes = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "DelayRenderTransparents")
-	{
-		mDelayRenderTransparents = (*static_cast<const bool *>(val));
-		return true;
-	}
-
-	if (key == "DepthWrite")
-	{
-		mEnableDepthWrite = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "UseItemBuffer")
-	{
-		mUseItemBuffer = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "ExecuteVertexProgramForAllPasses")
-	{ 
-		mExecuteVertexProgramForAllPasses  = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "RenderTransparentsForItemBuffer")
-	{ 
-		mRenderTransparentsForItemBuffer  = (*static_cast<const bool *>(val));
-		return true;
-	}
-	if (key == "NodeVizScale")
-	{ 
-		OctreeNode::setVizScale(*static_cast<const float *>(val));
-		return true;
-	}
-	if (key == "LoadViewCells")
-	{ 
-		if (!mViewCellsLoaded)
-		{
-			LoadViewCells(static_cast<const char *>(val));
-			mViewCellsLoaded = true;	
-		}
-
-		return true;
-	}
-	if (key == "UseViewCells")
-	{ 
-		mUseViewCells = *static_cast<const bool *>(val);
-
-		// reset view cell
-		OGRE_DELETE(mCurrentViewCell);
-		if (mUseViewCells)
-			mCurrentViewCell =  mViewCellsManager->GenerateViewCell();
-		mElementaryViewCell = NULL;
-		// if using view cells, all objects are set to false initially
-		SetObjectsVisible(!mUseViewCells);
-		
-		return true;
-	}
-	if (key == "UseVisibilityFilter")
-	{
-		mUseVisibilityFilter = *static_cast<const bool *>(val);
-		// set null =>recomputation of the pvs
-        mElementaryViewCell = NULL;
-		return true;
-	}
-	
-	return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
-		setOption(key, val) || OctreeSceneManager::setOption(key, val);
-}
-//-----------------------------------------------------------------------
-bool VisibilityOctreeSceneManager::getOption(const String & key, void *val)
-{
-	if (key == "NumHierarchyNodes")
-	{
-		* static_cast<unsigned int *>(val) = (unsigned int)mNumOctants;
-		return true;
-	}
-
-	return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
-		getOption(key, val) && OctreeSceneManager::getOption(key, val);
-}
-//-----------------------------------------------------------------------
-bool VisibilityOctreeSceneManager::getOptionValues(const String & key, StringVector  &refValueList)
-{
-	return OctreeSceneManager::getOptionValues( key, refValueList );
-}
-//-----------------------------------------------------------------------
-bool VisibilityOctreeSceneManager::getOptionKeys(StringVector & refKeys)
-{
-	return  VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
-		getOptionKeys (refKeys) || OctreeSceneManager::getOptionKeys(refKeys);
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::setVisibilityManager(GtpVisibility::VisibilityManager *visManager)
-{
-    mVisibilityManager = visManager;
-}
-//-----------------------------------------------------------------------
-GtpVisibility::VisibilityManager *VisibilityOctreeSceneManager::getVisibilityManager()
-{
-	return mVisibilityManager;
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::WriteLog()
-{
-	std::stringstream d;
-
-	d << "Depth pass: " << StringConverter::toString(mUseDepthPass) << ", "
-	  << "Delay transparents: " << StringConverter::toString(mDelayRenderTransparents) << ", "
-	  << "Use optimization: " << StringConverter::toString(mHierarchyInterface->GetTestGeometryForVisibleLeaves()) << ", "
-	  << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", "
-	  << "Hierarchy nodes: " << mNumOctants << ", " 
-	  << "Traversed nodes: " << mHierarchyInterface->GetNumTraversedNodes() << ", "
-	  << "Rendered nodes: " << mHierarchyInterface->GetNumRenderedNodes() << ", "
-	  << "Query culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumQueryCulledNodes() << ", "
-	  << "Frustum culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumFrustumCulledNodes() << ", "
-      << "Queries issued: " << mVisibilityManager->GetCullingManager()->GetNumQueriesIssued() << ", "
-	  << "Found objects: " << (int)mVisible.size() << "\n";
-
-	LogManager::getSingleton().logMessage(d.str());
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::renderBasicQueueGroupObjects(RenderQueueGroup* pGroup, 
-																QueuedRenderableCollection::OrganisationMode om)
-{
-    // Basic render loop
-    // Iterate through priorities
-    RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator();
-
-    while (groupIt.hasMoreElements())
-    {
-        RenderPriorityGroup* pPriorityGrp = groupIt.getNext();
-
-        // Sort the queue first
-        pPriorityGrp->sort(mCameraInProgress);
-
-        // Do solids
-        renderObjects(pPriorityGrp->getSolidsBasic(), om, true);
-
-		// for correct rendering, transparents must be rendered after hierarchical culling
-		// => do nothing
-
-        // Do transparents (always descending)
-		if (NORMAL_RENDER_HACK || !mSkipTransparents)
-		{
-			renderObjects(pPriorityGrp->getTransparents(), 
-			QueuedRenderableCollection::OM_SORT_DESCENDING, true);
-		}
-
-
-    }// for each priority
-}
-
-//-----------------------------------------------------------------------
-bool VisibilityOctreeSceneManager::validatePassForRendering(Pass* pass)
-{
-	if (NORMAL_RENDER_HACK)
-	{
-		return SceneManager::validatePassForRendering(pass);
-	}
-
-	// skip all but first pass if we are doing the depth pass
-	if ((mIsDepthPassPhase || mIsItemBufferPhase) && (pass->getIndex() > 0))
-	{
-		return false;
-	}
-	// all but first pass
-	/*else if ((!mIsDepthPassPhase || mIsItemBufferPhase) && (pass->getIndex() != 0))
-	{
-		return false;
-	}*/
-
-	return SceneManager::validatePassForRendering(pass);
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::_renderQueueGroupObjects(
-	RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om)
-{
-	if (NORMAL_RENDER_HACK || !mIsItemBufferPhase)
-	{
-		OctreeSceneManager::_renderQueueGroupObjects(pGroup, om);
-		return;
-	}
-#ifdef ITEM_BUFFER
-	//-- item buffer
-	//-- item buffer: render objects using false colors
-
-    // Iterate through priorities
-    RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator();
-
-	while (groupIt.hasMoreElements())
-    {
-		RenderItemBuffer(groupIt.getNext());
-	}
-#endif // ITEM_BUFFER
-}
-#ifdef ITEM_BUFFER
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup)
-{
-	// Do solids
-	QueuedRenderableCollection solidObjs = pGroup->getSolidsBasic();//msz
-
-	// ----- SOLIDS LOOP -----
-	RenderPriorityGroup::SolidRenderablePassMap::const_iterator ipass, ipassend;
-	ipassend = solidObjs.end();
-
-	for (ipass = solidObjs.begin(); ipass != ipassend; ++ipass)
-	{
-		// Fast bypass if this group is now empty
-		if (ipass->second->empty()) 
-			continue;
-
-		// Render only first pass of renderable as false color
-		if (ipass->first->getIndex() > 0)
-			continue;
-
-		RenderPriorityGroup::RenderableList* rendList = ipass->second;
-		
-		RenderPriorityGroup::RenderableList::const_iterator irend, irendend;
-		irendend = rendList->end();
-			
-		for (irend = rendList->begin(); irend != irendend; ++irend)
-		{
-			if (0)
-			{
-			std::stringstream d; d << "itembuffer, pass name: " << 
-				ipass->first->getParent()->getParent()->getName();
-				
-			LogManager::getSingleton().logMessage(d.str());
-			}
-			
-			RenderSingleObjectForItemBuffer(*irend, ipass->first);
-		}
-	}
-
-	//-- TRANSPARENT LOOP: must be handled differently from solids
-
-	// transparents are treated either as solids or completely discarded
-	if (mRenderTransparentsForItemBuffer)
-	{
-		QueuedRenderableCollection transpObjs = pGroup->getTransparents(); //msz
-		RenderPriorityGroup::TransparentRenderablePassList::const_iterator 
-			itrans, itransend;
-
-		itransend = transpObjs.end();
-		for (itrans = transpObjs.begin(); itrans != itransend; ++itrans)
-		{
-			// like for solids, render only first pass
-			if (itrans->pass->getIndex() == 0)
-			{	
-				RenderSingleObjectForItemBuffer(itrans->renderable, itrans->pass);
-			}
-		} 
-	}
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass)
-{
-	static LightList nullLightList;
-	
-	int col[4];
-	
-	// -- create color code out of object id
-	col[0] = (rend->getId() >> 16) & 255;
-	col[1] = (rend->getId() >> 8) & 255;
-	col[2] = rend->getId() & 255;
-//	col[3] = 255;
-
-	//mDestRenderSystem->setColour(col[0], col[1], col[2], col[3]);
-    
-	mItemBufferPass->setAmbient(ColourValue(col[0] / 255.0f,
-										    col[1] / 255.0f, 
-											col[2] / 255.0f, 1));
-
-	// set vertex program of current pass
-	if (mExecuteVertexProgramForAllPasses && pass->hasVertexProgram())
-	{
-		mItemBufferPass->setVertexProgram(pass->getVertexProgramName());
-
-		if (mItemBufferPass->hasVertexProgram())
-		{
-			const GpuProgramPtr& prg = mItemBufferPass->getVertexProgram();
-			// Load this program if not done already
-			if (!prg->isLoaded())
-				prg->load();
-			// Copy params
-			mItemBufferPass->setVertexProgramParameters(pass->getVertexProgramParameters());
-		}
-	}
-	else if (mItemBufferPass->hasVertexProgram())
-	{
-		mItemBufferPass->setVertexProgram("");
-	}
-
-	const Pass *usedPass = _setPass(mItemBufferPass); 
-
-
-	// render a single object, this will set up auto params if required
-	renderSingleObject(rend, usedPass, false, &nullLightList);
-}
-#endif // ITEM_BUFFER
-//-----------------------------------------------------------------------
-GtpVisibility::VisibilityManager *VisibilityOctreeSceneManager::GetVisibilityManager()
-{
-	return mVisibilityManager;
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::InitVisibilityCulling(Camera *cam)
-{
-	// reset culling manager stats
-	mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes);
-
-	// set depth pass flag before rendering
-	mIsDepthPassPhase = mUseDepthPass;
-
-	// from now on we are during hierarchical culling
-	mIsHierarchicalCulling = true; 
-
-	// item buffer needs full ambient lighting to use item colors as unique id
-	if (mUseItemBuffer) 
-	{
-		mIsItemBufferPhase = true;
-		setAmbientLight(ColourValue(1,1,1,1));
-	}
-
-
-	// set passes which are stored in render queue 
-	// for rendering AFTER hierarchical culling, i.e., passes which need 
-	// a special rendering order
-	
-	mLeavePassesInQueue = 0;
-
-	// if we have the depth pass or use an item buffer, no passes are left in the queue
-	if (1 && !mUseDepthPass && !mUseItemBuffer)
-	{
-		if (mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE)
-		{
-			// TODO: remove this pass because it should be processed during hierarchical culling
-			//mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_NOSHADOW;
-
-			mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_DECAL;
-			mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_DIFFUSE_SPECULAR;
-			mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES;
-
-			// just render ambient passes
-			/*** msz: no more IRS_AMBIENT, see OgreSceneManager.h ***/
-			// mIlluminationStage = IRS_AMBIENT;
-			getRenderQueue()->setSplitPassesByLightingType(true);
-		}
-	
-		if (mShadowTechnique == SHADOWTYPE_STENCIL_MODULATIVE)
-		{
-			mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_NOSHADOW;
-			mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES;
-		}
-	
-		// transparents should be rendered after hierarchical culling to 
-		// provide front-to-back ordering
-		if (mDelayRenderTransparents)
-		{
-			mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES;
-		}
-	}
-
-	// skip rendering transparents during the hierarchical culling
-	// (because they will be rendered afterwards)
-	mSkipTransparents = 
-		(mIsDepthPassPhase || (mLeavePassesInQueue & RenderPriorityGroup::TRANSPARENT_PASSES));
-
-	// -- initialise interface for rendering traversal of the hierarchy
-	mHierarchyInterface->SetHierarchyRoot(mOctree);
-	
-	// possible two cameras (one for culling, one for rendering)
-	mHierarchyInterface->InitTraversal(mCameraInProgress, 
-									   mCullCamera ? getCamera("CullCamera") : NULL,
-                                       mLeavePassesInQueue);
-		
-	//std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue;
-	//LogManager::getSingleton().logMessage(d.str());
-}
-//-----------------------------------------------------------------------
-OctreeHierarchyInterface *VisibilityOctreeSceneManager::GetHierarchyInterface()
-{
-	return mHierarchyInterface;
-}
-//-----------------------------------------------------------------------
-Entity* VisibilityOctreeSceneManager::createEntity(const String& entityName, 
-													const String& meshName)
-{
-	Entity *ent = SceneManager::createEntity(entityName, meshName);
-
-	for (int i = 0; i < (int)ent->getNumSubEntities(); ++i)
-	{
-		ent->getSubEntity(i)->setId(mCurrentEntityId);
-	}
-
-	// increase counter of entity id values
-	++ mCurrentEntityId;
-
-	return ent;
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(
-	RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om)
-{
-	// only render solid passes during hierarchical culling
-	if (mIsHierarchicalCulling)
-	{
-		RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator();
-	    LightList lightList;
-
-		while (groupIt.hasMoreElements())
-		{
-			RenderPriorityGroup* pPriorityGrp = groupIt.getNext();
-
-			// Sort the queue first
-			pPriorityGrp->sort(mCameraInProgress);
-
-			// Clear light list
-			lightList.clear();
-
-			// Render all the ambient passes first, no light iteration, no lights
-			/*** msz: no more IRS_AMBIENT, see OgreSceneManager.h ***/
-			// mIlluminationStage = IRS_AMBIENT;
-
-			OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsBasic(), om, false, &lightList);
-			// Also render any objects which have receive shadows disabled
-			OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsNoShadowReceive(), om, true);		
-#if 0		
-			std::stringstream d; 
-			d << " solid size: " << (int)pPriorityGrp->_getSolidPasses().size()
-				<< " solid no shadow size: " << (int)pPriorityGrp->_getSolidPassesNoShadow().size()
-				<< "difspec size: " << (int)pPriorityGrp->_getSolidPassesDiffuseSpecular().size()
-				<< " decal size: " << (int)pPriorityGrp->_getSolidPassesDecal().size();
-			LogManager::getSingleton().logMessage(d.str());
-#endif
-		}
-	}
-	else // render the rest of the passes
-	{
-		OctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(pGroup, om);
-	}
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::renderModulativeStencilShadowedQueueGroupObjects(
-	RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om)
-{
-   if (mIsHierarchicalCulling)
-   {
-	   // Iterate through priorities
-	   RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator();
-
-	   while (groupIt.hasMoreElements())
-	   {
-		   RenderPriorityGroup* pPriorityGrp = groupIt.getNext();
-
-		   // Sort the queue first
-		   pPriorityGrp->sort(mCameraInProgress);
-
-		   // Do (shadowable) solids
-		   OctreeSceneManager::renderObjects(pPriorityGrp->getSolidsBasic(), om, true);
-	   }
-   }
-   else
-   {
-	   SceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup, om);
-   }
-}
-//-------------------------------------------------------------------------
-void VisibilityOctreeSceneManager::SetObjectsVisible(const bool visible)
-{
-	GtpVisibilityPreprocessor::ObjectContainer::iterator it, it_end = mObjects.end();
-
-	for (it = mObjects.begin(); it != it_end; ++ it)
-	{
-		OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(*it);
-		Entity *ent = omi->GetMesh();
-		ent->setVisible(visible);
-	}
-}
-//-------------------------------------------------------------------------
-void VisibilityOctreeSceneManager::loadVisibilityConfig(const String& filename)
-{
-	// TODO matt
-	// Set up the options
-	ConfigFile config;
-	String val;
-
-	config.load(filename);
-
-	val = config.getSetting("Algorithm");
-
-    if (!val.empty())
-	{
-		 VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).setOption("Algorithm", val.c_str());
-	}
-
-	val = config.getSetting("UseDepthPass");
-
-	if (!val.empty())
-	{
-		 setOption("UseDepthPass", val.c_str());
-	}
-}
-//-------------------------------------------------------------------------
-inline static AxisAlignedBox EnlargeBox(const AxisAlignedBox &box)
-{
-	const float eps = 1e-3f;
-	const Vector3 veps(eps, eps, eps);
-	Vector3 max = box.getMaximum();
-	Vector3 min = box.getMinimum();
-
-	return AxisAlignedBox(min - veps, max + veps);
-}
-//-----------------------------------------------------------------------
-Entity *VisibilityOctreeSceneManager::FindCorrespondingObject(const AxisAlignedBox &box)
-{
-	list<SceneNode *> sceneNodeList;
-	AxisAlignedBox mybox = EnlargeBox(box);
-	//AxisAlignedBox dummy(Vector3(-50000, -50000, -50000), Vector3(50000, 50000, 50000));
-	
-	// get intersecting scene nodes
-	findNodesIn(mybox, sceneNodeList, NULL);
-	
-
-	list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end();
-
-	float overlap = 0;//GtpVisibilityPreprocessor::Limits::Small;
-
-	Entity *bestFittingObj = NULL;
-	float bestFit = overlap;
-
-	// perfect fit threshold
-	const float thresh = 1.0 - GtpVisibilityPreprocessor::Limits::Small;
-
-	
-	// find the bbox which is closest to the current bbox
-	for (sit = sceneNodeList.begin(); sit != sceneNodeList.end(); ++ sit)
-	{
-		SceneNode *sn = *sit;
-		SceneNode::ObjectIterator oit = sn->getAttachedObjectIterator();
-
-        while (oit.hasMoreElements())
-		{
-			MovableObject *mo = oit.getNext();
-
-			// we are only interested in scene entities
-			if (mo->getMovableType() != "Entity")
-			{
-				continue;
-			}
-			 
-			const AxisAlignedBox bbox = EnlargeBox(mo->getWorldBoundingBox());
-					
-
-			// compute measure how much aabbs overlap
-			overlap = RatioOfOverlap(OgreTypeConverter::ConvertFromOgre(mybox),
-									 OgreTypeConverter::ConvertFromOgre(bbox));
-	
-			 if (overlap > bestFit)
-			 {
-				 bestFit = overlap;
-			
-				 bestFittingObj = static_cast<Entity *>(mo);
-
-				 // perfect fit => object found, eraly exit
-				 if (overlap >= thresh)
-					 return bestFittingObj;				
-			 }
-		}
-	}
-
-	if (0)
-	{
-		std::stringstream d; 
-		if (bestFittingObj)
-			d << "best fit: " << bestFit;     
-		else
-			d << "warning, objects do not fit\n" << box;
-	
-		Ogre::LogManager::getSingleton().logMessage(d.str());
-	}
-
-	return bestFittingObj;
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::LoadViewCells(string filename)
-{
-	// the objects are set to invisible a prioriy
-	SetObjectsVisible(false);
-
-	// identify the corresponding Ogre meshes using the bounding boxes
-	IdentifyObjects(mObjects);
-
-	// load the view cells assigning the found objects to the pvss
-	mViewCellsManager = 
-		GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects);
-
-	std::stringstream d;
-	d << "view cells loaded" << endl;
-	Ogre::LogManager::getSingleton().logMessage(d.str());
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManager::IdentifyObjects(GtpVisibilityPreprocessor::ObjectContainer &objects)
-{
-	const string bboxesFilename = "boxes.out";
-
-	GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes;
-	mViewCellsManager->LoadBoundingBoxes(bboxesFilename, iboxes);
-
-	GtpVisibilityPreprocessor::IndexedBoundingBoxContainer::
-		const_iterator iit, iit_end = iboxes.end();
-
-	for (iit = iboxes.begin(); iit != iit_end; ++ iit)
-	{
-		  const GtpVisibilityPreprocessor::AxisAlignedBox3 box = (*iit).second;
-		  const AxisAlignedBox currentBox = OgreTypeConverter::ConvertToOgre(box);
-		 
-		  Entity *ent = FindCorrespondingObject(currentBox);
-
-		  // create new mesh instance
-		  OgreMeshInstance *omi = new OgreMeshInstance(ent);
-		  omi->SetId((*iit).first);
-		  objects.push_back(omi);
-	}
-}
-//-------------------------------------------------------------------------
-void VisibilityOctreeSceneManager::applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, 
-													const bool load)
-{	// NOTE: should not happen, rather apply view cell representing unbounded space then
-	if (!vc) 
-	{	
-		// set everything visible for savety
-		SetObjectsVisible(true);
-
-		return;
-	}
-
-	GtpVisibilityPreprocessor::ObjectPvsMap::const_iterator oit,
-			oit_end = vc->GetPvs().mEntries.end();
-
-	//-- PVS of view cell
-	for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit)
-	{
-		if (!(*oit).first) continue;
-
-		OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance*>((*oit).first);
-		omi->GetMesh()->setVisible(load);
-		//GtpVisibilityPreprocessor::Debug << "here45 " << omi->GetId() << endl;
-	}
-}
-//-------------------------------------------------------------------------
-void VisibilityOctreeSceneManager::updatePvs(Camera *cam)
-{
-	if (mViewCellsLoaded && mUseViewCells)
-	{
-		const GtpVisibilityPreprocessor::Vector3 viewPoint = 
-			OgreTypeConverter::ConvertFromOgre(cam->getDerivedPosition());
-
-		GtpVisibilityPreprocessor::ViewCell *newElementary = 
-			mViewCellsManager->GetViewCell(viewPoint);
-
-		// elementary view cell did not change => apply same pvs
-		if (mElementaryViewCell == newElementary)
-			return;
-
-		mElementaryViewCell = newElementary;
-
-		//-- unload old pvs
-		applyViewCellPvs(mCurrentViewCell, false);
-
-
-		//-- the new view cell
-		
-		GtpVisibilityPreprocessor::ViewCell *viewCell;
-
-		
-		if (mUseVisibilityFilter)
-		{
-			//-- compute new filtered cell
-			GtpVisibilityPreprocessor::PrVs prvs;
-			mViewCellsManager->GetPrVS(viewPoint, prvs, 5);
-			viewCell = prvs.mViewCell;
-		}
-		else
-		{
-			viewCell = newElementary;
-		}
-			
-		//-- load new pvs
-		applyViewCellPvs(viewCell, true);
-
-		// store pvs
-		mCurrentViewCell->SetPvs(viewCell->GetPvs());
-
-		// delete merge tree of filtered view cell
-		if (mUseVisibilityFilter)
-			mViewCellsManager->DeleteLocalMergeTree(viewCell);
-	}
-}
-
-
-
-//-----------------------------------------------------------------------
-const String VisibilityOctreeSceneManagerFactory::FACTORY_TYPE_NAME = "VisibilityOctreeSceneManager";
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManagerFactory::initMetaData(void) const
-{
-	mMetaData.typeName = FACTORY_TYPE_NAME;
-	mMetaData.description = "Scene manager organising the scene on the basis of an octree with advanced occlusion culling (TM).";
-	mMetaData.sceneTypeMask = 0xFFFF; // support all types
-	mMetaData.worldGeometrySupported = false;
-}
-//-----------------------------------------------------------------------
-SceneManager* VisibilityOctreeSceneManagerFactory::createInstance(
-	const String& instanceName)
-{
-	return new VisibilityOctreeSceneManager(instanceName, visManager);
-}
-//-----------------------------------------------------------------------
-void VisibilityOctreeSceneManagerFactory::destroyInstance(SceneManager* instance)
-{
-	delete instance;
-}
-
-}  // namespace Ogre
Index: P/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBspHierarchyInterface.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBspHierarchyInterface.cpp	(revision 345)
+++ 	(revision )
@@ -1,66 +1,0 @@
-#include "OgreBspHierarchyInterface.h"
-#include "OgreVisibilityOctreeSceneManager.h"
-
-//#include <windows.h>
-
-namespace Ogre {
-
-//-----------------------------------------------------------------------
-BspHierarchyInterface::BspHierarchyInterface(SceneManager *sm, RenderSystem *rsys): 
-PlatformHierarchyInterface(sm, rsys)
-{
-}
-//-----------------------------------------------------------------------
-void BspHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node)
-{
-}
-//-----------------------------------------------------------------------
-bool BspHierarchyInterface::IsLeaf(GtpVisibility::HierarchyNode *node) const
-{
-	return true;
-}
-//-----------------------------------------------------------------------
-bool BspHierarchyInterface::HasGeometry(GtpVisibility::HierarchyNode *node) const
-{
-	return true;
-}
-//-----------------------------------------------------------------------
-float BspHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const
-{
-	return 0.0f;
-}
-//-----------------------------------------------------------------------
-void BspHierarchyInterface::SetNodeVisible(GtpVisibility::HierarchyNode *node, 
-										   const bool visible) const
-{
-}
-//-----------------------------------------------------------------------
-void BspHierarchyInterface::SetLastVisited(GtpVisibility::HierarchyNode *node, 
-										   const unsigned int frameId) const
-{
-}
-//-----------------------------------------------------------------------
-void BspHierarchyInterface::PullUpVisibility(GtpVisibility::HierarchyNode *node) const
-{		
-}
-//-----------------------------------------------------------------------
-void BspHierarchyInterface::RenderNode(GtpVisibility::HierarchyNode *node)
-{
-}
-//-----------------------------------------------------------------------
-bool BspHierarchyInterface::IsNodeVisible(GtpVisibility::HierarchyNode *node) const
-{
-	return true;
-}
-//-----------------------------------------------------------------------
-unsigned int BspHierarchyInterface::LastVisited(GtpVisibility::HierarchyNode *node) const
-{
-	return 0;
-}
-//-----------------------------------------------------------------------
-AxisAlignedBox *BspHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node)
-{
-	return NULL;
-}
-
-} // namespace Ogre
Index: P/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityBspSceneManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityBspSceneManager.cpp	(revision 59)
+++ 	(revision )
@@ -1,108 +1,0 @@
-#include "OgreVisibilityBspSceneManager.h"
-#include <OgreMath.h>
-#include <OgreIteratorWrappers.h>
-#include <OgreRenderSystem.h>
-#include <OgreCamera.h>
-
-#include <windows.h>
-
-namespace Ogre {
-
-//-----------------------------------------------------------------------
-VisibilityBspSceneManager::VisibilityBspSceneManager(
-	GtpVisibility::Manager *visManager): mVisibilityManager(visManager)
-{
-	mHierarchyInterface = 
-		new BspHierarchyInterface(this, mDestRenderSystem);
-
-	//mDisplayNodes = true;
-	//mShowBoundingBoxes = true;
-	//mShowBoxes = true;
-	//mMaxDepth = 20;
-}
-//-----------------------------------------------------------------------
-VisibilityBspSceneManager::~VisibilityBspSceneManager()
-{
-	delete mHierarchyInterface;
-}
-//-----------------------------------------------------------------------
-void VisibilityBspSceneManager::_renderVisibleObjects()
-{
-	//-- render background
-	clearSpecialCaseRenderQueues();
-	addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND);
-	addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY);
-
-	setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
-	SceneManager::_renderVisibleObjects( );
-#ifdef GTP_VISIBILITY_MODIFIED_OGRE
-	_deleteRenderedQueueGroups();
-#endif
-
-	//-- render visible objects (i.e., all but overlay)
-	clearSpecialCaseRenderQueues();
-	addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY);
-	setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
-
-	mHierarchyInterface->InitFrame(mSceneRoot, mCameraInProgress);
-	mVisibilityManager->ApplyVisibilityCulling();
-
-#ifdef GTP_VISIBILITY_MODIFIED_OGRE
-	_deleteRenderedQueueGroups();
-#endif
-
-	//-- render rest, e.g., overlay
-	clearSpecialCaseRenderQueues();
-	SceneManager::_renderVisibleObjects();
-	//_deleteRenderedQueueGroups();
-}
-//-----------------------------------------------------------------------
-void VisibilityBspSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)
-{
-	// must be empty because objects are found and rendered in an interleaved fashion
-	// in _renderVisibibleObjects 
-}
-//-----------------------------------------------------------------------
-void VisibilityBspSceneManager::_updateSceneGraph(Camera* cam)
-{
-	//mOcclusionBspHierarchyInterface->setNumSceneNodes((int)mSceneNodes.size());
-	mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface);
-	mHierarchyInterface->SetRenderSystem(mDestRenderSystem);
-
-#ifdef GTP_VISIBILITY_MODIFIED_OGRE
-    mHierarchyInterface->SetNumOctreeNodes(mNumOctreeNodes);
-#endif
-	BspSceneManager::_updateSceneGraph(cam);
-}
-//-----------------------------------------------------------------------
-bool VisibilityBspSceneManager::setOption(const String & key, const void * val)
-{
-	return /*mVisibilitySceneTraverser->setOption( key, val) || */BspSceneManager::setOption( key, val );
-}
-//-----------------------------------------------------------------------
-bool VisibilityBspSceneManager::getOption(const String & key, void *val)
-{
-	return /*mVisibilitySceneTraverser->getOption( key, val) || */BspSceneManager::getOption(key, val);
-}
-//-----------------------------------------------------------------------
-bool VisibilityBspSceneManager::getOptionValues(const String & key, StringVector  &refValueList)
-{
-	return BspSceneManager::getOptionValues( key, refValueList );
-}
-//-----------------------------------------------------------------------
-bool VisibilityBspSceneManager::getOptionKeys(StringVector & refKeys)
-{
-	return /*mVisibilitySceneTraverser->getOptionKeys ( refKeys ) || */BspSceneManager::getOptionKeys(refKeys);
-}
-//-----------------------------------------------------------------------
-void VisibilityBspSceneManager::setVisibilityManager(GtpVisibility::Manager *visManager)
-{
-    mVisibilityManager = visManager;
-}
-//-----------------------------------------------------------------------
-GtpVisibility::Manager *VisibilityBspSceneManager::getVisibilityManager()
-{
-	return mVisibilityManager;
-}
-
-}   // namespace Ogre
Index: P/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityDotSceneManager.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityDotSceneManager.cpp	(revision 59)
+++ 	(revision )
@@ -1,107 +1,0 @@
-#include <OgreVisibilityDotSceneManager.h>
-#include <OgreMath.h>
-#include <OgreIteratorWrappers.h>
-#include <OgreRenderSystem.h>
-#include <OgreCamera.h>
-
-//#include <windows.h>
-
-namespace Ogre {
-
-//-----------------------------------------------------------------------
-VisibilityDotSceneManager::VisibilityDotSceneManager(GtpVisibility::VisibilityManager *visManager)
-:mVisibilityManager(visManager)
-{
-	mHierarchyInterface = 
-		new SceneNodeHierarchyInterface(this, mDestRenderSystem);
-	
-	mShowBoundingBoxes = true;
-	
-	//mDisplayNodes = true;
-	//mShowBoxes = true;
-}
-//-----------------------------------------------------------------------
-VisibilityDotSceneManager::~VisibilityDotSceneManager()
-{
-	delete mHierarchyInterface;
-}
-//-----------------------------------------------------------------------
-void VisibilityDotSceneManager::_renderVisibleObjects(void)
-{
-	//-- render background
-	clearSpecialCaseRenderQueues();
-	addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND);
-	addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY);
-
-	setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
-	DotSceneManager::_renderVisibleObjects();
-#ifdef GTP_VISIBILITY_MODIFIED_OGRE
-	_deleteRenderedQueueGroups();
-#endif
-	//-- render visible objects (i.e., all but overlay)
-	clearSpecialCaseRenderQueues();
-	addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY);
-	setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
-
-	mHierarchyInterface->InitFrame(mSceneRoot, mCameraInProgress);
-
-	mVisibilityManager->ApplyVisibilityCulling();
-
-#ifdef GTP_VISIBILITY_MODIFIED_OGRE
-	_deleteRenderedQueueGroups();
-#endif
-
-	//-- render overlay
-	clearSpecialCaseRenderQueues();
-	DotSceneManager::_renderVisibleObjects( );
-
-	clearSpecialCaseRenderQueues();
-}
-//-----------------------------------------------------------------------
-void VisibilityDotSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)
-{
-	// must be empty because objects are found and rendered in an interleaved fashion
-	// in _renderVisibibleObjects 
-}
-//-----------------------------------------------------------------------
-void VisibilityDotSceneManager::_updateSceneGraph(Camera* cam)
-{
-	//mVisibilitySceneTraverser->setNumSceneNodes((int)mSceneNodes.size());
-	mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface);
-	mHierarchyInterface->SetRenderSystem(mDestRenderSystem);
-		        	
-	DotSceneManager::_updateSceneGraph(cam);
-}
-//-----------------------------------------------------------------------
-bool VisibilityDotSceneManager::setOption(const String & key, const void * val)
-{
-	return /*mVisibilitySceneTraverser->setOption( key, val) || */DotSceneManager::setOption(key, val);
-}
-//-----------------------------------------------------------------------
-bool VisibilityDotSceneManager::getOption(const String & key, void *val)
-{
-	return /*mVisibilitySceneTraverser->getOption( key, val) || */DotSceneManager::getOption(key, val);
-}
-//-----------------------------------------------------------------------
-bool VisibilityDotSceneManager::getOptionValues(const String & key, StringVector  &refValueList)
-{
-	return DotSceneManager::getOptionValues(key, refValueList);
-}
-//-----------------------------------------------------------------------
-bool VisibilityDotSceneManager::getOptionKeys(StringVector & refKeys)
-{
-	return /*mVisibilitySceneTraverser->getOptionKeys ( refKeys ) || */DotSceneManager::getOptionKeys( refKeys );
-}
-//-----------------------------------------------------------------------
-void VisibilityDotSceneManager::setVisibilityManager(GtpVisibility::VisibilityManager *visManager)
-{
-	mVisibilityManager = visManager;
-}
-//-----------------------------------------------------------------------
-GtpVisibility::VisibilityManager *VisibilityDotSceneManager::getVisibilityManager()
-{
-	return mVisibilityManager;
-}
-
-//} // namespace GtpVisibility
-} // namespace Ogre
