2008-03-27 04:06:54 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2008-03-27 19:55:03 +08:00
|
|
|
#ifndef OSGTerrain
|
|
|
|
#define OSGTerrain 1
|
2008-03-27 04:06:54 +08:00
|
|
|
|
|
|
|
#include <osg/Group>
|
|
|
|
#include <osg/CoordinateSystemNode>
|
|
|
|
|
2008-03-27 18:55:39 +08:00
|
|
|
#include <osgTerrain/TerrainTile>
|
2008-03-27 04:06:54 +08:00
|
|
|
|
|
|
|
namespace osgTerrain {
|
|
|
|
|
2008-03-27 19:55:03 +08:00
|
|
|
/** Terrain provides a framework for loosely coupling height field data with height rendering algorithms.
|
2008-03-27 04:06:54 +08:00
|
|
|
* This allows TerrainTechnique's to be plugged in at runtime.*/
|
2008-03-27 19:55:03 +08:00
|
|
|
class OSGTERRAIN_EXPORT Terrain : public osg::Group
|
2008-03-27 04:06:54 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2008-03-27 19:55:03 +08:00
|
|
|
Terrain();
|
2008-03-27 04:06:54 +08:00
|
|
|
|
|
|
|
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
2008-03-27 19:55:03 +08:00
|
|
|
Terrain(const Terrain&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
2008-03-27 04:06:54 +08:00
|
|
|
|
2008-03-27 19:55:03 +08:00
|
|
|
META_Node(osgTerrain, Terrain);
|
2008-03-27 04:06:54 +08:00
|
|
|
|
|
|
|
virtual void traverse(osg::NodeVisitor& nv);
|
|
|
|
|
2008-04-22 19:39:47 +08:00
|
|
|
/** Set the sample ratio hint that TerrainTile should use when building geometry.
|
|
|
|
* Defaults to 1.0, which means use all original sample points.*/
|
|
|
|
void setSampleRatio(float ratio) { _sampleRatio = ratio; }
|
|
|
|
|
|
|
|
/** Get the sample ratio hint.*/
|
|
|
|
float getSampleRatio() const { return _sampleRatio; }
|
|
|
|
|
|
|
|
|
2008-03-27 21:21:36 +08:00
|
|
|
/** Get the TerrainTile for a given TileID.*/
|
|
|
|
TerrainTile* getTile(const TileID& tileID);
|
|
|
|
|
|
|
|
/** Get the const TerrainTile for a given TileID.*/
|
|
|
|
const TerrainTile* getTile(const TileID& tileID) const;
|
|
|
|
|
2008-03-27 04:06:54 +08:00
|
|
|
protected:
|
|
|
|
|
2008-03-27 19:55:03 +08:00
|
|
|
virtual ~Terrain();
|
2008-03-27 21:21:36 +08:00
|
|
|
|
|
|
|
friend class TerrainTile;
|
|
|
|
|
|
|
|
void registerTerrainTile(TerrainTile* tile);
|
|
|
|
void unregisterTerrainTile(TerrainTile* tile);
|
|
|
|
|
|
|
|
typedef std::map< TileID, TerrainTile* > TerrainTileMap;
|
|
|
|
typedef std::set< TerrainTile* > TerrainTileSet;
|
2008-03-27 04:06:54 +08:00
|
|
|
|
2008-04-22 19:39:47 +08:00
|
|
|
float _sampleRatio;
|
|
|
|
|
2008-03-28 23:31:46 +08:00
|
|
|
mutable OpenThreads::Mutex _mutex;
|
|
|
|
TerrainTileSet _terrainTileSet;
|
|
|
|
TerrainTileMap _terrainTileMap;
|
2008-03-27 21:21:36 +08:00
|
|
|
|
2008-03-27 04:06:54 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|