Introduce TerrainSystem node which decorates a complete terrain model made up of Terrain tiles.
This commit is contained in:
@@ -732,6 +732,22 @@ void DatabasePager::run()
|
||||
_changeAutoUnRef, _valueAutoUnRef,
|
||||
_changeAnisotropy, _valueAnisotropy,
|
||||
_drawablePolicy, this);
|
||||
|
||||
// push the soon to be parent on the nodepath of the NodeVisitor so that
|
||||
// during traversal one can test for where it'll be in the overall scene graph
|
||||
osg::NodePathList nodePathList = databaseRequest->_groupForAddingLoadedSubgraph->getParentalNodePaths();
|
||||
if (!nodePathList.empty())
|
||||
{
|
||||
osg::NodePath& nodePath = nodePathList.front();
|
||||
for(osg::NodePath::iterator nitr = nodePath.begin();
|
||||
nitr != nodePath.end();
|
||||
++nitr)
|
||||
{
|
||||
frov.pushOntoNodePath(*nitr);
|
||||
}
|
||||
}
|
||||
|
||||
frov.pushOntoNodePath(databaseRequest->_groupForAddingLoadedSubgraph.get());
|
||||
|
||||
databaseRequest->_loadedModel->accept(frov);
|
||||
|
||||
|
||||
@@ -34,8 +34,9 @@
|
||||
#define VERSION_0023 23
|
||||
#define VERSION_0024 24
|
||||
#define VERSION_0025 25
|
||||
#define VERSION_0026 26
|
||||
|
||||
#define VERSION VERSION_0025
|
||||
#define VERSION VERSION_0026
|
||||
|
||||
/* The BYTE_SEX tag is used to check the endian
|
||||
of the IVE file being read in. The IVE format
|
||||
|
||||
@@ -31,6 +31,13 @@ void Terrain::write(DataOutputStream* out)
|
||||
else
|
||||
throw Exception("Terrain::write(): Could not cast this osgTerrain::Terrain to an osg::Group.");
|
||||
|
||||
if (out->getVersion() >= VERSION_0026)
|
||||
{
|
||||
out->writeInt(getTileID().layer);
|
||||
out->writeInt(getTileID().x);
|
||||
out->writeInt(getTileID().y);
|
||||
}
|
||||
|
||||
if (out->getVersion() >= VERSION_0023)
|
||||
{
|
||||
out->writeLocator(getLocator());
|
||||
@@ -77,6 +84,14 @@ void Terrain::read(DataInputStream* in)
|
||||
else
|
||||
throw Exception("Terrain::read(): Could not cast this osgTerrain::Terrain to an osg::Group.");
|
||||
|
||||
if (in->getVersion() >= VERSION_0026)
|
||||
{
|
||||
int layer = in->readInt();
|
||||
int x = in->readInt();
|
||||
int y = in->readInt();
|
||||
setTileID(osgTerrain::TileID(layer,x,y));
|
||||
}
|
||||
|
||||
if (in->getVersion() >= VERSION_0023)
|
||||
{
|
||||
setLocator(in->readLocator());
|
||||
|
||||
@@ -12,6 +12,7 @@ SET(LIB_PUBLIC_HEADERS
|
||||
${HEADER_PATH}/Layer
|
||||
${HEADER_PATH}/Terrain
|
||||
${HEADER_PATH}/TerrainTechnique
|
||||
${HEADER_PATH}/TerrainSystem
|
||||
${HEADER_PATH}/TileSystem
|
||||
${HEADER_PATH}/GeometryTechnique
|
||||
${HEADER_PATH}/ValidDataOperator
|
||||
@@ -26,6 +27,7 @@ ADD_LIBRARY(${LIB_NAME}
|
||||
Locator.cpp
|
||||
Terrain.cpp
|
||||
TerrainTechnique.cpp
|
||||
TerrainSystem.cpp
|
||||
TileSystem.cpp
|
||||
GeometryTechnique.cpp
|
||||
Version.cpp
|
||||
|
||||
@@ -12,12 +12,16 @@
|
||||
*/
|
||||
|
||||
#include <osgTerrain/Terrain>
|
||||
#include <osgTerrain/TerrainSystem>
|
||||
|
||||
#include <osg/ClusterCullingCallback>
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgTerrain;
|
||||
|
||||
Terrain::Terrain():
|
||||
_terrainSystem(0),
|
||||
_hasBeenTraversal(false),
|
||||
_requiresNormals(true),
|
||||
_treatBoundariesToValidDataAsDefaultValue(false)
|
||||
{
|
||||
@@ -27,6 +31,8 @@ Terrain::Terrain():
|
||||
|
||||
Terrain::Terrain(const Terrain& terrain,const osg::CopyOp& copyop):
|
||||
Group(terrain,copyop),
|
||||
_terrainSystem(0),
|
||||
_hasBeenTraversal(false),
|
||||
_elevationLayer(terrain._elevationLayer),
|
||||
_colorLayers(terrain._colorLayers),
|
||||
_requiresNormals(terrain._requiresNormals),
|
||||
@@ -43,6 +49,30 @@ Terrain::~Terrain()
|
||||
|
||||
void Terrain::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (!_hasBeenTraversal)
|
||||
{
|
||||
if (!_terrainSystem)
|
||||
{
|
||||
osg::NodePath& nodePath = nv.getNodePath();
|
||||
if (!nodePath.empty())
|
||||
{
|
||||
for(osg::NodePath::reverse_iterator itr = nodePath.rbegin();
|
||||
itr != nodePath.rend() && !_terrainSystem;
|
||||
++itr)
|
||||
{
|
||||
osgTerrain::TerrainSystem* ts = dynamic_cast<TerrainSystem*>(*itr);
|
||||
if (ts)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Assigning terrain system "<<ts<<std::endl;
|
||||
_terrainSystem = ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_hasBeenTraversal = true;
|
||||
}
|
||||
|
||||
if (nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
|
||||
{
|
||||
osg::ClusterCullingCallback* ccc = dynamic_cast<osg::ClusterCullingCallback*>(getCullCallback());
|
||||
|
||||
34
src/osgTerrain/TerrainSystem.cpp
Normal file
34
src/osgTerrain/TerrainSystem.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/* -*-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.
|
||||
*/
|
||||
|
||||
#include <osgTerrain/TerrainSystem>
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgTerrain;
|
||||
|
||||
TerrainSystem::TerrainSystem()
|
||||
{
|
||||
}
|
||||
|
||||
TerrainSystem::~TerrainSystem()
|
||||
{
|
||||
}
|
||||
|
||||
TerrainSystem::TerrainSystem(const TerrainSystem& ts, const osg::CopyOp& copyop)
|
||||
{
|
||||
}
|
||||
|
||||
void TerrainSystem::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
Group::traverse(nv);
|
||||
}
|
||||
@@ -27,25 +27,3 @@ TileSystem::TileSystem(const TileSystem& tileSystem,const osg::CopyOp& copyop):
|
||||
TileSystem::~TileSystem()
|
||||
{
|
||||
}
|
||||
|
||||
TileID::TileID():
|
||||
_tileSystem(0),
|
||||
_layer(-1),
|
||||
_x(-1),
|
||||
_y(-1)
|
||||
{
|
||||
}
|
||||
|
||||
TileID::TileID(const TileID& tileID,const osg::CopyOp& copyop):
|
||||
osg::Object(tileID),
|
||||
_tileSystem(tileID._tileSystem),
|
||||
_layer(tileID._layer),
|
||||
_x(tileID._x),
|
||||
_y(tileID._y)
|
||||
{
|
||||
}
|
||||
|
||||
TileID::~TileID()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user