本文整理汇总了C++中osg::Vec3d::x方法的典型用法代码示例。如果您正苦于以下问题:C++ Vec3d::x方法的具体用法?C++ Vec3d::x怎么用?C++ Vec3d::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::Vec3d
的用法示例。
在下文中一共展示了Vec3d::x方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
LargeScaleCoord::LargeScaleCoord(const osg::Vec3d& realCoord)
{
m_smallScale.set(0, 0, 0);
m_largeScale.set(realCoord.x() / sizeFactor, realCoord.y() / sizeFactor, realCoord.z() / sizeFactor);
}
示例2:
bool
ElevationQuery::getElevationImpl(const osg::Vec3d& point,
const SpatialReference* pointSRS,
double& out_elevation,
double desiredResolution,
double* out_actualResolution)
{
if ( _maxDataLevel == 0 || _tileSize == 0 )
{
// this means there are no heightfields.
out_elevation = 0.0;
return true;
}
// this is the ideal LOD for the requested resolution:
unsigned int idealLevel = desiredResolution > 0.0
? _mapf.getProfile()->getLevelOfDetailForHorizResolution( desiredResolution, _tileSize )
: _maxDataLevel;
// based on the heightfields available, this is the best we can theorically do:
unsigned int bestAvailLevel = osg::minimum( idealLevel, _maxDataLevel );
if (_maxLevelOverride >= 0)
{
bestAvailLevel = osg::minimum(bestAvailLevel, (unsigned int)_maxLevelOverride);
}
// transform the input coords to map coords:
osg::Vec3d mapPoint = point;
if ( pointSRS && !pointSRS->isEquivalentTo( _mapf.getProfile()->getSRS() ) )
{
if ( !pointSRS->transform2D( point.x(), point.y(), _mapf.getProfile()->getSRS(), mapPoint.x(), mapPoint.y() ) )
{
OE_WARN << LC << "Fail: coord transform failed" << std::endl;
return false;
}
}
osg::ref_ptr<osg::HeightField> hf;
osg::ref_ptr<osgTerrain::TerrainTile> tile;
// get the tilekey corresponding to the tile we need:
TileKey key = _mapf.getProfile()->createTileKey( mapPoint.x(), mapPoint.y(), bestAvailLevel );
if ( !key.valid() )
{
OE_WARN << LC << "Fail: coords fall outside map" << std::endl;
return false;
}
// Check the tile cache. Note that the TileSource already likely has a MemCache
// attached to it. We employ a secondary cache here for a couple reasons. One, this
// cache will store not only the heightfield, but also the tesselated tile in the event
// that we're using GEOMETRIC mode. Second, since the call the getHeightField can
// fallback on a lower resolution, this cache will hold the final resolution heightfield
// instead of trying to fetch the higher resolution one each tiem.
TileCache::Record record = _tileCache.get( key );
if ( record.valid() )
tile = record.value().get();
// if we found it, make sure it has a heightfield in it:
if ( tile.valid() )
{
osgTerrain::HeightFieldLayer* layer = dynamic_cast<osgTerrain::HeightFieldLayer*>(tile->getElevationLayer());
if ( layer )
hf = layer->getHeightField();
if ( !hf.valid() )
tile = 0L;
}
// if we didn't find it (or it didn't have heightfield data), build it.
if ( !tile.valid() )
{
// generate the heightfield corresponding to the tile key, automatically falling back
// on lower resolution if necessary:
_mapf.getHeightField( key, true, hf, 0L, _interpolation );
// bail out if we could not make a heightfield a all.
if ( !hf.valid() )
{
OE_WARN << LC << "Unable to create heightfield for key " << key.str() << std::endl;
return false;
}
// All this stuff is requires for GEOMETRIC mode. An optimization would be to
// defer this so that PARAMETRIC mode doesn't waste time
GeoLocator* locator = GeoLocator::createForKey( key, _mapf.getMapInfo() );
tile = new osgTerrain::TerrainTile();
osgTerrain::HeightFieldLayer* layer = new osgTerrain::HeightFieldLayer( hf.get() );
layer->setLocator( locator );
tile->setElevationLayer( layer );
tile->setRequiresNormals( false );
tile->setTerrainTechnique( new osgTerrain::GeometryTechnique );
// store it in the local tile cache.
_tileCache.insert( key, tile.get() );
}
//.........这里部分代码省略.........
示例3: intersectAndClip
bool LineSegmentIntersector::intersectAndClip(osg::Vec3d& s, osg::Vec3d& e,const osg::BoundingBox& bbInput)
{
osg::Vec3d bb_min(bbInput._min);
osg::Vec3d bb_max(bbInput._max);
#if 1
double epsilon = 1e-4;
bb_min.x() -= epsilon;
bb_min.y() -= epsilon;
bb_min.z() -= epsilon;
bb_max.x() += epsilon;
bb_max.y() += epsilon;
bb_max.z() += epsilon;
#endif
// compate s and e against the xMin to xMax range of bb.
if (s.x()<=e.x())
{
// trivial reject of segment wholely outside.
if (e.x()<bb_min.x()) return false;
if (s.x()>bb_max.x()) return false;
if (s.x()<bb_min.x())
{
// clip s to xMin.
s = s+(e-s)*(bb_min.x()-s.x())/(e.x()-s.x());
}
if (e.x()>bb_max.x())
{
// clip e to xMax.
e = s+(e-s)*(bb_max.x()-s.x())/(e.x()-s.x());
}
}
else
{
if (s.x()<bb_min.x()) return false;
if (e.x()>bb_max.x()) return false;
if (e.x()<bb_min.x())
{
// clip s to xMin.
e = s+(e-s)*(bb_min.x()-s.x())/(e.x()-s.x());
}
if (s.x()>bb_max.x())
{
// clip e to xMax.
s = s+(e-s)*(bb_max.x()-s.x())/(e.x()-s.x());
}
}
// compate s and e against the yMin to yMax range of bb.
if (s.y()<=e.y())
{
// trivial reject of segment wholely outside.
if (e.y()<bb_min.y()) return false;
if (s.y()>bb_max.y()) return false;
if (s.y()<bb_min.y())
{
// clip s to yMin.
s = s+(e-s)*(bb_min.y()-s.y())/(e.y()-s.y());
}
if (e.y()>bb_max.y())
{
// clip e to yMax.
e = s+(e-s)*(bb_max.y()-s.y())/(e.y()-s.y());
}
}
else
{
if (s.y()<bb_min.y()) return false;
if (e.y()>bb_max.y()) return false;
if (e.y()<bb_min.y())
{
// clip s to yMin.
e = s+(e-s)*(bb_min.y()-s.y())/(e.y()-s.y());
}
if (s.y()>bb_max.y())
{
// clip e to yMax.
s = s+(e-s)*(bb_max.y()-s.y())/(e.y()-s.y());
}
}
// compate s and e against the zMin to zMax range of bb.
if (s.z()<=e.z())
{
// trivial reject of segment wholely outside.
if (e.z()<bb_min.z()) return false;
if (s.z()>bb_max.z()) return false;
if (s.z()<bb_min.z())
//.........这里部分代码省略.........
示例4: computeLocalBounds
bool Locator::computeLocalBounds(Locator& source, osg::Vec3d& bottomLeft, osg::Vec3d& topRight) const
{
typedef std::list<osg::Vec3d> Corners;
Corners corners;
osg::Vec3d cornerNDC;
if (convertLocalToModel(osg::Vec3d(0.0,0.0,0.0), cornerNDC))
{
corners.push_back(cornerNDC);
}
if (convertLocalToModel(osg::Vec3d(1.0,0.0,0.0), cornerNDC))
{
corners.push_back(cornerNDC);
}
if (convertLocalToModel(osg::Vec3d(0.0,1.0,0.0), cornerNDC))
{
corners.push_back(cornerNDC);
}
if (convertLocalToModel(osg::Vec3d(1.0,1.0,0.0), cornerNDC))
{
corners.push_back(cornerNDC);
}
if (convertLocalToModel(osg::Vec3d(0.0,0.0,1.0), cornerNDC))
{
corners.push_back(cornerNDC);
}
if (convertLocalToModel(osg::Vec3d(1.0,0.0,1.0), cornerNDC))
{
corners.push_back(cornerNDC);
}
if (convertLocalToModel(osg::Vec3d(0.0,1.0,1.0), cornerNDC))
{
corners.push_back(cornerNDC);
}
if (convertLocalToModel(osg::Vec3d(1.0,1.0,1.0), cornerNDC))
{
corners.push_back(cornerNDC);
}
if (corners.empty()) return false;
for(Corners::iterator itr = corners.begin();
itr != corners.end();
++itr)
{
bottomLeft.x() = osg::minimum( bottomLeft.x(), itr->x());
bottomLeft.y() = osg::minimum( bottomLeft.y(), itr->y());
bottomLeft.z() = osg::minimum( bottomLeft.z(), itr->z());
topRight.x() = osg::maximum( topRight.x(), itr->x());
topRight.y() = osg::maximum( topRight.y(), itr->y());
topRight.z() = osg::maximum( topRight.z(), itr->z());
}
return true;
}
示例5: switch
bool
MercatorLocator::convertModelToLocal(const osg::Vec3d& world, osg::Vec3d& local) const
{
bool result = false;
// required becasue of an OSG bug
if ( !_inverseCalculated )
{
const_cast<MercatorLocator*>(this)->_inverse.invert( _transform );
const_cast<MercatorLocator*>(this)->_inverseCalculated = true;
}
switch(_coordinateSystemType)
{
case(GEOCENTRIC):
{
double longitude, latitude, height;
_ellipsoidModel->convertXYZToLatLongHeight(world.x(), world.y(), world.z(),
latitude, longitude, height );
local = osg::Vec3d(longitude, latitude, height) * _inverse;
double lon_deg = osg::RadiansToDegrees(longitude);
double lat_deg = osg::RadiansToDegrees(latitude);
double xr, yr;
getUV( _geoDataExtent, lon_deg, lat_deg, xr, yr );
local.x() = xr;
local.y() = 1.0-yr;
result = true;
}
break;
case(GEOGRAPHIC):
{
local = world * _inverse;
osg::Vec3d w = world;
double lon_deg = w.x();
double lat_deg = w.y();
double xr, yr;
getUV( _geoDataExtent, lon_deg, lat_deg, xr, yr );
local.x() = xr;
local.y() = 1.0-yr;
result = true;
}
break;
case(PROJECTED):
{
local = world * _inverse;
result = true;
}
break;
}
return result;
}