FlightGear next
terrain_pgt.hxx
Go to the documentation of this file.
1// terrain_pgt.hxx -- data structures and routines for managing scenery.
2//
3// Written by Curtis Olson, started May 1997.
4//
5// Copyright (C) 1997 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 _TERRAIN_PGT_HXX
25#define _TERRAIN_PGT_HXX
26
27
28#ifndef __cplusplus
29# error This library requires C++
30#endif
31
32#include <osg/ref_ptr>
33#include <osg/Switch>
34
35#include <simgear/compiler.h>
36#include <simgear/props/props.hxx>
37#include <simgear/math/SGMath.hxx>
38#include <simgear/scene/model/particles.hxx>
39#include <simgear/structure/subsystem_mgr.hxx>
40#include <simgear/scene/dem/SGDem.hxx>
41
42#include "terrain.hxx"
43//#include "SceneryPager.hxx"
44//#include "tilemgr.hxx"
45
46namespace simgear {
47class BVHMaterial;
48}
49
50// Define a structure containing global scenery parameters
51class FGPgtTerrain : public FGTerrain
52{
53public:
54
57
58 // Implementation of SGSubsystem.
59 void init ( osg::Group* terrain );
60 void reinit();
61 void shutdown ();
62 void bind ();
63 void unbind ();
64 void update (double dt);
65
76 bool get_elevation_m(const SGGeod& geod, double& alt,
77 const simgear::BVHMaterial** material,
78 const osg::Node* butNotFrom = 0);
79
91 bool get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
92 double& elevation,
93 const simgear::BVHMaterial** material,
94 const osg::Node* butNotFrom = 0);
95
101 bool get_cart_ground_intersection(const SGVec3d& start, const SGVec3d& dir,
102 SGVec3d& nearestHit,
103 const osg::Node* butNotFrom = 0);
104
108 bool scenery_available(const SGGeod& position, double range_m);
109
110 // tile mgr api
111 bool schedule_scenery(const SGGeod& position, double range_m, double duration=0.0);
113
114 static const char* staticSubsystemClassId() { return "scenery"; }
115
116private:
117 // terrain branch of scene graph
118 osg::ref_ptr<osg::Group> terrain_branch;
119
120 SGPropertyNode_ptr _scenery_loaded, _scenery_override;
121
122 bool _inited;
123
124 SGDemPtr _dem;
125};
126
127#endif // _TERRAIN_PGT_HXX
bool scenery_available(const SGGeod &position, double range_m)
Returns true if scenery is available for the given lat, lon position within a range of range_m.
void shutdown()
static const char * staticSubsystemClassId()
bool get_cart_ground_intersection(const SGVec3d &start, const SGVec3d &dir, SGVec3d &nearestHit, const osg::Node *butNotFrom=0)
Compute the nearest intersection point of the line starting from start going in direction dir with th...
void init(osg::Group *terrain)
void update(double dt)
bool schedule_scenery(const SGGeod &position, double range_m, double duration=0.0)
bool get_elevation_m(const SGGeod &geod, double &alt, const simgear::BVHMaterial **material, const osg::Node *butNotFrom=0)
Compute the elevation of the scenery at geodetic latitude lat, geodetic longitude lon and not higher ...
bool get_cart_elevation_m(const SGVec3d &pos, double max_altoff, double &elevation, const simgear::BVHMaterial **material, const osg::Node *butNotFrom=0)
Compute the elevation of the scenery below the cartesian point pos.
void materialLibChanged()
FGTerrain()=default