本文整理汇总了C++中osg::NodeUnrecPtr::editVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeUnrecPtr::editVolume方法的具体用法?C++ NodeUnrecPtr::editVolume怎么用?C++ NodeUnrecPtr::editVolume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::NodeUnrecPtr
的用法示例。
在下文中一共展示了NodeUnrecPtr::editVolume方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
// 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;
//.........这里部分代码省略.........
示例2: init
//.........这里部分代码省略.........
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);
trans->editMatrix().setTranslate(
x*size[0]*1.1,
y*size[1]*1.1,
z*size[2]*1.1);
geoNode = OSG::cloneTree(scene);
geoNode->editSFVolume()->getValue() = scene->getSFVolume()->getValue();
geoNode->editVolume(false).setValid(true);
node->addChild( geoNode );
dlight->addChild(node);
}
}
else
{
dlight->addChild(scene);
}
if(ca>0)
{
sum_geometries*=OSG::UInt32(ca*cb*cc);
sum_triangles *=OSG::UInt32(ca*cb*cc);
sum_positions *=OSG::UInt32(ca*cb*cc);
}
OSG::Thread::getCurrentChangeList()->commitChanges();
// dlight->invalidateVolume();
printf("update Volume\n");
dlight->updateVolume();
printf("update Volume OK\n");
// should check first. ok for now.
const OSG::BoxVolume &vol = dlight->getVolume();
OSG::Pnt3f center;
vol.getBounds(min, max);
vol.getCenter(center);
size = max - min;