本文整理汇总了C++中osg::NodeRefPtr::getCore方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeRefPtr::getCore方法的具体用法?C++ NodeRefPtr::getCore怎么用?C++ NodeRefPtr::getCore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::NodeRefPtr
的用法示例。
在下文中一共展示了NodeRefPtr::getCore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
printf("Press key '1' or '2' to switch between one and two light sources.\n");
// OSG init
OSG::osgInit(argc,argv);
globals = new GlobalObjects;
// open a new scope, because the pointers below should go out of scope
// before entering glutMainLoop.
// Otherwise OpenSG will complain about objects being alive after shutdown.
{
// GLUT init
int winid = setupGLUT(&argc, argv);
globals->gwin = OSG::GLUTWindow::create();
/*
Construct a scene with a ground plane, some objects and two lights.
Nothing very interesting at this point.
See further down for the part relevant to shadows.
*/
globals->rootNode = OSG::makeCoredNode<OSG::Group>();
OSG::NodeRefPtr scene = OSG::makeCoredNode<OSG::Group>();
// create lights
OSG::TransformRefPtr point1_trans;
OSG::NodeRefPtr point1 = OSG::makeCoredNode<OSG::PointLight>(&globals->point1_core);
OSG::NodeRefPtr point1_beacon = OSG::makeCoredNode<OSG::Transform >(&point1_trans);
point1_trans->editMatrix().setTranslate(0.0, 0.0, 15.0);
globals->point1_core->setAmbient(0.15f,0.15f,0.15f,1);
globals->point1_core->setDiffuse(0.4f,0.4f,0.4f,1);
globals->point1_core->setSpecular(0.0f,0.0f,0.0f,1);
globals->point1_core->setBeacon(point1_beacon);
globals->point1_core->setOn(true);
OSG::TransformRefPtr point2_trans;
OSG::NodeRefPtr point2 = OSG::makeCoredNode<OSG::PointLight>(&globals->point2_core);
OSG::NodeRefPtr point2_beacon = OSG::makeCoredNode<OSG::Transform >(&point2_trans);
point2_trans->editMatrix().setTranslate(2.5, 2.5, 15.0);
globals->point2_core->setAmbient(0.15f,0.15f,0.15f,1);
globals->point2_core->setDiffuse(0.4f,0.4f,0.4f,1);
globals->point2_core->setSpecular(0.0f,0.0f,0.0f,1);
globals->point2_core->setBeacon(point2_beacon);
globals->point2_core->setOn(true);
point1->addChild(point2);
point2->addChild(scene );
// create scene
// bottom
OSG::NodeRefPtr plane = OSG::makePlane(25.0, 25.0, 128, 128);
OSG::UChar8 imgdata[] =
{ 255,0,0, 0,255,0, 0,0,255, 255,255,0 };
OSG::ImageRefPtr plane_img = OSG::Image::create();
plane_img->set(OSG::Image::OSG_RGB_PF, 2, 2, 1, 1, 1, 0, imgdata);
OSG::TextureObjChunkRefPtr plane_tex = OSG::TextureObjChunk::create();
plane_tex->setImage(plane_img);
plane_tex->setMinFilter(GL_LINEAR);
plane_tex->setMagFilter(GL_LINEAR);
plane_tex->setWrapS(GL_REPEAT);
plane_tex->setWrapT(GL_REPEAT);
OSG::TextureEnvChunkRefPtr plane_tex_env = OSG::TextureEnvChunk::create();
plane_tex_env->setEnvMode(GL_MODULATE);
OSG::SimpleMaterialRefPtr 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);
plane_mat->addChunk(plane_tex_env);
OSG::GeometryRefPtr plane_geo = dynamic_cast<OSG::Geometry *>(plane->getCore());
plane_geo->setMaterial(plane_mat);
// box
OSG::NodeRefPtr box_trans_node = OSG::makeCoredNode<OSG::Transform>(&globals->box_trans);
globals->box_trans->editMatrix().setTranslate(0.0, 0.0, 2.0);
OSG::NodeRefPtr box = OSG::makeBox(8.0f, 8.0f, 0.8f, 10, 10 , 10);
box_trans_node->addChild(box);
OSG::SimpleMaterialRefPtr box_mat = OSG::SimpleMaterial::create();
box_mat->setAmbient(OSG::Color3f(0.0f,0.0f,0.0f));
box_mat->setDiffuse(OSG::Color3f(0.0f,0.0f,1.0f));
OSG::GeometryRefPtr box_geo = dynamic_cast<OSG::Geometry *>(box->getCore());
box_geo->setMaterial(box_mat);
// cylinder1
OSG::NodeRefPtr cylinder1_trans_node = OSG::makeCoredNode<OSG::Transform>(&globals->cylinder1_trans);
globals->cylinder1_trans->editMatrix().setTranslate(0.0, 0.0, 5.0);
//.........这里部分代码省略.........