Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/DummyPreprocessingManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/DummyPreprocessingManager.h	(revision 316)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/DummyPreprocessingManager.h	(revision 316)
@@ -0,0 +1,61 @@
+#ifndef _VisibilityDummyPreprocessingManager_H__
+#define _VisibilityDummyPreprocessingManager_H__
+
+#include "PreprocessingManager.h"
+
+
+namespace GtpVisibility {
+  
+  /**
+     Implements a dummy interface to the external visibility preprocessing.
+  */
+class DummyPreprocessingManager : public PreprocessingManager
+{
+public:
+
+
+  /** Constructor taking a scene traverser for a specific type of
+      hierarchyInterface as argument. 
+  */
+  DummyPreprocessingManager( HierarchyInterface *hierarchyInterface );
+  
+  
+  /** 
+      Export the scene for visibility preprocessing. Exports the hierarchyInterface including
+      its bounding boxes + mesh data for occluders. The viewcell data will either be
+      supplied directly to the visibility preprocessing standalone module
+  */
+  virtual bool ExportScene(const string filename);
+  
+  
+  /** 
+      Load preprocessed visibility information
+  */
+  virtual bool LoadPreprocessedData(const string filename);
+  
+  
+protected:
+
+  /** 
+      Find viewcells intersecting a spherical neighborhood of a point.
+      Returns false if no viewcell was found.
+    */
+  virtual bool LocateViewCellIds(const Vector3 &center,
+				 const float radius,
+				 vector<int> *viewCellIds
+				 );
+
+
+  /**
+     Add a PVS of the given viewcell to the already evaluated PVS by computing
+     a union with visibleNodes and visibleMeshes. Returns the number of added entries.
+  */
+  virtual int AddViewCellPVS(const int cellID,
+			     NodeInfoContainer *visibleNodes,
+			     MeshInfoContainer *visibleMeshes);
+
+};
+
+};
+
+#endif // VisibilityPreprocessingManager
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityVector3.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityVector3.h	(revision 65)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityVector3.h	(revision 65)
@@ -0,0 +1,13 @@
+#ifndef _VisibilityVector3_H__
+#define _VisibilityVector3_H__
+
+#include "OgreVector3.h"
+
+namespace GtpVisibility {
+  /** Vector3 class currently uses the native Ogre vector when compiled with the Ogre platform */
+  typedef Ogre::Vector3 Vector3;
+}
+
+
+
+#endif
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/DistanceQueue.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/DistanceQueue.h	(revision 316)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/DistanceQueue.h	(revision 316)
@@ -0,0 +1,40 @@
+#ifndef _DistanceQueue_H__
+#define _DistanceQueue_H__
+
+#include "OcclusionQuery.h"
+
+#include <queue>
+
+namespace GtpVisibility {
+
+/*  We define HierarchyNode as void * because
+	there is no common ancestor for hierarchy nodes in Ogre
+*/
+typedef void HierarchyNode;
+
+class HierarchyInterface;
+/** This class implements the less operator for the priority queue, i.e.,
+	a greater distance has a lower priority in the queue.
+*/
+template <typename T> class GtDistance
+{
+public:
+	GtDistance(HierarchyInterface *hierarchyInterface): mHierarchyInterface(hierarchyInterface)
+	{}
+	
+	bool operator() (T v1, T v2) const
+	{
+		return mHierarchyInterface->GetSquaredDistance(v1) > mHierarchyInterface->GetSquaredDistance(v2);
+	}
+		
+private:
+	HierarchyInterface *mHierarchyInterface;
+};
+
+/** A priority queue where closer hierarchy nodes are given a higher priority.
+*/
+typedef std::priority_queue<HierarchyNode *, std::vector<HierarchyNode *>, GtDistance<std::vector<HierarchyNode *>::value_type> > DistanceQueue;
+
+} // namespace GtpVisibility
+
+#endif // DistanceQueue_H
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/HierarchyInterface.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/HierarchyInterface.h	(revision 606)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/HierarchyInterface.h	(revision 606)
@@ -0,0 +1,180 @@
+#ifndef _GtpVisibilityHierarchyInterface_H__
+#define _GtpVisibilityHierarchyInterface_H__
+
+#include "DistanceQueue.h"
+#include "VisibilityMesh.h"
+#include <stack>
+
+namespace GtpVisibility {
+
+enum  CullingType {QUERY_CULLED, FRUSTUM_CULLED};
+
+typedef std::vector<HierarchyNode *> NodeVector;
+typedef std::vector<GtpVisibility::Mesh *> GeometryVector;
+typedef std::vector<GtpVisibility::Patch *> PatchVector;
+typedef std::pair<HierarchyNode *, OcclusionQuery *> QueryPair;
+typedef std::pair<HierarchyNode *, bool> PendingQuery;
+typedef std::queue<QueryPair> QueryQueue;
+typedef std::queue<PendingQuery> PendingQueue;
+
+
+/**	Class which implements a hierarchy interface for a scene hierarchy.
+*/
+class HierarchyInterface
+{
+public:
+	/** Default constructor.
+	*/
+	HierarchyInterface();
+	virtual ~HierarchyInterface();
+	/** Returns true if current node is leaf of the hierarchy. 
+		@param node hierarchy node
+		@returns true if node is leaf
+	*/
+    virtual bool IsLeaf(HierarchyNode *node) const = 0;
+	/** Traverses and renders the given node. 
+		@param node the hierarchy node
+	*/
+	virtual void TraverseNode(HierarchyNode *node) = 0;
+	/** Renders current hierarchy node.
+		@param node current hierarchy node to be rendered
+	*/
+	virtual void RenderNode(HierarchyNode *node) = 0;
+	/** Pulls up the visibility from the current node recursively to the parent nodes. 
+		@param node the current node 
+	*/
+	virtual void PullUpVisibility(HierarchyNode *node) const = 0;
+	/** Issue a occlusion query for this node. 
+		@param node the current hierarchy node
+		@returns occlusion query for this node
+	*/
+	virtual OcclusionQuery *IssueNodeOcclusionQuery(HierarchyNode *node, 
+		const bool wasVisible = false) = 0;
+	/** Sets the root of the scene hierarchy.
+		@param root the hierarchy root
+	*/
+	void SetHierarchyRoot(HierarchyNode *root);
+    /** Get the root of the scene hierarchy.
+		@return the hierarchy root
+	*/
+	HierarchyNode *GetHierarchyRoot() const;
+	/** Sets the scene root and initialises this hierarchy interface for a traversal.		
+		@remark also resets the statistics evaluated in the last traversal
+	*/
+	void InitTraversal();
+	/** Returns current frame id.
+		@returns frame id
+	*/
+	unsigned int GetFrameId() const;
+	/** Returns a pointer to the distance queue.
+		@returns current distance queue.
+		@remark the distance queue stores hierarchy nodes in a front-to-back order
+	*/
+	DistanceQueue *GetQueue();
+	/** Returns distance of the node to the view plane.
+		@param node1 the hierarchy node
+	*/			
+	virtual float GetSquaredDistance(HierarchyNode *node) const = 0;
+	/** Checks if the node is visible from the current view frustum.
+		@param node the current node
+		@param intersects returns true if the current node intersects the near plane
+	*/
+	virtual bool CheckFrustumVisible(HierarchyNode *node, bool &intersects) = 0;
+	/** Checks if the node is visible from the current view frustum.
+		@param node the current node
+	*/
+	bool CheckFrustumVisible(HierarchyNode *node);
+	/** Returns next available occlusion query or creates new one.
+		@return the next occlusion query
+	*/
+	virtual OcclusionQuery *GetNextOcclusionQuery() = 0;
+	/** Returns true if there is renderable geometry attached to this node
+		@param node the current node
+		@returns if the node has renderable geometry
+	*/
+    virtual bool HasGeometry(HierarchyNode *node) const = 0;
+	/** Sets the visible flag for this node.
+		@param node the current node
+		@param visible the visible flag
+	*/
+	virtual void SetNodeVisible(HierarchyNode *node, const bool visible) const = 0;
+	/** Returns true if node has the visible flag set. See set
+	*/
+	virtual bool IsNodeVisible(HierarchyNode *node) const = 0;
+	/** Sets the last visited frame id for this node.
+		@param node the current node
+		@param frameId the current frame id
+	*/
+	virtual void SetLastVisited(HierarchyNode *node, 
+								const unsigned int frameId) const = 0;
+	/** Returns frame id when this node was last visited by the traverser. See set
+	*/
+	virtual unsigned int LastVisited(HierarchyNode *node) const = 0;
+	/** Returns number of traversed nodes.
+	*/
+	unsigned int GetNumTraversedNodes();
+	/** Returns number of rendered nodes.
+	*/
+	unsigned int GetNumRenderedNodes();
+		
+	//bool mIsShadowPass;
+
+	/** Visualization of a culled node, dependent on the culling type. 
+		@param type can be one of FRUSTUM_CULLED, QUERY_CULLED
+	*/
+	virtual void VisualizeCulledNode(HierarchyNode *node, 
+		CullingType type) const = 0;
+
+	/** Returns vector of visible hierarchy nodes from previous render.
+	*/
+	std::vector<HierarchyNode *> *GetVisibleNodes();
+	/** Returns vector of previoulsy rendered geometry.
+	*/
+	
+	/** Returns the geometry of a given hierarchy node. 
+		@param node the hierarchy node containing the geometry
+		@param geometryList geometry is returned in this list
+		@param includeChildren if the geometry of the children should be taken into account
+	*/
+	virtual void GetNodeGeometryList(GtpVisibility::HierarchyNode *node,	
+					 		 GeometryVector *geometryList, 
+							 bool includeChildren) = 0;
+
+	
+	/** This is an optimization when issuing the occlusion test. 
+		The test is done with actual geometry rather than the bounding 
+		box of leave nodes previously marked as visible.
+
+		@param testGeometry if this optimization should be used
+		@remark this option is only useful for the coherent hierarchical culling algorithm
+	*/
+	void TestGeometryForVisibleLeaves(bool testGeometry);
+
+
+protected:
+
+
+	/// chc optimization for testing geometry of leaves instead of bounding box
+	bool mTestGeometryForVisibleLeaves;
+	/// the current frame number
+	unsigned int mFrameId;
+	/// points to the last occlusion query in the query list
+	int mCurrentTestIdx;
+	
+	/// number of traversed nodes
+	unsigned int mNumTraversedNodes;
+
+	/// The queue is useful for rendering hierarchy nodes in front to back order.
+	DistanceQueue *mDistanceQueue;
+
+	/// the root of the hierarchy
+	HierarchyNode *mHierarchyRoot;
+	
+	/// buffer for a node pointer
+	HierarchyNode *mSavedNode;
+	/// list of rendered hierarchy nodes (e.g., useful for exact visibility queries)
+	std::vector<HierarchyNode *> mVisibleNodes;
+};
+} // namespace GtpVisibility
+
+#endif // GtpVisisibilityHierarchyInterface_H
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/QueryManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/QueryManager.h	(revision 316)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/QueryManager.h	(revision 316)
@@ -0,0 +1,104 @@
+#ifndef _VisibilityQueryManager_H__
+#define _VisibilityQueryManager_H__
+
+#include <vector>
+
+#include "VisibilityInfo.h"
+#include "VisibilityVector3.h"
+#include "VisibilityCamera.h"
+#include "VisibilityRay.h"
+
+namespace GtpVisibility {
+  
+typedef std::vector<OcclusionQuery *> QueryList;
+
+/** This abstract class defines interface for a specific visibility query
+    algorithm. The interface supports two from point visibility queries and
+    the ray shooting query. The output of the queries consists of list of
+    visible meshes and hierarchy nodes. The from point queries will be implemented
+    either with item bufferring or based purelly on occlusion queries. Note that
+    the actuall implementation can also exploit the
+    output of the visibility preprocessor.
+*/
+class QueryManager
+{
+public:
+    /** Constructor taking a hierarchy interface as an argument. This allows to operate
+	on different hierarchy types, while reusing the implementation of the query methods.
+     */
+    QueryManager(HierarchyInterface *hierarchyInterface, int queryModes);
+    
+    /** 
+	Computes restricted visibility from point by using an explicit camera to execute
+	the visibility query.
+	@param camera The camera to be used
+
+	@param visibleNodes Pointer to the container where visible nodes should be added.
+	This set is formed of visible leafs or fully visible interior nodes.
+	If NULL no visible nodes are not evaluated.
+
+	@param visibleGeometry Pointer to the container where visible meshes should be added.
+	If NULL no visible meshes are not evaluated.
+
+	@param projectedPixels If true the visibility member for
+	NodeInfo and MeshInfo represent relative visibility; i.e. the number of visible
+	pixels divided by the the number of projected pixels.
+
+	@return true if the corresponding PVS exists.
+    */
+    virtual void
+    ComputeCameraVisibility(const Camera &camera,
+			    NodeInfoContainer *visibleNodes,
+			    MeshInfoContainer *visibleGeometry,
+				PatchInfoContainer *visiblePatches,
+			    bool relativeVisibility = false
+			    ) = 0;
+    
+    /** 
+	Uses the specified point to execute the visibility query in all directions. 
+	@sa ComputeCameraVisibility()
+    */
+    virtual void
+    ComputeFromPointVisibility(const Vector3 &point,
+			       NodeInfoContainer *visibleNodes,
+			       MeshInfoContainer *visibleGeometry,
+				   PatchInfoContainer *visiblePatches,
+			       bool relativeVisibility = false
+			       ) = 0;
+    
+  /** 
+      Ray shooting interface: finds an intersection with objects in the scene.
+
+      @param ray The given input ray (assuming the ray direction is normalized)
+
+      @param visibleMeshes List of meshes intersecting the ray
+
+      @param isGlobalLine If false only first intersection with opaque object is returned.
+      Otherwise all intersections of the ray with the scene are found.
+
+      @return true if there is any intersection. 
+	*/
+    virtual bool
+    ShootRay(const Ray &ray,
+	     std::vector<Mesh *> *visibleMeshes,
+	     bool isGlobalLine = false
+	     );
+  
+	/** Sets the hierarchy interface.
+      @remark the traversal depends on the type of hierarchyInterface the scene consists of.
+	*/
+	void SetHierarchyInterface(HierarchyInterface *hierarchyInterface);
+
+	enum {PATCH_VISIBILITY = 2,
+		  GEOMETRY_VISIBILITY = 4,
+		  NODE_VISIBILITY = 8};
+
+protected:
+  
+	HierarchyInterface *mHierarchyInterface;
+	int mQueryModes;  
+};
+
+};
+
+#endif // VisibilityQueryManager
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityCamera.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityCamera.h	(revision 65)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityCamera.h	(revision 65)
@@ -0,0 +1,13 @@
+#ifndef _VisibilityCamera_H__
+#define _VisibilityCamera_H__
+
+#include "OgreCamera.h"
+
+namespace GtpVisibility {
+  /** Camera class currently uses the native Ogre camera when compiled with the Ogre platform */
+  typedef Ogre::Camera Camera;
+}
+
+
+
+#endif
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/BatchedQueriesCullingManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/BatchedQueriesCullingManager.h	(revision 373)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/BatchedQueriesCullingManager.h	(revision 373)
@@ -0,0 +1,37 @@
+#ifndef _BatchedQueriesCullingManager_H__
+#define _BatchedQueriesCullingManager_H__
+
+#include "CoherentHierarchicalCullingManager.h"
+#include "HierarchyInterface.h"
+
+
+namespace GtpVisibility
+{
+
+/** Renders the scene with the coherent hierarchical culling algorithm. 
+*/
+class BatchedQueriesCullingManager : public CoherentHierarchicalCullingManager
+{
+public:
+	BatchedQueriesCullingManager();
+	/** Constructor taking the assumed visibility into account, i.e., the estimation
+		for how many frames the current visibility is considered to be valid
+	*/
+	BatchedQueriesCullingManager(const unsigned int assumedVisibility);
+
+	void RenderScene();
+	
+	void SetMaxPending(int maxPending);
+
+protected:
+
+	void IssueMultipleQueries(PendingQueue &pendingQueue, QueryQueue &queryQueue);
+
+	/** maximal pending nodes.
+	*/
+	int mMaxPending;
+};
+
+} // namespace GtpVisibility
+
+#endif // BatchedQueriesCullingManager_H
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityRay.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityRay.h	(revision 65)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityRay.h	(revision 65)
@@ -0,0 +1,13 @@
+#ifndef _VisibilityRay_H__
+#define _VisibilityRay_H__
+
+#include "OgreRay.h"
+
+namespace GtpVisibility {
+  /** Ray class currently uses native Ogre ray when compiled with the Ogre platform */
+  typedef Ogre::Ray Ray;
+}
+
+
+
+#endif
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityInfo.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityInfo.h	(revision 318)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityInfo.h	(revision 318)
@@ -0,0 +1,151 @@
+#ifndef _VisibilityInfo_H__
+#define _VisibilityInfo_H__
+
+#include <vector>
+
+#include "VisibilityMesh.h"
+#include "HierarchyInterface.h"
+
+namespace GtpVisibility {
+ 
+/** Class storing visibility information.
+*/
+template<typename T>
+class VisibilityInfo
+{
+public:
+	VisibilityInfo(T source, const int visiblePixels, const int projectedPixels);
+
+	/** set source of the info. 
+	*/
+	void SetSource(T source);
+	/** get source of the info. 
+	*/
+	T GetSource() const;
+
+	int GetVisiblePixels() const;
+	int GetProjectedPixels() const;
+
+	void SetVisiblePixels(int vis);
+	void SetProjectedPixels(int vis);
+	
+	/** Computes ratio of visible to projected pixels. 
+	*/
+	float ComputeRelativeVisibility();
+
+	/** Adds visibility to current visibility information.
+	*/
+	void AddVisibility(const VisibilityInfo<T> &info);
+	/** Adds visibility to current visibility information.
+	*/
+	void AddVisibility(const int visiblePixels, const int projectedPixels);
+
+	bool operator<(const VisibilityInfo<T> &b) const 
+	{
+		return mSource < b.mSource;
+	}
+
+	bool operator==(const VisibilityInfo<T> &b) const 
+	{
+		return mSource == b.mSource;
+	}
+
+protected:
+	/** number of visible pixels. 
+	*/
+    int mVisiblePixels;
+	/** number of projected pixels 
+	*/
+	int mProjectedPixels;
+
+	T mSource;
+};
+
+//-----------------------------------------------------------------------
+template <typename T>
+T VisibilityInfo<T>::GetSource() const
+{
+	return mSource;
+}
+
+//-----------------------------------------------------------------------
+template <typename T>
+void VisibilityInfo<T>::SetSource(T source)
+{
+	return mSource;
+}
+
+//-----------------------------------------------------------------------
+template <typename T>
+VisibilityInfo<T>::VisibilityInfo(T source, const int visiblePixels, const int projectedPixels): 
+mSource(source), mProjectedPixels(projectedPixels), mVisiblePixels(visiblePixels) 
+{
+}
+
+//-----------------------------------------------------------------------
+template <typename T>
+int VisibilityInfo<T>::GetVisiblePixels() const 
+{
+	return mVisiblePixels;
+}
+//-----------------------------------------------------------------------
+template <typename T>
+int VisibilityInfo<T>::GetProjectedPixels() const 
+{
+	return mProjectedPixels;
+}
+//-----------------------------------------------------------------------
+template <typename T>
+void VisibilityInfo<T>::SetVisiblePixels(int vis) 
+{
+	mVisiblePixels = vis;
+}
+//-----------------------------------------------------------------------
+template <typename T>
+void VisibilityInfo<T>::SetProjectedPixels(int vis) 
+{
+	mProjectedPixels = vis;
+}
+//-----------------------------------------------------------------------
+template <typename T>
+float VisibilityInfo<T>::ComputeRelativeVisibility() 
+{ 
+	if (!mProjectedPixels) 
+		return 0;
+
+	return (float)mVisiblePixels / (float)mProjectedPixels; 
+}
+//-----------------------------------------------------------------------
+template <typename T>
+void VisibilityInfo<T>::AddVisibility(const VisibilityInfo<T> &info)
+{
+	mVisiblePixels += info.GetVisiblePixels();
+	mProjectedPixels += info.GetProjectedPixels();
+}
+
+//-----------------------------------------------------------------------
+template <typename T>
+void VisibilityInfo<T>::AddVisibility(const int visiblePixels, const int projectedPixels)
+{
+	mVisiblePixels += visiblePixels;
+	mProjectedPixels += projectedPixels;
+}
+
+typedef VisibilityInfo<Patch *> PatchInfo;
+typedef VisibilityInfo<Mesh *> MeshInfo;
+typedef VisibilityInfo<HierarchyNode *> NodeInfo;
+
+
+template<class T>
+struct InfoContainer
+{
+	typedef std::vector<VisibilityInfo<T> > Type;
+};
+
+typedef std::vector<PatchInfo> PatchInfoContainer;
+typedef std::vector<MeshInfo> MeshInfoContainer;
+typedef std::vector<NodeInfo> NodeInfoContainer;
+
+} // namespace GtpVisibility
+
+#endif
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityMesh.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityMesh.h	(revision 159)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityMesh.h	(revision 159)
@@ -0,0 +1,13 @@
+#ifndef _VisibilityMesh_H__
+#define _VisibilityMesh_H__
+
+//#include <OgreMesh.h>
+#include <OgreEntity.h>
+
+namespace GtpVisibility {
+  typedef Ogre::Entity Mesh;
+  typedef Ogre::SubEntity Patch;
+}
+
+
+#endif // VisibilityMesh.h
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/StopAndWaitCullingManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/StopAndWaitCullingManager.h	(revision 74)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/StopAndWaitCullingManager.h	(revision 74)
@@ -0,0 +1,17 @@
+#ifndef _StopAndWaitCullingManager_H__
+#define _StopAndWaitCullingManager_H__
+
+#include "CullingManager.h"
+
+namespace GtpVisibility {
+
+/** Renders the scene with the hierarchical stop and wait algorithm. 
+*/
+class StopAndWaitCullingManager : public CullingManager
+{
+public:
+	void RenderScene();
+};
+
+} // namespace GtpVisibility
+#endif // StopAndWaitCullingManager
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityAxisAlignedBox.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityAxisAlignedBox.h	(revision 65)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityAxisAlignedBox.h	(revision 65)
@@ -0,0 +1,14 @@
+#ifndef _VisibilityAxisAlignedBox_H__
+#define _VisibilityAxisAlignedBox_H__
+
+#include "OgreAxisAlignedBox.h"
+
+namespace GtpVisibility {
+  /** This class currently uses the native Ogre AxisAlignedBox when
+      compiled with the Ogre platform */
+  typedef Ogre::AxisAlignedBox AxisAlignedBox;
+}
+
+
+
+#endif
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/DummyQueryManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/DummyQueryManager.h	(revision 316)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/DummyQueryManager.h	(revision 316)
@@ -0,0 +1,44 @@
+#ifndef _VisibilityDummyQueryManager_H__
+#define _VisibilityDummyQueryManager_H__
+
+#include "VisibilityInfo.h"
+#include "QueryManager.h"
+
+namespace GtpVisibility {
+/** This implements dummy visibility queries. The queries return only the root of the
+    hierarchy as visible node.
+*/
+  class DummyQueryManager : public QueryManager
+  {
+  public:
+    /** Constructor taking a scene traverser for a specific type of hierarchyInterface
+	as argument. 
+    */
+    DummyQueryManager( HierarchyInterface *hierarchyInterface ):
+      QueryManager(hierarchyInterface, 0) {}
+    
+    /**
+       @sa QueryManager::ComputeCameraVisibility()
+     */
+    virtual void
+    ComputeCameraVisibility(const Camera &camera,
+			    NodeInfoContainer *visibleNodes,
+			    MeshInfoContainer *visibleGeometry,
+				PatchInfoContainer *visiblePatches,
+			    bool relativeVisibility = false );
+    
+    /**
+       @sa QueryManager::ComputeFromPointVisibility()
+     */
+    virtual void
+    ComputeFromPointVisibility(const Vector3 &point,
+			       NodeInfoContainer *visibleNodes,
+			       MeshInfoContainer *visibleGeometry,
+				   PatchInfoContainer *visiblePatches,
+			       bool relativeVisibility = false
+			       );
+    
+  };
+  
+};
+#endif // VisibilitySummyQueryManager
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityEnvironment.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityEnvironment.h	(revision 254)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityEnvironment.h	(revision 254)
@@ -0,0 +1,26 @@
+#ifndef _VisibilityEnvironment_H__
+#define _VisibilityEnvironment_H__
+
+namespace GtpVisibility {
+
+/** This class provides different parameters for the visibility manager.
+*/
+class VisibilityEnvironment
+{
+public:
+    VisibilityEnvironment();
+	
+	/** Different types of occlusion culling algorithms 
+	*/
+	enum CullingManagerType {COHERENT_HIERARCHICAL_CULLING, 
+							 FRUSTUM_CULLING, 
+							 STOP_AND_WAIT_CULLING, 
+							 NUM_CULLING_MANAGERS};
+
+	/** Loads an environment from disk.
+	*/
+	void LoadEnvironment();
+};
+} // namespace GtpVisibility
+
+#endif // VisibilityEnvironment_H
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/FrustumCullingManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/FrustumCullingManager.h	(revision 74)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/FrustumCullingManager.h	(revision 74)
@@ -0,0 +1,17 @@
+#ifndef _FrustumCullingManager_H__
+#define _FrustumCullingManager_H__
+
+#include "CullingManager.h"
+
+namespace GtpVisibility {
+
+/** Renders the scene, applies only view frustum culling. 
+*/
+
+class FrustumCullingManager : public CullingManager
+{
+public:
+	void RenderScene();
+};
+} // namespace GtpVisibility
+#endif // FrustumCullingManager_H
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/PreprocessingManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/PreprocessingManager.h	(revision 316)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/PreprocessingManager.h	(revision 316)
@@ -0,0 +1,135 @@
+#ifndef _VisibilityPreprocessingManager_H__
+#define _VisibilityPreprocessingManager_H__
+
+#include <string>
+using namespace std;
+
+#include "HierarchyInterface.h"
+#include "VisibilityInfo.h"
+#include "VisibilityVector3.h"
+
+namespace GtpVisibility {
+  
+/**
+	This class defines an interface to the external visibility preprocessor.
+    It allows to export the static part of the scene to a file in the XML format
+    understood by the preprocessor. By default all the exported meshes are considered
+    as scene occluders, whereas occludees are formed by their bounding boxes,
+    and bounding boxes of the scene hierarchy.
+
+    This class also allows to import the preprocessed data with PVS
+    information for the viewcells (note that the viewcells are either generated
+    automatically by the preprocessor or loaded from a polyhedral definition stored
+    in a file (see documentation for the Preprocessor class).
+*/
+  
+class PreprocessingManager
+{
+public:
+    
+	/** Constructor taking a HierarchyInterface as argument.
+        The HierarchyInterface makes the PreprocessingManager independent from the actual
+        scene representation as long as it supports a required set of methods.
+    */
+    PreprocessingManager(HierarchyInterface *hierarchyInterface);
+    
+
+    /**
+        Destructor which deletes all data describing static scene visibility.
+    */
+    virtual ~PreprocessingManager();
+
+    /** Export the scene for visibility preprocessing. Exports the hierarchyInterface including
+        its bounding boxes + mesh data. Note that the bounding boxes can be used as occludees
+        by the extrenal preprocessor. The viewcell data will either be supplied directly to the
+        visibility preprocessing standalone module.
+
+        @param filename name of the file to export.
+        @return true if the export was succesful.
+    */
+    virtual bool ExportScene(const string filename) = 0;
+    
+	/** Load preprocessed visibility information. The loaded data is matched with the current
+        scene graph. The topology of the current scene graph has to match with the loaded data.
+        There is also geometrical check of the bounding boxes. Once loading is succesful the
+        PreprocessingManager establishes links from its internal visibility representation
+        to the scene graph: no change of this part of the scene graph is allowed; this would
+        violate the static scene assumption!
+
+        @param filename name of the file to load.
+        @return true if the loading was succesful.
+    */
+    virtual bool LoadPreprocessedData(const string filename) = 0;
+    
+    /** 
+	Retrieve a PVS corresponding to the given spherical neighborhood of the point.
+	Typically the implementation of this method will firs locate all viewcells
+	intersecting the sphere using efficient logarithmic search enhanced with caching
+	the last query. Then it computes a union of the PVS for the found viewcells.
+
+	@param point the center point of the spherical neighborhood
+
+	@param radius the radius of the spherical neighborhood. Note that if radius==0 a
+	more efficient implementation of the method for this special case can be used.
+
+	@param visibleNodes of not NULL
+	a set of visible hierarchy nodes is added to the visibleNodes container.
+	This set is formed of visible leafs or fully visible interior nodes.
+
+	@param visibleMeshes if not NULL the set of visible meshes is
+	added to the container. Returns true if the corresponding PVS exists.
+    */
+    virtual bool GetPVS(const Vector3 &point,
+			const float radius,
+			NodeInfoContainer *visibleNodes,
+			MeshInfoContainer *visibleMeshes);
+    
+    
+  
+    /** Sets the scene traverser.
+	@remark the scene traverser is dependent on the type of hierarchyInterface the scene consists of.
+    */
+    virtual void SetSceneTraverser(HierarchyInterface *hierarchyInterface) {
+      mSceneTraverser = hierarchyInterface;
+    }
+    
+  protected:
+    /** Get checksum of the current occluder set in the scene graph. This method is used to check
+	if the preprocessed data matches the current scene graph
+	-> $$ could be moved to VisibilitySceneTraverser */
+    long GetOccluderChecksum() const {
+      return 0;
+    }
+      
+    
+    /** Get checksum of the current occludee set in the scene graph. This method is used to check
+	if the preprocessed data matches the current scene graph
+	-> $$ could be moved to VisibilitySceneTraverser */
+    long GetOccludeeChecksum() const {
+      return 0;
+    }
+    
+    
+    /** 
+	Find viewcells intersecting a spherical neighborhood of a point.
+	Returns false if no viewcell was found.
+    */
+    virtual bool LocateViewCellIds(const Vector3 &center,
+				   const float radius,
+				   vector<int> *viewCellIds
+				   ) = 0;
+    
+    /**
+       Add a PVS of the given viewcell to the already evaluated PVS by computing
+       a union with visibleNodes and visibleMeshes. Returns the number of added entries.
+    */
+    virtual int AddViewCellPVS(const int cellID,
+							   NodeInfoContainer *visibleNodes,
+							   MeshInfoContainer *visibleMeshes ) = 0;
+    
+    HierarchyInterface *mSceneTraverser;
+  };
+  
+};
+
+#endif // VisibilityPreprocessingInterafce
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/CoherentHierarchicalCullingManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/CoherentHierarchicalCullingManager.h	(revision 345)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/CoherentHierarchicalCullingManager.h	(revision 345)
@@ -0,0 +1,53 @@
+#ifndef _CoherentHierarchicalCullingManager_H__
+#define _CoherentHierarchicalCullingManager_H__
+
+#include "CullingManager.h"
+#include "HierarchyInterface.h"
+
+
+namespace GtpVisibility
+{
+
+/** Renders the scene with the coherent hierarchical culling algorithm. 
+*/
+class CoherentHierarchicalCullingManager : public CullingManager
+{
+public:
+	CoherentHierarchicalCullingManager();
+	/** Constructor taking the assumed visibility into account, i.e., the estimation
+		for how many frames the current visibility is considered to be valid
+	*/
+	CoherentHierarchicalCullingManager(const unsigned int assumedVisibility);
+
+	void RenderScene();
+	/** Sets assumed visibility (i.e., an estimation for 
+		how many frames the visibility is considered to be valid).
+		@param assumedVisibility indicates for how many frames the 
+		same visibility is be assumed.
+		if 0, the visibility is tested deterministically for each frame.
+	*/
+	void SetAssumedVisibility(const unsigned int assumedVisibility);
+
+protected:
+	/** Decides if node is considered to be visible depeding on the 
+		assumed visibility factor.
+		@returns if node is considered to be visible
+	*/
+	bool DecideVisible(HierarchyNode *node) const;
+
+	unsigned int mAssumedVisibility;
+	
+	/** Skip query for this node.
+	*/
+	void SkipQuery(HierarchyNode *node) const;
+
+
+	/** Threshold for rand function to return positive result with respect to
+		mAssumedVisibility.
+	*/
+	int mThreshold;
+};
+
+} // namespace GtpVisibility
+
+#endif // CoherentHierarchicalCullingManager_H
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityManager.h	(revision 155)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityManager.h	(revision 155)
@@ -0,0 +1,80 @@
+#ifndef _VisibilityManager_H__
+#define _VisibilityManager_H__
+
+#include "CullingManager.h"
+#include "VisibilityEnvironment.h"
+
+/** This namespace includes all classes which are created by the VUT (Vienna University
+	of Technology for the Visibility module of the GTP (GameTools Project) (www.gametools.org),
+	and are not directly derived from an Ogre class.
+*/
+namespace GtpVisibility {
+
+  class QueryManager;
+  class PreprocessingManager;
+  
+/** This class manages all forms of visibility. It is the main
+	class of our visibility module and manages online occlusion culling,
+	offline culling, and visibility queries.
+*/
+class VisibilityManager
+{
+public:
+	/** Constructor taking the visibility environment object as parameter
+		@param visEnvironment the visibility environment
+	*/
+	VisibilityManager(VisibilityEnvironment *visEnvironment);
+	
+	~VisibilityManager();
+	/** Sets the current online occlusion culling manager, e.g.,
+		the stop and wait algorithm or coherent hierarchical culling.
+		@param ocmType the online occlusion culling manager type
+	*/
+	void SetCullingManager(VisibilityEnvironment::CullingManagerType ocmType);
+	/** Returns the current online occlusion culling manager.
+	*/
+	CullingManager *GetCullingManager();
+	/** Returns the current online occlusion culling manager type. See set
+	*/
+	VisibilityEnvironment::CullingManagerType GetCullingManagerType();
+
+	/** Applies the online visibility culling algorithm on a scene.
+		@remark the algorithm depends on the current culling manager.
+	*/
+	void ApplyVisibilityCulling();
+
+	/** Sets the threshold for the visibiliy culling algorithm.
+		@param visibilityThreshold number of visible pixels where an object 
+		is still considered invisible.
+		@remark automatically sets the threshold of the current and of 
+		new culling managers to this value.
+	*/
+	void SetVisibilityCullingThreshold(unsigned int threshold);
+
+	/** Indicates for how long a frame is considered to be visible.
+		@param assumedVisibility estimation for how long visibility is assumed to be valid.
+		@remark this option is only valid for the coherent hierarchical culling algorithm
+	*/
+	void SetAssumedVisibilityForChc(unsigned int assumedVisibility);
+	
+	/** Sets pointer to a query manager. 
+	*/
+	void SetQueryManager(QueryManager *queryManager);
+	/** see set 
+	*/
+	QueryManager *GetQueryManager();
+
+protected:
+	
+	CullingManager *mCullingManager;
+	QueryManager *mQueryManager;
+	PreprocessingManager *mPreprocessingManager;
+	VisibilityEnvironment *mVisibilityEnvironment;
+	VisibilityEnvironment::CullingManagerType mCullingManagerType;
+
+	unsigned int mVisibilityThreshold;
+	unsigned int mAssumedVisibilityForChc;
+};
+} // namespace GtpVisibility
+
+#endif // VisibilityManager
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/OcclusionQuery.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/OcclusionQuery.h	(revision 87)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/OcclusionQuery.h	(revision 87)
@@ -0,0 +1,29 @@
+#ifndef _OcclusionQuery_H__
+#define _OcclusionQuery_H__
+
+namespace GtpVisibility {
+
+/** This class is an abstract interface for occlusion queries.
+*/
+class OcclusionQuery
+{
+public:
+	virtual ~OcclusionQuery() {};
+	/** Returns the result of an occlusion query in terms of visible pixels.
+		@param queryResult the number of visible pixels if the result was available
+		@param waitForResult if we should wait for the result until available
+		@returns if the result was already available
+	*/
+	virtual bool GetQueryResult(unsigned int &queryResult, 
+		const bool waitForResult) const = 0;
+	/** Begins occlusion query.
+		@remark the query counts the number of visible pixels between it's begin and end
+	*/
+	virtual void BeginQuery() = 0;
+	/** Ends occlusion query.
+	*/
+	virtual void EndQuery() = 0;
+};
+
+} // namespace GtpVisibility
+#endif // OcclusionQuery_H
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/CullingManager.h
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/include/CullingManager.h	(revision 114)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/include/CullingManager.h	(revision 114)
@@ -0,0 +1,65 @@
+#ifndef _CullingManager_H__
+#define _CullingManager_H__
+
+#include "HierarchyInterface.h"
+
+namespace GtpVisibility {
+
+/** This abstract class implements an interface for a specific culling 
+	algorithm. The algorithm is either used to render a scene or to make a visibility query.
+*/
+class CullingManager
+{
+public:
+	/** Default constructor. 
+		@remark an appropriate hierarchy interface must be provided for the algorithms to
+		work on specific hierarchy
+	*/
+	CullingManager();
+	/** Renders the scene using a specific occlusion culling algorithm, e.g., coherent
+		hierarchical culling or stop and wait.
+	*/
+	virtual void RenderScene() = 0;
+	/** Sets the hierarchy interface.
+		@param hierarchyInterface
+		@remark the hierarchy interface encapsulates the hierarchy we are working on
+	*/
+	void SetHierarchyInterface(HierarchyInterface *hierarchyInterface);
+	/** Sets the threshold for the visibiliy culling algorithm.
+		@param visibilityThreshold number of visible pixels where an object 
+		is still considered invisible.
+	*/
+	void SetVisibilityThreshold(unsigned int visibilityThreshold);
+
+	/** Returns number of frustum culled nodes.
+	*/
+	unsigned int GetNumFrustumCulledNodes();
+	/** Returns number of occlusion query culled nodes.
+	*/
+	unsigned int GetNumQueryCulledNodes();
+	/** Returns number of issued occlusion queries.
+	*/
+	unsigned int GetNumQueriesIssued();
+	/** basic initializations on beginning of each frame, e.g., 
+		resets statistics.
+	*/
+	void InitFrame(bool visualizeCulledNodes);
+
+	/** Some visualization of culled nodes are shown, depending 
+	on the type of hierarchy.
+	@param showVisualization if true, culled nodes are visualized
+	*/
+	void SetVisualizeCulledNodes(bool visualizeCulledNodes);
+
+protected:
+	
+	unsigned int mNumQueryCulledNodes;
+	unsigned int mNumFrustumCulledNodes;
+	unsigned int mVisibilityThreshold;
+	unsigned int mNumQueriesIssued;
+
+	HierarchyInterface *mHierarchyInterface;
+	bool mVisualizeCulledNodes;
+};
+} // namespace GtpVisibility
+#endif // CullingManager
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/GtpVisibility.pro
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/GtpVisibility.pro	(revision 65)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/GtpVisibility.pro	(revision 65)
@@ -0,0 +1,31 @@
+
+TEMPLATE = app
+
+TARGET = visibility
+
+INCLUDEPATH += ../include \
+c:/stlport-4.6.2/stlport \
+D:\gametools\ogrenew\PlugIns\OctreeSceneManager\include \
+d:/gametools/ogrenew/OgreMain/include
+
+# debuc config
+CONFIG		+= console warn_on debug thread
+
+#DEFINES 	+=EXT_HASH
+# RELEASE CONFIG
+#CONFIG		+= windows warn_on thread
+
+# DEPENDPATH	= ../../include
+
+# Input
+HEADERS += 
+
+	
+SOURCES += \
+CoherentHierarchicalCullingManager.cpp  PreprocessingManager.cpp \
+CullingManager.cpp                      QueryManager.cpp \
+DummyPreprocessingManager.cpp           StopAndWaitCullingManager.cpp \
+DummyQueryManager.cpp                   VisibilityEnvironment.cpp \
+FrustumCullingManager.cpp               VisibilityManager.cpp \
+HierarchyInterface.cpp
+
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/GtpVisibility.vcproj
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/GtpVisibility.vcproj	(revision 373)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/GtpVisibility.vcproj	(revision 373)
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="GtpVisibility"
+	ProjectGUID="{101A7691-74F3-48B4-96A3-CF35578F5900}"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="..\lib\$(ConfigurationName)"
+			IntermediateDirectory="..\obj\$(ConfigurationName)"
+			ConfigurationType="4"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				RuntimeTypeInfo="TRUE"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(OutDir)/GtpVisibility.lib"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="..\lib\$(ConfigurationName)"
+			IntermediateDirectory="..\obj\$(ConfigurationName)"
+			ConfigurationType="4"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\OgreMain\include&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+				RuntimeLibrary="2"
+				RuntimeTypeInfo="TRUE"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(OutDir)/GtpVisibility.lib"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+			<File
+				RelativePath="..\src\BatchedQueriesCullingManager.cpp">
+			</File>
+			<File
+				RelativePath="..\src\CoherentHierarchicalCullingManager.cpp">
+			</File>
+			<File
+				RelativePath="..\src\CullingManager.cpp">
+			</File>
+			<File
+				RelativePath="..\src\DummyPreprocessingManager.cpp">
+			</File>
+			<File
+				RelativePath="..\src\FrustumCullingManager.cpp">
+			</File>
+			<File
+				RelativePath="..\src\HierarchyInterface.cpp">
+			</File>
+			<File
+				RelativePath="..\src\PreprocessingManager.cpp">
+			</File>
+			<File
+				RelativePath="..\src\QueryManager.cpp">
+			</File>
+			<File
+				RelativePath="..\src\StopAndWaitCullingManager.cpp">
+			</File>
+			<File
+				RelativePath="..\src\VisibilityEnvironment.cpp">
+			</File>
+			<File
+				RelativePath="..\src\VisibilityManager.cpp">
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+			<File
+				RelativePath="..\include\BatchedQueriesCullingManager.h">
+			</File>
+			<File
+				RelativePath="..\include\CoherentHierarchicalCullingManager.h">
+			</File>
+			<File
+				RelativePath="..\include\CullingManager.h">
+			</File>
+			<File
+				RelativePath="..\include\DistanceQueue.h">
+			</File>
+			<File
+				RelativePath="..\include\DummyPreprocessingManager.h">
+			</File>
+			<File
+				RelativePath="..\include\DummyQueryManager.h">
+			</File>
+			<File
+				RelativePath="..\include\FrustumCullingManager.h">
+			</File>
+			<File
+				RelativePath="..\include\HierarchyInterface.h">
+			</File>
+			<File
+				RelativePath="..\include\OcclusionQuery.h">
+			</File>
+			<File
+				RelativePath="..\include\PreprocessingManager.h">
+			</File>
+			<File
+				RelativePath="..\include\QueryManager.h">
+			</File>
+			<File
+				RelativePath="..\include\StopAndWaitCullingManager.h">
+			</File>
+			<File
+				RelativePath="..\include\VisibilityEnvironment.h">
+			</File>
+			<File
+				RelativePath="..\include\VisibilityInfo.h">
+			</File>
+			<File
+				RelativePath="..\include\VisibilityManager.h">
+			</File>
+			<File
+				RelativePath="..\include\VisibilityMesh.h">
+			</File>
+		</Filter>
+		<File
+			RelativePath=".\VTune\GtpVisibility.vpj">
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/FrustumCullingManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/FrustumCullingManager.cpp	(revision 259)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/FrustumCullingManager.cpp	(revision 259)
@@ -0,0 +1,36 @@
+#include "FrustumCullingManager.h"
+#include <OgreLogManager.h>
+
+namespace GtpVisibility {
+
+//-----------------------------------------------------------------------
+void FrustumCullingManager::RenderScene()
+{
+	//Ogre::LogManager::getSingleton().logMessage("Frustum Culling");
+	while (!mHierarchyInterface->GetQueue()->empty())
+	{
+		HierarchyNode *node = mHierarchyInterface->GetQueue()->top();
+		mHierarchyInterface->GetQueue()->pop();
+		
+		// interesting for visualization purpose
+		mHierarchyInterface->SetNodeVisible(node, false);
+		mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());
+
+		if (!mHierarchyInterface->CheckFrustumVisible(node))
+		{
+			++ mNumFrustumCulledNodes;
+
+			if (mVisualizeCulledNodes)
+			{
+				mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED);
+			}
+		}
+		else
+		{
+			mHierarchyInterface->SetNodeVisible(node, true);
+			mHierarchyInterface->TraverseNode(node);
+		}
+	}
+}
+
+} // namespace GtpVisibility
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/PreprocessingManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/PreprocessingManager.cpp	(revision 316)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/PreprocessingManager.cpp	(revision 316)
@@ -0,0 +1,31 @@
+#include "PreprocessingManager.h"
+
+namespace GtpVisibility {
+  
+PreprocessingManager::PreprocessingManager(HierarchyInterface *hierarchyInterface)
+{
+}
+
+PreprocessingManager::~PreprocessingManager()
+{
+}
+
+bool PreprocessingManager::GetPVS(const Vector3 &center,
+								  const float radius,
+								  NodeInfoContainer *visibleNodes,
+								  MeshInfoContainer *visibleMeshes)
+{
+    vector<int> viewCellIds;
+    if (LocateViewCellIds(center, radius, &viewCellIds)) 
+	{
+		for (vector<int>::iterator ci = viewCellIds.begin(); ci != viewCellIds.end(); ci++) 
+		{
+			AddViewCellPVS(*ci, visibleNodes, visibleMeshes );
+			// remove duplicates of the PVS entries if any?
+		}
+		return true;
+    }
+    return false;
+  }
+  
+};
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CoherentHierarchicalCullingManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CoherentHierarchicalCullingManager.cpp	(revision 350)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CoherentHierarchicalCullingManager.cpp	(revision 350)
@@ -0,0 +1,162 @@
+#include "CoherentHierarchicalCullingManager.h"
+#include <OgreLogManager.h>
+
+namespace GtpVisibility {
+
+//-----------------------------------------------------------------------
+CoherentHierarchicalCullingManager::CoherentHierarchicalCullingManager()
+{
+	SetAssumedVisibility(0);
+	// initialise random generator in case we use assumed visibility
+	srand(time(NULL));
+}
+//-----------------------------------------------------------------------
+CoherentHierarchicalCullingManager::CoherentHierarchicalCullingManager(const unsigned int 
+																	   assumedVisibility)
+{
+	SetAssumedVisibility(assumedVisibility);
+	// initialise random generator in case we use assumed visibility
+	srand(time(NULL));
+}
+//-----------------------------------------------------------------------
+void CoherentHierarchicalCullingManager::RenderScene()
+{
+	QueryQueue queryQueue;
+	unsigned int visiblePixels = 0;
+	bool isAvailable = false;
+	//Ogre::LogManager::getSingleton().logMessage("Coherent Hierarchical Culling");
+
+	//-- PART 1: process finished occlusion queries
+	while (!mHierarchyInterface->GetQueue()->empty() || !queryQueue.empty())
+	{
+		while (!queryQueue.empty() && 
+			   queryQueue.front().second->GetQueryResult(visiblePixels, 
+									mHierarchyInterface->GetQueue()->empty()))
+		{
+           	HierarchyNode *node = queryQueue.front().first;
+			
+			queryQueue.pop();
+
+			if (visiblePixels > mVisibilityThreshold)
+			{
+				// ensure that we only traverse once if geometry in node
+				if (!mHierarchyInterface->IsNodeVisible(node))
+					mHierarchyInterface->TraverseNode(node);
+				mHierarchyInterface->PullUpVisibility(node);
+			}
+			else
+			{	
+				mHierarchyInterface->SetNodeVisible(node, false);
+
+				++ mNumQueryCulledNodes;
+				
+				if (mVisualizeCulledNodes)
+				{
+					mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED);
+				}
+			}
+		}
+		
+		//-- PART 2: hierarchical traversal
+		if (!mHierarchyInterface->GetQueue()->empty())
+		{
+			HierarchyNode *node = mHierarchyInterface->GetQueue()->top();
+			mHierarchyInterface->GetQueue()->pop();
+				
+			bool intersects = false;
+
+			if (!mHierarchyInterface->CheckFrustumVisible(node, intersects))
+			{
+				++ mNumFrustumCulledNodes;
+				
+				if (mVisualizeCulledNodes)
+				{
+					mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED);
+				}
+			}
+			// -- if node intersects near plane, skip query because wrong results possible
+			else if (intersects)
+			{
+				SkipQuery(node);
+			}
+			else
+			{
+				// identify previously visible nodes
+				bool wasVisible = mHierarchyInterface->IsNodeVisible(node) && 
+					(mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId() - 1);
+				
+				// if we assume node to be visible in this frame => skip query 
+				bool skipQuery = wasVisible && (mAssumedVisibility > 0) && 
+					DecideVisible(node) && mHierarchyInterface->HasGeometry(node);
+
+				//if (mHierarchyInterface->LastVisited(node) >= mHierarchyInterface->GetFrameId())
+				//	Ogre::LogManager::getSingleton().logMessage("error");
+				
+				if (skipQuery)
+				{
+					SkipQuery(node);
+
+					continue;
+				}
+
+                // identify nodes that we cannot skip queries for
+				// geometry not only in leaves => test for renderable geometry
+				bool issueQuery = !wasVisible || mHierarchyInterface->HasGeometry(node);
+							
+				// reset node's visibility classification
+				// set visibe if geometry in node so we only traverse once
+				mHierarchyInterface->SetNodeVisible(node, wasVisible && issueQuery);
+
+				// update node's visited flag
+				mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());
+
+				// skip testing previously visible nodes without geometry
+				if (issueQuery)
+				{
+					++ mNumQueriesIssued;
+					
+					queryQueue.push(QueryPair(node, mHierarchyInterface->
+						IssueNodeOcclusionQuery(node, wasVisible)));
+				}
+				
+				// always traverse a node if it was visible
+				if (wasVisible)
+				{
+					mHierarchyInterface->TraverseNode(node);
+				}
+			}
+		}
+	}
+}
+//-----------------------------------------------------------------------
+void CoherentHierarchicalCullingManager::SetAssumedVisibility(const unsigned int assumedVisibility)
+{
+	mAssumedVisibility = assumedVisibility;
+	
+	mThreshold = 0;
+
+	if (mAssumedVisibility > 0)
+	{
+		mThreshold =  RAND_MAX - RAND_MAX / mAssumedVisibility;
+	}
+	//std::stringstream d; d << "*** setting assumed vis: " << mAssumedVisibility; Ogre::LogManager::getSingleton().logMessage(d.str());
+}
+//-----------------------------------------------------------------------
+inline bool CoherentHierarchicalCullingManager::DecideVisible(HierarchyNode *node) const
+{
+	//bool result = rand() < mThreshold; std::stringstream d; d << "Assumed vis: " << mAssumedVisibility << ", result: " << result;
+	//Ogre::LogManager::getSingleton().logMessage(d.str()); return result;
+	
+	return rand() < mThreshold;
+}
+//-----------------------------------------------------------------------
+inline void CoherentHierarchicalCullingManager::SkipQuery(HierarchyNode *node) const
+{
+	// -- set node to be visible in this frame, then traverse it
+	mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());
+	
+	mHierarchyInterface->PullUpVisibility(node);			
+	mHierarchyInterface->TraverseNode(node);
+}
+
+} // namespace GtpVisibility
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/HierarchyInterface.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/HierarchyInterface.cpp	(revision 316)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/HierarchyInterface.cpp	(revision 316)
@@ -0,0 +1,77 @@
+#include "HierarchyInterface.h"
+
+#include <windows.h>
+
+namespace GtpVisibility {
+
+//-----------------------------------------------------------------------
+HierarchyInterface::HierarchyInterface(): 
+mFrameId(0), mNumTraversedNodes(0), mHierarchyRoot(NULL), 
+mSavedNode(NULL), mCurrentTestIdx(0), mTestGeometryForVisibleLeaves(false)
+{	
+	mDistanceQueue = new DistanceQueue(GtDistance<HierarchyNode *>(this));
+}
+//-----------------------------------------------------------------------
+HierarchyInterface::~HierarchyInterface()
+{		
+	delete mDistanceQueue;
+}
+//-----------------------------------------------------------------------
+void HierarchyInterface::SetHierarchyRoot(HierarchyNode *root)
+{
+	mHierarchyRoot = root;
+}
+//-----------------------------------------------------------------------
+void HierarchyInterface::InitTraversal()
+{
+	// initialise for front-to-back rendering
+
+	++ mFrameId;
+	mCurrentTestIdx = 0;
+	mNumTraversedNodes = 0;
+	mVisibleNodes.clear();
+
+	mDistanceQueue->push(mHierarchyRoot);
+}
+//-----------------------------------------------------------------------
+unsigned int HierarchyInterface::GetFrameId() const
+{
+	return mFrameId;
+}
+//-----------------------------------------------------------------------
+DistanceQueue *HierarchyInterface::GetQueue()
+{
+	return mDistanceQueue;
+}
+//-----------------------------------------------------------------------
+bool HierarchyInterface::CheckFrustumVisible(HierarchyNode *node)
+{
+	bool intersects = false;
+	return CheckFrustumVisible(node, intersects);
+}
+//-----------------------------------------------------------------------
+HierarchyNode *HierarchyInterface::GetHierarchyRoot() const
+{
+	return mHierarchyRoot;
+}
+//-----------------------------------------------------------------------
+unsigned int HierarchyInterface::GetNumTraversedNodes()
+{
+	return mNumTraversedNodes;
+}
+//-----------------------------------------------------------------------
+unsigned int HierarchyInterface::GetNumRenderedNodes()
+{
+	return (unsigned int)mVisibleNodes.size();
+}
+//-----------------------------------------------------------------------
+void HierarchyInterface::TestGeometryForVisibleLeaves(bool testGeometry)
+{
+	mTestGeometryForVisibleLeaves = testGeometry;
+}
+//-----------------------------------------------------------------------
+std::vector<HierarchyNode *> *HierarchyInterface::GetVisibleNodes()
+{
+	return &mVisibleNodes;
+}
+} // namespace GtpVisibility
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/QueryManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/QueryManager.cpp	(revision 174)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/QueryManager.cpp	(revision 174)
@@ -0,0 +1,18 @@
+#include "QueryManager.h"
+
+
+namespace GtpVisibility {
+ 
+QueryManager::QueryManager(HierarchyInterface *hierarchyInterface, int queryModes):
+mHierarchyInterface(hierarchyInterface),
+mQueryModes(queryModes)
+{
+}
+ 
+bool QueryManager::ShootRay(const Ray &ray, std::vector<Mesh *> *visibleMeshes, bool isGlobalLine)
+{
+    // run OGRE ray shooting query
+    return false;
+}
+  
+} // namespace GtpVisibility
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/BatchedQueriesCullingManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/BatchedQueriesCullingManager.cpp	(revision 373)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/BatchedQueriesCullingManager.cpp	(revision 373)
@@ -0,0 +1,158 @@
+#include "BatchedQueriesCullingManager.h"
+#include <OgreLogManager.h>
+
+namespace GtpVisibility {
+
+//-----------------------------------------------------------------------
+BatchedQueriesCullingManager::BatchedQueriesCullingManager():
+mMaxPending(5)
+{
+}
+//-----------------------------------------------------------------------
+BatchedQueriesCullingManager::BatchedQueriesCullingManager(const unsigned int 
+														   assumedVisibility):
+CoherentHierarchicalCullingManager(assumedVisibility), mMaxPending(5)
+{
+}
+
+//-----------------------------------------------------------------------
+void BatchedQueriesCullingManager::RenderScene()
+{
+	QueryQueue queryQueue;
+	unsigned int visiblePixels = 0;
+	bool isAvailable = false;
+
+	//Ogre::LogManager::getSingleton().logMessage("Batched Culling");
+
+	PendingQueue pendingQueue;
+
+	//-- PART 1: process finished occlusion queries
+	while (!mHierarchyInterface->GetQueue()->empty() || !queryQueue.empty() ||!pendingQueue.empty())
+	{
+		while (!queryQueue.empty() && 
+			   queryQueue.front().second->GetQueryResult(visiblePixels, 
+									mHierarchyInterface->GetQueue()->empty()))
+		{
+           	HierarchyNode *node = queryQueue.front().first;
+			
+			queryQueue.pop();
+
+			if (visiblePixels > mVisibilityThreshold)
+			{
+				// ensure that we only traverse once if geometry in node
+				if (!mHierarchyInterface->IsNodeVisible(node))
+					mHierarchyInterface->TraverseNode(node);
+				mHierarchyInterface->PullUpVisibility(node);
+			}
+			else
+			{	
+				mHierarchyInterface->SetNodeVisible(node, false);
+
+				++ mNumQueryCulledNodes;
+				
+				if (mVisualizeCulledNodes)
+				{
+					mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED);
+				}
+			}
+		}
+		
+		//-- PART 2: hierarchical traversal
+		if (!mHierarchyInterface->GetQueue()->empty())
+		{
+			HierarchyNode *node = mHierarchyInterface->GetQueue()->top();
+			mHierarchyInterface->GetQueue()->pop();
+				
+			bool intersects = false;
+
+			if (!mHierarchyInterface->CheckFrustumVisible(node, intersects))
+			{
+				++ mNumFrustumCulledNodes;
+				
+				if (mVisualizeCulledNodes)
+				{
+					mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED);
+				}
+			}
+			// -- if node intersects near plane, skip query because wrong results possible
+			else if (intersects)
+			{
+				SkipQuery(node);
+			}
+			else
+			{
+				// identify previously visible nodes
+				bool wasVisible = mHierarchyInterface->IsNodeVisible(node) && 
+					(mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId() - 1);
+				
+				// if we assume node to be visible in this frame => skip query 
+				bool skipQuery = wasVisible && (mAssumedVisibility > 0) && 
+					DecideVisible(node) && mHierarchyInterface->HasGeometry(node);
+
+				//if (mHierarchyInterface->LastVisited(node) >= mHierarchyInterface->GetFrameId())
+				//	Ogre::LogManager::getSingleton().logMessage("error");
+				
+				if (skipQuery)
+				{
+					SkipQuery(node);
+
+					continue;
+				}
+
+                // identify nodes that we cannot skip queries for
+				// geometry not only in leaves => test for renderable geometry
+				bool issueQuery = !wasVisible || mHierarchyInterface->HasGeometry(node);
+							
+				// reset node's visibility classification
+				// set visibe if geometry in node so we only traverse once
+				mHierarchyInterface->SetNodeVisible(node, wasVisible && issueQuery);
+
+				// update node's visited flag
+				mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());
+
+				// skip testing previously visible nodes without geometry
+				if (issueQuery)
+				{
+					++ mNumQueriesIssued;
+					// add to the pending queue instead of immediate query
+					if ((int)pendingQueue.size() < mMaxPending)
+						pendingQueue.push(PendingQuery(node, wasVisible));
+					else
+					{
+						IssueMultipleQueries(pendingQueue, queryQueue);	
+					}
+				}
+				
+				// always traverse a node if it was visible
+				if (wasVisible)
+				{
+					mHierarchyInterface->TraverseNode(node);
+				}
+			}
+		}
+		// add rest of queries
+		IssueMultipleQueries(pendingQueue, queryQueue);
+	}
+}
+
+void BatchedQueriesCullingManager::IssueMultipleQueries(PendingQueue &pendingQueue, 
+														QueryQueue &queryQueue)
+{
+	while (!pendingQueue.empty())
+	{
+		HierarchyNode *node = pendingQueue.front().first;
+		const bool wasVisible = pendingQueue.front().second;
+
+		pendingQueue.pop();
+
+		queryQueue.push(QueryPair(node, mHierarchyInterface->
+					IssueNodeOcclusionQuery(node, wasVisible)));
+	}
+}
+
+void BatchedQueriesCullingManager::SetMaxPending(int maxPending)
+{
+	mMaxPending = maxPending;
+}
+
+} // namespace GtpVisibility
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityManager.cpp	(revision 371)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityManager.cpp	(revision 371)
@@ -0,0 +1,116 @@
+#include "VisibilityManager.h"
+#include "StopAndWaitCullingManager.h"
+#include "CoherentHierarchicalCullingManager.h"
+#include "FrustumCullingManager.h"
+#include "DummyPreprocessingManager.h"
+#include "DummyQueryManager.h"
+//#include "BatchedQueriesCullingManager.h"
+
+namespace GtpVisibility {
+
+//-----------------------------------------------------------------------
+VisibilityManager::VisibilityManager(VisibilityEnvironment *visEnvironment):
+mVisibilityThreshold(0), mCullingManager(NULL),
+mQueryManager(NULL),
+mPreprocessingManager(new DummyPreprocessingManager(NULL)),
+mVisibilityEnvironment(visEnvironment),
+mAssumedVisibilityForChc(0)
+{
+	SetCullingManager(VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING);
+	//SetCullingManager(VisibilityEnvironment::STOP_AND_WAIT_CULLING);
+	//SetCullingManager(VisibilityEnvironment::FRUSTUM_CULLING);
+}
+//-----------------------------------------------------------------------
+VisibilityManager::~VisibilityManager()
+{
+	delete mCullingManager;
+	delete mPreprocessingManager;
+}
+//-----------------------------------------------------------------------
+void VisibilityManager::SetCullingManager(VisibilityEnvironment::
+										  CullingManagerType ocmType)
+{
+	// change only if necessary
+	if (!mCullingManager || (mCullingManagerType != ocmType))
+	{
+		// delete old culling manager
+		if (mCullingManager)
+		{
+			delete mCullingManager;
+		}
+
+		mCullingManagerType = ocmType;
+		
+		switch (ocmType)
+		{
+		case VisibilityEnvironment::STOP_AND_WAIT_CULLING:
+			mCullingManager = new StopAndWaitCullingManager();
+				//new BatchedQueriesCullingManager();
+			break;
+
+		case VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING:
+			mCullingManager = new CoherentHierarchicalCullingManager(mAssumedVisibilityForChc);
+			break;
+
+		case VisibilityEnvironment::FRUSTUM_CULLING:
+			mCullingManager = new FrustumCullingManager();
+			break;
+
+		default:
+			mCullingManager = new StopAndWaitCullingManager();
+			break;
+
+		}
+
+		//-- set threshold
+		mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);		
+	}
+}
+//-----------------------------------------------------------------------
+void VisibilityManager::SetVisibilityCullingThreshold(unsigned int visibilityThreshold)
+{
+	mVisibilityThreshold = visibilityThreshold;
+	mCullingManager->SetVisibilityThreshold(mVisibilityThreshold);
+}
+//-----------------------------------------------------------------------
+CullingManager *VisibilityManager::GetCullingManager()
+{
+	return mCullingManager;
+}
+//-----------------------------------------------------------------------
+void VisibilityManager::ApplyVisibilityCulling()
+{
+	mCullingManager->RenderScene();
+}
+//-----------------------------------------------------------------------
+VisibilityEnvironment::CullingManagerType VisibilityManager::GetCullingManagerType()
+{
+	return mCullingManagerType;
+}
+//-----------------------------------------------------------------------
+void VisibilityManager::SetQueryManager(QueryManager *queryManager)
+{
+	mQueryManager = queryManager;
+}
+//-----------------------------------------------------------------------
+QueryManager *VisibilityManager::GetQueryManager()
+{
+	return mQueryManager;
+}
+//-----------------------------------------------------------------------
+void VisibilityManager::SetAssumedVisibilityForChc(unsigned int assumedVisibility) 
+									 
+{
+	mAssumedVisibilityForChc = assumedVisibility;
+
+	// in case we currently use chc
+	if (VisibilityManager::GetCullingManagerType() == 
+		VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING)
+	{
+		dynamic_cast<CoherentHierarchicalCullingManager *>(mCullingManager)->
+				SetAssumedVisibility(assumedVisibility);
+	}
+}
+
+
+} // namespace GtpVisibility
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/StopAndWaitCullingManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/StopAndWaitCullingManager.cpp	(revision 346)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/StopAndWaitCullingManager.cpp	(revision 346)
@@ -0,0 +1,61 @@
+#include "StopAndWaitCullingManager.h"
+#include <OgreLogManager.h>
+
+namespace GtpVisibility {
+
+//-----------------------------------------------------------------------
+void StopAndWaitCullingManager::RenderScene()
+{
+	//Ogre::LogManager::getSingleton().logMessage("Stop and Wait Culling");
+	while (!mHierarchyInterface->GetQueue()->empty())
+	{
+		HierarchyNode *node = mHierarchyInterface->GetQueue()->top();
+		mHierarchyInterface->GetQueue()->pop();
+			
+		// interesting for visualization purpose
+		mHierarchyInterface->SetNodeVisible(node, false);
+		mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId());
+
+		bool intersects = false;
+	
+		if (!mHierarchyInterface->CheckFrustumVisible(node, intersects))
+		{
+			++ mNumFrustumCulledNodes;
+		
+			if (mVisualizeCulledNodes)
+			{
+				mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED);
+			}
+		}
+		// if intersects near plane => skip occlusion query because wrong results possible
+		else if (intersects)
+		{
+			mHierarchyInterface->SetNodeVisible(node, true);
+			mHierarchyInterface->TraverseNode(node);
+		}
+		else
+		{
+			++ mNumQueriesIssued;
+
+			unsigned int visiblePixels = 0;
+
+			mHierarchyInterface->IssueNodeOcclusionQuery(node)->GetQueryResult(visiblePixels, true);
+			
+			// node visible
+			if (visiblePixels > mVisibilityThreshold)
+			{
+				mHierarchyInterface->TraverseNode(node);
+			}
+			else
+			{	
+				++ mNumQueryCulledNodes;
+
+				if (mVisualizeCulledNodes)
+				{
+					mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED);
+				}
+			}
+		}
+	}
+}
+} // namespace GtpVisibility
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CullingManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CullingManager.cpp	(revision 112)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CullingManager.cpp	(revision 112)
@@ -0,0 +1,48 @@
+#include "CullingManager.h"
+
+namespace GtpVisibility {
+
+//-----------------------------------------------------------------------
+CullingManager::CullingManager():
+mHierarchyInterface(NULL), mVisibilityThreshold(0), mNumQueryCulledNodes(0), 
+mNumFrustumCulledNodes(0), mNumQueriesIssued(0),
+mVisualizeCulledNodes(false)
+{
+}
+//-----------------------------------------------------------------------
+void CullingManager::SetHierarchyInterface(HierarchyInterface *hierarchyInterface)
+{
+	mHierarchyInterface = hierarchyInterface;
+}
+//-----------------------------------------------------------------------
+void CullingManager::SetVisibilityThreshold(unsigned int visibilityThreshold)
+{
+	mVisibilityThreshold = visibilityThreshold;
+}
+//-----------------------------------------------------------------------
+unsigned int CullingManager::GetNumFrustumCulledNodes()
+{
+	return mNumFrustumCulledNodes;
+}
+//-----------------------------------------------------------------------
+unsigned int CullingManager::GetNumQueryCulledNodes()
+{
+	return mNumQueryCulledNodes;
+}
+//-----------------------------------------------------------------------
+unsigned int CullingManager::GetNumQueriesIssued()
+{
+	return mNumQueriesIssued;
+}
+//-----------------------------------------------------------------------
+void CullingManager::SetVisualizeCulledNodes(bool visualizeCulledNodes)
+{
+	mVisualizeCulledNodes = visualizeCulledNodes;
+}
+//-----------------------------------------------------------------------
+void CullingManager::InitFrame(bool visualizeCulledNodes)
+{
+	mNumFrustumCulledNodes = mNumQueryCulledNodes = mNumQueriesIssued = 0;
+	mVisualizeCulledNodes = visualizeCulledNodes;
+}
+} // namespace GtpVisibility
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/DummyPreprocessingManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/DummyPreprocessingManager.cpp	(revision 316)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/DummyPreprocessingManager.cpp	(revision 316)
@@ -0,0 +1,50 @@
+#include "DummyPreprocessingManager.h"
+
+namespace GtpVisibility {
+
+DummyPreprocessingManager::DummyPreprocessingManager(HierarchyInterface *hierarchyInterface)
+  :PreprocessingManager(hierarchyInterface)
+{
+}
+  
+
+bool DummyPreprocessingManager::ExportScene(const string filename)
+{
+  ofstream s(filename.c_str());
+  s<<"#VRML 2.0 utf8"<<endl;
+  s<<"#Dummy module output"<<endl;
+  return true;
+}
+  
+
+bool DummyPreprocessingManager::LoadPreprocessedData(const string filename)
+{
+  // do nothing
+  return false;
+}
+
+  
+  /** 
+      Find viewcells intersecting a spherical neighborhood of a point.
+      Returns false if no viewcell was found.
+    */
+bool DummyPreprocessingManager::LocateViewCellIds(const Vector3 &center,
+												  const float radius,
+												  vector<int> *viewCellIds)
+{
+  return false;
+}
+  
+/** 
+    Uses the specified viewcell to find its PVS
+*/
+int DummyPreprocessingManager::AddViewCellPVS(const int cellID,
+					  NodeInfoContainer *visibleNodes,
+					  MeshInfoContainer *visibleMeshes )
+{
+  // return the root of the hierarchyInterface regardless of the cellId
+  //  visibleNodes->push_back(traverser->GetRoot());
+  return false;
+}
+
+}
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/DummyQueryManager.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/DummyQueryManager.cpp	(revision 316)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/DummyQueryManager.cpp	(revision 316)
@@ -0,0 +1,44 @@
+#include "DummyQueryManager.h"
+
+
+namespace GtpVisibility {
+
+  /** 
+	Uses explicit camera to execute the visibility query
+  */
+  void
+  DummyQueryManager::ComputeCameraVisibility(const Camera &camera,
+					     NodeInfoContainer *visibleNodes,
+					     MeshInfoContainer *visibleGeometry,
+						 PatchInfoContainer *visiblePatches,
+					     bool relativeVisibility)
+  {
+	  visibleNodes->Type.push_back(NodeInfo(mHierarchyInterface->GetHierarchyRoot(), 0, 0));
+    
+//      HierarchyInterface::MeshIterator *mi =
+//        hierarchyInterface->GetMeshIterator(hierarchyInterface->GetRoot());
+    
+//      for (; mi(); mi++)
+//        visibleGeometry.push_back(MeshInfo(*mi, 1.0f));
+  }
+  
+  /** 
+      Uses the specified point to execute the visibility query in all directions
+  */
+  void
+  DummyQueryManager::ComputeFromPointVisibility(const Vector3 &point,
+						NodeInfoContainer *visibleNodes,
+						MeshInfoContainer *visibleGeometry,
+						PatchInfoContainer *visiblePatches,
+						bool relativeVisibility)
+  {
+	  visibleNodes->Type.push_back(NodeInfo(mHierarchyInterface->GetHierarchyRoot(), 0, 0));
+    
+//      HierarchyInterface::MeshIterator *mi =
+//        hierarchyInterface->GetMeshIterator(hierarchyInterface->GetRoot());
+    
+//      for (; mi(); mi++)
+//        visibleGeometry.push_back(MeshInfo(*mi, 1.0f));
+  }
+  
+};
Index: GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityEnvironment.cpp
===================================================================
--- GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityEnvironment.cpp	(revision 100)
+++ GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityEnvironment.cpp	(revision 100)
@@ -0,0 +1,14 @@
+#include "VisibilityEnvironment.h"
+
+namespace GtpVisibility {
+
+//-----------------------------------------------------------------------
+VisibilityEnvironment::VisibilityEnvironment()
+{
+}
+//-----------------------------------------------------------------------
+void VisibilityEnvironment::LoadEnvironment()
+{
+}
+
+} // namespace GtpVisibility
