1 // tileentry.hxx -- routines to handle an individual scenery tile
3 // Written by Curtis Olson, started May 1998.
5 // Copyright (C) 1998, 1999 Curtis L. Olson - curt@flightgear.org
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #ifndef _TILEENTRY_HXX
25 #define _TILEENTRY_HXX
29 # error This library requires C++
41 #include <simgear/xgl/xgl.h>
43 #include <simgear/compiler.h>
48 #include <plib/ssg.h> // plib includes
50 #include <simgear/bucket/newbucket.hxx>
51 #include <simgear/math/point3d.hxx>
61 typedef vector < Point3D > point_list;
62 typedef point_list::iterator point_list_iterator;
63 typedef point_list::const_iterator const_point_list_iterator;
74 Scheduled_for_use = 1,
75 Scheduled_for_cache = 2,
82 typedef vector < sgVec3 * > free_vec3_list;
83 typedef vector < sgVec2 * > free_vec2_list;
84 typedef vector < unsigned short * > free_index_list;
92 // global tile culling data
94 double bounding_radius;
97 // this tile's official location in the world
100 // the tile cache will keep track here if the tile is being used
103 // list of pointers to memory chunks that need to be freed when
104 // tile entry goes away
105 free_vec3_list vec3_ptrs;
106 free_vec2_list vec2_ptrs;
107 free_index_list index_ptrs;
109 // ssg tree structure for this tile is as follows:
111 // - ssgBranch(terrain)
112 // - ssgSelector(tile)
113 // - ssgTransform(tile)
114 // - ssgRangeSelector(tile)
121 // selector (turn tile on/off)
122 ssgSelector *select_ptr;
124 // pointer to ssg transform for this tile
125 ssgTransform *transform_ptr;
127 // pointer to ssg range selector for this tile
128 ssgRangeSelector *range_ptr;
133 FGTileEntry ( void );
136 ~FGTileEntry ( void );
138 // Clean up the memory used by this tile and delete the arrays
139 // used by ssg as well as the whole ssg branch
142 // Calculate this tile's offset
143 void SetOffset( const Point3D& p)
148 // Return this tile's offset
149 inline Point3D get_offset( void ) const { return offset; }
151 inline bool is_unused() const { return state == Unused; }
152 inline bool is_scheduled_for_use() const {
153 return state == Scheduled_for_use;
155 inline bool is_scheduled_for_cache() const {
156 return state == Scheduled_for_cache;
158 inline bool is_loaded() const { return state == Loaded; }
159 inline bool is_cached() const { return state == Cached; }
161 inline void mark_unused() { state = Unused; }
162 inline void mark_scheduled_for_use() { state = Scheduled_for_use; }
163 inline void mark_scheduled_for_cache() { state = Scheduled_for_use; }
164 inline void mark_loaded() { state = Loaded; }
167 // when a tile is still in the cache, but not in the immediate
168 // draw l ist, it can still remain in the scene graph, but we use
169 // a range selector to disable it from ever being drawn.
174 typedef vector < FGTileEntry > tile_list;
175 typedef tile_list::iterator tile_list_iterator;
176 typedef tile_list::const_iterator const_tile_list_iterator;
179 #endif // _TILEENTRY_HXX