本文整理汇总了C++中NodePtr::findChild方法的典型用法代码示例。如果您正苦于以下问题:C++ NodePtr::findChild方法的具体用法?C++ NodePtr::findChild怎么用?C++ NodePtr::findChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodePtr
的用法示例。
在下文中一共展示了NodePtr::findChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: key
void key(unsigned char key, int, int)
{
switch ( key )
{
case 27: osgExit(); exit(0);
case 'a': glDisable( GL_LIGHTING );
std::cerr << "Lighting disabled." << std::endl;
break;
case 's': glEnable( GL_LIGHTING );
std::cerr << "Lighting enabled." << std::endl;
break;
case 'z': glPolygonMode( GL_FRONT_AND_BACK, GL_POINT);
std::cerr << "PolygonMode: Point." << std::endl;
break;
case 'x': glPolygonMode( GL_FRONT_AND_BACK, GL_LINE);
std::cerr << "PolygonMode: Line." << std::endl;
break;
case 'c': glPolygonMode( GL_FRONT_AND_BACK, GL_FILL);
std::cerr << "PolygonMode: Fill." << std::endl;
break;
case 'q':
if( activeIndex != 0 )
{
beginEditCP(root);
root->replaceChild( activeObj, objects[0] );
root->replaceChild( activeNorm, normals[0] );
activeObj = root->findChild( objects[0] );
activeNorm = root->findChild( normals[0] );
endEditCP(root);
activeIndex = 0;
}
break;
case 'w':
if( activeIndex != 1 )
{
beginEditCP(root);
root->replaceChild( activeObj, objects[1] );
root->replaceChild( activeNorm, normals[1] );
activeObj = root->findChild( objects[1] );
activeNorm = root->findChild( normals[1] );
endEditCP(root);
activeIndex = 1;
}
break;
case 'e':
if( activeIndex != 2 )
{
beginEditCP(root);
root->replaceChild( activeObj, objects[2] );
root->replaceChild( activeNorm, normals[2] );
activeObj = root->findChild( objects[2] );
activeNorm = root->findChild( normals[2] );
endEditCP(root);
activeIndex = 2;
}
break;
case 'r':
if( activeIndex != 3 )
{
beginEditCP(root);
root->replaceChild( activeObj, objects[3] );
root->replaceChild( activeNorm, normals[3] );
activeObj = root->findChild( objects[3] );
activeNorm = root->findChild( normals[3] );
endEditCP(root);
activeIndex = 3;
}
break;
}
}
示例2: main
//.........这里部分代码省略.........
obj3Pnts->addValue( Pnt3f(4, 0,0) );
endEditCP( obj3Pnts );
beginEditCP( obj3Types );
//obj3Types->addValue( GL_TRIANGLES );
//obj3Types->addValue( GL_QUADS );
//obj3Types->addValue( GL_TRIANGLES );
obj3Types->addValue( GL_POLYGON );
endEditCP( obj3Types );
beginEditCP( obj3Lengths );
//obj3Lengths->addValue( 3 );
//obj3Lengths->addValue( 4 );
//obj3Lengths->addValue( 3 );
obj3Lengths->addValue( 6 );
endEditCP( obj3Lengths );
beginEditCP( obj3Colors );
for( UInt32 i=0; i<obj3Pnts->getSize(); ++i )
{
obj3Colors->addValue( Color3f(.7,.7,.7) );
}
endEditCP( obj3Colors );
beginEditCP( obj3Index );
//for( UInt32 i=0; i<obj3Pnts->getSize(); ++i )
//{
// obj3Index->addValue( i );
//}
obj3Index->addValue( 0 );
obj3Index->addValue( 1 );
obj3Index->addValue( 5 );
obj3Index->addValue( 9 );
obj3Index->addValue( 6 );
obj3Index->addValue( 2 );
endEditCP( obj3Index );
beginEditCP( obj3Core );
obj3Core->setIndices( obj3Index );
obj3Core->setPositions( obj3Pnts );
obj3Core->setTypes( obj3Types );
obj3Core->setLengths( obj3Lengths );
obj3Core->setColors( obj3Colors );
endEditCP( obj3Core );
beginEditCP( objects[3] );
objects[3]->setCore( obj3Core );
endEditCP( objects[3] );
calcFaceNormals( GeometryPtr::dcast(objects[3]->getCore()) );
normals[3] = calcFaceNormalsGeo( GeometryPtr::dcast(objects[3]->getCore()), 0.5 );
//ROOT
root = Node::create();
GroupPtr rootCore = Group::create();
beginEditCP(root);
root->setCore(rootCore);
root->addChild(transNode);
root->addChild(objects[0]);
root->addChild(normals[0]);
activeObj = root->findChild( objects[0] );
activeNorm = root->findChild( normals[0] );
endEditCP(root);
camera = PerspectiveCamera::create();
camera->setBeacon( beaconNode );
camera->setFov( 90 );
camera->setNear( 0.1 );
camera->setFar( 10000 );
SolidBackgroundPtr background = SolidBackground::create();
viewp = Viewport::create();
viewp->setCamera( camera );
viewp->setBackground( background );
viewp->setRoot( root );
viewp->setSize( 0,0, 1,1 );
GLint glVP[4];
glGetIntegerv( GL_VIEWPORT, glVP );
GLUTWindowPtr gwin = GLUTWindow::create();
gwin->setId(winID);
gwin->setSize(glVP[2], glVP[3]);
window = gwin;
window->addPort( viewp );
window->init();
drAct = DrawAction::create();
Vec3f pos( 0, 0, 3 );
tball.setMode( Trackball::OSGObject );
tball.setStartPosition( pos, true );
tball.setSum( true );
tball.setTranslationMode( Trackball::OSGFree );
glutMainLoop();
return 0;
}