本文整理汇总了C++中osg::Node类的典型用法代码示例。如果您正苦于以下问题:C++ Node类的具体用法?C++ Node怎么用?C++ Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
virtual void apply(osg::Node& node)
{
if (node.getStateSet())
{
node.setStateSet(0);
++_numStateSetRemoved;
}
traverse(node);
}
示例2: apply
virtual void apply(osg::Node& node)
{
for(int i=0;i<_indent;++i)
std::cout<<" ";
std::cout<<"["<<_indent+1<<"]"<<node.libraryName()
<<"::"<<node.className()<<std::endl;
_indent++;
traverse(node);
_indent--;
}
示例3: traverse
void
CountStateSets::apply( osg::Node& node )
{
if( !processStateSet( node.getStateSet() ) && _removeEmptyStateSets )
{
node.setStateSet( NULL );
_removedStateSets++;
}
traverse( node );
}
示例4: apply
void RemoveQueries::apply( osg::Node& node )
{
QueryCullCallback* qcc = dynamic_cast< QueryCullCallback* >(
node.getCullCallback() );
if( qcc != NULL )
node.setCullCallback( NULL );
traverse( node );
}
示例5: setMaterialColor
void osgManipulator::setMaterialColor(const osg::Vec4& color, osg::Node& node)
{
osg::Material* mat = dynamic_cast<osg::Material*>(node.getOrCreateStateSet()->getAttribute(osg::StateAttribute::MATERIAL));
if (! mat)
{
mat = new osg::Material;
node.getOrCreateStateSet()->setAttribute(mat);
}
mat->setDiffuse(osg::Material::FRONT_AND_BACK, color);
}
示例6: apply
void apply( osg::Node& node )
{
if ( !node.getName().empty() )
{
output() << node.getName() << std::endl;
enter();
traverse( node );
leave();
}
else osgUtil::PrintVisitor::apply(node);
}
示例7: getNodeName
// ### provide a name to node
std::string daeWriter::getNodeName(const osg::Node &node, const std::string &defaultName)
{
std::string nodeName;
if (node.getName().empty())
nodeName = uniquify(defaultName);
else
nodeName = uniquify(node.getName());
return nodeName;
}
示例8: apply
void ShaderVisitor::apply(osg::Node& node)
{
if (node.getStateSet())
{
pushRequirements();
applyStateSet(node.getStateSet(), node);
traverse(node);
popRequirements();
}
else
traverse(node);
}
示例9: ext
osgDB::ReaderWriter::WriteResult
ReaderWriterDAE::writeNode( const osg::Node& node,
const std::string& fname, const osgDB::ReaderWriter::Options* options ) const
{
SERIALIZER();
bool bOwnDAE = false;
DAE* pDAE = NULL;
std::string ext( osgDB::getLowerCaseFileExtension(fname) );
if( ! acceptsExtension(ext) ) return WriteResult::FILE_NOT_HANDLED;
// Process options
osgDAE::daeWriter::Options pluginOptions;
std::string srcDirectory( osgDB::getFilePath(node.getName().empty() ? fname : node.getName()) ); // Base dir when relativising images paths
if( options )
{
pDAE = (DAE*)options->getPluginData("DAE");
const std::string & baseDir = options->getPluginStringData("baseImageDir"); // Rename "srcModelPath" (and call getFilePath() on it)?
if (!baseDir.empty()) srcDirectory = baseDir;
const std::string & relativiseImagesPathNbUpDirs = options->getPluginStringData("DAE-relativiseImagesPathNbUpDirs");
if (!relativiseImagesPathNbUpDirs.empty()) {
std::istringstream iss(relativiseImagesPathNbUpDirs);
iss >> pluginOptions.relativiseImagesPathNbUpDirs;
}
// Sukender's note: I don't know why DAE seems to accept comma-sparated options instead of space-separated options as other ReaderWriters. However, to avoid breaking compatibility, here's a workaround:
std::string optString( options->getOptionString() );
for(std::string::iterator it=optString.begin(); it!=optString.end(); ++it) {
if (*it == ' ') *it = ',';
}
std::istringstream iss( optString );
std::string opt;
//while (iss >> opt)
while( std::getline( iss, opt, ',' ) )
{
if( opt == "polygon") pluginOptions.usePolygons = true;
else if (opt == "GoogleMode") pluginOptions.googleMode = true;
else if (opt == "NoExtras") pluginOptions.writeExtras = false;
else if (opt == "daeEarthTex") pluginOptions.earthTex = true;
else if (opt == "daeZUpAxis") {} // Nothing (old option)
else if (opt == "daeLinkOriginalTexturesNoForce") { pluginOptions.linkOrignialTextures = true; pluginOptions.forceTexture = false; }
else if (opt == "daeLinkOriginalTexturesForce") { pluginOptions.linkOrignialTextures = true; pluginOptions.forceTexture = true; }
else if (opt == "daeNamesUseCodepage") pluginOptions.namesUseCodepage = true;
else if (!opt.empty())
{
OSG_NOTICE << std::endl << "COLLADA dae plugin: unrecognized option \"" << opt << std::endl;
}
}
}
示例10: handle
void SimpleDotVisitor::handle(osg::Node &node, int id)
{
std::stringstream label;
label << "<top> Node";
if (!node.getName().empty())
{
label << "| " << node.getName();
}
drawNode(id, "record", "solid", label.str(), "black", "white");
}
示例11: enter
bool PrimitiveIntersector::enter(const osg::Node& node)
{
if (reachedLimit()) return false;
osg::BoundingSphere bs = node.getBound();
if (bs.valid())
{
bs.radius() += (_thickness - _start).length();
}
return !node.isCullingActive() || intersects(bs);
}
示例12: isBasicRootNode
/// Returns true if the given node is a basic root group with no special information.
/// Used in conjunction with UseFbxRoot option.
/// Identity transforms are considered as basic root nodes.
bool isBasicRootNode(const osg::Node &node)
{
const osg::Group *osgGroup = node.asGroup();
if (!osgGroup || node.asGeode()) // WriterNodeVisitor handles Geodes the "old way" (= Derived from Node, not Group as for now). Geodes may be considered "basic root nodes" when WriterNodeVisitor will be adapted.
{
// Geodes & such are not basic root nodes
return false;
}
// Test if we've got an empty transform (= a group!)
const osg::Transform *transform = osgGroup->asTransform();
if (transform)
{
if (const osg::MatrixTransform *matrixTransform = transform->asMatrixTransform())
{
if (!matrixTransform->getMatrix().isIdentity())
{
// Non-identity matrix transform
return false;
}
}
else if (const osg::PositionAttitudeTransform *pat = transform->asPositionAttitudeTransform())
{
if (pat->getPosition() != osg::Vec3d() ||
pat->getAttitude() != osg::Quat() ||
pat->getScale() != osg::Vec3d(1.0f, 1.0f, 1.0f) ||
pat->getPivotPoint() != osg::Vec3d())
{
// Non-identity position attribute transform
return false;
}
}
else
{
// Other transform (not identity or not predefined type)
return false;
}
}
// Test the presence of a non-empty stateset
if (node.getStateSet())
{
osg::ref_ptr<osg::StateSet> emptyStateSet = new osg::StateSet;
if (node.getStateSet()->compare(*emptyStateSet, true) != 0)
{
return false;
}
}
return true;
}
示例13: OSG_VERSION_GREATER_THAN
void
ProxyCullVisitor::handle_cull_callbacks_and_traverse(osg::Node& node)
{
#if OSG_VERSION_GREATER_THAN(3,3,1)
osg::Callback* callback = node.getCullCallback();
if (callback) callback->run(&node, this);
else traverse(node);
#else
osg::NodeCallback* callback = node.getCullCallback();
if (callback) (*callback)(&node,this);
else traverse(node);
#endif
}
示例14: apply
virtual void apply(osg::Node& node)
{
std::cout
<< spaces()
<< node.libraryName()
<< "::"
<< node.className()
<< std::endl;
level_++;
traverse(node);
level_--;
}
示例15: traverse
void
ShaderGenerator::apply( osg::Node& node )
{
if ( !_active ) return;
if ( node.getStateSet() )
_state->pushStateSet( node.getStateSet() );
traverse(node);
if ( node.getStateSet() )
_state->popStateSet();
}