FlightGear next
tileentry.hxx
Go to the documentation of this file.
1// tileentry.hxx -- routines to handle an individual scenery tile
2//
3// Written by Curtis Olson, started May 1998.
4//
5// Copyright (C) 1998 - 2001 Curtis L. Olson - http://www.flightgear.org/~curt
6//
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.
11//
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.
16//
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20//
21// $Id$
22
23
24#ifndef _TILEENTRY_HXX
25#define _TILEENTRY_HXX
26
27
28#ifndef __cplusplus
29# error This library requires C++
30#endif
31
32#include <Main/globals.hxx>
33#include <Main/fg_props.hxx>
34
35#include <simgear/compiler.h>
36
37#include <vector>
38#include <string>
39
40#include <simgear/bucket/newbucket.hxx>
41#include <simgear/misc/sg_path.hxx>
42#include <simgear/scene/util/OrthophotoManager.hxx>
43#include <simgear/scene/util/SGReaderWriterOptions.hxx>
44
45#include <osg/ref_ptr>
46#include <osgDB/ReaderWriter>
47#include <osg/Group>
48#include <osg/LOD>
49
53class TileEntry {
54
55public:
56 // this tile's official location in the world
57 SGBucket tile_bucket;
58 std::string tileFileName;
59
60protected:
61 // pointer to ssg range selector for this tile
62 osg::ref_ptr<osg::LOD> _node;
63
64private:
65 // Reference to DatabaseRequest object set and used by the
66 // osgDB::DatabasePager.
67 osg::ref_ptr<osg::Referenced> _databaseRequest;
68 // Overlay image/orthophoto for this tile
69 simgear::OrthophotoRef _orthophoto;
70
77 float _priority;
79 bool _current_view;
81 double _time_expired;
82
83 void _create_orthophoto();
84
85public:
86
87 // Constructor.
88 TileEntry( const SGBucket& b );
89 TileEntry( const TileEntry& t );
90
91 // Destructor
92 virtual ~TileEntry() = 0;
93
94 // Update the ssg transform node for this tile so it can be
95 // properly drawn relative to our (0,0,0) point
96 void prep_ssg_node(float vis);
97
102 inline bool is_loaded() const
103 {
104 return _node->getNumChildren() > 0;
105 }
106
110 inline const SGBucket& get_tile_bucket() const { return tile_bucket; }
111
115 void addToSceneGraph( osg::Group *terrain_branch);
116
122
126 osg::LOD *getNode() const { return _node.get(); }
127
128 inline double get_time_expired() const { return _time_expired; }
129 inline void update_time_expired( double time_expired ) { if (_time_expired<time_expired) _time_expired = time_expired; }
130
131 inline void set_priority(float priority) { _priority=priority; }
132 inline float get_priority() const { return _priority; }
133 inline void set_current_view(bool current_view) { _current_view = current_view; }
134 inline bool is_current_view() const { return _current_view; }
135
140 inline bool is_expired(double current_time) const { return (_current_view) ? false : (current_time > _time_expired); }
141
142 // Get the ref_ptr to the DatabaseRequest object, in order to pass
143 // this to the pager.
144 osg::ref_ptr<osg::Referenced>& getDatabaseRequest()
145 {
146 return _databaseRequest;
147 }
148
151 };
152
154};
155
156class STGTileEntry : public TileEntry {
157 public:
158 STGTileEntry ( const SGBucket& b );
161};
162
163class VPBTileEntry : public TileEntry {
164 public:
165 VPBTileEntry ( const SGBucket& b, osg::ref_ptr<simgear::SGReaderWriterOptions> options );
168};
169
170
171#endif // _TILEENTRY_HXX
bool options(int, char **)
Definition JSBSim.cpp:568
TileEntry::Extension getExtension()
STGTileEntry(const SGBucket &b)
std::string tileFileName
Definition tileentry.hxx:58
void prep_ssg_node(float vis)
Definition tileentry.cxx:91
void set_priority(float priority)
double get_time_expired() const
bool is_expired(double current_time) const
Return false if the tile entry is still needed, otherwise return true indicating that the tile is no ...
float get_priority() const
osg::ref_ptr< osg::Referenced > & getDatabaseRequest()
void addToSceneGraph(osg::Group *terrain_branch)
Add terrain mesh and ground lighting to scene graph.
virtual TileEntry::Extension getExtension()=0
bool is_current_view() const
const SGBucket & get_tile_bucket() const
Return the "bucket" for this tile.
void set_current_view(bool current_view)
bool is_loaded() const
Return true if the tile entry is loaded, otherwise return false indicating that the loading thread is...
void removeFromSceneGraph()
disconnect terrain mesh and ground lighting nodes from scene graph for this tile.
TileEntry(const SGBucket &b)
Definition tileentry.cxx:42
osg::LOD * getNode() const
return the scenegraph node for the terrain
void update_time_expired(double time_expired)
virtual ~TileEntry()=0
Definition tileentry.cxx:85
SGBucket tile_bucket
Definition tileentry.hxx:57
osg::ref_ptr< osg::LOD > _node
Definition tileentry.hxx:62
VPBTileEntry(const SGBucket &b, osg::ref_ptr< simgear::SGReaderWriterOptions > options)
TileEntry::Extension getExtension()