Index: trunk/VUT/Ogre/include/OgreVisibilityOptionsManager.h
===================================================================
--- trunk/VUT/Ogre/include/OgreVisibilityOptionsManager.h	(revision 114)
+++ trunk/VUT/Ogre/include/OgreVisibilityOptionsManager.h	(revision 130)
@@ -2,8 +2,10 @@
 #define _VisibilityOptionsManager_H__
 
+
+#include <OgreString.h>
+#include <OgreStringVector.h>
 #include "VisibilityManager.h"
 #include "HierarchyInterface.h"
-#include <OgreString.h>
-#include <OgreStringVector.h>
+
 
 namespace Ogre {
@@ -30,10 +32,10 @@
 		"Algorithm", "Threshold";			
 	*/
-	bool setOption( const String &, const void * );
+	bool setOption(const String &, const void *);
 	/** Gets the given option for the scene traverser.
 	    @remarks
 	    See setOption
 	*/
-	bool getOption( const String &, void * );
+	bool getOption(const String &, void *);
 	bool getOptionKeys( StringVector &refKeys );
 	
Index: trunk/VUT/Ogre/include/OgreSceneContentGenerator.h
===================================================================
--- trunk/VUT/Ogre/include/OgreSceneContentGenerator.h	(revision 107)
+++ trunk/VUT/Ogre/include/OgreSceneContentGenerator.h	(revision 130)
@@ -37,13 +37,18 @@
 	void SetScale(Vector3 scale);
 	
-	/** the number of created objects */
+	/** The number of created objects */
 	int GetObjectCount();
 
-	/** writes scene nodes to file */
+	/** Writes scene nodes to file */
 	bool WriteObjects(const std::string &filename);
 
-	/** loads scene nodes from file */
+	/** Loads scene nodes from file */
 	bool LoadObjects(const std::string &filename);
-
+	/** Generates a scene object with the specified parameters
+		@param position the position of the scene object
+		@param orientation the orientation of the scene object
+		@param objName the mesh name of the scene object
+		@returns the created scene object
+	*/
 	SceneNode *GenerateSceneObject(const Vector3 &position, 
 		const Quaternion &orientation, const String &objName);
Index: trunk/VUT/Ogre/include/OgreOctreeHierarchyInterface.h
===================================================================
--- trunk/VUT/Ogre/include/OgreOctreeHierarchyInterface.h	(revision 112)
+++ trunk/VUT/Ogre/include/OgreOctreeHierarchyInterface.h	(revision 130)
@@ -3,5 +3,6 @@
 
 #include <OgreOctree.h>
-#include "OgrePlatformHierarchyInterface.h"
+#include <OgreOctreeSceneManager.h>
+#include "OgreSceneNodeHierarchyInterface.h"
 
 namespace Ogre {
@@ -9,8 +10,8 @@
 	This class implements the hierarchy interface for the Ogre octree hierarchy.
 */
-class OctreeHierarchyInterface : public PlatformHierarchyInterface
+class OctreeHierarchyInterface : public SceneNodeHierarchyInterface
 {
 public:
-	OctreeHierarchyInterface(SceneManager *sm, RenderSystem *rsys);
+	OctreeHierarchyInterface(OctreeSceneManager *sm, RenderSystem *rsys);
 	
 	/** Sets the number of nodes in this octree 
@@ -46,4 +47,11 @@
 							 GtpVisibility::CullingType type);
 
+	/*bool FindVisibleObjects(GtpVisibility::HierarchyNode *node,	
+							InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 
+							bool includeChildren = false);*/
+	void GetGeometry(GtpVisibility::HierarchyNode *node,
+					 GtpVisibility::GeometryList *geometryList, 
+					 bool includeChildren);
+
 protected:
 	/** Returns pointer to the bounding box of the node.
@@ -57,4 +65,5 @@
 	*/
 	Real GetSquaredViewDepth(const Camera* cam, const AxisAlignedBox* box) const;
+	/** number of octree hierarchy nodes */
 	unsigned int mNumOctreeNodes;
 };
Index: trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h
===================================================================
--- trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h	(revision 122)
+++ trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h	(revision 130)
@@ -65,4 +65,6 @@
 	/** Creates material for depth pass, e.g., a pass that only fills the depth buffer */
 	void InitDepthPass();
+	
+	/** Prepares visualization of hierarchical culling. */
 	void ShowVisualization(Camera *cam);
 	OctreeHierarchyInterface *mHierarchyInterface;
Index: trunk/VUT/Ogre/include/OgreSceneNodeHierarchyInterface.h
===================================================================
--- trunk/VUT/Ogre/include/OgreSceneNodeHierarchyInterface.h	(revision 112)
+++ trunk/VUT/Ogre/include/OgreSceneNodeHierarchyInterface.h	(revision 130)
@@ -3,4 +3,7 @@
 
 #include "OgrePlatformHierarchyInterface.h"
+#include "VisibilityInfo.h"
+#include "QueryManager.h"
+
 
 namespace Ogre {
@@ -38,4 +41,12 @@
 	void VisualizeCulledNode(GtpVisibility::HierarchyNode *node, 
 							GtpVisibility::CullingType type);
+
+	/*bool FindVisibleObjects(GtpVisibility::HierarchyNode *node,	
+							InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 
+							bool includeChildren = false);*/
+	
+	void GetGeometry(GtpVisibility::HierarchyNode *node,	
+					 GtpVisibility::GeometryList *geometryList, 
+					 bool includeChildren);
 };
 
Index: trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h
===================================================================
--- trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h	(revision 121)
+++ trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h	(revision 130)
@@ -10,4 +10,5 @@
 #include "OgreSolidBoundingBox.h"
 #include "HierarchyInterface.h"
+#include "VisibilityInfo.h"
 #include "OgrePlatformOcclusionQuery.h"
 
@@ -51,5 +52,6 @@
 		@remark If null, the actual camera is used for both viewing and culling		
 	*/
-	void InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam = NULL, bool leaveTransparentsInQueue = false);
+	void InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam = NULL, 
+		bool leaveTransparentsInQueue = false);
 	/** Checks if the node is visible from the current view frustum.
 		@param node the current node
@@ -78,19 +80,61 @@
 		GtpVisibility::HierarchyNode *node, const bool wasVisible);
 
+	/** Issue a occlusion query for this mesh.
+		@param node the current mesh
+		@returns occlusion query for this node
+	*/
+	GtpVisibility::OcclusionQuery *IssueOcclusionQuery(GtpVisibility::Mesh *mesh);
+
 	/** If true, the interface finds and renders only objects which are marked as shadow casters.
 		@remark This is important for the shadow texture pass
 	*/
 	void SetOnlyShadowCasters(bool onlyShadowCasters);
