Node派生类的遍历等

需求背景

需求是这样的,需要用一个几何体,在一个体元素中提取一部分的插值结果。自然是没有现成的算法。实现的过程中,就需要对Geode、Geometry进行遍历。
由于我之前编译帮助文档失败了,虽然OSG版本是3.6.5的,但是帮助文档的版本却是2.9.11的。一些方法还是有出入的。所以记录一下

遍历Geode内的Geometry

1
2
3
4
cout << "Geode2的数量" << this->temp_gde->getNumChildren() << endl;
for (unsigned int i = 0; i < this->temp_gde->getNumDrawables(); i++) {
osg::ref_ptr<osg::Geometry> pgeo = this->temp_gde->getDrawable(i)->asGeometry();
}

getNumChildren()getNumDrawables()的值是一样的。不知道是不是巧合