Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/terrain/src/lib/graphics/importer/terrain/terrain_quad.h @ 8697

Last change on this file since 8697 was 8697, checked in by patrick, 18 years ago

merged the terrain with the new trunk (MARK TERRAIN)

File size: 2.4 KB
Line 
1/*
2        orxonox - the future of 3D-vertical-scrollers
3 
4        Copyright (C) 2006 orx
5 
6        This program is free software; you can redistribute it and/or modify
7        it under the terms of the GNU General Public License as published by
8        the Free Software Foundation; either version 2, or (at your option)
9        any later version.
10 
11        ### File Specific:
12        main programmer: Marco Biasini
13 
14 */
15#ifndef _TERRAIN_QUAD_TREE_H
16#define _TERRAIN_QUAD_TREE_H
17
18#include "types.h"
19#include "frustum.h"
20#include <stdio.h>
21class Terrain;
22class TerrainQuad;
23typedef TerrainQuad *pTerrainQuad;
24
25typedef enum { TL_CHILD = 0, TR_CHILD = 1, BL_CHILD = 2, BR_CHILD = 3 } TerrainQuadChild;
26       
27class TerrainQuad {
28        public:
29                TerrainQuad( Terrain *_owner, int _xOffset, int _zOffset );
30                TerrainQuad( Terrain *_owner, int _x0, int _z0, int _x1, int _z1 );
31               
32                virtual ~TerrainQuad( ) 
33                {
34                        for ( int i = 0; i < 4; ++i )
35                                if ( children[i] != NULL )
36                                        delete children[i];                                     
37                }
38                int cull( );
39               
40                /**
41                 * Returns the array containing the children quad-nodes of this node in the following
42                 * order: top-left, top-right, bottom-left, bottom-right
43                 */
44                inline pTerrainQuad* getChildren( ) 
45                { 
46                        return children; 
47                }
48               
49                /**
50                 * Sets the child-nodes to the specified _children elements.
51                 */
52                void setChildren( pTerrainQuad _children[] )
53                {
54                        for ( int i = 0; i < 4; ++i )
55                                children[i] = _children[i];
56                }
57               
58                inline bool isChildless() { return ( children[0] == NULL ); }
59               
60                /**
61                 * Returns the child node given by _child. The returned node may be null.
62                 */
63                inline pTerrainQuad getChild( TerrainQuadChild _child ) 
64                { 
65                        return children[_child]; 
66                }
67                inline void setScale( Triple _scale )
68                {
69                        scale = _scale;
70                }
71                inline const ABox getBounds() { return bounds; }
72                inline void setChildren( pTerrainQuad _bl, pTerrainQuad _br, pTerrainQuad _tl,
73                        pTerrainQuad _tr )
74                {
75                        children[TL_CHILD] = _tl;
76                        children[TR_CHILD] = _tr;
77                        children[BR_CHILD] = _br;
78                        children[BL_CHILD] = _bl;
79                }
80                /**
81                 * Calculates the mininum and maximum value of this box based on the size
82                 * and position of its children.
83                 */
84                virtual void calculateBounds( );
85                inline int getXOffset() { return xOffset; }
86                inline int getZOffset() { return zOffset; }
87                inline int getWidth() { return width; }
88                inline int getHeight() { return height; }
89               
90        protected:
91                TerrainQuad( ) {}
92                Terrain                 *owner;
93                int                             xOffset, zOffset;
94                int                             width,  height;
95                Triple                  scale;
96                pTerrainQuad    children[4];
97                ABox                    bounds;
98};
99
100#endif
Note: See TracBrowser for help on using the repository browser.