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; ...
if (numProcessors >= static_cast<int>(cameras.size()+contexts.size())) { return CullThreadPerCameraDrawThreadPerContext; } #endif return DrawThreadPerContext; } OSG 选择使用哪种线程模型是以窗口和相机数为准则,再考虑CPU物理核心数给出结果。 如果是单窗口应用 CPU 是单核, 返回 SingleThreaded,这...
int value = readModeValue(is); pm.setMode(osg::PolygonMode::FRONT, static_cast<osg::PolygonMode::Mode>(value)); 2.4 自定义compressor/decompressor 我们已经自定义了一个ZLIB的压缩器,在src/osgDB/Compressor.cpp中,但是我们可能希望自定义压缩器,只需要重写两个虚函数就可以了。 下面的例子会在输出文件...
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( osgEarth::Drivers::ImageLayer...
(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) ...
OSG master osgearth master Environment: MacBook Pro (Retina, 13-inch, Mid 2014) macOS Sierra 10.12.4 (16E195) errors: osgearth_viewerd[69855:10712897] dynamic_cast error 1: Both of the following type_info's should have public visibility...
transform1->setMatrix(osg::Matrix::rotate(static_cast<double>(phi), osg::Vec3(0.0f, 0.0f, 1.0f))); viewer.frame(); phi += delta; } 最终我们得到一个有趣的结果: 在此示例中,我们实现了一些场景动画,但请记住,从组织对不同流的数据访问的角度来看,在渲染帧之前或之后扩展run()循环并更改渲染...
{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...