本文整理汇总了C++中osg::Geode类的典型用法代码示例。如果您正苦于以下问题:C++ Geode类的具体用法?C++ Geode怎么用?C++ Geode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Geode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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);
}
开发者ID:whztt07,项目名称:osgVegetation,代码行数:32,代码来源:MRTShaderInstancing.cpp
示例2: 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);
}
开发者ID:kamalsirsa,项目名称:vtp,代码行数:33,代码来源:Vehicles.cpp
示例3: 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);
}
开发者ID:cumtmyf,项目名称:MFC_Viewer,代码行数:25,代码来源:MFC_OSG.cpp
示例4: 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);
}
开发者ID:energonQuest,项目名称:dtEarth,代码行数:31,代码来源:DrawInstanced.cpp
示例5: apply
void
ShaderGenerator::apply( osg::Geode& geode )
{
if ( !_active ) return;
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();
// optimize state set sharing
if ( _stateSetCache.valid() )
_stateSetCache->share(replacement, replacement);
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();
}
}
开发者ID:myemail2235,项目名称:osgearth,代码行数:35,代码来源:ShaderGenerator.cpp
示例6: 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);
}
开发者ID:artoolkit,项目名称:osg,代码行数:32,代码来源:WriterNodeVisitor.cpp
示例7: apply
void ComputeCylinderVisitor::apply( osg::Geode & geode )
{
for( unsigned int i = 0; i < geode.getNumDrawables(); ++i )
{
applyDrawable( geode.getDrawable( i ) );
}
}
开发者ID:AditGame,项目名称:Adit,代码行数:7,代码来源:ComputeCylinderVisitor.cpp
示例8: 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);
}
开发者ID:ldelgass,项目名称:osgearth,代码行数:33,代码来源:DrawInstanced.cpp
示例9: apply
void CURRENT_CLASS::apply(osg::Geode &geode)
{
// Contained drawables will only be individually considered if we are
// allowed to continue traversing.
if(shouldContinueTraversal(geode))
{
osg::Drawable *drawable;
double zNear, zFar;
// Handle each drawable in this geode
for(unsigned int i = 0; i < geode.getNumDrawables(); ++i)
{
drawable = geode.getDrawable(i);
const osg::BoundingBox &bb = drawable->getBound();
if(bb.valid())
{
bool containsTest = _localFrusta.back().contains(bb);
// Make sure drawable will be visible in the scene
if(!containsTest)
continue;
// Compute near/far distances for current drawable
zNear = distanceDA(bb.corner(_bbCorners.back().first),
_viewMatrices.back());
zFar = distanceDA(bb.corner(_bbCorners.back().second),
_viewMatrices.back());
if(zNear > zFar)
std::swap(zNear,zFar);
pushDistancePair(zNear,zFar);
}
}
}
}
开发者ID:dacevedofeliz,项目名称:calvr,代码行数:34,代码来源:DistanceAccumulator.cpp
示例10: 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();
}
}
开发者ID:ReWeb3D,项目名称:osgearth,代码行数:27,代码来源:ShaderGenerator.cpp
示例11: 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 );
}
}
}
开发者ID:BackupTheBerlios,项目名称:yag2002-svn,代码行数:27,代码来源:vrc_lod.cpp
示例12: 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);
}
开发者ID:cheind,项目名称:gpu-bake,代码行数:30,代码来源:convert_surface.cpp
示例13: 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--;
}
}
开发者ID:mapleyustat,项目名称:EAView,代码行数:27,代码来源:EAView.cpp
示例14: incStatistics
void
GeometryModifier::apply( osg::Geode& geode )
{
// merge drawables if possible for best results
if (getDrawableMerge())
{
osgUtil::Optimizer::MergeGeometryVisitor mgv;
mgv.setTargetMaximumNumberOfVertices(1000000);
mgv.mergeGeode(geode);
}
for(unsigned int i=0;i<geode.getNumDrawables();++i)
{
_drawableCount++;
osg::ref_ptr< osg::Geometry > geometry = geode.getDrawable(i)->asGeometry();
if( geometry.valid() )
{
_geometryCount++;
if( geometry->containsSharedArrays() )
osg::notify( osg::DEBUG_INFO ) << "Warning! Geometry contains shared arrays" << std::endl;
// Get statistics before
incStatistics( geometry.get(), _preVertices, _preIndices, _preTriangles );
osg::ref_ptr< osg::Geometry > newGeom = (*_geomOp)( *geometry );
geode.replaceDrawable( geometry.get(), newGeom.get() );
// Get statistics after
incStatistics( newGeom.get(), _postVertices, _postIndices, _postTriangles );
}
}
}
开发者ID:NaohiroHayashi,项目名称:bulletsim,代码行数:32,代码来源:GeometryModifier.cpp
示例15: 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 );
}
开发者ID:caomw,项目名称:osgPhysX,代码行数:28,代码来源:PhysicsUtil.cpp
示例16:
void osgToy::FacetingVisitor::apply(osg::Geode& geode)
{
for(unsigned int i = 0; i < geode.getNumDrawables(); i++ )
{
osg::Geometry* geom = dynamic_cast<osg::Geometry*>(geode.getDrawable(i));
if (geom) facet(*geom);
}
}
开发者ID:mew-cx,项目名称:osgtoy,代码行数:8,代码来源:FacetingVisitor.cpp
示例17: apply
void apply(osg::Geode& node)
{
apply((osg::Node&)node);
for(unsigned int i=0;i<node.getNumDrawables();++i)
{
osg::Drawable* drawable = node.getDrawable(i);
if (drawable->getStateSet()) process(drawable->getStateSet());
}
}
开发者ID:BriacB,项目名称:osg,代码行数:9,代码来源:SlideEventHandler.cpp
示例18: apply
void DisableFreezeOnCullVisitor::apply(osg::Geode &geode)
{
for (unsigned int i=0; i<geode.getNumDrawables(); ++i)
{
osg::Drawable* drw = geode.getDrawable(i);
if (osgParticle::ParticleSystem* partsys = dynamic_cast<osgParticle::ParticleSystem*>(drw))
partsys->setFreezeOnCull(false);
}
}
开发者ID:Pjstaab,项目名称:openmw,代码行数:9,代码来源:visitor.cpp
示例19: apply
void PhysicsVisitor::apply( osg::Geode& node )
{
// retrieve the node mask which is used for physics material and later for other properies
// only the first byte is relevant for pyhsics material description
_attribute = node.getNodeMask() & 0xFF;
// this means no need for building static collision geom
// this is not the same as MAT_NOCOL, as MAT_NOCOL collisions are detected
if ( _attribute == Physics::NO_BUILD )
return;
// get the accumulated world matrix for this node
osg::Matrixf mat = computeLocalToWorld( getNodePath() );
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 )
{
osg::Array* p_verts = p_geom->getVertexArray();
osg::IndexArray* p_indices = p_geom->getVertexIndices();
unsigned int numPrims = p_geom->getNumPrimitiveSets();
{
for ( unsigned int primcnt = 0; primcnt < numPrims; ++primcnt )
{
osg::PrimitiveSet* p_set = p_geom->getPrimitiveSet( primcnt );
switch( p_set->getMode() )
{
case osg::PrimitiveSet::POINTS:
case osg::PrimitiveSet::LINES:
case osg::PrimitiveSet::LINE_STRIP:
case osg::PrimitiveSet::LINE_LOOP:
return;
case osg::PrimitiveSet::TRIANGLES:
buildTrianlges( p_set, p_verts, mat, p_indices );
break;
case osg::PrimitiveSet::TRIANGLE_STRIP:
buildTrianlgeStrip( p_set, p_verts, mat, p_indices );
break;
case osg::PrimitiveSet::TRIANGLE_FAN:
case osg::PrimitiveSet::QUADS:
case osg::PrimitiveSet::QUAD_STRIP:
case osg::PrimitiveSet::POLYGON:
default:
log_error << "Physics Serializer: unsupported primitive set for physics geometry! currently only TRIANGLES and TRIANGLE_STRIP types are supported." << std::endl;
}
}
}
}
}
}
开发者ID:BackupTheBerlios,项目名称:yag2002-svn,代码行数:57,代码来源:physics_helpers.cpp
示例20: apply
virtual void apply( osg::Geode& geode )
{
for( unsigned int i=0; i<geode.getNumDrawables(); i++ )
{
osg::StateSet* ss = geode.getDrawable( i )->getStateSet();
if ( ss ) rewrite( ss );
osg::NodeVisitor::apply( geode );
}
}
开发者ID:aarnchng,项目名称:osggis,代码行数:9,代码来源:LayerCompiler.cpp
注:本文中的osg::Geode类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论