Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
quadtree.h
Go to the documentation of this file.
1 #ifndef QUADTREE_H_
2 #define QUADTREE_H_
3 #include "quadsquare.h"
4 #include "xml_support.h"
5 #include "matrix.h"
6 
7 class Texture;
8 struct TerraXML;
9 
15 class QuadTree
16 {
17  int minX;
18  int minZ;
19  unsigned int maxX;
20  unsigned int maxZ;
21  void SetXSizes( int mX, unsigned int maxX );
22  void SetZSizes( int mZ, unsigned int maxZ );
23  Vector Scales;
24  float detail;
25  IdentityTransform *nonlinear_transform;
26  quadcornerdata RootCornerData;
27  quadsquare *root;
28  quadsquare *neighbors[4];
29  std::vector< TerrainTexture >textures;
30  std::vector< unsigned int >unusedvertices;
31  GFXVertexList vertices;
32  unsigned int VertexAllocated;
33  unsigned int VertexCount;
34  void LoadData();
35  void LoadXML( const char *filename, const Vector &scales, const float radius );
36  TerraXML *xml;
37  void SetNeighbors( quadsquare *east, quadsquare *north, quadsquare *west, quadsquare *south );
38 protected:
40 public: QuadTree( const char *filename, const Vector &scales, const float Radius );
41  ~QuadTree();
42  void Render();
43  void SetNeighbors( QuadTree *east, QuadTree *north, QuadTree *west, QuadTree *south );
44  void Update( unsigned short numstages, unsigned short whichstage, updateparity *updateorder = identityparity );
46  float GetHeight( Vector Location,
47  Vector &normal,
48  const Matrix &transform,
49  float TotalTerrainSizeX = 0,
50  float TotalTerrainSizeZ = 0 ) const;
51  static void beginElement( void *userData, const XML_Char *name, const XML_Char **atts );
52  static void endElement( void *userData, const XML_Char *name );
53  void beginElement( const std::string &name, const XMLSupport::AttributeList &attributes );
54  void endElement( const std::string &name );
55  float getminX() const
56  {
57  return 0;
58  }
59  float getminZ() const
60  {
61  return 0;
62  }
63  float getmaxX() const
64  {
65  return minX+(float) maxX;
66  }
67  float getmaxZ() const
68  {
69  return minZ+(float) maxZ;
70  }
71  float getSizeX() const
72  {
73  return maxX;
74  }
75  float getSizeZ() const
76  {
77  return maxZ;
78  }
79  void StaticCullData( const float detail );
80  bool GetGroundPos( QVector &Location, Vector &norm, float TTSX = 0, float TTSZ = 0 ) const
81  {
82  return GetGroundPos( Location, norm, transformation, TTSX, TTSZ );
83  }
84  bool GetGroundPos( QVector &Location,
85  Vector &norm,
86  const Matrix &trans,
87  float TotalTerrainSizeX = 0,
88  float TotalTerrainSizeZ = 0 ) const;
89  Vector GetNormal( const Vector &position, const Vector &requestednorm ) const;
90 };
91 
92 #endif
93