Index: trunk/VUT/GtpVisibilityPreprocessor/include/ExactPreprocessor.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/include/ExactPreprocessor.h	(revision 68)
+++ trunk/VUT/GtpVisibilityPreprocessor/include/ExactPreprocessor.h	(revision 68)
@@ -0,0 +1,17 @@
+#ifndef _ExactPreprocessor_H__
+#define _ExactPreprocessor_H__
+
+#include "Preprocessor.h"
+
+namespace GtpVisibilityPreprocessor {
+  /** Exact visibility preprocessing. The implementation is based on 6D BSP and
+      Plucker coordinates */
+  class ExactPreprocessor : public Preprocessor {
+  public:
+    virtual bool ComputeVisibility();
+  };
+  
+};
+
+
+#endif
Index: trunk/VUT/GtpVisibilityPreprocessor/include/Mesh.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/include/Mesh.h	(revision 68)
+++ trunk/VUT/GtpVisibilityPreprocessor/include/Mesh.h	(revision 68)
@@ -0,0 +1,49 @@
+#ifndef _Mesh_H__
+#define _Mesh_H__
+
+#include <vector>
+#include "Plane3.h"
+
+namespace GtpVisibilityPreprocessor {
+
+  /** Patch used as an element of the mesh */
+  class Patch {
+  public:
+    Patch():mVertices() {}
+  protected:
+    /// list of vertex pointers
+    vector<Vector3 *> mVertices;
+  };
+
+  /** Mesh containing polygonal patches */
+  class Mesh {
+  public:
+    /// default vertex container for Mesh
+    typedef std::vector<Vector3> VertexContainer;
+    /// default patch container for Mesh
+    typedef std::vector<Patch *> PatchContainer;
+
+    /// Default constructor
+    Mesh():mVertices(), mPatches() {}
+
+    /// Constructor with container preallocation
+    Mesh(const int vertices,
+	 const int patches):mVertices(),
+			    mPatches()
+    {
+      mVertices.reserve(vertices);
+      mPatches.reserve(patches);
+    }
+    
+  protected:
+    /** Vertices forming the mesh */
+    VertexContainer mVertices;
+    /** Patches forming the mesh */
+    PatchContainer mPatches;
+  };
+  
+};
+
+
+
+#endif
Index: trunk/VUT/GtpVisibilityPreprocessor/include/KdTree.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/include/KdTree.h	(revision 68)
+++ trunk/VUT/GtpVisibilityPreprocessor/include/KdTree.h	(revision 68)
@@ -0,0 +1,119 @@
+#ifndef _KdTree_H__
+#define _KdTree_H__
+
+#include "Containers.h"
+#include "AxisAlignedBox3.h"
+
+namespace GtpVisibilityPreprocessor {
+  
+  class KdNode;
+  /** KdTree for indexing scene entities - occluders/occludees/viewcells */
+  class KdTree {
+  public:
+
+    /** Insert occluder into the tree */
+    virtual void InsertOccluder(Mesh *occluder) {
+      //      mRoot->mOccluders.push_back(occluder);
+    }
+
+    /** Insert occludee into the tree */
+    virtual void InsertOccludee(Mesh *occludee) {
+      //      mRoot->mOccludees.push_back(occludee);
+    }
+    
+    /** Insert view cell into the tree */
+    virtual void InsertViewCell(ViewCell *viewCell) {
+      //      mRoot->mViewcells.push_back(viewCell);
+    }
+    
+    /** Check whether subdivision criteria are met for the given subtree.
+	If not subdivide the leafs of the subtree. The criteria are specified in
+	the environment as well as the subdivision method. By default surface area
+	heuristics is used.
+	
+	@param subtree root of the subtree
+
+	@return true if subdivision was performed, false if subdivision criteria
+	were already met
+    */
+    virtual bool Subdivide(KdNode *subtree);
+
+    /** Get the root of the tree */
+    KdNode *GetRoot() const {
+      return mRoot;
+    }
+
+  protected:
+    /// root of the tree
+    KdNode *mRoot;
+    /// bounding box of the tree root
+    AxisAlignedBox3 mBox;
+  };
+  
+  
+  class KdInterior;
+  /** Abstract class for kd-tree node */
+  class KdNode {
+
+    /** Determines whether this node is a leaf or interior node
+	@return true if leaf
+    */
+    virtual bool IsLeaf() const = 0;
+
+    /** Determines whether this node is the root of the tree
+	@return true if root
+    */
+    virtual bool IsRoot() const {
+      return mParent == NULL;
+    }
+
+  protected:
+    /** Parent of the node - the parent is a little overhead for maintanance of the tree,
+	but allows various optimizations of tree traversal algorithms */
+    KdInterior *mParent;
+  };
+
+  /** Implementation of the kd-tree interior node */
+  class KdInterior : public KdNode {
+
+  public:
+    /** \sa KdNode::IsLeaf() */
+    virtual bool IsLeaf() const { return false; }
+
+  protected:
+    /** splitting axis */
+    int axis;
+    /** splitting position, absolute position within the bounding box of this node */
+    float mPosition;
+
+    /** back node */
+    KdNode *mBack;
+    /** front node */
+    KdNode *mFront;
+
+  };
+  
+  
+  /** Implementation of the kd-tree leaf node */
+  class KdLeaf : public KdNode {
+  public:
+    /** \sa KdNode::IsLeaf() */
+    virtual bool IsLeaf() const { return true; }
+
+  protected:
+    /** pointers to occluders contained in this node */
+    MeshContainer mOccluders;
+    /** pointers to occludees contained in this node */
+    MeshContainer mOccludees;
+    /** pointers to viewcells contained in this node */
+    ViewCellContainer mViewCells;
+  };
+  
+  
+  
+};
+
+
+
+
+#endif
Index: trunk/VUT/GtpVisibilityPreprocessor/include/SceneGraph.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/include/SceneGraph.h	(revision 68)
+++ trunk/VUT/GtpVisibilityPreprocessor/include/SceneGraph.h	(revision 68)
@@ -0,0 +1,33 @@
+#ifndef _SceneGraph_H__
+#define _SceneGraph_H__
+
+#include "Containers.h"
+#include "AxisAlignedBox3.h"
+
+namespace GtpVisibilityPreprocessor {
+  
+  /** Basic scene graph node, we are interested only in bounding boxes and topology
+      of the scene graph */
+  class SceneGraphNode {
+  public:
+    
+    
+  protected:
+    MeshContainer mGeometry;
+    NodeContainer mChildren;
+    AxisAlignedBox3 mBox;
+  };
+  
+
+  /** Scene graph class */
+  class SceneGraph {
+    
+  protected:
+    SceneGraphNode *mRoot;
+  };
+  
+
+};
+
+
+#endif
Index: trunk/VUT/GtpVisibilityPreprocessor/include/ViewCellBSP.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/include/ViewCellBSP.h	(revision 68)
+++ trunk/VUT/GtpVisibilityPreprocessor/include/ViewCellBSP.h	(revision 68)
@@ -0,0 +1,81 @@
+#ifndef _ViewCellBsp_H__
+#define _ViewCellBsp_H__
+
+namespace GtpVisibilityPreprocessor {
+  
+  
+  class BSPInterior;
+
+  /**
+     BSPNode abstract class serving for interior and leaf node implementation
+  */
+  class BSPNode {
+  public:
+    /** Determines whether this node is a leaf or not
+	@return true if leaf
+    */
+    virtual bool IsLeaf() const = 0;
+    
+    /** Determines whether this node is a root
+	@return true if root
+    */
+    virtual bool IsRoot() const {
+      return parent == NULL;
+    }
+  protected:
+    /// parent of this node
+    BSPInterior *parent;
+  };
+
+  /** BSP interior node implementation */
+  class BSPInterior : public BSPNode {
+    
+    /** @return false since it is an interior node */
+    virtual bool IsLeaf() const { return false; }
+
+  protected:
+    /// Splitting plane corresponding to this node
+    Plane3 mPlane;
+    /// back node
+    BSPNode *mBack;
+    /// front node
+    BSPNode *mFront;
+  };
+  
+  
+  /** BSP leaf node implementation */
+  class BSPLeaf : public BSPNode {
+  public:
+    BSPLeaf(ViewCell *viewCell = NULL):mViewCell(viewCell) {}
+    /** @return true since it is an interior node */
+    virtual bool IsLeaf() const { return true; }
+
+  protected:
+    /// polygonal representation of this viewcell
+    /// if NULL this note does not correspond to feasible viewcell
+    ViewCell *mViewCell;
+  };
+  
+  /** Implementation of the ViewCell BSP tree */
+  class BSPTree {
+  public:
+    /** Constructor takes a pointer to the cell corresponding to the whole
+	viewspace */
+    BSPTree(ViewCell *cell) {
+      mRootCell = cell;
+      mRoot = new BSPLeaf(mRootCell);
+    }
+    
+    
+  protected:
+    /// Pointer to the root of the tree
+    BSPNode *mRoot;
+    /// Pointer to the root cell of the viewspace */
+    ViewCell *mRootCell;
+  };
+  
+};
+
+
+
+#endif
Index: trunk/VUT/GtpVisibilityPreprocessor/include/SamplingPreprocessor.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/include/SamplingPreprocessor.h	(revision 68)
+++ trunk/VUT/GtpVisibilityPreprocessor/include/SamplingPreprocessor.h	(revision 68)
@@ -0,0 +1,18 @@
+#ifndef _SamplingPreprocessor_H__
+#define _SamplingPreprocessor_H__
+
+#include "Preprocessor.h"
+
+namespace GtpVisibilityPreprocessor {
+
+  /** Sampling based visibility preprocessing. The implementation is based on heuristical
+      sampling of view space */
+  class SamplingPreprocessor : public Preprocessor {
+  public:
+    virtual bool ComputeVisibility();
+  };
+  
+};
+
+
+#endif
Index: trunk/VUT/GtpVisibilityPreprocessor/include/Plane3.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/include/Plane3.h	(revision 68)
+++ trunk/VUT/GtpVisibilityPreprocessor/include/Plane3.h	(revision 68)
@@ -0,0 +1,20 @@
+#ifndef _Plane3_H__
+#define _Plane3_H__
+
+#include "vector3.h"
+
+namespace GtpVisibilityPreprocessor {
+  
+  /** 3D Plane */
+  class Plane3 {
+  public:
+    Vector3 mNormal;
+    float mD;
+  };
+  
+  
+};
+
+
+
+#endif
Index: trunk/VUT/GtpVisibilityPreprocessor/include/AxisAlignedBox3.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/include/AxisAlignedBox3.h	(revision 68)
+++ trunk/VUT/GtpVisibilityPreprocessor/include/AxisAlignedBox3.h	(revision 68)
@@ -0,0 +1,19 @@
+#ifndef _AxisAlignedBox3_H__
+#define _AxisAlignedBox3_H__
+
+#include "vector3.h"
+
+
+namespace GtpVisibilityPreprocessor {
+  
+  /** Axis aligned box */
+  class AxisAlignedBox3 {
+  protected:
+    Vector3 min, max;
+  };
+  
+
+};
+
+
+#endif
Index: trunk/VUT/GtpVisibilityPreprocessor/include/Containers.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/include/Containers.h	(revision 68)
+++ trunk/VUT/GtpVisibilityPreprocessor/include/Containers.h	(revision 68)
@@ -0,0 +1,24 @@
+#ifndef _Container_H__
+#define _Container_H__
+
+#include <vector>
+using namespace std;
+
+namespace GtpVisibilityPreprocessor {
+  class Mesh;
+  class ViewCell;
+  class HierarchyNode;
+  /** Container for Mesh pointers primarily for the use within the kDTree and
+      BSP hierarchies */
+  typedef vector<Mesh *> MeshContainer;
+  /** Container for ViewCell pointers primarily for the use within the kDTree and
+      BSP hierarchies */
+  typedef vector<ViewCell *> ViewCellContainer;
+  /** Container for HierarchyNodes pointers primarily for the use within the kDTree and
+      BSP hierarchies */
+  typedef vector<HierarchyNode *> NodeContainer;
+};
+
+
+#endif // _Container_H__
+
Index: trunk/VUT/GtpVisibilityPreprocessor/include/Vector3.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/include/Vector3.h	(revision 68)
+++ trunk/VUT/GtpVisibilityPreprocessor/include/Vector3.h	(revision 68)
@@ -0,0 +1,17 @@
+#ifndef _Vector3_H__
+#define _Vector3_H__
+
+
+namespace GtpVisibilityPreprocessor {
+  /** 3D vector */
+  class Vector3 {
+  public:
+    float x, y, z;
+  };
+  
+  
+};
+
+
+
+#endif
Index: trunk/VUT/GtpVisibilityPreprocessor/include/Preprocessor.h
===================================================================
--- trunk/VUT/GtpVisibilityPreprocessor/include/Preprocessor.h	(revision 68)
+++ trunk/VUT/GtpVisibilityPreprocessor/include/Preprocessor.h	(revision 68)
@@ -0,0 +1,87 @@
+#ifndef _Preprocessor_H__
+#define _Preprocessor_H__
+
+#include "Containers.h"
+#include "Mesh.h"
+#include "KdTree.h"
+#include "ViewCellBsp.h"
+#include "SceneGraph.h"
+
+/** Namespace for the external visibility preprocessor
+
+    This namespace includes all classes which are created by the VUT (Vienna University
+    of Technology) for the External Visibility Preprocessor of the GTP (GameTools Project)
+    (www.gametools.org).
+ */
+namespace GtpVisibilityPreprocessor {
+  /** Main class of the visibility preprocessor. Responsible for loading and
+      saving of the input and output files. Initiates construction of the kD-tree,
+      viewcell loading/generation and the visibility computation itself.
+  */
+  class Preprocessor {
+  public:
+    /** Load the input scene. 
+	@param filename file to load
+	@return true on success
+    */
+    virtual bool LoadScene(const string filename);
+
+    /** Load the input viewcells. The input viewcells should be given as a collection
+	of meshes. Each mesh is assume to form a bounded polyhedron defining the interior of
+	the viewcell. The method then builds a BSP tree of these view cells.
+	@param filename file to load
+	@return true on success
+    */
+    virtual bool LoadViewcells(const string filename);
+
+    /** Generate the viewCells automatically. The particular algorithm to be used depends
+	on the environment setting. Initially the generated viewcells will cover the whole
+	bounding volume of the scene. They can be pruned later depending on the results
+	of visibility computations.
+	@return true on successful viewcell generation.
+    */
+    virtual bool GenerateViewcells();
+    
+    /** Export all preprocessed data in a XML format understandable by the
+	PreprocessingInterface of the GtpVisibilityPreprocessor Module. The file can be compressed depending
+	on the environement settings.
+	@return true on successful export
+    */
+    virtual bool ExportPreprocessedData(const string filename);
+
+    /** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction
+	is driven by the environment settings, which also sais which of the three types of
+	entities should be used to drive the heuristical construction (only occluders by default)
+    */
+    virtual bool BuildKdTree();
+
+    /** Compute visibility method. This method has to be reimplemented by the actual
+	Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor,
+	GlobalSamplingpreprocessor)
+    */
+    virtual bool ComputeVisibility() = 0;
+
+
+  protected:
+    /// scene graph loaded from file
+    SceneGraph *mSceneGraph;
+    /// BSP tree representing the viewcells
+    BSPTree *mViewCellBSPTree;
+    /// kD-tree organizing the scene graph (occluders + occludees) + viewcells
+    KdTree *mKdTree;
+
+    /// list of all loaded occluders
+    MeshContainer mOccluders;
+    /// list of all loaded occludees
+    MeshContainer mOccludees;
+    /// list of all loaded/generated viewcells
+    ViewCellContainer mViewcells;
+
+  };
+  
+};
+
+
+
+
+#endif
