osgEarth的Rex引擎原理分析(七十一)
作者:互联网
目标:(五十五)中的问题142
1、在RexTerrainEngineNode遍历时生成renderleaf,其中的drawable为LayerDrawable(其对应earth文件中每一个高程、影像层)。在TerrainCuller进行遍历时,会对LayerDrawable添加实际瓦片对应的高程影像纹理,这样绘制出来就能看到高程影像效果了。
osgEarthDrivers/engine_rex/RexTerrainEngineNode.cpp
void
RexTerrainEngineNode::dirtyState()
{
LayerDrawable* lastLayer = 0L;
for(LayerDrawableList::iterator i = culler._terrain.layers().begin();
i != culler._terrain.layers().end();
++i)
{
lastLayer = i->get();
cv->apply(*lastLayer);
}
}
osgUtil/RenderLeaf
inline RenderLeaf(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* modelview, float depth=0.0f, unsigned int traversalOrderNumber=0):
osg::Referenced(false),
_parent(0),
_drawable(drawable),
_projection(projection),
_modelview(modelview),
_depth(depth),
_traversalOrderNumber(traversalOrderNumber)
{
_dynamic = (drawable->getDataVariance()==osg::Object::DYNAMIC);
}
2、在渲染时从renderleaf中取出drawable进行绘制,此时会用到顶点着色器,对顶点位置进行设置,对高程进行设置的着色器代码为RexEngine.Elevation.glsl(它里面调用了RexEngine.SDK.vert.glsl的函数)
osgEarthDrivers/engine_rex/LayerDrawable.cpp
void
LayerDrawable::drawImplementation(osg::RenderInfo& ri) const
{
for (DrawTileCommands::const_iterator tile = _tiles.begin(); tile != _tiles.end(); ++tile)
{
tile->draw(ri, *_drawState, 0L);
}
}
osgEarthDrivers/engine_rex/DrawTileCommand.cpp
void
DrawTileCommand::draw(osg::RenderInfo& ri, DrawState& dsMaster, osg::Referenced* layerData) const
{
_geom->render(ptype, ri);
}
osgEarthDrivers/engine_rex/GeometryPool.cpp
void SharedGeometry::render(GLenum primitiveType, osg::RenderInfo& renderInfo) const
{
//调用opengl进行绘制,并进入图形管线
glDrawElements(primitiveType, _drawElements->getNumIndices(), _drawElements->getDataType(), (const GLvoid *)(ebo->getOffset(_drawElements->getBufferIndex())));
}
hankern 发布了372 篇原创文章 · 获赞 33 · 访问量 9万+ 私信 关注
标签:Rex,const,void,rex,osgEarth,LayerDrawable,drawable,七十一,osg 来源: https://blog.csdn.net/hankern/article/details/104192146