-	/** see set */
+	/** see set 
+	*/
 	bool GetOnlyShadowCasters();
-	/** see set */
+	/** see set 
+	*/
 	bool GetUseOptimization();
+	/** see set
+	*/
+	SceneManager *GetSceneManager();
 
-	/** true if bounding box query is currently active. */
+	/** see set 
+	*/
+	RenderSystem *GetRenderSystem();
+	
+	/** true if bounding box query is currently active. 
+	*/
     bool IsBoundingBoxQuery();
 
+	/** Finds visible objects of hierarchy node using occlusion queries
+	@param node the current scene node
+	@param objs the visible objects
+	@param includeChildren if the children of current scene nodes should also be traversed
+	*/
+	/*virtual bool FindVisibleObjects(GtpVisibility::HierarchyNode *node,	
+									InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 
+									bool includeChildren = false) = 0;*/
 protected:
-	/** materials for visualizing frustum and query culled nodes */
+	/** Renders geometry 
+	*/
+	void RenderGeometry(GtpVisibility::Mesh *geom);
+
+	/** Materials for visualizing frustum and query culled nodes.
+	*/
 	void CreateNodeVizMaterials();
+
+	/** Deletes all occlusion queries.
+	*/
+	void DeleteQueries();
+	
+	/** Renders bounding box of specified node.
+		@param box the bounding box of the scene node to be rendered 
+	*/
+	void RenderBoundingBox(AxisAlignedBox *box);
+
+	/** Returns pointer to current renderable bounding box geometry.
+	*/
+	SolidBoundingBox *GetSolidBoundingBox();
 
 	/** A pass that prepares an occlusion query.
@@ -98,23 +142,10 @@
 		vertex and fragment program.
 	*/
-	void SetOcclusionPass();
+	//void SetOcclusionPass();
 
-	/** Deletes all occlusion queries.
-	*/
-	void DeleteQueries();
-	/** Renders bounding box of specified node.
-		@param box the bounding box of the scene node to be rendered 
-	*/
-	void RenderBoundingBox(AxisAlignedBox *box);
-
-	/** Returns pointer to current renderable bounding box geometry
-	*/
-	SolidBoundingBox *GetSolidBoundingBox();
-
-	/** Returns pointer to current renderable half bounding box geometry
-	*/
+	/** Returns pointer to current renderable half bounding box geometry.*/
 	//SolidHalfBoundingBox *GetSolidHalfBoundingBox();
 
-	/** Renderable of an aabb
+	/** Renderable of an aabb.
 	*/
 	SolidBoundingBox *mSolidBoundingBox;
Index: trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
===================================================================
--- trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h	(revision 129)
+++ trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h	(revision 130)
@@ -9,4 +9,5 @@
 
 #include "OgreOctreeHierarchyInterface.h"
+#include "OgrePlatformQueryManager.h"
 #include "VisibilityManager.h"
 
@@ -17,5 +18,5 @@
 	using occlusion queries for visibility culling.
 */
-class VisibilityTerrainSceneManager: public TerrainSceneManager
+class __declspec(dllexport) VisibilityTerrainSceneManager: public TerrainSceneManager
 {
 public:
@@ -74,4 +75,7 @@
 	Entity* createEntity(const String& entityName, const String& meshName);
 
+	/** Returns pointer to visibility manager */
+	GtpVisibility::VisibilityManager *GetVisibilityManager();
+
 protected:
 	
@@ -101,4 +105,6 @@
 
 	int mCurrentEntityId;
+
+	PlatformQueryManager *mQueryManager;
 };
 
Index: trunk/VUT/Ogre/include/OgreTerrainContentGenerator.h
===================================================================
--- trunk/VUT/Ogre/include/OgreTerrainContentGenerator.h	(revision 110)
+++ trunk/VUT/Ogre/include/OgreTerrainContentGenerator.h	(revision 130)
@@ -35,5 +35,5 @@
 	*/
 	SceneNode *GenerateSceneObject(const Vector3 &position, 
-		const Vector3 &rotation, const String &objName);
+		const Vector3 &rotation, const String &objName, const bool clampToTerrain = true);
 	
 	/** offset which is added to objects when put into the terrain */
