本文整理汇总了C++中ViewportRefPtr::setRoot方法的典型用法代码示例。如果您正苦于以下问题:C++ ViewportRefPtr::setRoot方法的具体用法?C++ ViewportRefPtr::setRoot怎么用?C++ ViewportRefPtr::setRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewportRefPtr
的用法示例。
在下文中一共展示了ViewportRefPtr::setRoot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createDynamicViewport
static void createDynamicViewport()
{
win->subPortByObj(staticVp);
FBOBackgroundUnrecPtr fboBckgnd = FBOBackground::create();
fboBckgnd->setFrameBufferObject(spSimpleFBO->fbo());
NodeUnrecPtr root = makeCoredNode<Group>();
root->addChild(dynamicScene);
mgr->setRoot(root);
dynamicVp = Viewport::create();
dynamicVp->setRoot (rootNode(root));
dynamicVp->setBackground(fboBckgnd);
dynamicVp->setCamera (camera);
dynamicVp->setSize (0,0, 1,1);
mgr->getNavigator()->setViewport(dynamicVp);
win->addPort(dynamicVp);
mgr->update();
}
示例2: attachApplication
//.........这里部分代码省略.........
//{
//SWARNING << "Could not load Torus Knot from: "
//<< TorusKnotFile.string() << " because this file doesn't exist." << std::endl;
TorusGeometryNode = makeTorus(.5, 2, 64, 64);
//}
//Scene Transformation
TransformRefPtr SceneTransformCore = Transform::create();
NodeRefPtr SceneTransformNode = Node::create();
SceneTransformNode->setCore(SceneTransformCore);
SceneTransformNode->addChild(TorusGeometryNode);
//Light
NodeRefPtr LightBeaconNode = Node::create();
LightBeaconNode->setCore(Transform::create());
DirectionalLightRefPtr SceneLightCore = DirectionalLight::create();
SceneLightCore->setDirection(1.0,0.0,0.0);
SceneLightCore->setBeacon(LightBeaconNode);
NodeRefPtr SceneLightNode = Node::create();
SceneLightNode->setCore(SceneLightCore);
SceneLightNode->addChild(SceneTransformNode);
// Make Main Scene Node and add the Torus
NodeRefPtr DefaultRootNode = OSG::Node::create();
DefaultRootNode->setCore(OSG::Group::create());
DefaultRootNode->addChild(CameraBeaconNode);
DefaultRootNode->addChild(SceneLightNode);
DefaultRootNode->addChild(LightBeaconNode);
//Camera
PerspectiveCameraRefPtr DefaultCamera = PerspectiveCamera::create();
DefaultCamera->setBeacon(CameraBeaconNode);
DefaultCamera->setFov (osgDegree2Rad(60.f));
DefaultCamera->setNear (0.1f);
DefaultCamera->setFar (10000.f);
//Background
GradientBackgroundRefPtr DefaultBackground = GradientBackground::create();
DefaultBackground->addLine(Color3f(0.0f,0.0f,0.0f), 0.0f);
DefaultBackground->addLine(Color3f(0.0f,0.0f,0.5f), 1.0f);
//Animation
//KeyFrames
KeyframeTransformationSequenceRefPtr TransformationKeyframes = KeyframeTransformationSequenceMatrix4f::create();
OSG::Matrix TempMat;
TransformationKeyframes->addKeyframe(TempMat,0.0f);
TempMat.setRotate(Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*0.5));
TransformationKeyframes->addKeyframe(TempMat,4.0f);
TempMat.setRotate(Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*1.0));
TransformationKeyframes->addKeyframe(TempMat,8.0f);
TempMat.setRotate(Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*1.5));
TransformationKeyframes->addKeyframe(TempMat,12.0f);
TempMat.setRotate(Quaternion(Vec3f(0.0f,1.0f,0.0f), 0.0f));
TransformationKeyframes->addKeyframe(TempMat,16.0f);
//Animator
KeyframeAnimatorRefPtr TorusAnimator = OSG::KeyframeAnimator::create();
TorusAnimator->setKeyframeSequence(TransformationKeyframes);
//Animation
_TorusAnimation = FieldAnimation::create();
_TorusAnimation->setAnimator(TorusAnimator);
_TorusAnimation->setInterpolationType(Animator::LINEAR_INTERPOLATION);
_TorusAnimation->setCycling(-1);
_TorusAnimation->setAnimatedField(SceneTransformCore, std::string("matrix"));
_TorusAnimation->attachUpdateProducer(MainApplication::the()->getMainWindow()->editEventProducer());
_TorusAnimation->start();
//Foreground
//ImageForegroundRefPtr LogoForeground = ImageForeground::create();
//BoostPath LogoPath(MainApplication::the()->getSettings()->getDataDirectory() / "Images/Logo.png");
//ImageRefPtr LoadedImage = ImageFileHandler::the().read(LogoPath.string().c_str());
// LogoForeground->addImage( LoadedImage, Pnt2f( 0,0 ) );
ForegroundRefPtr UserInterfaceForeground = createInterface();
_TheUIDrawingSurface->setEventProducer(MainApplication::the()->getMainWindow());
if(MainApplication::the()->getMainWindow() != NULL &&
MainApplication::the()->getMainWindow()->getMFPort()->size() == 0)
{
ViewportRefPtr DefaultViewport = Viewport::create();
DefaultViewport->setCamera (DefaultCamera);
DefaultViewport->setRoot (DefaultRootNode);
DefaultViewport->setSize (0.0f,0.0f, 1.0f,1.0f);
DefaultViewport->setBackground (DefaultBackground);
DefaultViewport->addForeground (UserInterfaceForeground);
MainApplication::the()->getMainWindow()->addPort(DefaultViewport);
}
MainApplication::the()->getMainWindow()->addKeyListener(&_StartScreenKeyListener);
MainApplication::the()->getMainWindow()->addUpdateListener(&_ScreenUpdateListener);
}