osg::Node* child = dynamic_cast<osg::Node*>( is.readObject() ); if ( child ) node.addChild( child ); } is >> osgDB::END_BRACKET; return true; 1. 2. 3. 4. 5. 6. 7. 8. OutputStream 接受<< 重载操作,因此需要对类定义 writeObject(), writeImage(), writePrimitiveSet() 和 wri...
returnmin+static_cast<float>(xorshift32()/static_cast<float>(0xFFFFFFFF/(max-min))); } //线性插值 floatlerp(floatmin,floatmax,floatt) { returnmin*(1.0-t)+max*t; } osg::Vec3f*generateHemisphereSamples(intkernelSize) { osg::Vec3f* kernel=newosg::Vec3f[kernelSize]; for(inti =0; ...
osgEarth::Map* mMapPtr; mMapNode = dynamic_cast<osgEarth::MapNode*>(mRoot->getChild(0)); mMapPtr = mMapNode->getMap(); osgEarth::Drivers::GDALOptions imageryGDAL; imageryGDAL.url() = IMAGERY_URL; osgEarth::Drivers::ImageLayer* tempImageLayer = new osgEarth::Drivers::ImageLayer( os...
通过GUIActionAdapter 类可以实现用户向系统传递请求(常见的用户请求包括窗口的刷新以及鼠标坐标的设置) //由于该类函数较少,一般用于转化为子类//由父类转化到子类拿到场景数据,如果没有场景数据就返回osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer* >(&aa);if(!viewer)returnfalse; 五.事件队列和...
(loadedModel);//增加宽高比设置QSize size=widget.size();float aspectRatio=static_cast<float>(size.width())/static_cast<float>(size.height());widget.getOsgViewer()->getCamera()->setProjectionMatrixAsPerspective(60.f,aspectRatio,1.f,1000.f);return0;});widget.resize(200,600);widget.show()...
osgViewer::GraphicsWindow* graphWin = dynamic_cast<osgViewer::GraphicsWindow*>(viewer->getCamera()->getGraphicsContext()); graphWin->setWindowRectangle(200, 200, 500, 500); } osg::ref_ptr<osg::Node> buildShapeBox(double x, double y, double z, bool ifAnimation) ...
{ osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv); if (cv) { // 假设黄道赤道交角23度 float sunz = sinf(23 * 3.14 / 180); float suny = cosf(23 * 3.14 / 180); osg::Vec4 sunPosNormalized = osg::Vec4(0.0, suny, sunz, 0); // Vec4.w设置为0用于阻止...
transform1->setMatrix(osg::Matrix::rotate(static_cast<double>(phi), osg::Vec3(0.0f, 0.0f, 1.0f))); viewer.frame(); phi += delta; } 最终我们得到一个有趣的结果: 在此示例中,我们实现了一些场景动画,但请记住,从组织对不同流的数据访问的角度来看,在渲染帧之前或之后扩展run()循环并更改渲染...
0f, static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0f, 10000.0f ); view->setSceneData( scene ); view->addEventHandler( new osgViewer::StatsHandler ); view->setCameraManipulator( new osgGA::MultiTouchTrackballManipulator ); gw->setTouchEventsEnabled( true ); ...
{osg::NodeVisitor sss=osg::NodeVisitor::TRAVERSE_ALL_CHILDREN;}voidapply(osg::Node&node){if(_am.valid())return;if(node.getUpdateCallback()){osgAnimation::AnimationManagerBase*b=dynamic_cast<osgAnimation::AnimationManagerBase*>(node.getUpdateCallback());if(b){_am=newosgAnimation::Basic...