首页 > 解决方案 > OpenSceneGraph:分析场景图

问题描述

我想通过 OSG 读取 3D 模型并了解有关顶点、法线和纹理坐标等的 3D 模型信息。

我不明白下面的代码(从这里完成教程)。我们为什么要prset->index(ic)用作索引?我很困惑。(* verts)是顶点数组,但什么是prset->index(ic)

for (ic=0; ic<prset->getNumIndices(); ic++) { // NB the vertices are held in the drawable -
    osg::notify(osg::WARN) << "vertex "<< ic << " is index "<<prset->index(ic) << " at " <<
        (* verts)[prset->index(ic)].x() << "," <<
        (* verts)[prset->index(ic)].y() << "," << 
        (* verts)[prset->index(ic)].z() << std::endl;
}

标签: c++openglopenscenegraph

解决方案


如果您的可绘制对象使用索引图元,则需要取消引用查看索引数组的三角形顶点,因为您可能会重复使用顶点数组的共享顶点。像这样的东西。


推荐阅读