本文整理汇总了C++中ViewportRecPtr::setSize方法的典型用法代码示例。如果您正苦于以下问题:C++ ViewportRecPtr::setSize方法的具体用法?C++ ViewportRecPtr::setSize怎么用?C++ ViewportRecPtr::setSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewportRecPtr
的用法示例。
在下文中一共展示了ViewportRecPtr::setSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
{
// Set up Window
WindowEventProducerRecPtr TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
// Create the SimpleSceneManager helper
SimpleSceneManager sceneManager;
TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));
// Tell the Manager what to manage
sceneManager.setWindow(TutorialWindow);
TutorialWindow->connectKeyTyped(boost::bind(keyPressed, _1));
// Make Torus Node (creates Torus in background of scene)
NodeRecPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRecPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRecPtr TutorialGraphics = Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
//Create the nessicary parts for a viewport
Matrix TransformMatrix;
TransformMatrix.setTranslate(0.0f,0.0f, 0.0f);
TransformRecPtr CameraBeaconTransform = Transform::create();
CameraBeaconTransform->setMatrix(TransformMatrix);
NodeRecPtr CameraBeaconNode = Node::create();
CameraBeaconNode->setCore(CameraBeaconTransform);
// Make Torus Node (creates Torus in background of scene)
NodeRecPtr GeometryNode = makeTorus(.5, 2, 32, 32);
//Make a light Node
NodeRecPtr LightBeaconNode = makeCoredNode<Transform>();
DirectionalLightRecPtr SceneLight = DirectionalLight::create();
SceneLight->setAmbient(Color4f(0.3f,0.3f,0.3f,1.0f));
SceneLight->setDiffuse(Color4f(0.8f,0.8f,0.8f,1.0f));
SceneLight->setSpecular(Color4f(1.0f,1.0f,1.0f,1.0f));
SceneLight->setOn(true);
SceneLight->setBeacon(LightBeaconNode);
NodeRecPtr LightNode = makeNodeFor(SceneLight);
LightNode->addChild(GeometryNode);
// Make Main Scene Node and add the Torus
NodeRecPtr DefaultRootNode = Node::create();
DefaultRootNode->setCore(Group::create());
DefaultRootNode->addChild(LightNode);
DefaultRootNode->addChild(LightBeaconNode);
DefaultRootNode->addChild(CameraBeaconNode);
//Camera
PerspectiveCameraRecPtr DefaultCamera = PerspectiveCamera::create();
DefaultCamera->setBeacon(CameraBeaconNode);
DefaultCamera->setFov (osgDegree2Rad(60.f));
DefaultCamera->setNear (0.1f);
DefaultCamera->setFar (100.f);
//Background
GradientBackgroundRecPtr DefaultBackground = GradientBackground::create();
DefaultBackground->addLine(Color3f(0.0f,0.0f,0.0f), 0.0f);
DefaultBackground->addLine(Color3f(0.0f,0.0f,1.0f), 1.0f);
//Viewport
ViewportRecPtr DefaultViewport = Viewport::create();
DefaultViewport->setCamera (DefaultCamera);
DefaultViewport->setRoot (DefaultRootNode);
DefaultViewport->setSize (0.0f,0.0f, 1.0f,1.0f);
DefaultViewport->setBackground (DefaultBackground);
//GL Viewport Component
LineBorderRecPtr TheGLViewportBorder = LineBorder::create();
TheGLViewportBorder->setColor(Color4f(1.0,0.0,0.0,1.0));
TheGLViewportBorder->setWidth(3.0);
GLViewportRecPtr TheGLViewport = GLViewport::create();
TheGLViewport->setPort(DefaultViewport);
TheGLViewport->setPreferredSize(Vec2f(400.0f,400.0f));
TheGLViewport->setBorders(TheGLViewportBorder);
TheGLViewport->lookAt(Pnt3f(0.0f,0.0f,10.0f), //From
Pnt3f(0.0f,0.0f,0.0f), //At
Vec3f(0.0f,1.0f,0.0f)); //Up
ButtonRecPtr ExampleButton = Button::create();
//.........这里部分代码省略.........