本文整理汇总了C++中Road::getRoadGeode方法的典型用法代码示例。如果您正苦于以下问题:C++ Road::getRoadGeode方法的具体用法?C++ Road::getRoadGeode怎么用?C++ Road::getRoadGeode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Road
的用法示例。
在下文中一共展示了Road::getRoadGeode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loaded
void LevelTerrainCallback::loaded(osgTerrain::TerrainTile *tile, const osgDB::ReaderWriter::Options *options) const
{
//Change TerrainTechnique
tile->setTerrainTechnique(new DecoratedGeometryTechnique(voidBoundingAreaVector, treeStateSet.get(), buildingStateSet.get(), shapeFileVector));
std::stringstream nameStream;
nameStream << "tile_L" << tile->getTileID().level << "_X" << tile->getTileID().x << "_Y" << tile->getTileID().y;
tile->setName(nameStream.str());
/*tile->setName("TerrainTile");
osg::Vec3d model;
tile->getLocator()->convertLocalToModel(osg::Vec3d(0.0,0.0,0.0), model);
char name[1000];
sprintf(name,"X%f_Y%f_Z%f", model.x(), model.y(), model.z());
tile->setName(name);*/
//MTRand mt(10101);
osgTerrain::HeightFieldLayer *hflayer = dynamic_cast<osgTerrain::HeightFieldLayer *>(tile->getElevationLayer());
osg::HeightField *field = NULL;
if (hflayer)
{
field = hflayer->getHeightField();
}
else
{
return;
}
double tileXInterval = field->getXInterval();
double tileYInterval = field->getYInterval();
double tileElementArea = tileXInterval * tileYInterval;
double tileXMin = offset.x() + field->getOrigin().x();
double tileXMax = tileXMin + tileXInterval * (double)field->getNumColumns();
double tileYMin = offset.y() + field->getOrigin().y();
double tileYMax = tileYMin + tileYInterval * (double)field->getNumRows();
//osg::BoundingBox tileBB(tileXMin, tileYMin, -10.000, tileXMax, tileYMax, 10.000);
if (tileXInterval > 10.0 && tileYInterval > 10.0)
{
return;
}
for (int i = 0; i < RoadSystem::Instance()->getNumRoads(); ++i)
{
Road *road = RoadSystem::Instance()->getRoad(i);
double roadLength = road->getLength();
const osg::BoundingBox &roadBB = road->getRoadGeode()->getBoundingBox();
//if(roadBB.intersects(tileBB)) {
if (((roadBB.xMax() >= tileXMin && roadBB.xMax() <= tileXMax) || (roadBB.xMin() >= tileXMin && roadBB.xMin() <= tileXMax) || (roadBB.xMin() <= tileXMin && roadBB.xMax() >= tileXMax)) && (roadBB.yMax() >= tileYMin && roadBB.yMin() <= tileYMax))
{
//double h = sqrt(tileXInterval*tileXInterval + tileYInterval*tileYInterval);
double h = 20.0;
std::deque<RoadPoint> pointDeque(4);
double widthRight, widthLeft;
road->getRoadSideWidths(0.0, widthRight, widthLeft);
pointDeque.pop_front();
pointDeque.pop_front();
pointDeque.push_back(road->getRoadPoint(0.0, widthLeft + 10.0));
pointDeque.push_back(road->getRoadPoint(0.0, widthRight - 10.0));
std::map<std::pair<int, int>, double> coordHeightMap;
for (double s_ = h; s_ < roadLength + h; s_ = s_ + h)
{
double s = s_;
if (s > roadLength)
s = roadLength;
road->getRoadSideWidths(s, widthRight, widthLeft);
pointDeque.pop_front();
pointDeque.pop_front();
pointDeque.push_back(road->getRoadPoint(s, widthLeft + 10.0));
pointDeque.push_back(road->getRoadPoint(s, widthRight - 10.0));
//Bresenham
// y x z
std::map<int, std::map<int, double> > fillBorderMap;
//iteration over four lines
for (int i = 0; i < 4; ++i)
{
int j;
switch (i)
{
case 0:
j = 1;
break;
case 1:
j = 3;
break;
case 2:
j = 0;
break;
case 3:
j = 2;
break;
}
double fx0 = (pointDeque[i].x() - tileXMin) / tileXInterval;
double fy0 = (pointDeque[i].y() - tileYMin) / tileYInterval;
//.........这里部分代码省略.........