本文整理汇总了C++中osg::SimpleSceneManagerRefPtr::getRoot方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleSceneManagerRefPtr::getRoot方法的具体用法?C++ SimpleSceneManagerRefPtr::getRoot怎么用?C++ SimpleSceneManagerRefPtr::getRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::SimpleSceneManagerRefPtr
的用法示例。
在下文中一共展示了SimpleSceneManagerRefPtr::getRoot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyboard
//
// react to keys
//
void keyboard(unsigned char k, int, int)
{
static OSG::Real32 val0 = 0.f;
static OSG::Real32 val1 = 0.f;
static OSG::Real32 x1 = 0.f;
static OSG::Real32 y1 = 0.f;
static OSG::Real32 z1 = 0.f;
static OSG::Real32 x2 = 0.f;
static OSG::Real32 y2 = 0.f;
static OSG::Real32 z2 = 0.f;
switch(k)
{
case ' ':
{
OSG::SceneGraphPrinter sgp(mgr->getRoot());
sgp.printDownTree(std::cout);
}
break;
case '1': // enable/disable clip plane 0
{
vecClipPlaneData[0]._enabled = !vecClipPlaneData[0]._enabled;
updateClipPlanes(vecClipPlaneData);
}
break;
case '2': // enable/disable clip plane 1
{
vecClipPlaneData[1]._enabled = !vecClipPlaneData[1]._enabled;
updateClipPlanes(vecClipPlaneData);
}
break;
case '3': // enable/disable box geometry
{
if(vecGeometries[0] == NULL)
{
OSG::Matrix matrix;
OSG::Vec3f v(10.f, 0.f, 15.f);
matrix.setTranslate(v);
OSG::GeometryRefPtr boxGeo =
OSG::makeBoxGeo(15, 15, 15, 1, 1, 1);
OSG::NodeRefPtr boxTree = buildGeoTree(scene,
boxGeo,
matrix);
vecGeometries[0] = boxTree;
scene->addChild(boxTree);
}
else
{
scene->subChild(vecGeometries[0]);
vecGeometries[0] = NULL;
}
// mgr->showAll();
// mgr->redraw();
}
break;
case '4': // enable/disable torus geometry
{
if (vecGeometries[1] == NULL)
{
OSG::Matrix matrix;
OSG::Vec3f v( 0.f, 10.f, 0.f);
matrix.setTranslate(v);
OSG::GeometryRefPtr torusGeo = OSG::makeTorusGeo(2, 6, 8, 16);
OSG::NodeRefPtr torusTree = buildGeoTree(scene,
torusGeo, matrix);
vecGeometries[1] = torusTree;
scene->addChild(torusTree);
}
else
{
scene->subChild(vecGeometries[1]);
vecGeometries[1] = NULL;
}
// mgr->showAll();
// mgr->redraw();
}
break;
case '5':
{
OSG::SceneFileHandler::the()->write(mgr->getRoot(),
"clipplane_model.osb", true);
}
break;
case 'n': // move clip plane 0 opposite to the normal direction of the plane
{
val0 -= 0.2;
//.........这里部分代码省略.........
示例2: keyboard
//.........这里部分代码省略.........
{
(*ngIt)->setTravMask(OSG::TypeTraits<OSG::UInt32>::BitsSet);
}
std::cout << "Normals enabled" << std::endl;
}
}
break;
case 'm':
{
normalsLen /= 1.25f;
constructNormalsGeo(sceneN);
std::cout << "Normals length " << normalsLen << std::endl;
}
break;
case 'M':
{
normalsLen *= 1.25f;
constructNormalsGeo(sceneN);
std::cout << "Normals length " << normalsLen << std::endl;
}
break;
case 'v':
{
mgr->getRenderAction()->setVolumeDrawing(
!mgr->getRenderAction()->getVolumeDrawing());
std::cout << "Volume drawing: "
<< (mgr->getRenderAction()->getVolumeDrawing() ? "enabled" : "disabled")
<< std::endl;
}
break;
case 'p':
{
OSG::SceneGraphPrinter sgp(mgr->getRoot());
sgp.addPrintFunc(OSG::SkinnedGeometry::getClassType(),
&printVolume );
sgp.printDownTree(std::cout);
NodeStore::const_iterator nIt = skinnedGeoN.begin();
NodeStore::const_iterator nEnd = skinnedGeoN.end ();
for(OSG::UInt32 i = 0; nIt != nEnd; ++nIt, ++i)
{
OSG::SkinnedGeometry *sgeo = dynamic_cast<OSG::SkinnedGeometry *>(
(*nIt)->getCore());
std::cout << "Skeleton:\n";
OSG::SceneGraphPrinter skelPrinter(sgeo->getSkeleton()->getRoots(0));
skelPrinter.addPrintFunc(OSG::Transform ::getClassType(),
&printXForm );
//skelPrinter.addPrintFunc(OSG::SkeletonJoint::getClassType(),
// &printJoint );
skelPrinter.printDownTree(std::cout);
}
}
break;
case 'a':
{
mgr->showAll();
std::cout << "Showing all of scene." << std::endl;
}
break;
case '[':
示例3: keyboard
// react to keys
void keyboard(unsigned char k, int , int )
{
switch (k)
{
case 27:
{
mgr = NULL;
delete gTextStuff;
OSG::commitChanges();
OSG::osgExit();
exit(0);
}
break;
case '-':
gTextStuff->incFaceSize(false);
break;
case '=':
gTextStuff->incFaceSize(true);
break;
case '[':
gTextStuff->incTextureSize(false);
break;
case ']':
gTextStuff->incTextureSize(true);
break;
case '<':
gTextStuff->incMaxExtent(false);
break;
case '>':
gTextStuff->incMaxExtent(true);
break;
case ',':
gTextStuff->incLineSpacing(false);
break;
case '.':
gTextStuff->incLineSpacing(true);
break;
case '{':
gTextStuff->incGeoScale(false);
break;
case '}':
gTextStuff->incGeoScale(true);
break;
case 'f':
gTextStuff->goToNextFamily();
break;
case 'd':
OSG::SceneFileHandler::the()->write(mgr->getRoot(),"dump_scene.osb");
std::cout << "Wrote out scene: dump_scene.osb" << std::endl;
break;
case 't':
mgr->setNavigationMode(OSG::Navigator::TRACKBALL);
break;
case 'l':
mgr->setHeadlight(!mgr->getHeadlightState());
std::cout << "Set headlight: " << mgr->getHeadlightState() << 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 'h':
std::cerr << "Keys:" << std::endl;
std::cerr << "- =: change face size" << std::endl;
std::cerr << "{ }: change geo scale" << std::endl;
std::cerr << "[ ]: change texture size" << std::endl;
std::cerr << "< >: change max extend for 1st line" << std::endl;
std::cerr << ", .: change line spacing" << std::endl;
std::cerr << "f : next font family" << std::endl;
std::cerr << "d : dump scene" << std::endl;
}
}