本文整理汇总了C++中osg::NodeUnrecPtr::getNChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeUnrecPtr::getNChildren方法的具体用法?C++ NodeUnrecPtr::getNChildren怎么用?C++ NodeUnrecPtr::getNChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::NodeUnrecPtr
的用法示例。
在下文中一共展示了NodeUnrecPtr::getNChildren方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
int init(int argc, char **argv)
{
OSG::osgInit(argc,argv);
// GLUT init
glutInit(&argc, argv);
glutInitDisplayMode( GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
int winid = glutCreateWindow("OpenSG");
glutKeyboardFunc(key);
glutVisibilityFunc(vis);
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutIdleFunc(display);
// glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
// glEnable( GL_DEPTH_TEST );
// glEnable( GL_LIGHTING );
// glEnable( GL_LIGHT0 );
// glFrontFace(GL_CW);
glEnable(GL_CULL_FACE);
// OSG
OSG::SceneFileHandler::the()->print();
// create the graph
// beacon for camera and light
OSG::NodeUnrecPtr b1n = OSG::Node::create();
OSG::GroupUnrecPtr b1 = OSG::Group::create();
b1n->setCore( b1 );
// transformation
OSG::NodeUnrecPtr t1n = OSG::Node::create();
OSG::TransformUnrecPtr t1 = OSG::Transform::create();
t1n->setCore( t1 );
t1n->addChild( b1n );
cam_trans = t1;
// light
OSG::NodeUnrecPtr dlight = OSG::Node::create();
OSG::DirectionalLightUnrecPtr dl = OSG::DirectionalLight::create();
dlight->setCore( dl );
// dlight->setCore( Group::create() );
dl->setAmbient( .0, .0, .0, 1 );
dl->setDiffuse( .8f, .8f, .8f, 1.f );
dl->setDirection(0,0,1);
dl->setBeacon( b1n);
// root
root = OSG::Node::create();
OSG::GroupUnrecPtr gr1 = OSG::Group::create();
root->setCore( gr1 );
root->addChild( t1n );
root->addChild( dlight );
// Load the file
OSG::NodeUnrecPtr file = NULL;
if(argc > 1)
file = OSG::SceneFileHandler::the()->read(argv[1], NULL);
if ( file == NULL )
{
std::cerr << "Couldn't load file, ignoring" << std::endl;
file = OSG::makeSphere(4, 2.0);
}
#if 0
OSG::GeometryPtr pGeo = cast_dynamic<OSG::GeometryPtr>(file->getCore());
if(pGeo == NULL && file->getNChildren() != 0)
{
pGeo = cast_dynamic<OSG::GeometryPtr>(file->getChild(0)->getCore());
}
if(pGeo == NULL)
{
fprintf(stderr, "no geo\n");
}
#endif
// OSG::GraphOpRefPtr op = OSG::GraphOpFactory::the()->create("Stripe");
// op->traverse(file);
//.........这里部分代码省略.........