本文整理汇总了C++中osg::Geometry::accept方法的典型用法代码示例。如果您正苦于以下问题:C++ Geometry::accept方法的具体用法?C++ Geometry::accept怎么用?C++ Geometry::accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::Geometry
的用法示例。
在下文中一共展示了Geometry::accept方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void osgToy::FacetingVisitor::facet( osg::Geometry& geom )
{
// count #surfaces, exit if none
osg::Geometry::PrimitiveSetList& primitives = geom.getPrimitiveSetList();
osg::Geometry::PrimitiveSetList::iterator itr;
unsigned int numSurfacePrimitives=0;
for(itr=primitives.begin();
itr!=primitives.end();
++itr)
{
switch((*itr)->getMode())
{
case osg::PrimitiveSet::TRIANGLES:
case osg::PrimitiveSet::TRIANGLE_STRIP:
case osg::PrimitiveSet::TRIANGLE_FAN:
case osg::PrimitiveSet::QUADS:
case osg::PrimitiveSet::QUAD_STRIP:
case osg::PrimitiveSet::POLYGON:
++numSurfacePrimitives;
break;
default:
break;
}
}
if (!numSurfacePrimitives) return;
// exit if no vertices
osg::Vec3Array *coords = dynamic_cast<osg::Vec3Array*>(geom.getVertexArray());
if (!coords || !coords->size()) return;
// generate the normals
osg::Vec3Array *normals = new osg::Vec3Array(coords->size());
osg::TriangleIndexFunctor<FacetingOperator> ftif;
ftif.set( coords, normals );
geom.accept(ftif);
geom.setNormalArray( normals );
geom.setNormalIndices( geom.getVertexIndices() );
geom.setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
geom.dirtyDisplayList();
}
示例2: if
void
MeshConsolidator::convertToTriangles( osg::Geometry& geom, bool force )
{
if ( !force && !canOptimize(geom) )
return;
osg::Geometry::PrimitiveSetList& primSets = geom.getPrimitiveSetList();
osg::Geometry::PrimitiveSetList triSets, nonTriSets;
for( osg::Geometry::PrimitiveSetList::iterator i = primSets.begin(); i != primSets.end(); ++i )
{
osg::PrimitiveSet* pset = i->get();
switch( pset->getMode() )
{
case osg::PrimitiveSet::TRIANGLES:
case osg::PrimitiveSet::TRIANGLE_STRIP:
case osg::PrimitiveSet::TRIANGLE_FAN:
case osg::PrimitiveSet::QUADS:
case osg::PrimitiveSet::QUAD_STRIP:
case osg::PrimitiveSet::POLYGON:
triSets.push_back( pset );
break;
default:
nonTriSets.push_back( pset );
}
}
if ( triSets.size() > 0 )
{
// we are assuming at this point that all the primitive sets in a single geometry
// share a single user data structure.
osg::Referenced* sharedUserData = triSets[0]->getUserData();
osg::Array* vertexArray = geom.getVertexArray();
unsigned numVerts = vertexArray->getNumElements();
osg::Geometry::PrimitiveSetList newPrimSets;
if ( numVerts < 0x100 )
{
osg::TriangleIndexFunctor< Collector<osg::DrawElementsUByte> > collector;
collector._newPrimSets = &newPrimSets;
collector._maxSize = 0xFF;
geom.accept( collector );
}
else if ( numVerts < 0x10000 )
{
osg::TriangleIndexFunctor< Collector<osg::DrawElementsUShort> > collector;
collector._newPrimSets = &newPrimSets;
collector._maxSize = 0xFFFF;
geom.accept( collector );
}
else
{
#ifdef OSG_GLES2_AVAILABLE
// GLES only supports UShort, not UInt
osg::TriangleIndexFunctor< Collector<osg::DrawElementsUShort> > collector;
collector._newPrimSets = &newPrimSets;
collector._maxSize = 0xFFFF;
geom.accept( collector );
#else
osg::TriangleIndexFunctor< Collector<osg::DrawElementsUInt> > collector;
collector._newPrimSets = &newPrimSets;
collector._maxSize = 0xFFFFFFFF;
geom.accept( collector );
#endif
}
for( osg::Geometry::PrimitiveSetList::iterator i = newPrimSets.begin(); i != newPrimSets.end(); ++i )
{
i->get()->setUserData( sharedUserData );
nonTriSets.push_back( i->get() );
}
}
geom.setPrimitiveSetList( nonTriSets );
}