本文整理汇总了C++中osg::ref_ptr::getVertexArray方法的典型用法代码示例。如果您正苦于以下问题:C++ ref_ptr::getVertexArray方法的具体用法?C++ ref_ptr::getVertexArray怎么用?C++ ref_ptr::getVertexArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::ref_ptr
的用法示例。
在下文中一共展示了ref_ptr::getVertexArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createVertexNode
void Scene::createVertexNode()
{
_vgeode = new osg::Geode;
_vgeode->setDataVariance(osg::Object::DYNAMIC);
osg::Vec3f lightDir(1.0f, 1.0f, 1.0f);
lightDir.normalize();
auto offsets = new osg::Uniform(osg::Uniform::FLOAT_VEC3, "offsets", Scene::VertexInstances);
offsets->setDataVariance(osg::Object::DYNAMIC);
auto stateSet = _vgeode->getOrCreateStateSet();
stateSet->setAttributeAndModes(_instancedProgram, osg::StateAttribute::ON);
stateSet->addUniform(new osg::Uniform("ecLightDirection", lightDir));
stateSet->addUniform(new osg::Uniform("lightColor", osg::Vec3(1.0f, 1.0f, 1.0f)));
stateSet->addUniform(offsets);
osg::Vec3 scale(1.0f, 1.0f, 1.0f);
osg::Vec4 color(0.25f, 0.25f, 0.25f, 1.0f);
auto vertexMatrix = osg::Matrixf::scale(scale * 0.125f * 0.25f);
auto normalMatrix = inverseTranspose(vertexMatrix);
_vgeometry = new osgKaleido::PolyhedronGeometry("#27");
_vgeometry->setUseDisplayList(false);
_vgeometry->setUseVertexBufferObjects(true);
_vgeometry->update(nullptr); // Force geometry generation
auto vertices = dynamic_cast<osg::Vec3Array*>(_vgeometry->getVertexArray());
if (vertices != nullptr) {
transform(*vertices, vertexMatrix);
}
auto normals = dynamic_cast<osg::Vec3Array*>(_vgeometry->getNormalArray());
if (normals != nullptr) {
transform(*normals, normalMatrix);
}
auto colors = dynamic_cast<osg::Vec4Array*>(_vgeometry->getColorArray());
if (colors != nullptr) {
fill(*colors, color);
}
makeInstanced(_vgeometry, Scene::VertexInstances);
auto size = 1.0f;
osg::BoundingBox bb(-size, -size, -size, +size, +size, +size);
_vgeometry->setInitialBound(bb);
_vgeode->addDrawable(_vgeometry);
addChild(_vgeode);
}