本文整理汇总了C++中Bounds::center2d方法的典型用法代码示例。如果您正苦于以下问题:C++ Bounds::center2d方法的具体用法?C++ Bounds::center2d怎么用?C++ Bounds::center2d使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bounds
的用法示例。
在下文中一共展示了Bounds::center2d方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: i
osg::Vec3d
Geometry::localize()
{
osg::Vec3d offset;
Bounds bounds = getBounds();
if ( bounds.isValid() )
{
osg::Vec2d center = bounds.center2d();
offset.set( center.x(), center.y(), 0 );
GeometryIterator i( this );
while( i.hasMore() )
{
Geometry* part = i.next();
for( Geometry::iterator j = part->begin(); j != part->end(); ++j )
{
*j = *j - offset;
}
}
}
return offset;
}
示例2: zfinder
bool
ExtrudeGeometryFilter::buildStructure(const Geometry* input,
double height,
double heightOffset,
bool flatten,
const SkinResource* wallSkin,
const SkinResource* roofSkin,
Structure& structure,
FilterContext& cx )
{
bool makeECEF = false;
const SpatialReference* srs = 0L;
const SpatialReference* mapSRS = 0L;
if ( cx.isGeoreferenced() )
{
srs = cx.extent()->getSRS();
makeECEF = cx.getSession()->getMapInfo().isGeocentric();
mapSRS = cx.getSession()->getMapInfo().getProfile()->getSRS();
}
// whether this is a closed polygon structure.
structure.isPolygon = (input->getComponentType() == Geometry::TYPE_POLYGON);
// extrusion working variables
double targetLen = -DBL_MAX;
osg::Vec3d minLoc(DBL_MAX, DBL_MAX, DBL_MAX);
double minLoc_len = DBL_MAX;
osg::Vec3d maxLoc(0,0,0);
double maxLoc_len = 0;
// Initial pass over the geometry does two things:
// 1: Calculate the minimum Z across all parts.
// 2: Establish a "target length" for extrusion
double absHeight = fabs(height);
ConstGeometryIterator zfinder( input );
while( zfinder.hasMore() )
{
const Geometry* geom = zfinder.next();
for( Geometry::const_iterator m = geom->begin(); m != geom->end(); ++m )
{
osg::Vec3d m_point = *m;
if ( m_point.z() + absHeight > targetLen )
targetLen = m_point.z() + absHeight;
if (m_point.z() < minLoc.z())
minLoc = m_point;
if (m_point.z() > maxLoc.z())
maxLoc = m_point;
}
}
// apply the height offsets
height -= heightOffset;
targetLen -= heightOffset;
float roofRotation = 0.0f;
Bounds roofBounds;
float sinR = 0.0f, cosR = 0.0f;
double roofTexSpanX = 0.0, roofTexSpanY = 0.0;
osg::ref_ptr<const SpatialReference> roofProjSRS;
if ( roofSkin )
{
roofBounds = input->getBounds();
// if our data is lat/long, we need to reproject the geometry and the bounds into a projected
// coordinate system in order to properly generate tex coords.
if ( srs && srs->isGeographic() )
{
osg::Vec2d geogCenter = roofBounds.center2d();
roofProjSRS = srs->createUTMFromLonLat( Angle(geogCenter.x()), Angle(geogCenter.y()) );
if ( roofProjSRS.valid() )
{
roofBounds.transform( srs, roofProjSRS.get() );
osg::ref_ptr<Geometry> projectedInput = input->clone();
srs->transform( projectedInput->asVector(), roofProjSRS.get() );
roofRotation = getApparentRotation( projectedInput.get() );
}
}
else
{
roofRotation = getApparentRotation( input );
}
sinR = sin(roofRotation);
cosR = cos(roofRotation);
if ( !roofSkin->isTiled().value() )
{
//note: non-tiled roofs don't really work atm.
roofTexSpanX = cosR*roofBounds.width() - sinR*roofBounds.height();
roofTexSpanY = sinR*roofBounds.width() + cosR*roofBounds.height();
}
else
{
roofTexSpanX = roofSkin->imageWidth().isSet() ? *roofSkin->imageWidth() : roofSkin->imageHeight().isSet() ? *roofSkin->imageHeight() : 10.0;
//.........这里部分代码省略.........
示例3: zfinder
//.........这里部分代码省略.........
osg::ref_ptr<const SpatialReference> roofProjSRS;
if ( roof )
{
roofVerts = new osg::Vec3Array( pointCount );
roof->setVertexArray( roofVerts );
// per-vertex colors are necessary if we are going to use the MeshConsolidator -gw
if ( useColor )
{
osg::Vec4Array* roofColors = new osg::Vec4Array();
roofColors->reserve( pointCount );
roofColors->assign( pointCount, roofColor );
roof->setColorArray( roofColors );
roof->setColorBinding( osg::Geometry::BIND_PER_VERTEX );
}
if ( roofSkin )
{
roofTexcoords = new osg::Vec2Array( pointCount );
roof->setTexCoordArray( 0, roofTexcoords );
// Get the orientation of the geometry. This is a hueristic that will help
// us align the roof skin texture properly. TODO: make this optional? It makes
// sense for buildings and such, but perhaps not for all extruded shapes.
roofRotation = getApparentRotation( input );
roofBounds = input->getBounds();
// if our data is lat/long, we need to reproject the geometry and the bounds into a projected
// coordinate system in order to properly generate tex coords.
if ( srs && srs->isGeographic() )
{
osg::Vec2d geogCenter = roofBounds.center2d();
roofProjSRS = srs->createUTMFromLonLat( Angular(geogCenter.x()), Angular(geogCenter.y()) );
roofBounds.transform( srs, roofProjSRS.get() );
osg::ref_ptr<Geometry> projectedInput = input->clone();
srs->transform( projectedInput->asVector(), roofProjSRS.get() );
roofRotation = getApparentRotation( projectedInput.get() );
}
else
{
roofRotation = getApparentRotation( input );
}
sinR = sin(roofRotation);
cosR = cos(roofRotation);
if ( !roofSkin->isTiled().value() )
{
//note: doesn't really work
roofTexSpanX = cosR*roofBounds.width() - sinR*roofBounds.height();
roofTexSpanY = sinR*roofBounds.width() + cosR*roofBounds.height();
}
else
{
roofTexSpanX = roofSkin->imageWidth().isSet() ? *roofSkin->imageWidth() : roofSkin->imageHeight().isSet() ? *roofSkin->imageHeight() : 10.0;
if ( roofTexSpanX <= 0.0 ) roofTexSpanX = 10.0;
roofTexSpanY = roofSkin->imageHeight().isSet() ? *roofSkin->imageHeight() : roofSkin->imageWidth().isSet() ? *roofSkin->imageWidth() : 10.0;
if ( roofTexSpanY <= 0.0 ) roofTexSpanY = 10.0;
}
}
}
osg::Vec3Array* baseVerts = NULL;
if ( base )