Earth的渲染机制和OSG的不一样,具体区别我也说不出一二来,直接上代码。
_global->Caster->setLight( _global->Viewer->getLight() );
_global->Caster->getShadowCastingGroup()->addChild( _global->MapNode->getModelLayerGroup() );
if ( _global->MapNode->getNumParents() > 0 )
{
osgEarth::insertGroup(_global->Caster, _global->MapNode->getParent(0));
}
else
{
_global->Caster->addChild(_global->MapNode);
_global->Root->addChild(_global->Caster);
}
为了使得模型支持高亮、半透明,添加的模型需要加入渲染器中
_global->Caster->getShadowCastingGroup()->addChild(xxx);
还有资料说用下面的方法也可以
osgEarth::Registry::shaderGenerator().run( myNode );
这个我测试了一下,是可以渲染,但是模型不支持高亮、半透明,研究的不深,或许使用错了。