本文整理汇总了C++中osg::NodeUnrecPtr::updateVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeUnrecPtr::updateVolume方法的具体用法?C++ NodeUnrecPtr::updateVolume怎么用?C++ NodeUnrecPtr::updateVolume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::NodeUnrecPtr
的用法示例。
在下文中一共展示了NodeUnrecPtr::updateVolume方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
//.........这里部分代码省略.........
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);
// createOptimizedPrimitives(pGeo);
// createSharedIndex(pGeo);
OSG::Thread::getCurrentChangeList()->commitChanges();
// file->dump();
file->updateVolume();
#if 0
const char *outFileName = "/tmp/foo1.osg";
OSG::IndentFileOutStream outFileStream(outFileName);
if( !outFileStream )
{
std::cerr << "Can not open output stream to file: "
<< outFileName << std::endl;
return -1;
}
std::cerr << "STARTING PRINTOUT:" << std::endl;
OSGWriter writer( outFileStream, 4 );
writer.write( file );
outFileStream.close();
OSG::SceneFileHandler::the()->write(file, "/tmp/foo.osb");
#endif
// return 0;
OSG::Vec3f min,max;
file->getVolume().getBounds( min, max );
std::cout << "Volume: from " << min << " to " << max << std::endl;
示例2: doMain
//.........这里部分代码省略.........
pCubeSceneRoot->setCore(pCubeVisit);
pCubeVisit->setSubTreeRoot(root);
pCubeGen->setRoot (pCubeSceneRoot);
pCubeGen->setTextureFormat(GL_RGB32F_ARB );
pCubeGen->setSize (512,
512 );
pCubeGen->setTexUnit (3);
// Cubemap Background
OSG::SolidBackgroundUnrecPtr cubeBkgnd = OSG::SolidBackground::create();
{
cubeBkgnd->setColor(OSG::Color3f(0.5f, 0.3f, 0.3f));
}
pCubeGen->setBackground(cubeBkgnd);
OSG::NodeUnrecPtr pAnimRoot = setupAnim();
scene_trans = OSG::Transform::create();
OSG::NodeUnrecPtr sceneTrN = OSG::Node::create();
scene_trans->editMatrix()[3][2] = -50.f;
sceneTrN->setCore (scene_trans);
sceneTrN->addChild(pCubeRoot );
sceneTrN->addChild(pAnimRoot );
OSG::Thread::getCurrentChangeList()->commitChanges();
OSG::Vec3f min,max;
sceneTrN->updateVolume();
sceneTrN->getVolume().getBounds(min, max);
std::cout << "Volume: from " << min << " to " << max << std::endl;
dlight->addChild(sceneTrN);
// Camera
cam = OSG::PerspectiveCamera::create();
{
cam->setBeacon( b1n );
cam->setFov( OSG::osgDegree2Rad( 90 ) );
cam->setNear( 0.1f );
cam->setFar( 100000 );
}
// Background
OSG::SolidBackgroundUnrecPtr bkgnd = OSG::SolidBackground::create();
{
bkgnd->setColor(OSG::Color3f(0.3f, 0.3f, 0.3f));
}
// Viewport
vp = OSG::Viewport::create();
{
vp->setCamera( cam );
vp->setBackground( bkgnd );
vp->setRoot( hdrroot );
// vp->setRoot( root );
vp->setSize( 0,0, 1,1 );
}
示例3: 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);
// 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);
dl->setAmbient (0.0, 0.0, 0.0, 1.0);
dl->setDiffuse (0.8, 0.8, 0.8, 1.0);
dl->setDirection(0.0, 0.0, 1.0 );
dl->setBeacon (b1n );
// root
OSG::NodeUnrecPtr 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);
file = OSG::Node::create();
OSG::AlgorithmStageUnrecPtr pStage = OSG::AlgorithmStage::create();
file->setCore(pStage);
pAlgo = OSG::GPUVolRTV2::create();
pStage->setAlgorithm(pAlgo);
// fix/freeze the node volume
file->editVolume().setStatic(true);
file->editVolume().setBounds( 0.f, 0.f, 0.f,
1.f, 1.f, 1.f);
}
OSG::commitChanges();
file->updateVolume();
OSG::Vec3f min,max;
file->getVolume().getBounds( min, max );
std::cout << "Volume: from " << min << " to " << max << std::endl;
//.........这里部分代码省略.........
示例4: doMain
//.........这里部分代码省略.........
scene->addChild(stones);
scene->addChild(dinos);
svp = OSG::ShadowStage::create();
OSG::GradientBackgroundUnrecPtr gbg = OSG::GradientBackground::create();
OSG::SolidBackgroundUnrecPtr sbg = OSG::SolidBackground::create();
gbg->addLine(OSG::Color3f(0.7f, 0.7f, 0.8f), 0);
gbg->addLine(OSG::Color3f(0.0f, 0.1f, 0.3f), 1);
rootNode->setCore(svp);
rootNode->addChild(light1);
rootNode->addChild(light1_beacon);
rootNode->addChild(light2_beacon);
rootNode->addChild(cam_beacon);
// Shadow viewport
#ifdef SHADOW_CHECK
svp->setBackground(gbg);
svp->setRoot(rootNode);
svp->setSize(0, 0, 1, 1);
#endif
//svp->setOffFactor(4.0);
//svp->setOffBias(8.0);
//used to set global shadow intensity, ignores shadow intensity from light sources if != 0.0
//svp->setGlobalShadowIntensity(0.8);
svp->setMapSize(1024);
//ShadowSmoothness used for PCF_SHADOW_MAP and VARIANCE_SHADOW_MAP, defines Filter Width. Range can be 0.0 ... 1.0.
//ShadowSmoothness also used to define the light size for PCSS_SHADOW_MAP
svp->setShadowSmoothness(0.5);
// add light sources here
//svp->editMFLightNodes ()->push_back(light1);
//svp->editMFLightNodes ()->push_back(light2);
svp->editMFExcludeNodes()->push_back(obj1_trans_node);
svp->setAutoSearchForLights(true);
//one active light at startup
_light2_core->setOn(true);
_light2_core->setAmbient(0.3f, 0.3f, 0.3f, 1);
_light2_core->setDiffuse(0.8f, 0.8f, 0.8f, 1);
_light1_core->setOn(false);
_light1_core->setAmbient(0.3, 0.3, 0.3, 1);
_light1_core->setDiffuse(0.8, 0.8, 0.8, 1);
gwin->setGlutId(winid);
#ifdef SHADOW_CHECK
gwin->addPort(svp);
#endif
gwin->init();
OSG::Vec3f min, max;
rootNode->updateVolume();
rootNode->getVolume().getBounds(min, max);
// create the SimpleSceneManager helper
mgr = OSG::SimpleSceneManager::create();
mgr->setWindow(gwin);
mgr->setCamera(Pcamera);
mgr->setRoot(rootNode);
_navigator.setMode(OSG::Navigator::TRACKBALL);
#ifdef SHADOW_CHECK
_navigator.setViewport(svp);
#endif
_navigator.setCameraTransformation(cam_beacon);
OSG::Vec3f up(0,1,0);
OSG::Pnt3f at(0,0,0);
OSG::Pnt3f from(0.0f,-100.1f,20.0f);
_navigator.set(from, at, up);
_navigator.setMotionFactor(0.5f);
#ifdef SHADOW_CHECK
svp->setCamera(Pcamera);
#endif
//activate Framecounter
startFpsCounter();
// dynamic_cast<RenderAction *>(mgr->getAction())->setLocalLights(true);
mgr->turnHeadlightOff();
mgr->showAll();
mgr->getCamera()->setNear( 1.0f);
mgr->getCamera()->setFar (1000000.f );
_navigator.setViewport(gwin->getPort(0));
return 0;
}
示例5: doMain
int doMain (int argc, char **argv)
{
int dummy;
// OSG init
OSG::osgInit(argc, argv);
// 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 );
dl->setAmbient( .3, .3, .3, 1 );
dl->setDiffuse( 1, 1, 1, 1 );
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]);
if ( file == NULL )
{
std::cerr << "Couldn't load file, ignoring" << std::endl;
file = OSG::makeTorus( .5, 2, 16, 16 );
}
OSG::Thread::getCurrentChangeList()->commitChanges();
file->updateVolume();
OSG::Vec3f min,max;
file->getVolume().getBounds( min, max );
std::cout << "Volume: from " << min << " to " << max << std::endl;
dlight->addChild( file );
std::cerr << "Tree: " << std::endl;
//root->dump();
// Camera
cam = OSG::PerspectiveCamera::create();
cam->setBeacon( b1n );
cam->setFov( OSG::osgDegree2Rad( 90 ) );
cam->setNear( 0.1 );
cam->setFar( 100000 );
// Background
OSG::SolidBackgroundUnrecPtr bkgnd = OSG::SolidBackground::create();
bkgnd->setColor(OSG::Color3f(0,0,1));
// Viewport
vp = OSG::Viewport::create();
vp->setCamera( cam );
vp->setBackground( bkgnd );
vp->setRoot( root );
vp->setSize( 0,0, 1,1 );
// Action
ract = OSG::RenderAction::create();
// tball
OSG::Vec3f pos;
pos.setValues(min[0] + ((max[0] - min[0]) * 0.5),
min[1] + ((max[1] - min[1]) * 0.5),
max[2] + ( max[2] - min[2] ) * 1.5 );
//.........这里部分代码省略.........
示例6: initAnimSetup
// Setup the part of the scene rooted at animRoot
// This includes a file to animate, a beacon for a light,
// and a staged core to render this subtree from the position
// of the light.
void initAnimSetup(int argc, char **argv)
{
// beacon for light and stage camera
OSG::GroupNodeRefPtr beacon = OSG::GroupNodeRefPtr::create();
// transformation for beacon
cam_transScene = OSG::TransformNodeRefPtr::create();
cam_transScene.node()->addChild(beacon);
// light
OSG::DirectionalLightNodeRefPtr dlight =
OSG::DirectionalLightNodeRefPtr::create();
dlight->setAmbient (.3f, .3f, .3f, 1);
dlight->setDiffuse ( 1, 1, 1, 1);
dlight->setDirection( 0, 0, 1 );
dlight->setBeacon (beacon );
// animRoot
animRoot = OSG::GroupNodeRefPtr::create();
animRoot.node()->addChild(cam_transScene );
// Load the file and put it in the graph
// under the sceneXform node.
OSG::NodeUnrecPtr file = NULL;
if(argc > 1)
{ file = OSG::SceneFileHandler::the()->read(argv[1]); }
if(file == NULL)
{
std::cerr << "Couldn't load file, ignoring" << std::endl;
file = OSG::makeTorus(.5, 2, 16, 16);
}
OSG::Vec3f min,max;
OSG::commitChanges();
file->updateVolume();
file->dump();
file->getVolume().getBounds(min, max);
std::cout << "Volume: from " << min << " to " << max << std::endl;
sceneTrans.setValues(min[0] + ((max[0] - min[0]) * 0.5),
min[1] + ((max[1] - min[1]) * 0.5),
max[2] + ( max[2] - min[2]) * 4.5 );
sceneXform = OSG::TransformNodeRefPtr::create();
sceneXform.node()->addChild(file);
OSG::NodeUnrecPtr pBoxNode = OSG::makeBox(1, 1, 1, 5, 5, 5);
pBoxNode->setTravMask(pBoxNode->getTravMask() & 0x0001);
sceneXform.node()->addChild(pBoxNode);
dlight.node()->addChild(sceneXform);
// ---- STAGE RENDERING SETUP --- //
// Camera: setup camera to point from beacon (light pos)
// with a 90deg FOV to render the scene
OSG::PerspectiveCameraUnrecPtr stage_cam = OSG::PerspectiveCamera::create();
stage_cam->setBeacon(beacon);
stage_cam->setFov (OSG::osgDegree2Rad(90));
stage_cam->setNear (0.1f);
stage_cam->setFar (100000);
// Background
OSG::SolidBackgroundUnrecPtr bkgnd = OSG::SolidBackground::create();
bkgnd->setColor(OSG::Color3f(0,1,0));
// FBO setup
pFBO = OSG::FrameBufferObject::create();
pTexBuffer = OSG::TextureBuffer::create();
#ifdef USE_DEPTH_TEXTURE
OSG::TextureBufferUnrecPtr pDepthBuffer = OSG::TextureBuffer::create();
pDepthBuffer->setTexture(txDepth);
#else
OSG::RenderBufferUnrecPtr pDepthBuffer = OSG::RenderBuffer ::create();
pDepthBuffer->setInternalFormat(GL_DEPTH_COMPONENT24 );
#endif
pTexBuffer->setTexture (tx1o);
pTexBuffer->setReadBack(true);
pFBO->setSize(512, 512);
pFBO->setColorAttachment(pTexBuffer, 0);
pFBO->setDepthAttachment(pDepthBuffer );
pFBO->editMFDrawBuffers()->clear();
pFBO->editMFDrawBuffers()->push_back(GL_COLOR_ATTACHMENT0_EXT);
//.........这里部分代码省略.........
示例7: init
void init(std::vector<std::string> &filenames)
{
size_t i;
OSG::DirectionalLightUnrecPtr dl;
OSG::Real32 x,y,z;
OSG::BoxVolume volume;
OSG::Vec3f min,max;
OSG::Vec3f size;
glEnable( GL_DEPTH_TEST );
glEnable( GL_LIGHTING );
glEnable( GL_LIGHT0 );
// GLint twoSide = 1;
// glLightModeliv(GL_LIGHT_MODEL_TWO_SIDE,&twoSide);
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
// 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();
dl = OSG::DirectionalLight::create();
dlight->setCore( dl );
dl->setAmbient( .3f, .3f, .3f, 1 );
dl->setDiffuse( 1, 1, 1, 1 );
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 scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
OSG::NodeUnrecPtr file;
for(i=0;i<filenames.size();i++)
{
file = OSG::SceneFileHandler::the()->read(filenames[i].c_str(),0);
if(file != NULL)
scene->addChild(file);
else
std::cerr << "Couldn't load file, ignoring " << filenames[i] << std::endl;
}
if ( filenames.size()==0 )
{
file = OSG::makeTorus( .5, 2, 16, 16 );
scene->addChild(file);
// scene->addChild(makeBox(.6,.6,.6,5,5,5));
}
prepareSceneGraph(scene);
OSG::Thread::getCurrentChangeList()->commitChanges();
scene->invalidateVolume();
scene->updateVolume();
volume=scene->getVolume();
volume.getBounds(min,max);
size = max-min;
if(ca>0)
{
if(cb==-1)
cb=ca;
if(cc==-1)
cc=cb;
OSG::NodeUnrecPtr node;
OSG::NodeUnrecPtr geoNode;
OSG::TransformUnrecPtr trans;
for(x=-ca/2.0 ; x<ca/2.0 ; x++)
for(y=-cb/2.0 ; y<cb/2.0 ; y++)
for(z=-cc/2.0 ; z<cc/2.0 ; z++)
{
trans=OSG::Transform::create();
node=OSG::Node::create();
node->setCore(trans);
//.........这里部分代码省略.........
示例8: doMain
int doMain (int argc, char **argv)
{
osx_AllowForeground();
// OSG init
OSG::osgInit(argc, argv);
// 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 );
dl->setAmbient( .0, .0, .0, 1 );
dl->setDiffuse( .8, .8, .8, .8 );
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]);
if ( file == NULL )
{
std::cerr << "Couldn't load file, ignoring" << std::endl;
file = OSG::makeTorus( .5, 2, 16, 16 );
}
OSG::Thread::getCurrentChangeList()->commitChanges();
file->updateVolume();
OSG::Vec3f min,max;
file->getVolume().getBounds( min, max );
std::cout << "Volume: from " << min << " to " << max << std::endl;
dlight->addChild( file );
std::cerr << "Tree: " << std::endl;
//root->dump();
// Camera
cam = OSG::PerspectiveCamera::create();
cam->setBeacon( b1n );
cam->setFov( OSG::osgDegree2Rad( 90 ) );
cam->setNear( 0.1 );
cam->setFar( 100000 );
// Background
OSG::SolidBackgroundUnrecPtr bkgnd = OSG::SolidBackground::create();
bkgnd->setColor(OSG::Color3f(0,0,1));
// Viewport
vp = OSG::Viewport::create();
vp->setCamera( cam );
vp->setBackground( bkgnd );
vp->setRoot( root );
vp->setSize( 0,0, 1,1 );
// Action
ract = OSG::RenderAction::create();
// tball
OSG::Vec3f pos;
pos.setValues(min[0] + ((max[0] - min[0]) * 0.5),
min[1] + ((max[1] - min[1]) * 0.5),
max[2] + ( max[2] - min[2] ) * 1.5 );
//.........这里部分代码省略.........