本文整理汇总了C++中osg::SimpleSceneManagerRefPtr::turnHeadlightOff方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleSceneManagerRefPtr::turnHeadlightOff方法的具体用法?C++ SimpleSceneManagerRefPtr::turnHeadlightOff怎么用?C++ SimpleSceneManagerRefPtr::turnHeadlightOff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::SimpleSceneManagerRefPtr
的用法示例。
在下文中一共展示了SimpleSceneManagerRefPtr::turnHeadlightOff方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doMain
//.........这里部分代码省略.........
shl_fp->setProgram(_fp_program);
shl->addShader(shl_fp);
shl_vp->addProceduralVariable ("Light0Active", &light0Active);
shl_vp->addProceduralVariable ("Light1Active", &light1Active);
shl_vp->addNodeProceduralVariable("Light2Active", &light2Active);
cmat->addChunk(matc);
cmat->addChunk(shl);
// create root node
_scene = OSG::Node::create();
// create two light sources.
OSG::TransformUnrecPtr point1_trans;
OSG::NodeUnrecPtr point1 =
OSG::makeCoredNode<OSG::PointLight>(&_point1_core);
point1_beacon = OSG::makeCoredNode<OSG::Transform >(&point1_trans);
point1_trans->editMatrix().setTranslate(-10.0, 5.0, 5.0);
_point1_core->setAmbient(0.0f, 0.0f, 0.0f , 1.0f);
_point1_core->setDiffuse(1.0f, 0.0f, 0.0f, 1.0f);
_point1_core->setSpecular(1.0f, 1.0f, 1.0f, 1.0f);
_point1_core->setBeacon(point1_beacon);
_point1_core->setOn(true);
OSG::TransformUnrecPtr point2_trans;
OSG::NodeUnrecPtr point2 =
OSG::makeCoredNode<OSG::PointLight>(&_point2_core);
point2_beacon = OSG::makeCoredNode<OSG::Transform >(&point2_trans);
point2_trans->editMatrix().setTranslate(10.0, 5.0, 5.0);
_point2_core->setAmbient(0.0f, 0.0f, 0.0f, 1.0f);
_point2_core->setDiffuse(0.0f, 1.0f, 0.0f, 1.0f);
_point2_core->setSpecular(1.0f, 1.0f, 1.0f, 1.0f);
_point2_core->setBeacon(point2_beacon);
_point2_core->setOn(true);
point1->addChild(point2);
OSG::TransformUnrecPtr point3_trans;
OSG::NodeUnrecPtr point3 =
OSG::makeCoredNode<OSG::PointLight>(&_point3_core);
point3_beacon = OSG::makeCoredNode<OSG::Transform >(&point3_trans);
point3_trans->editMatrix().setTranslate(0.0, -12.0, 5.0);
_point3_core->setAmbient(0.0f, 0.0f, 0.0f, 1.0f);
_point3_core->setDiffuse(0.5f, 0.0f, 1.0f, 1.0f);
_point3_core->setSpecular(1.0f, 1.0f, 1.0f, 1.0f);
_point3_core->setBeacon(point3_beacon);
_point3_core->setOn(true);
point2->addChild(point3);
// create a sphere.
OSG::GeometryUnrecPtr geo = OSG::makeLatLongSphereGeo (100, 100, 1.0);
geo->setMaterial(cmat);
OSG::NodeUnrecPtr sphere = OSG::makeNodeFor(geo);
point3->addChild(sphere);
_scene->setCore(OSG::Group::create());
_scene->addChild(point1);
// create the SimpleSceneManager helper
_mgr = OSG::SimpleSceneManager::create();
// tell the manager what to manage
_mgr->setWindow(gwin );
_mgr->setRoot(_scene);
_mgr->turnHeadlightOff();
// show the whole scene
_mgr->showAll();
// enable local lights.
// OSG::RenderAction *ract =
// dynamic_cast<OSG::RenderAction *>(_mgr->getRenderAction());
// ract->setLocalLights(true);
return 0;
}
示例2: 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;
}