|
发表于 2015-3-26 12:32:05
|
显示全部楼层
大概是这样:
int _tmain(int argc, char* argv[])
{
std::string topFile = "E:/alb/model/RevitExport/cvx.ive";//"top.osg";
std::string bottomFile = "E:/alb/model/RevitExport/cvx.ive";//"bottom.osg";
osg::ref_ptr<osg::Node> topNode = osgDB::readNodeFile(topFile);
osg::ref_ptr<osg::Node> bottomNode = osgDB::readNodeFile(topFile);
osg::ComputeBoundsVisitor cbvtop;
topNode->accept(cbvtop);
osg::BoundingBox topBox = cbvtop.getBoundingBox();
osg::ComputeBoundsVisitor cbvbot;
bottomNode->accept(cbvbot);
osg::BoundingBox botBox = cbvbot.getBoundingBox();
osg::Vec3 trans(topBox.center() - botBox.center());
trans.z() = botBox.zMax() - topBox.zMin();
osg::MatrixTransform* mt = new osg::MatrixTransform(osg::Matrix::translate(trans));
mt->addChild(topNode);
osg::Group* root = new osg::Group;
root->addChild(mt);
root->addChild(bottomNode);
//osg:ightModel* lightModel = new osg::LightModel;
//lightModel->setTwoSided(true);//双面灯光
//node->getOrCreateStateSet()->setAttribute(lightModel);
osgViewer::Viewer viewer;
//viewer.setSceneData(node.get());
viewer.setSceneData(root);
viewer.setUpViewInWindow(100, 100, 800, 600);
return viewer.run();
} |
|