本文整理汇总了C++中Geode::getDrawable方法的典型用法代码示例。如果您正苦于以下问题:C++ Geode::getDrawable方法的具体用法?C++ Geode::getDrawable怎么用?C++ Geode::getDrawable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geode
的用法示例。
在下文中一共展示了Geode::getDrawable方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
void ShadowVolumeGeometryGenerator::apply( Geode& geode )
{
StateSet *ss = geode.getStateSet();
if(ss)
setCurrentFacingAndOrdering(ss);
if( geode.getStateSet() )
pushState( geode.getStateSet() );
for( unsigned int i=0; i<geode.getNumDrawables(); ++i )
{
Drawable* drawable = geode.getDrawable( i );
if( drawable->getStateSet() )
pushState( drawable->getStateSet() );
apply( geode.getDrawable( i ) );
if( drawable->getStateSet() )
popState(drawable->getStateSet());
}
if(ss)
setCurrentFacingAndOrdering(ss);
if( geode.getStateSet() )
popState(geode);
}
示例2: apply
void POVWriterNodeVisitor::apply( Geode& node )
{
pushStateSet( node.getStateSet() );
// iterate through drawables
for(unsigned int i=0; i<node.getNumDrawables(); ++i)
{
// get drawable
const Drawable *d = node.getDrawable(i);
if (!d) continue;
// push state set
const StateSet *ss = d->getStateSet();
if( ss ) pushStateSet( ss );
// transformation matrix
Matrix m = _transformationStack.top();
// process lights
processLights( _stateSetStack.top().get(), m );
// process geometry
const Geometry *g = d->asGeometry();
if( g )
processGeometry( g, _stateSetStack.top().get(), m );
// pop state set
if( ss ) popStateSet( ss );
}
popStateSet( node.getStateSet() );
}
示例3: apply
void BaseDotVisitor::apply(Geode& node) {
int id;
if ( getOrCreateId( &node, id ) ) {
handle( node, id );
handleNodeAndTraverse( node, id );
unsigned int i;
for ( i = 0; i < node.getNumDrawables(); i++ ) {
osg::Drawable* drawable = node.getDrawable( i );
int id2;
if ( getOrCreateId( drawable, id2 ) ) {
handle( *drawable, id2 );
osg::StateSet* s = drawable->getStateSet();
if ( s ) {
int id3;
if ( getOrCreateId( s, id3 ) ) {
handle( *s, id3 );
}
handle( *drawable, *s, id2, id3 );
}
}
handle( node, *drawable, id, id2 );
}
}
}
示例4: applyTextures
void applyTextures(Group* root, vector<string>& fileVect, vector<Vec2Array*>& coordVect) {
/*osg::Vec4Array* colors = new osg::Vec4Array;
if (i == 29){
colors->push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
}
else{
colors->push_back(osg::Vec4(i/(float)numPlanes, i/(float)numPlanes, i/(float)numPlanes, 1.0f) );
}
planeGeometry->setColorArray(colors);
planeGeometry->setColorBinding(osg::Geometry::BIND_OVERALL);*/
for (int i = 0; i < fileVect.size(); i ++ ){
if (fileVect[i] == ""){
continue;
}
Geode* currGeode = (Geode*)root->getChild(i);
Geometry* currGeometry = (Geometry*)currGeode->getDrawable(0);
Vec2Array* currVectArray = coordVect[i];
osg::Vec2Array* texcoords = new osg::Vec2Array(currVectArray->size());
for (int j = 0; j < currVectArray->size(); j ++ ){
(*texcoords)[j].set(currVectArray->at(j)[0], currVectArray->at(j)[1]);
}
currGeometry->setTexCoordArray(0,texcoords);
osg::Texture2D* currTexture = new osg::Texture2D;
currTexture->setDataVariance(osg::Object::DYNAMIC);
osg::Image* currFace = osgDB::readImageFile(fileVect[i]);
currTexture->setImage(currFace);
osg::StateSet* state = new osg::StateSet;
state->setTextureAttributeAndModes(0, currTexture,osg::StateAttribute::ON);
currGeode->setStateSet(state);
}
}
示例5: apply
/** The 'apply' method for 'Geode' type instances
* @param searchNode : Geode : node that is searched
*/
void lgNodeOverseer::apply(Geode &searchNode)
{
cout << spaces() << "Géode :"<< searchNode.getName() << ", " << searchNode.getNumDrawables() << " drawables" << endl;
if(searchNode.getNumDrawables()>0 && showDrawable){
for (unsigned i=0;i<searchNode.getNumDrawables();i++)
{
_level++;
cout << spaces() << "Drawable " << i << " : " << searchNode.getDrawable(i)->getName() << endl;
ref_ptr<Geometry> myGeom = dynamic_cast<Geometry*>(searchNode.getDrawable(i));
if(myGeom)
{
ref_ptr<Vec3Array> arrayVertex = (Vec3Array*) myGeom->getVertexArray();
_level++;
int size = arrayVertex->size();
cout << spaces() << "Il y a " << size << " sommets" << endl;
for (int j=0; j<size;j++)
{
cout << spaces() << "Sommet " << j+1 << " : x=" << arrayVertex->at(j).x() <<
", y=" << arrayVertex->at(j).y() << ", z=" << arrayVertex->at(j).z() << endl;
}
_level--;
}
else
{
cout << "Pas de géométrie" << endl;
}
_level--;
}
cout << spaces() << endl;
}
// If no node is found, return searchNode
if (searchForName == "")
{
foundNodeList.push_back(&searchNode);
}
else
{
if (searchNode.getName() == searchForName)
{
foundNodeList.push_back(&searchNode);
}
_level++;
traverse(searchNode);
_level--;
}
}
示例6: apply
void IntersectVisitor::apply(Geode& geode)
{
if (!enterNode(geode)) return;
for(unsigned int i = 0; i < geode.getNumDrawables(); i++ )
{
intersect(*geode.getDrawable(i));
}
leaveNode();
}
示例7: apply
void StateSetVisitor::apply( Geode& geode )
{
StateSet *ss = geode.getStateSet();
if( ss )
apply( *ss );
for( unsigned int i=0; i<geode.getNumDrawables(); ++i )
apply( *geode.getDrawable( i ) );
traverse( geode );
}
示例8: apply
void DisplayRequirementsVisitor::apply(Geode& geode)
{
osg::StateSet* geode_stateset = geode.getStateSet();
if (geode_stateset) applyStateSet(*geode_stateset);
for(unsigned int i = 0; i < geode.getNumDrawables(); i++ )
{
osg::StateSet* stateset = geode.getDrawable(i)->getStateSet();
if (stateset) applyStateSet(*stateset);
}
}
示例9:
Drawable *Object3D::getDrawable(Node *node, unsigned int index)
{
GeodeFindVisitor visitor;
node->accept(visitor);
Geode *geode = visitor.getFirst();
if(geode)
{
Drawable *drawable = geode->getDrawable(index);
return drawable;
}
return NULL;
}
示例10: geom
void Object3D::dirty()
{
GeodeFindVisitor visitor;
_originalNode->accept(visitor);
std::vector<Geode*> geodeList = visitor.getGeodeList();
std::vector<Geode*>::iterator it;
for(it=geodeList.begin(); it!=geodeList.end(); ++it)
{
Geode *geode = *it;
if(geode)
{
for(unsigned int i=0; i<geode->getNumDrawables(); i++)
{
Drawable *drawable = geode->getDrawable(i);
drawable->dirtyBound();
Geometry* geom(drawable->asGeometry());
osgUtil::SmoothingVisitor sv;
sv.smooth(*geom);
geom->getNormalArray()->dirty();
}
}
}
}
示例11: apply
void ScreenMVCullVisitor::apply(Geode& node)
{
bool status = _cullingStatus;
bool firstStatus = _firstCullStatus;
if(isCulled(node))
{
_firstCullStatus = firstStatus;
_cullingStatus = status;
return;
}
// push the node's state.
StateSet* node_state = node.getStateSet();
if(node_state)
pushStateSet(node_state);
// traverse any call callbacks and traverse any children.
handle_cull_callbacks_and_traverse(node);
RefMatrix& matrix = *getModelViewMatrix();
for(unsigned int i = 0; i < node.getNumDrawables(); ++i)
{
Drawable* drawable = node.getDrawable(i);
const BoundingBox &bb = drawable->getBound();
if(drawable->getCullCallback())
{
if(drawable->getCullCallback()->cull(this,drawable,&_renderInfo)
== true)
continue;
}
//else
{
if(node.isCullingActive() && isCulled(bb))
continue;
}
if(_computeNearFar && bb.valid())
{
if(!updateCalculatedNearFar(matrix,*drawable,false))
continue;
}
// need to track how push/pops there are, so we can unravel the stack correctly.
unsigned int numPopStateSetRequired = 0;
// push the geoset's state on the geostate stack.
StateSet* stateset = drawable->getStateSet();
if(stateset)
{
++numPopStateSetRequired;
pushStateSet(stateset);
}
CullingSet& cs = getCurrentCullingSet();
if(!cs.getStateFrustumList().empty())
{
osg::CullingSet::StateFrustumList& sfl = cs.getStateFrustumList();
for(osg::CullingSet::StateFrustumList::iterator itr = sfl.begin();
itr != sfl.end(); ++itr)
{
if(itr->second.contains(bb))
{
++numPopStateSetRequired;
pushStateSet(itr->first.get());
}
}
}
float depth = bb.valid() ? distance(bb.center(),matrix) : 0.0f;
if(osg::isNaN(depth))
{
/*OSG_NOTIFY(osg::NOTICE)<<"CullVisitor::apply(Geode&) detected NaN,"<<std::endl
<<" depth="<<depth<<", center=("<<bb.center()<<"),"<<std::endl
<<" matrix="<<matrix<<std::endl;
OSG_NOTIFY(osg::DEBUG_INFO) << " NodePath:" << std::endl;
for (NodePath::const_iterator i = getNodePath().begin(); i != getNodePath().end(); ++i)
{
OSG_NOTIFY(osg::DEBUG_INFO) << " \"" << (*i)->getName() << "\"" << std::endl;
}*/
}
else
{
addDrawableAndDepth(drawable,&matrix,depth);
}
for(unsigned int i = 0; i < numPopStateSetRequired; ++i)
{
popStateSet();
}
}
// pop the node's state off the geostate stack.
if(node_state)
popStateSet();
_firstCullStatus = firstStatus;
//.........这里部分代码省略.........
示例12: v
void Normals::MakeNormalsVisitor::apply( Geode &geode )
{
for( unsigned int i = 0; i < geode.getNumDrawables(); i++ )
{
Geometry *geom = dynamic_cast<Geometry *>(geode.getDrawable(i));
if( geom )
{
if (geom->containsDeprecatedData()) geom->fixDeprecatedData();
Vec3Array *coords = dynamic_cast<Vec3Array*>(geom->getVertexArray());
if( coords == 0L )
continue;
Vec3Array *normals = dynamic_cast<Vec3Array*>(geom->getNormalArray());
if( normals == 0L )
continue;
Geometry::AttributeBinding binding = geom->getNormalBinding();
if( binding == Geometry::BIND_OFF )
continue;
if( binding == Geometry::BIND_OVERALL )
{
Vec3 v(0,0,0);
Vec3 n = normals->front();
Vec3Array::iterator coord_index = coords->begin();
while( coord_index != coords->end() )
v += *(coord_index++) * _mat;
v /= (float)(coords->size());
n *= _normal_scale;
_local_coords->push_back( v );
_local_coords->push_back( (v + n));
}
else // BIND_PER_PRIMITIVE_SET, BIND_PER_VERTEX
{
Geometry::PrimitiveSetList& primitiveSets = geom->getPrimitiveSetList();
Geometry::PrimitiveSetList::iterator itr;
Vec3Array::iterator coord_index = coords->begin();
Vec3Array::iterator normals_index = normals->begin();
for(itr=primitiveSets.begin(); itr!=primitiveSets.end(); ++itr)
{
#ifdef DEBUG
_printPrimitiveType( (*itr).get() );
#endif
if( binding == Geometry::BIND_PER_PRIMITIVE_SET )
{
Vec3 v(0,0,0);
Vec3 n = *(normals_index++);
int ni = (*itr)->getNumIndices();
for( int i = 0; i < ni; i++ )
v += *(coord_index++) * _mat;
v /= (float)(ni);
n *= _normal_scale;
_local_coords->push_back( v );
_local_coords->push_back( (v + n));
}
else
{
switch((*itr)->getMode())
{
case(PrimitiveSet::TRIANGLES):
{
for( unsigned int j = 0; j < (*itr)->getNumPrimitives(); j++ )
{
_processPrimitive( 3, coord_index, normals_index, binding );
coord_index += 3;
normals_index+=3;
}
break;
}
case(PrimitiveSet::TRIANGLE_STRIP):
{
for( unsigned int j = 0; j < (*itr)->getNumIndices()-2; j++ )
{
_processPrimitive( 3, coord_index, normals_index, binding );
coord_index++;
normals_index++;
}
coord_index += 2;
if( binding == Geometry::BIND_PER_VERTEX )
normals_index += 2;
break;
}
case(PrimitiveSet::TRIANGLE_FAN):
break;
case(PrimitiveSet::QUADS):
{
for( unsigned int j = 0; j < (*itr)->getNumPrimitives(); j++ )
{
_processPrimitive( 4, coord_index, normals_index, binding );
coord_index += 4;
normals_index +=4;
}
break;
//.........这里部分代码省略.........
示例13: v
void osgToy::Normals::MakeNormalsVisitor::apply( Geode &geode )
{
for( unsigned int i = 0; i < geode.getNumDrawables(); i++ )
{
osg::Geometry *geom = dynamic_cast<osg::Geometry *>(geode.getDrawable(i));
if( geom )
{
osg::Vec3Array *coords = dynamic_cast<osg::Vec3Array*>(geom->getVertexArray());
if( coords == 0L )
continue;
osg::Vec3Array *normals = dynamic_cast<osg::Vec3Array*>(geom->getNormalArray());
if( normals == 0L )
continue;
osg::Geometry::AttributeBinding binding = geom->getNormalBinding();
if( binding == osg::Geometry::BIND_OFF )
continue;
if( binding == osg::Geometry::BIND_OVERALL )
{
osg::Vec3 v(0,0,0);
osg::Vec3 n = normals->front();
osg::Vec3Array::iterator coord_index = coords->begin();
while( coord_index != coords->end() )
v += *(coord_index++);
v /= (float)(coords->size());
n *= _normal_scale;
_local_coords->push_back( v );
_local_coords->push_back( (v + n));
}
else // BIND_PER_PRIMTIVE_SET, BIND_PER_PRIMTITIV, BIND_PER_VERTEX
{
osg::Geometry::PrimitiveSetList& primitiveSets = geom->getPrimitiveSetList();
osg::Geometry::PrimitiveSetList::iterator itr;
osg::Vec3Array::iterator coord_index = coords->begin();
osg::Vec3Array::iterator normals_index = normals->begin();
for(itr=primitiveSets.begin(); itr!=primitiveSets.end(); ++itr)
{
if( binding == osg::Geometry::BIND_PER_PRIMITIVE_SET )
{
osg::Vec3 v(0,0,0);
osg::Vec3 n = *(normals_index++);
int ni = (*itr)->getNumIndices();
for( int i = 0; i < ni; i++ )
v += *(coord_index++);
v /= (float)(ni);
n *= _normal_scale;
_local_coords->push_back( v );
_local_coords->push_back( (v + n));
}
else
{
switch((*itr)->getMode())
{
case(osg::PrimitiveSet::TRIANGLES):
for( unsigned int j = 0; j < (*itr)->getNumPrimitives(); j++ )
{
_processPrimitive( 3, coord_index, normals_index, binding );
coord_index += 3;
if( binding == osg::Geometry::BIND_PER_PRIMITIVE )
normals_index++;
else
normals_index+=3;
}
break;
case(osg::PrimitiveSet::TRIANGLE_STRIP):
for( unsigned int j = 0; j < (*itr)->getNumIndices()-2; j++ )
{
_processPrimitive( 3, coord_index, normals_index, binding );
coord_index++;
normals_index++;
}
coord_index += 2;
if( binding == osg::Geometry::BIND_PER_VERTEX )
normals_index += 2;
break;
case(osg::PrimitiveSet::TRIANGLE_FAN):
break;
case(osg::PrimitiveSet::QUADS):
for( unsigned int j = 0; j < (*itr)->getNumPrimitives(); j++ )
{
_processPrimitive( 4, coord_index, normals_index, binding );
coord_index += 4;
if( binding == osg::Geometry::BIND_PER_PRIMITIVE )
normals_index++;
else
normals_index+=4;
}
break;
//.........这里部分代码省略.........