本文整理汇总了C++中GeoPoint::createWorldUpVector方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoPoint::createWorldUpVector方法的具体用法?C++ GeoPoint::createWorldUpVector怎么用?C++ GeoPoint::createWorldUpVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoPoint
的用法示例。
在下文中一共展示了GeoPoint::createWorldUpVector方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: establish
void
ModelSplatter::operator()(const TileKey& key, osg::Node* node)
{
TerrainTileNode* tile = osgEarth::findTopMostNodeOfType<TerrainTileNode>(node);
if ( !tile )
return;
if ( key.getLOD() >= _minLOD && _model.valid() )
{
// make sure the correct model is loaded
establish();
// elevation texture and matrix are required
osg::Texture* elevationTex = tile->getElevationTexture();
if ( !elevationTex )
{
//OE_WARN << LC << "No elevation texture for key " << key.str() << "\n";
return;
}
osg::RefMatrix* elevationTexMat = tile->getElevationTextureMatrix();
if ( !elevationTexMat )
{
//OE_WARN << LC << "No elevation texture matrix for key " << key.str() << "\n";
return;
}
tile->addChild( _model.get() );
osg::StateSet* ss = tile->getOrCreateStateSet();
// first, a rotation vector to make trees point up.
GeoPoint p;
key.getExtent().getCentroid(p);
osg::Vec3d up;
p.createWorldUpVector(up);
osg::Quat q;
q.makeRotate(osg::Vec3d(0,0,1), up);
osg::Matrixd zup = osg::Matrixd::rotate(q);
// matrices to resolve the weird terrain localization into a usable LTP.
osg::Matrix tile2world = tile->getMatrix();
osg::Matrix world2ltp;
p.createWorldToLocal(world2ltp);
osg::Matrix local2ltp = tile2world * world2ltp;
osg::Matrix ltp2local;
ltp2local.invert(local2ltp);
// after inverting the matrix, combine the ZUP (optimization)
local2ltp.preMult( zup );
ss->addUniform( new osg::Uniform("oe_trees_local2ltp", osg::Matrixf(local2ltp)) );
ss->addUniform( new osg::Uniform("oe_trees_ltp2local", osg::Matrixf(ltp2local)) );
// calculate the scatter area:
float h = key.getExtent().height() * 111320.0f;
float w = key.getExtent().width() * 111320.0f * cos(fabs(osg::DegreesToRadians(p.y())));
ss->addUniform( new osg::Uniform("oe_trees_span", osg::Vec2f(w,h)) );
ss->setTextureAttributeAndModes(2, tile->getElevationTexture(), 1);
ss->addUniform( new osg::Uniform("oe_terrain_tex_matrix", osg::Matrixf(*elevationTexMat)) );
}
}
示例2: start
bool
ElevationQuery::getElevationImpl(const GeoPoint& point,
float& out_elevation,
double desiredResolution,
double* out_actualResolution)
{
// assertion.
if ( !point.isAbsolute() )
{
OE_WARN << LC << "Assertion failure; input must be absolute" << std::endl;
return false;
}
osg::Timer_t begin = osg::Timer::instance()->tick();
// first try the terrain patches.
if ( _terrainModelLayers.size() > 0 )
{
osgUtil::IntersectionVisitor iv;
if ( _ivrc.valid() )
iv.setReadCallback(_ivrc.get());
for(LayerVector::iterator i = _terrainModelLayers.begin(); i != _terrainModelLayers.end(); ++i)
{
// find the scene graph for this layer:
Layer* layer = i->get();
osg::Node* node = layer->getNode();
if ( node )
{
// configure for intersection:
osg::Vec3d surface;
point.toWorld( surface );
// trivial bounds check:
if ( node->getBound().contains(surface) )
{
osg::Vec3d nvector;
point.createWorldUpVector(nvector);
osg::Vec3d start( surface + nvector*5e5 );
osg::Vec3d end ( surface - nvector*5e5 );
// first time through, set up the intersector on demand
if ( !_lsi.valid() )
{
_lsi = new osgUtil::LineSegmentIntersector(start, end);
_lsi->setIntersectionLimit( _lsi->LIMIT_NEAREST );
}
else
{
_lsi->reset();
_lsi->setStart( start );
_lsi->setEnd ( end );
}
// try it.
iv.setIntersector( _lsi.get() );
node->accept( iv );
// check for a result!!
if ( _lsi->containsIntersections() )
{
osg::Vec3d isect = _lsi->getIntersections().begin()->getWorldIntersectPoint();
// transform back to input SRS:
GeoPoint output;
output.fromWorld( point.getSRS(), isect );
out_elevation = (float)output.z();
if ( out_actualResolution )
*out_actualResolution = 0.0;
return true;
}
}
else
{
//OE_INFO << LC << "Trivial rejection (bounds check)" << std::endl;
}
}
}
}
if (_elevationLayers.empty())
{
// this means there are no heightfields.
out_elevation = NO_DATA_VALUE;
return true;
}
// secure map pointer:
osg::ref_ptr<const Map> map;
if (!_map.lock(map))
{
return false;
}
// tile size (resolution of elevation tiles)
unsigned tileSize = 257; // yes?
//.........这里部分代码省略.........
示例3: start
bool
ElevationQuery::getElevationImpl(const GeoPoint& point, /* abs */
double& out_elevation,
double desiredResolution,
double* out_actualResolution)
{
// assertion.
if ( !point.isAbsolute() )
{
OE_WARN << LC << "Assertion failure; input must be absolute" << std::endl;
return false;
}
osg::Timer_t begin = osg::Timer::instance()->tick();
// first try the terrain patches.
if ( _patchLayers.size() > 0 )
{
osgUtil::IntersectionVisitor iv;
for(std::vector<ModelLayer*>::iterator i = _patchLayers.begin(); i != _patchLayers.end(); ++i)
{
// find the scene graph for this layer:
osg::Node* node = (*i)->getSceneGraph( _mapf.getUID() );
if ( node )
{
// configure for intersection:
osg::Vec3d surface;
point.toWorld( surface );
// trivial bounds check:
if ( node->getBound().contains(surface) )
{
osg::Vec3d nvector;
point.createWorldUpVector(nvector);
osg::Vec3d start( surface + nvector*5e5 );
osg::Vec3d end ( surface - nvector*5e5 );
// first time through, set up the intersector on demand
if ( !_patchLayersLSI.valid() )
{
_patchLayersLSI = new DPLineSegmentIntersector(start, end);
_patchLayersLSI->setIntersectionLimit( _patchLayersLSI->LIMIT_NEAREST );
}
else
{
_patchLayersLSI->reset();
_patchLayersLSI->setStart( start );
_patchLayersLSI->setEnd ( end );
}
// try it.
iv.setIntersector( _patchLayersLSI.get() );
node->accept( iv );
// check for a result!!
if ( _patchLayersLSI->containsIntersections() )
{
osg::Vec3d isect = _patchLayersLSI->getIntersections().begin()->getWorldIntersectPoint();
// transform back to input SRS:
GeoPoint output;
output.fromWorld( point.getSRS(), isect );
out_elevation = output.z();
if ( out_actualResolution )
*out_actualResolution = 0.0;
return true;
}
}
else
{
//OE_INFO << LC << "Trivial rejection (bounds check)" << std::endl;
}
}
}
}
if ( _mapf.elevationLayers().empty() )
{
// this means there are no heightfields.
out_elevation = 0.0;
return true;
}
// tile size (resolution of elevation tiles)
unsigned tileSize = std::max(_mapf.getMapOptions().elevationTileSize().get(), 2u);
//This is the max resolution that we actually have data at this point
unsigned int bestAvailLevel = getMaxLevel( point.x(), point.y(), point.getSRS(), _mapf.getProfile());
if (desiredResolution > 0.0)
{
unsigned int desiredLevel = _mapf.getProfile()->getLevelOfDetailForHorizResolution( desiredResolution, tileSize );
if (desiredLevel < bestAvailLevel) bestAvailLevel = desiredLevel;
}
OE_DEBUG << LC << "Best available data level " << point.x() << ", " << point.y() << " = " << bestAvailLevel << std::endl;
//.........这里部分代码省略.........