本文整理汇总了C++中osg::NodeUnrecPtr::getCore方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeUnrecPtr::getCore方法的具体用法?C++ NodeUnrecPtr::getCore怎么用?C++ NodeUnrecPtr::getCore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::NodeUnrecPtr
的用法示例。
在下文中一共展示了NodeUnrecPtr::getCore方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createScene
OSG::NodeTransitPtr createScene(OSG::Window *win)
{
OSG::NodeRecPtr rootN = OSG::makeNodeFor(OSG::Group::create());
// Create ground:
OSG::NodeUnrecPtr groundN = OSG::makePlane(25,25,1,1);
OSG::Matrix m;
OSG::Quaternion q;
q.setValueAsAxisDeg(OSG::Vec3f(1,0,0), -90);
m.setRotate(q);
OSG::TransformUnrecPtr groundTransC = OSG::Transform::create();
groundTransC->setMatrix(m);
OSG::NodeUnrecPtr groundTransN = OSG::makeNodeFor(groundTransC);
groundTransN->addChild(groundN);
rootN->addChild(groundTransN);
// Set ground material:
OSG::SimpleMaterialUnrecPtr mat = OSG::SimpleMaterial::create();
mat->setDiffuse(OSG::Color3f(0.8,0.8,0.8));
dynamic_cast<OSG::Geometry*>(groundN->getCore())->setMaterial(mat);
// // Create figure:
// OSG::NodeUnrecPtr figure1N =
// OSG::SceneFileHandler::the()->read("../Models/Figure.obj");
// G.figure1TransC = OSG::Transform::create();
// OSG::NodeUnrecPtr trans1N = OSG::makeNodeFor(G.figure1TransC);
// trans1N->addChild(figure1N);
// rootN->addChild(trans1N);
OSG::NodeUnrecPtr figureModelA =
OSG::SceneFileHandler::the()->read("../assets/Figure.obj");
BoardGame::Figure* figureA = new BoardGame::Figure();
figureA->setModel(figureModelA);
rootN->addChild(figureA->getRoot());
OSG::NodeUnrecPtr figureModelB =
OSG::SceneFileHandler::the()->read("../assets/Figure.obj");
BoardGame::Figure* figureB = new BoardGame::Figure();
figureB->setModel(figureModelB);
rootN->addChild(figureB->getRoot());
G.selectedNode = figureModelA;
return(OSG::NodeTransitPtr(rootN));
}
示例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
//.........这里部分代码省略.........
//Eigene Kamera erstellen
Pcamera = OSG::PerspectiveCamera::create();
cam_beacon = OSG::makeCoredNode<OSG::Transform>(&cam_trans);
cam_trans->editMatrix().setTranslate(0.0, 0.0, 25.0);
Pcamera->setBeacon(cam_beacon);
Pcamera->setFov(OSG::osgDegree2Rad(60));
Pcamera->setNear(1.0);
Pcamera->setFar(1000);
// create scene
// bottom
OSG::NodeUnrecPtr plane = OSG::makePlane(300.0, 300.0, 256, 256);
OSG::ImageUnrecPtr plane_img = OSG::Image::create();
plane_img->read("gras.jpg");
OSG::TextureObjChunkUnrecPtr plane_tex_obj = OSG::TextureObjChunk::create();
OSG::TextureEnvChunkUnrecPtr plane_tex_env = OSG::TextureEnvChunk::create();
plane_tex_obj->setImage(plane_img);
plane_tex_obj->setMinFilter(GL_LINEAR);
plane_tex_obj->setMagFilter(GL_LINEAR);
plane_tex_obj->setWrapS(GL_REPEAT);
plane_tex_obj->setWrapT(GL_REPEAT);
plane_tex_env->setEnvMode(GL_MODULATE);
OSG::SimpleMaterialUnrecPtr plane_mat = OSG::SimpleMaterial::create();
plane_mat->setAmbient(OSG::Color3f(0.3f, 0.3f, 0.3f));
plane_mat->setDiffuse(OSG::Color3f(1.0f, 1.0f, 1.0f));
plane_mat->addChunk(plane_tex_obj);
plane_mat->addChunk(plane_tex_env);
OSG::Geometry *plane_geo = dynamic_cast<OSG::Geometry *>(plane->getCore());
plane_geo->setMaterial(plane_mat);
//load Tree Objects
OSG::NodeUnrecPtr tree1_trans_node = OSG::makeCoredNode<OSG::Transform>
(&_tree1_trans);
OSG::NodeUnrecPtr tree2_trans_node = OSG::makeCoredNode<OSG::Transform>
(&_tree2_trans);
OSG::NodeUnrecPtr tree3_trans_node = OSG::makeCoredNode<OSG::Transform>
(&_tree3_trans);
OSG::NodeUnrecPtr tree4_trans_node = OSG::makeCoredNode<OSG::Transform>
(&_tree4_trans);
OSG::NodeUnrecPtr tree5_trans_node = OSG::makeCoredNode<OSG::Transform>
(&_tree5_trans);
OSG::NodeUnrecPtr tree6_trans_node = OSG::makeCoredNode<OSG::Transform>
(&_tree6_trans);
OSG::NodeUnrecPtr tree7_trans_node = OSG::makeCoredNode<OSG::Transform>
(&_tree7_trans);
OSG::NodeUnrecPtr tree8_trans_node = OSG::makeCoredNode<OSG::Transform>
(&_tree8_trans);
OSG::NodeUnrecPtr tree9_trans_node = OSG::makeCoredNode<OSG::Transform>
(&_tree9_trans);
_tree1_trans->editMatrix().setTranslate(-80.0, -80.0, 0.0);
_tree1_trans->editMatrix().setScale(OSG::Vec3f(12.0, 12.0, 10.0));
_tree2_trans->editMatrix().setTranslate(0.0, -80.0, 0.0);
_tree2_trans->editMatrix().setScale(OSG::Vec3f(12.0, 12.0, 10.0));
_tree3_trans->editMatrix().setTranslate(80.0, -80.0, 0.0);
_tree3_trans->editMatrix().setScale(OSG::Vec3f(12.0, 12.0, 10.0));