CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

csgeom/polytree.h

00001 /*
00002     Copyright (C) 2003 by Jorrit Tyberghein
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_POLYTREE_H__
00020 #define __CS_POLYTREE_H__
00021 
00022 #include "csextern.h"
00023 
00024 #include "csgeom/box.h"
00025 #include "csgeom/vector3.h"
00026 #include "csutil/array.h"
00027 
00028 #define CS_POLYTREE_AXISINVALID -1
00029 #define CS_POLYTREE_AXISX 0
00030 #define CS_POLYTREE_AXISY 1
00031 #define CS_POLYTREE_AXISZ 2
00032 
00033 struct iPolygonMesh;
00034 struct csMeshedPolygon;
00035 
00039 class CS_CSGEOM_EXPORT csPolygonTree
00040 {
00041 private:
00042   csBox3 bbox;                  // Bounding box of all polygons in this node.
00043   csArray<int> polygons;        // Indices of polygons in this node.
00044 
00045   csPolygonTree* child1;        // If child1 is not 0 then child2 will
00046   csPolygonTree* child2;        // also be not 0.
00047 
00048   int split_axis;               // One of CS_POLYTREE_AXIS?
00049   float split_location;         // Where is the split?
00050 
00051   void MakeLeaf (csArray<int>& polyidx);
00052   void CalculateBBox (csArray<int>& polyidx, iPolygonMesh* mesh);
00053   void Build (csArray<int>& polyidx, iPolygonMesh* mesh);
00054 
00055 public:
00057   csPolygonTree ();
00059   ~csPolygonTree ();
00060 
00062   void Clear ();
00063 
00065   void Build (iPolygonMesh* mesh);
00066 
00068   const csBox3& GetBoundingBox () const { return bbox; }
00069 
00071   const csArray<int>& GetPolygons () const { return polygons; }
00072 
00074   void IntersectBox (csArray<int>& polyidx, const csBox3& box);
00075 
00077   void IntersectSphere (csArray<int>& polyidx, const csVector3& center,
00078         float sqradius);
00079 
00081   void RemoveDoubles (csArray<int>& polyidx);
00082 };
00083 
00084 #endif // __CS_POLYTREE_H__
00085 

Generated for Crystal Space by doxygen 1.2.18