本文整理汇总了C++中osg::WindowRecPtr::init方法的典型用法代码示例。如果您正苦于以下问题:C++ WindowRecPtr::init方法的具体用法?C++ WindowRecPtr::init怎么用?C++ WindowRecPtr::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::WindowRecPtr
的用法示例。
在下文中一共展示了WindowRecPtr::init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
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);
//.........这里部分代码省略.........
示例3: doMain
int doMain (int argc, char **argv)
{
OSG::osgInit(argc,argv);
// GLUT init
glutInit(&argc, argv);
glutInitDisplayMode( GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
glutInitWindowSize(800, 800);
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();
fprintf(stderr, "Create b1n %p %d %d \n",
b1n.get(),
b1n->getRefCount(),
b1n->getWeakRefCount());
b1n->setCore( b1 );
// transformation
OSG::NodeUnrecPtr t1n = OSG::Node::create();
OSG::TransformUnrecPtr t1 = OSG::Transform::create();
t1n->setCore (t1 );
t1n->addChild(b1n);
fprintf(stderr, "Create t1n %p %d %d \n",
t1n.get(),
t1n->getRefCount(),
t1n->getWeakRefCount());
cam_trans = t1;
// light
OSG::NodeUnrecPtr dlight = OSG::Node::create();
OSG::DirectionalLightUnrecPtr dl = OSG::DirectionalLight::create();
{
dlight->setCore(dl);
dl->setAmbient( .3f, .3f, .3f, 1 );
dl->setDiffuse( .8f, .8f, .8f, .8f );
dl->setDirection(0,0,1);
dl->setBeacon( b1n);
}
fprintf(stderr, "Create dlight %p %d %d \n",
dlight.get(),
dlight->getRefCount(),
dlight->getWeakRefCount());
hdrroot = OSG::Node::create();
hdrroot->editVolume().setInfinite();
hdrroot->editVolume().setStatic ();
hdrroot->setCore(OSG::Group::create());
// root
root = OSG::Node:: create();
OSG::GroupUnrecPtr gr1 = OSG::Group::create();
root->setCore(gr1);
hdrroot->addChild(root);
root->addChild(t1n );
root->addChild(dlight);
fprintf(stderr, "Create root %p %d %d \n",
root.get(),
root->getRefCount(),
root->getWeakRefCount());
// Load the file
OSG::NodeUnrecPtr file = NULL;
//.........这里部分代码省略.........