|
void main()
{
osgViewer::Viewer viewer;
osg::Group* rootNode = new osg::Group();
osg::Node* tankNode = NULL;
osg::Node* terrainNode = NULL;
osg:ositionAttitudeTransform* tankXform = new osg::PositionAttitudeTransform();
tankNode = osgDB::readNodeFile("F:\\models\\T72-Tank\\T72-tank_des.flt");
terrainNode = osgDB::readNodeFile("F:\\models\\JoeDirt\\JoeDirt.flt");
rootNode->addChild(terrainNode);
rootNode->addChild(tankXform);
tankXform->addChild(tankNode);
double tankXPosition = -10.0;
double tankYPosition = -10.0;
osg:ineSegment* tankLocationSegment = new osg::LineSegment();
tankLocationSegment->set(osg::Vec3(tankXPosition, tankYPosition, 999) ,osg::Vec3(tankXPosition, tankYPosition, -999) );
osgUtil::IntersectVisitor findTankElevationVisitor;
findTankElevationVisitor.addLineSegment(tankLocationSegment);
terrainNode->accept(findTankElevationVisitor);
osgUtil::IntersectVisitor::HitList tankElevationLocatorHits;
tankElevationLocatorHits = findTankElevationVisitor.getHitList(tankLocationSegment);
osgUtil::Hit heightTestResults;
heightTestResults = tankElevationLocatorHits.front();
osg::Vec3d terrainHeight = heightTestResults.getWorldIntersectPoint();
tankXform->setPosition( terrainHeight );
viewer.setSceneData(rootNode);
viewer.realize();
viewer.run();
}
上面是从海军教程上看到 但是现在感觉好多类都变了 而且感觉这个比较麻烦 想问下现在求交怎么做 在线等 希望那个大侠帮个忙 谢谢 |
|