本文整理汇总了C++中osg::Geode::getDrawable方法的典型用法代码示例。如果您正苦于以下问题:C++ Geode::getDrawable方法的具体用法?C++ Geode::getDrawable怎么用?C++ Geode::getDrawable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::Geode
的用法示例。
在下文中一共展示了Geode::getDrawable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
void OptTexture::apply(osg::Geode& geode)
{
// if(geode.getStateSet())
// {
// apply(geode.getStateSet());
// }
unsigned int cnt = geode.getNumDrawables();
for(unsigned int i = 0; i < cnt; i++)
{
//20130915 MYF模型深度测试不正确
osg::StateSet *stateset = geode.getDrawable(i)->getOrCreateStateSet();
stateset->setMode(GL_BLEND,osg::StateAttribute::ON); //取消深度测试
stateset->setMode( GL_DEPTH_TEST, osg::StateAttribute::ON );
// stateset->setMode( GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED );
//stateset->setRenderBinDetails(0, "RenderBin");
//设置渲染优先级------级别理论上来讲 比你背景的node靠后就行,没设置过的是-1.
geode.getDrawable(i)->setStateSet(stateset);
//geode.getDrawable(i)->getStateSet()->setRenderBinMode(osg::StateSet::RenderBinMode::INHERIT_RENDERBIN_DETAILS);
// apply(geode.getDrawable(i)->getStateSet());
}
traverse(geode);
}
示例2: apply
void GeometryDataCollector::apply( osg::Geode& node )
{
//osg::Matrix matrix = osg::computeLocalToWorld( node.getParentalNodePaths()[0] );
osg::Matrix matrix;
if ( matrixStack.size()>0 ) matrix = matrixStack.back();
for ( unsigned int i=0; i<node.getNumDrawables(); ++i )
{
osg::Geometry* geom = node.getDrawable(i)->asGeometry();
if ( geom )
{
osg::Vec3Array* va = dynamic_cast<osg::Vec3Array*>( geom->getVertexArray() );
numTotalVertices += (va ? va->size() : 0);
osg::TriangleFunctor<CollectFaceOperator> functor;
functor.collector = this;
functor.matrix = matrix;
geom->accept( functor );
}
else
{
osg::TriangleFunctor<CollectFaceOperator> functor;
functor.collector = this;
functor.matrix = matrix;
node.getDrawable(i)->accept( functor );
}
}
traverse( node );
}
示例3: apply
void ProjectVisitor::apply(osg::Geode& node)
{
if (_clearEveryDrawable)
_projector.clear();
std::vector<osg::Drawable*> toremove;
std::vector<osg::ref_ptr<osg::Geometry> > toadd;
for (int i = 0; i < node.getNumDrawables(); i++) {
osg::Timer_t t0 = osg::Timer::instance()->tick();
node.getDrawable(i)->accept(_projector);
double duration = osg::Timer::instance()->delta_s(t0, osg::Timer::instance()->tick());
if (_projector.hasGeometry()) {
toremove.push_back(node.getDrawable(i));
std::stringstream ss;
ss << "projected_" << _index << ".osg";
osg::notify(osg::INFO) << "duration " << duration << " " << ss.str() << std::endl;
if (_writeResultOnDisk)
_projector.write(ss.str());
if (!_mergeGeometry) {
osg::ref_ptr<osg::Geometry> result = _projector._result.get();
result->setUserData(node.getDrawable(i)->getUserData());
toadd.push_back(result);
_projector.clear();
}
}
_index++;
_cummulatedTime += duration;
}
if (_mergeGeometry) {
if (_projector.hasGeometry()) {
toadd.push_back(_projector._result.get());
}
}
for (int i = 0; i < toremove.size(); i++) // remove only where success to project data
node.removeDrawable(toremove[i]);
for (int i = 0; i < toadd.size(); i++) {// remove only where success to project data
node.addDrawable(toadd[i]);
}
if (_projectToXYZ) {
osg::ref_ptr<LatLongHeight2xyz> visitor = new LatLongHeight2xyz();
node.accept(*visitor);
}
// smooth after project
if (_smooth) {
osgUtil::SmoothingVisitor smooth;
for (int i = 0; i < toadd.size(); i++) {// remove only where success to project data
smooth.smooth(*toadd[i]);
}
}
}
示例4: apply
virtual void apply(osg::Geode& geode)
{
apply(geode.getStateSet());
for(unsigned int i=0; i<geode.getNumDrawables(); ++i)
{
apply(geode.getDrawable(i)->getStateSet());
osg::Geometry* geometry = geode.getDrawable(i)->asGeometry();
if (geometry) apply(geometry);
}
}
示例5: apply
void apply(osg::Geode& geode)
{
if (_visited.count(&geode)!=0) return;
_visited.insert(&geode);
if (geode.getStateSet()) apply(*(geode.getStateSet()));
for(unsigned int i=0; i<geode.getNumDrawables(); ++i)
{
if (geode.getDrawable(i)->getStateSet()) apply(*(geode.getDrawable(i)->getStateSet()));
osg::Geometry* geom = geode.getDrawable(i)->asGeometry();
if (geom) apply(*geom);
}
}
示例6: apply
void
ShaderGenerator::apply( osg::Geode& geode )
{
osg::ref_ptr<osg::StateSet> ss = geode.getStateSet();
if ( ss.valid() )
{
_state->pushStateSet( ss.get() );
osg::ref_ptr<osg::StateSet> replacement;
if ( processGeometry(ss.get(), replacement) )
{
_state->popStateSet();
geode.setStateSet( replacement.get() );
_state->pushStateSet( replacement.get() );
}
}
for( unsigned d = 0; d < geode.getNumDrawables(); ++d )
{
apply( geode.getDrawable(d) );
}
if ( ss.valid() )
{
_state->popStateSet();
}
}
示例7: apply
void LODVisitor::apply( osg::Geode& node )
{
unsigned int numDrawables = node.getNumDrawables();
for ( unsigned int cnt = 0; cnt < numDrawables; ++cnt )
{
osg::Drawable* p_drawable = node.getDrawable( cnt );
osg::Geometry* p_geom = p_drawable->asGeometry();
// evaluate the geom and generate an appropriate collision geometry
if ( p_geom )
{
p_drawable->setUseDisplayList( false );
p_drawable->setSupportsDisplayList( false );
osg::ref_ptr< GLODMesh > p_lodmesh = new GLODMesh( p_geom );
p_lodmesh->createObject( *( _p_lodSettings.get() ) );
// the actual lod mesh object is stored in geometry object, the following update and draw callbacks hold references to it
p_geom->setUserData( p_lodmesh.get() );
LODDrawCallback* p_cbdraw = new LODDrawCallback( p_lodmesh.get() );
p_geom->setDrawCallback( p_cbdraw );
//! TODO get the adaptation period from lod settings!
LODUpdateCallback* p_cbupdate = new LODUpdateCallback( p_lodmesh.get(), 1.0 );
p_geom->setUpdateCallback( p_cbupdate );
}
}
}
示例8: apply
virtual void apply(osg::Geode &n) {
unsigned int nDraws = n.getNumDrawables();
for (unsigned int idraw = 0 ; idraw < nDraws; ++idraw) {
osg::Geometry *geom = n.getDrawable( idraw )->asGeometry();
osg::Vec3Array *v = static_cast<osg::Vec3Array*>(geom->getVertexArray());
osg::Vec4Array *vc = static_cast<osg::Vec4Array*>(geom->getColorArray());
osg::Vec3Array *vn = static_cast<osg::Vec3Array*>(geom->getNormalArray());
osg::Vec2Array *vt = static_cast<osg::Vec2Array*>(geom->getTexCoordArray(0));
if (geom) {
unsigned int nPrims = geom->getNumPrimitiveSets();
for (unsigned int iprim = 0; iprim < nPrims; ++iprim) {
osg::PrimitiveSet *p = geom->getPrimitiveSet(iprim);
for (GLsizei i = 0; i < p->getNumIndices(); ++i) {
_s.vertexPositions.col(_idx) = toE(v->at(p->index(i)));
if (_opts & ConvertVertexColors)
_s.vertexColors.col(_idx) = toE(vc->at(p->index(i)));
if (_opts & ConvertVertexNormals)
_s.vertexNormals.col(_idx) = toE(vn->at(p->index(i))).normalized();
if (_opts & ConvertVertexUVs) {
_s.vertexUVs.col(_idx) = toE(vt->at(p->index(i)));
}
++_idx;
}
}
}
}
traverse(n);
}
示例9: apply
virtual void apply(osg::Geode& node)
{
for (int i=0;i<_indent;++i)
{
std::cout<<" ";
}
std::cout<<"["<<_indent+1<<"]"<<node.libraryName()
<<"::"<<node.className()<<std::endl;
for (unsigned int n=0;n<node.getNumDrawables();++n)
{
osg::Drawable *drawable=node.getDrawable(n);
if(!drawable)continue;
for (int i=0;i<_indent;++i)
{
for (int i=0;i<_indent;++i)
{
std::cout<<" ";
}
std::cout<<drawable->libraryName()<<"::"
<<drawable->className()<<std::endl;
}
_indent++;
traverse(node);
_indent--;
}
}
示例10: apply
void WriterNodeVisitor::apply( osg::Geode &node )
{
pushStateSet(node.getStateSet());
//_nameStack.push_back(node.getName());
unsigned int count = node.getNumDrawables();
ListTriangle listTriangles;
bool texcoords = false;
for ( unsigned int i = 0; i < count; i++ )
{
osg::Geometry *g = node.getDrawable( i )->asGeometry();
if ( g != NULL )
{
pushStateSet(g->getStateSet());
createListTriangle(g, listTriangles, texcoords, i); // May set _succeded to false
popStateSet(g->getStateSet());
if (!succeeded()) break;
}
}
if (succeeded() && count > 0)
{
#if DISABLE_3DS_ANIMATION
osg::Matrix mat( osg::computeLocalToWorld(getNodePath()) );
buildFaces(node, mat, listTriangles, texcoords); // May set _succeded to false
#else
buildFaces(node, osg::Matrix(), listTriangles, texcoords); // May set _succeded to false
#endif
}
popStateSet(node.getStateSet());
//_nameStack.pop_back();
if (succeeded())
traverse(node);
}
示例11: LODCallback
void
ConvertToDrawInstanced::apply( osg::Geode& geode )
{
for( unsigned d=0; d<geode.getNumDrawables(); ++d )
{
osg::Geometry* geom = geode.getDrawable(d)->asGeometry();
if ( geom )
{
if ( _optimize )
{
// activate VBOs
geom->setUseDisplayList( false );
geom->setUseVertexBufferObjects( true );
}
geom->setInitialBound(_bbox);
// convert to use DrawInstanced
for( unsigned p=0; p<geom->getNumPrimitiveSets(); ++p )
{
osg::PrimitiveSet* ps = geom->getPrimitiveSet(p);
ps->setNumInstances( _numInstances );
_primitiveSets.push_back( ps );
}
#ifdef USE_INSTANCE_LODS
geom->setDrawCallback( new LODCallback() );
#endif
}
}
traverse(geode);
}
示例12: apply
void apply( osg::Geode& geode )
{
for( unsigned d=0; d<geode.getNumDrawables(); ++d )
{
osg::Geometry* geom = geode.getDrawable(d)->asGeometry();
if ( geom )
{
if ( _optimize )
{
// activate VBOs
geom->setUseDisplayList( false );
geom->setUseVertexBufferObjects( true );
}
//geom->setComputeBoundingBoxCallback( new StaticBoundingBox(_bb));
//geom->setComputeBoundingBoxCallback(NULL);
geom->setInitialBound(_bb);
//geom->dirtyBound();
// convert to use DrawInstanced
for( unsigned p=0; p<geom->getNumPrimitiveSets(); ++p )
{
osg::PrimitiveSet* ps = geom->getPrimitiveSet(p);
ps->setNumInstances( _numInstances );
_primitiveSets.push_back( ps );
}
_geometries.push_back(geom);
}
}
traverse(geode);
}
示例13: apply
virtual void apply(osg::Geode& geode)
{
for (unsigned i=0; i<geode.getNumDrawables(); ++i)
{
osg::Geometry *geo = dynamic_cast<osg::Geometry *>(geode.getDrawable(i));
if (!geo) continue;
osg::StateSet *stateset = geo->getStateSet();
if (!stateset) continue;
osg::StateAttribute *state = stateset->getAttribute(osg::StateAttribute::MATERIAL);
if (!state) continue;
osg::Material *mat = dynamic_cast<osg::Material *>(state);
if (!mat) continue;
const osg::Vec4 v4 = mat->getDiffuse(FAB);
if (v4.r() == 1.0f && v4.g() == 0.0f && v4.b() == 1.0f)
{
//VTLOG("oldmat rc %d, ", mat->referenceCount());
osg::Material *newmat = (osg::Material *)mat->clone(osg::CopyOp::DEEP_COPY_ALL);
newmat->setDiffuse(FAB, osg::Vec4(c.r*2/3,c.g*2/3,c.b*2/3,1));
newmat->setAmbient(FAB, osg::Vec4(c.r*1/3,c.g*1/3,c.b*1/3,1));
//VTLOG("newmat rc %d\n", newmat->referenceCount());
stateset->setAttribute(newmat);
//VTLOG(" -> %d %d\n", mat->referenceCount(), newmat->referenceCount());
}
}
osg::NodeVisitor::apply(geode);
}
示例14: apply
void ComputeCylinderVisitor::apply( osg::Geode & geode )
{
for( unsigned int i = 0; i < geode.getNumDrawables(); ++i )
{
applyDrawable( geode.getDrawable( i ) );
}
}
示例15: traverse
void
ConvertToDrawInstanced::apply( osg::Geode& geode )
{
for( unsigned d=0; d<geode.getNumDrawables(); ++d )
{
osg::Geometry* geom = geode.getDrawable(d)->asGeometry();
if ( geom )
{
if ( _optimize )
{
//osgUtil::IndexMeshVisitor imv;
//imv.makeMesh( *geom );
// activate VBOs
geom->setUseDisplayList( false );
geom->setUseVertexBufferObjects( true );
}
geom->setComputeBoundingBoxCallback( _staticBBoxCallback.get() );
geom->dirtyBound();
// convert to use DrawInstanced
for( unsigned p=0; p<geom->getNumPrimitiveSets(); ++p )
{
geom->getPrimitiveSet(p)->setNumInstances( _numInstances );
}
}
}
traverse(geode);
}