当前位置: 首页>>代码示例>>C++>>正文


C++ WindowEventProducerRefPtr::getDesktopSize方法代码示例

本文整理汇总了C++中WindowEventProducerRefPtr::getDesktopSize方法的典型用法代码示例。如果您正苦于以下问题:C++ WindowEventProducerRefPtr::getDesktopSize方法的具体用法?C++ WindowEventProducerRefPtr::getDesktopSize怎么用?C++ WindowEventProducerRefPtr::getDesktopSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WindowEventProducerRefPtr的用法示例。


在下文中一共展示了WindowEventProducerRefPtr::getDesktopSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........

    MaterialChunkRefPtr PSMaterialChunkChunk = MaterialChunk::create();
    PSMaterialChunkChunk->setAmbient(Color4f(1.0f,1.0f,1.0f,1.0f));
    PSMaterialChunkChunk->setDiffuse(Color4f(0.7f,0.7f,0.7f,1.0f));
    PSMaterialChunkChunk->setSpecular(Color4f(0.9f,0.9f,0.9f,1.0f));
    PSMaterialChunkChunk->setColorMaterial(GL_NONE);

    ChunkMaterialRefPtr PSMaterial = ChunkMaterial::create();
    PSMaterial->addChunk(PSPointChunk);
    PSMaterial->addChunk(PSMaterialChunkChunk);
    PSMaterial->addChunk(PSBlendChunk);

    //Particle System
    ParticleSystemRefPtr ExampleParticleSystem = OSG::ParticleSystem::create();
    ExampleParticleSystem->addParticle(Pnt3f(0,100,0),
                                       Vec3f(0.0,0.0f,1.0f),
                                       Color4f(1.0,1.0,1.0,1.0), 
                                       Vec3f(1.0,1.0,1.0), 
                                       0.1, 
                                       Vec3f(0.0f,0.0f,0.0f), //Velocity
                                       Vec3f(0.0f,0.0f,0.0f)
                                      );
    ExampleParticleSystem->addParticle(Pnt3f(0,-100,0),
                                       Vec3f(0.0,0.0f,1.0f),
                                       Color4f(1.0,1.0,1.0,1.0), 
                                       Vec3f(1.0,1.0,1.0), 
                                       0.1, 
                                       Vec3f(0.0f,0.0f,0.0f), //Velocity
                                       Vec3f(0.0f,0.0f,0.0f)
                                      );
    ExampleParticleSystem->attachUpdateListener(TutorialWindow);

    //Particle System Drawer (Point)
    PointParticleSystemDrawerRefPtr ExampleParticleSystemDrawer = OSG::PointParticleSystemDrawer::create();


    //Create a Rate Particle Generator
    RateParticleGeneratorRefPtr ExampleGenerator = OSG::RateParticleGenerator::create();

    //Attach the function objects to the Generator
    ExampleGenerator->setPositionDistribution(createPositionDistribution());
    ExampleGenerator->setLifespanDistribution(createLifespanDistribution());
    ExampleGenerator->setGenerationRate(80.0);
    ExampleGenerator->setVelocityDistribution(createVelocityDistribution());

    ExampleRadialAffector = OSG::RadialParticleAffector::create();
    ExampleRadialAffector->setMagnitude(15.0);
    NodeRefPtr RadialBeacon = OSG::Node::create();
    ExampleRadialAffector->setBeacon(RadialBeacon); // set to 'emulate' from (0,0,0)
    ExampleRadialAffector->setMaxDistance(-1.0); // particles affected regardless of distance
    ExampleRadialAffector->setAttenuation(0.0); // strength of uniform field dimishes by dist^attenuation



    //Attach the Generator and Affector to the Particle System
    ExampleParticleSystem->pushToGenerators(ExampleGenerator);
    ExampleParticleSystem->pushToAffectors(ExampleRadialAffector);
    ExampleParticleSystem->setMaxParticles(800);


    //Particle System Node
    ParticleSystemCoreRefPtr ParticleNodeCore = OSG::ParticleSystemCore::create();
    ParticleNodeCore->setSystem(ExampleParticleSystem);
    ParticleNodeCore->setDrawer(ExampleParticleSystemDrawer);
    ParticleNodeCore->setMaterial(PSMaterial);

    NodeRefPtr ParticleNode = OSG::Node::create();
    ParticleNode->setCore(ParticleNodeCore);


    // Make Main Scene Node and add the Torus
    NodeRefPtr scene = OSG::Node::create();
    scene->setCore(OSG::Group::create());
    scene->addChild(ParticleNode);

    mgr->setRoot(scene);

    // Show the whole Scene
    mgr->showAll();

    mgr->getCamera()->setFar(1000.0);

    std::cout << "Radial Particle Affector Tutorial Controls:\n"
        << "R: Reverse direction of field\n"
        << "Ctrl + Q: Exit Tutorial";

    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
                               WinSize,
                               "23RadialFieldParticleAffector");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:101,代码来源:23RadialFieldParticleAffector.cpp

示例2: main


//.........这里部分代码省略.........
    PSMaterialChunkChunk->setColorMaterial(GL_AMBIENT_AND_DIFFUSE);

    ChunkMaterialRefPtr PSMaterial = ChunkMaterial::create();
    PSMaterial->addChunk(PSPointChunk);
    PSMaterial->addChunk(PSMaterialChunkChunk);
    PSMaterial->addChunk(PSBlendChunk);

    //Particle System
    ParticleSystemRefPtr ExampleParticleSystem = OSG::ParticleSystem::create();
    ExampleParticleSystem->addParticle(Pnt3f(0,0,0),
                                       Vec3f(0.0,0.0f,1.0f),
                                       Color4f(1.0,1.0,1.0,1.0), 
                                       Vec3f(1.0,1.0,1.0), 
                                       0.1, 
                                       Vec3f(0.0f,0.0f,0.0f), //Velocity
                                       Vec3f(0.0f,0.0f,0.0f)
                                      );
    ExampleParticleSystem->addParticle(Pnt3f(50,0,0),
                                       Vec3f(0.0,0.0f,1.0f),
                                       Color4f(1.0,1.0,1.0,1.0), 
                                       Vec3f(1.0,1.0,1.0), 
                                       0.1, 
                                       Vec3f(0.0f,0.0f,0.0f), //Velocity
                                       Vec3f(0.0f,0.0f,0.0f)
                                      );
    ExampleParticleSystem->attachUpdateListener(TutorialWindow);

    //Particle System Drawer (Point)
    ExamplePointParticleSystemDrawer = OSG::PointParticleSystemDrawer::create();

    //Particle System Drawer (line)
    ExampleLineParticleSystemDrawer = OSG::LineParticleSystemDrawer::create();
    ExampleLineParticleSystemDrawer->setLineDirectionSource(LineParticleSystemDrawer::DIRECTION_VELOCITY);
    ExampleLineParticleSystemDrawer->setLineLengthSource(LineParticleSystemDrawer::LENGTH_SIZE_X);
    ExampleLineParticleSystemDrawer->setLineLength(0.5f);
    ExampleLineParticleSystemDrawer->setEndPointFading(Vec2f(1.0f,0.0f));

    //Create a Rate Particle Generator
    RateParticleGeneratorRefPtr ExampleGenerator = OSG::RateParticleGenerator::create();

    //Attach the function objects to the Generator
    ExampleGenerator->setPositionDistribution(createPositionDistribution());
    ExampleGenerator->setLifespanDistribution(createLifespanDistribution());
    ExampleGenerator->setVelocityDistribution(createVelocityDistribution());
    ExampleGenerator->setGenerationRate(2.0);

    ExampleConserveVelocityAffector = OSG::ConserveVelocityParticleAffector::create();
    ExampleConserveVelocityAffector->setConserve(0.0); // all velocity conserved initially.  Use keys 3 and 4 to change this value while running.



    //Attach the Generator and Affector to the Particle System
    ExampleParticleSystem->pushToGenerators(ExampleGenerator);
    ExampleParticleSystem->pushToAffectors(ExampleConserveVelocityAffector);
    ExampleParticleSystem->setMaxParticles(500);


    //Particle System Node
    ParticleNodeCore = OSG::ParticleSystemCore::create();
    ParticleNodeCore->setSystem(ExampleParticleSystem);
    ParticleNodeCore->setDrawer(ExamplePointParticleSystemDrawer);
    ParticleNodeCore->setMaterial(PSMaterial);

    NodeRefPtr ParticleNode = OSG::Node::create();
    ParticleNode->setCore(ParticleNodeCore);


    // Make Main Scene Node and add the Torus
    NodeRefPtr scene = OSG::Node::create();
    scene->setCore(OSG::Group::create());
    scene->addChild(ParticleNode);

    mgr->setRoot(scene);

    // Show the whole Scene
    mgr->showAll();

    mgr->getCamera()->setFar(1000.0);

    std::cout << "Conserve Velocity Particle Affector Tutorial Controls:\n"
        << "1: Use point drawer\n"
        << "2: Use line drawer\n"
        << "3: Decrease velocity conserved.\n"
        << "4: Increase velocity conserved.\n"
        << "Ctrl + Q: Exit Tutorial";

    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
                               WinSize,
                               "28ConserveVelocityParticleAffector");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:101,代码来源:28ConserveVelocityParticleAffector.cpp

示例3: main


//.........这里部分代码省略.........
    MaterialChunkRefPtr PSMaterialChunk = MaterialChunk::create();
    PSMaterialChunk->setAmbient(Color4f(0.3f,0.3f,0.3f,1.0f));
    PSMaterialChunk->setDiffuse(Color4f(0.7f,0.7f,0.7f,1.0f));
    PSMaterialChunk->setSpecular(Color4f(0.9f,0.9f,0.9f,1.0f));
    PSMaterialChunk->setColorMaterial(GL_AMBIENT_AND_DIFFUSE);

    ChunkMaterialRefPtr PSMaterial = ChunkMaterial::create();
    PSMaterial->addChunk(QuadTextureObjChunk);
    PSMaterial->addChunk(QuadTextureEnvChunk);
    PSMaterial->addChunk(PSMaterialChunk);
    PSMaterial->addChunk(PSBlendChunk);



    //Affector
    ExampleAgeSizeParticleAffector = OSG::AgeSizeParticleAffector::create();
    //ages
    ExampleAgeSizeParticleAffector->editMFAges()->push_back(0.0);
    ExampleAgeSizeParticleAffector->editMFAges()->push_back(0.05);
    ExampleAgeSizeParticleAffector->editMFAges()->push_back(0.2);
    ExampleAgeSizeParticleAffector->editMFAges()->push_back(0.36);
    ExampleAgeSizeParticleAffector->editMFAges()->push_back(0.7);
    ExampleAgeSizeParticleAffector->editMFAges()->push_back(0.8);
    ExampleAgeSizeParticleAffector->editMFAges()->push_back(1.0);

    //sizes
    ExampleAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(1.0,0.5,1.0));
    ExampleAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(1.0,0.5,1.0));
    ExampleAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(20.0,0.5,30.0));
    ExampleAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(3.0,3.0,3.0));
    ExampleAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(6.0,60.0,6.0));
    ExampleAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(2.0,3.0,1.0));
    ExampleAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(10.0,1.0,10.0));

    //Particle System
    ExampleParticleSystem = OSG::ParticleSystem::create();
    ExampleParticleSystem->attachUpdateListener(TutorialWindow);
    ExampleParticleSystem->pushToAffectors(ExampleAgeSizeParticleAffector);

    //Particle System Drawer
    ExampleParticleSystemDrawer = OSG::QuadParticleSystemDrawer::create();


    ExampleBurstGenerator = OSG::BurstParticleGenerator::create();
    //Attach the function objects to the Generator
    ExampleBurstGenerator->setPositionDistribution(createPositionDistribution());
    ExampleBurstGenerator->setLifespanDistribution(createLifespanDistribution());
    ExampleBurstGenerator->setBurstAmount(10.0);
    ExampleBurstGenerator->setVelocityDistribution(createVelocityDistribution());
    //ExampleBurstGenerator->setAccelerationDistribution(createAccelerationDistribution());
    ExampleBurstGenerator->setSizeDistribution(createSizeDistribution());

    //Particle System Node
    ParticleSystemCoreRefPtr ParticleNodeCore = OSG::ParticleSystemCore::create();
    ParticleNodeCore->setSystem(ExampleParticleSystem);
    ParticleNodeCore->setDrawer(ExampleParticleSystemDrawer);
    ParticleNodeCore->setMaterial(PSMaterial);

    NodeRefPtr ParticleNode = OSG::Node::create();
    ParticleNode->setCore(ParticleNodeCore);

    //Ground Node
    NodeRefPtr GoundNode = makePlane(30.0,30.0,10,10);

    Matrix GroundTransformation;
    GroundTransformation.setRotate(Quaternion(Vec3f(1.0f,0.0,0.0), -3.14195f));
    TransformRefPtr GroundTransformCore = Transform::create();
    GroundTransformCore->setMatrix(GroundTransformation);

    NodeRefPtr GroundTransformNode = Node::create();
    GroundTransformNode->setCore(GroundTransformCore);
    GroundTransformNode->addChild(GoundNode);


    // Make Main Scene Node and add the Torus
    NodeRefPtr scene = OSG::Node::create();
    scene->setCore(OSG::Group::create());
    scene->addChild(ParticleNode);
    scene->addChild(GroundTransformNode);

    mgr->setRoot(scene);

    // Show the whole Scene
    mgr->showAll();


    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
                               WinSize,
                               "07AgeSizeParticleAffector");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
开发者ID:rdgoetz,项目名称:OpenSGToolbox,代码行数:101,代码来源:07AgeSizeParticleAffector.cpp

示例4: main


//.........这里部分代码省略.........
    ExampleTabPanel->addTab(MultiFieldLabel, createMultiFieldPanel());
    ExampleTabPanel->addTab(SinglePtrFieldLabel, createSinglePtrFieldPanel());
    ExampleTabPanel->addTab(MultiPtrFieldLabel, createMultiPtrFieldPanel());
    ExampleTabPanel->setTabAlignment(0.5f);
    ExampleTabPanel->setTabPlacement(TabPanel::PLACEMENT_NORTH);
    ExampleTabPanel->setSelectedIndex(0);

	//UndoList
	UndoRedoListModel = DefaultListModel::create();
    UndoRedoListModel->pushBack(boost::any(std::string("Top")));
	ListSelectionModelPtr UndoRedoListSelectionModel(new DefaultListSelectionModel());

	UndoRedoList = List::create();
        UndoRedoList->setPreferredSize(Vec2f(200, 300));
        UndoRedoList->setOrientation(List::VERTICAL_ORIENTATION);
		UndoRedoList->setModel(UndoRedoListModel);

    UndoRedoList->setSelectionModel(UndoRedoListSelectionModel);

    UndoRedoListListener TheUndoRedoListListener;
    UndoRedoList->getSelectionModel()->addListSelectionListener(&TheUndoRedoListListener);

    UndoButton = OSG::Button::create();
            UndoButton->setText("Undo");
			UndoButton->setEnabled(TheUndoManager->numberOfUndos() != 0);
    UndoButtonActionListener TheUndoButtonActionListener;
    UndoButton->addActionListener(&TheUndoButtonActionListener);
	

    RedoButton = OSG::Button::create();
            RedoButton->setText("Redo");
			RedoButton->setEnabled(TheUndoManager->numberOfRedos() != 0);
    RedoButtonActionListener TheRedoButtonActionListener;
    RedoButton->addActionListener(&TheRedoButtonActionListener);

    // Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
    ScrollPanelRefPtr UndoRedoScrollPanel = ScrollPanel::create();
        UndoRedoScrollPanel->setPreferredSize(Vec2f(200,200));
        UndoRedoScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
    UndoRedoScrollPanel->setViewComponent(UndoRedoList);

    // Create The Main InternalWindow
    // Create Background to be used with the Main InternalWindow
    ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
        MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
    InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
    LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
       MainInternalWindow->pushToChildren(ExampleTabPanel);
       MainInternalWindow->pushToChildren(UndoRedoScrollPanel);
       MainInternalWindow->pushToChildren(UndoButton);
       MainInternalWindow->pushToChildren(RedoButton);
       MainInternalWindow->setLayout(MainInternalWindowLayout);
       MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
	   MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
	   MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.95f,0.95f));
	   MainInternalWindow->setDrawTitlebar(false);
	   MainInternalWindow->setResizable(false);

    // Create the Drawing Surface
    UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);
    
	TutorialDrawingSurface->openWindow(MainInternalWindow);
	
	// Create the UI Foreground Object
    UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);
    mgr->setRoot(scene);

    // Add the UI Foreground Object to the Scene
    ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
    TutorialViewport->addForeground(TutorialUIForeground);
    TutorialViewport->setBackground(TutorialBackground);

    // Show the whole Scene
    mgr->showAll();


    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
            WinSize,
            "01ChangeFieldCommands");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:101,代码来源:01ChangeFieldCommands.cpp

示例5: main


//.........这里部分代码省略.........
    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);

    //Particle System Material
    PointChunkRefPtr PSPointChunk = PointChunk::create();
    PSPointChunk->setSize(6.0f);
    PSPointChunk->setSmooth(true);

    BlendChunkRefPtr PSBlendChunk = BlendChunk::create();
    PSBlendChunk->setSrcFactor(GL_SRC_ALPHA);
    PSBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);

    MaterialChunkRefPtr PSMaterialChunkChunk = MaterialChunk::create();
    PSMaterialChunkChunk->setAmbient(Color4f(0.2f,0.6f,0.5f,0.3f));
    PSMaterialChunkChunk->setDiffuse(Color4f(0.2f,0.9f,0.1f,0.3f));
    PSMaterialChunkChunk->setSpecular(Color4f(0.5f,0.4f,0.2f,0.6f));
    PSMaterialChunkChunk->setEmission(Color4f(0.2f,0.6f,0.5f,0.3f));
    PSMaterialChunkChunk->setColorMaterial(GL_NONE);

    //enable depth test
    DepthChunkRefPtr PSDepthChunk = DepthChunk::create();

    ChunkMaterialRefPtr PSMaterial = ChunkMaterial::create();
    PSMaterial->addChunk(PSPointChunk);
    PSMaterial->addChunk(PSMaterialChunkChunk);
    PSMaterial->addChunk(PSBlendChunk);
    PSMaterial->addChunk(PSDepthChunk);

    //Particle System
    ParticleSystemRefPtr ExampleParticleSystem = OSG::ParticleSystem::create();
    ExampleParticleSystem->attachUpdateListener(TutorialWindow);

    //Particle System Drawer
    //Point
    ExamplePointParticleSystemDrawer = OSG::PointParticleSystemDrawer::create();
    //ExamplePointParticleSystemDrawer->setForcePerParticleSizing(true);

    //Line
    ExampleLineParticleSystemDrawer = OSG::LineParticleSystemDrawer::create();
    ExampleLineParticleSystemDrawer->setLineDirectionSource(LineParticleSystemDrawer::DIRECTION_NORMAL);//DIRECTION_VELOCITY_CHANGE);
    ExampleLineParticleSystemDrawer->setLineLengthSource(LineParticleSystemDrawer::LENGTH_SIZE_X);
    ExampleLineParticleSystemDrawer->setEndPointFading(Vec2f(1.0,0.0));
    //Quad
    ExampleQuadParticleSystemDrawer = OSG::QuadParticleSystemDrawer::create();
    ExampleQuadParticleSystemDrawer->setQuadSizeScaling(Vec2f(0.1,0.1));
    ExampleQuadParticleSystemDrawer->setNormalAndUpSource(QuadParticleSystemDrawer::NORMAL_PARTICLE_NORMAL,QuadParticleSystemDrawer::UP_STATIC);

    RateParticleGeneratorRefPtr ExampleGeneratorTheSequel = OSG::RateParticleGenerator::create();

    //Attach the function objects to the Generator
    ExampleGeneratorTheSequel->setPositionDistribution(createPositionDistribution());
    ExampleGeneratorTheSequel->setLifespanDistribution(createLifespanDistribution());
    ExampleGeneratorTheSequel->setGenerationRate(300.0);
    ExampleGeneratorTheSequel->setVelocityDistribution(createVelocityDistribution());


    //Attach the Generator to the Particle System
    //ExampleParticleSystem->pushToGenerators(ExampleGenerator);
    ExampleParticleSystem->setMaxParticles(500);
    ExampleParticleSystem->pushToGenerators(ExampleGeneratorTheSequel);

    //Particle System Node
    ParticleNodeCore = OSG::ParticleSystemCore::create();
    ParticleNodeCore->setSystem(ExampleParticleSystem);
    ParticleNodeCore->setDrawer(ExamplePointParticleSystemDrawer);
    ParticleNodeCore->setMaterial(PSMaterial);

    NodeRefPtr ParticleNode = OSG::Node::create();
    ParticleNode->setCore(ParticleNodeCore);


    // Make Main Scene Node and add the Torus
    NodeRefPtr scene = OSG::Node::create();
    scene->setCore(OSG::Group::create());
    scene->addChild(ParticleNode);

    mgr->setRoot(scene);

    // Show the whole Scene
    mgr->showAll();

    mgr->getCamera()->setFar(500.0);

    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
                               WinSize,
                               "14ParticleSorting");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
开发者ID:danguilliams,项目名称:OpenSGToolbox,代码行数:101,代码来源:14ParticleSorting.cpp

示例6: main


//.........这里部分代码省略.........
	// SpringLayoutConstraints Information
	// It is possible to set the constraint for the Y_EDGE, X_EDGE, BASELINE_EDGE, NORTH_EDGE, SOUTH_EDGE, EAST_EDGE, WEST_EDGE, HEIGHT_EDGE, and/or WIDTH_EDGE of a component.
	// It is possible to constrain a component's edge x pixels above, below, to the right of, or to the left of the edges other components, frames, and/or the MainInternalWindow.
	// It is possible to constrain a component to the Y_EDGE, X_EDGE, BASELINE_EDGE, NORTH_EDGE, SOUTH_EDGE, EAST_EDGE, WEST_EDGE, HORIZONTAL_CENTER_EDGE, VERTICAL_CENTER_EDGE, HEIGHT_EDGE, and/or WIDTH_EDGE of whatever component to which it is constrained.
	
	//Example Button 1    
    MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ExampleButton1, 25, SpringLayoutConstraints::NORTH_EDGE, MainInternalWindow);  // The North edge of ExampleButton1 is 25 pixels below the North edge of the MainInternalWindow.
    MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ExampleButton1, -5, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, MainInternalWindow);  // The South edge of ExampleButton1 is 5 pixels above the Vertical Center of the MainInternalWindow.
    MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ExampleButton1, -25, SpringLayoutConstraints::EAST_EDGE, MainInternalWindow);  // The East edge of ExampleButton1 is 25 pixels to the left of the East edge of the MainInternalWindow.
    MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton1, 25, SpringLayoutConstraints::WEST_EDGE, MainInternalWindow);  // The West edge of ExampleButton1 is 25 pixels to the right of the West edge of the MainInternalWindow.

	//Example Button 2
	MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, ExampleButton2, LayoutSpring::height(ExampleButton2));  // The Height edge of ExampleButton2 is set to the height of ExampleButton2.
	MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ExampleButton2, -25, SpringLayoutConstraints::SOUTH_EDGE, MainInternalWindow);  // The South edge of ExampleButton2 is 25 pixels above the South edge of the MainInternalWindow.
	MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ExampleButton2, -5, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow);  // The East edge of ExampleButton2 is 5 pixels to the left of the Horizontal Center of the MainInternalWindow.
    MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton2, 25, SpringLayoutConstraints::WEST_EDGE, MainInternalWindow);  // The West edge of ExampleButton2 is 25 pixels to the right of the West edge of the MainInternalWindow.

	//Example Button 3
	MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, ExampleButton3, LayoutSpring::height(ExampleButton3));  // The Height edge of ExampleButton3 is set to the height of ExampleButton3.
	MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ExampleButton3, -25, SpringLayoutConstraints::SOUTH_EDGE, MainInternalWindow);  // The South edge of ExampleButton3 is 25 pixels above the South edge of the MainInternalWindow.
	MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton3, 5, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow);  // The West edge of ExampleButton3 is 5 pixels to the right of the Horizontal Center of the MainInternalWindow.
    MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ExampleButton3, -25, SpringLayoutConstraints::EAST_EDGE, MainInternalWindow);  // The East edge of ExampleButton3 is 25 pixels to the left of the East edge of the MainInternalWindow.

	//Example Button 4
	MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ExampleButton4, 25, SpringLayoutConstraints::SOUTH_EDGE, ExampleButton1);  // The North edge of ExampleButton4 is 25 pixels below the South edge of ExampleButton1.
	MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ExampleButton4, -25, SpringLayoutConstraints::NORTH_EDGE, ExampleButton2);  // The South edge of ExampleButton4 is 25 pixels above the North edge of ExampleButton2.
	MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton4, 25, SpringLayoutConstraints::WEST_EDGE, MainInternalWindow);  // The West edge of ExampleButton4 is 25 pixels to the right of the West edge of the MainInternalWindow.
    MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ExampleButton4, -100, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow);  // The East edge of ExampleButton4 is 100 pixels to the left of the Horizontal Center of the MainInternalWindow.
	
	//Example Button 5
	MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ExampleButton5, 25, SpringLayoutConstraints::SOUTH_EDGE, ExampleButton1);  // The North edge of ExampleButton5 is 25 pixels below the South edge of ExampleButton1.
	MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, ExampleButton5, 0, SpringLayoutConstraints::HEIGHT_EDGE, ExampleButton4);  // The Height of ExampleButton5 is set to the Height of ExampleButton4.
	MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ExampleButton5, 75, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow);  // The East edge of ExampleButton5 is 75 pixels to the right of the Horizontal Center of the MainInternalWindow.
    MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton5, -75, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow);  // The West edge of ExampleButton5 is 75 pixels to the left of the Horizontal Center of the MainInternalWindow.

	//Example Button 6
	MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ExampleButton6, 25, SpringLayoutConstraints::SOUTH_EDGE, ExampleButton1);  // The North edge of ExampleButton6 is 25 pixels below the South edge of ExampleButton1.
	MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ExampleButton6, -25, SpringLayoutConstraints::NORTH_EDGE, ExampleButton2);  // The South edge of ExampleButton6 is 25 pixels above the North edge of ExampleButton2.
	MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton6, 100, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow);  // The West edge of ExampleButton6 is 100 pixels to the right of the Horizontal Center of the MainInternalWindow.
    MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, ExampleButton6, 0, SpringLayoutConstraints::WIDTH_EDGE, ExampleButton4);  // The Width of ExampleButton6 is set to the Width of ExampleButton4.

    // Create The Main InternalWindow
    // Create Background to be used with the Main InternalWindow
    ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
        MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

       MainInternalWindow->pushToChildren(ExampleButton1);
       MainInternalWindow->pushToChildren(ExampleButton2);
       MainInternalWindow->pushToChildren(ExampleButton3);
	   MainInternalWindow->pushToChildren(ExampleButton4);
       MainInternalWindow->pushToChildren(ExampleButton5);
       MainInternalWindow->pushToChildren(ExampleButton6);
       MainInternalWindow->setLayout(MainInternalWindowLayout);
       MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
	   MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
	   MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
	   MainInternalWindow->setDrawTitlebar(false);
	   MainInternalWindow->setResizable(false);

    // Create the Drawing Surface
    UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);
    
	TutorialDrawingSurface->openWindow(MainInternalWindow);

    // Create the UI Foreground Object
    UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);
    mgr->setRoot(scene);

    // Add the UI Foreground Object to the Scene
    ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
        TutorialViewport->addForeground(TutorialUIForeground);

    // Show the whole Scene
    mgr->showAll();


    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
            WinSize,
            "36SpringLayout");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
开发者ID:danguilliams,项目名称:OpenSGToolbox,代码行数:101,代码来源:36SpringLayout.cpp

示例7: main


//.........这里部分代码省略.........
    ExampleButton->setTextColor(Color4f(1.0, 0.0, 0.0, 1.0));
    ExampleButton->setRolloverTextColor(Color4f(1.0, 0.0, 1.0, 1.0));
    ExampleButton->setActiveTextColor(Color4f(1.0, 0.0, 0.0, 1.0));
    ExampleButton->setAlignment(Vec2f(1.0,0.0));


    /******************************************************

      Create a ToggleButton and determine its
      characteristics.  ToggleButton inherits
      off of Button, so all characteristsics
      used above can be used with ToggleButtons
      as well.

      The only difference is that when pressed,
      ToggleButton remains pressed until pressed
      again.

      -setSelected(bool): Determine whether the
      ToggleButton is Selected (true) or
      deselected (false).

     ******************************************************/
    ToggleButtonRefPtr ExampleToggleButton = OSG::ToggleButton::create();

    ExampleToggleButton->setSelected(false);
    ExampleToggleButton->setText("ToggleMe");
    ExampleToggleButton->setToolTipText("Toggle Button ToolTip");


    // Create Background to be used with the MainInternalWindow
    ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
    MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

    // Create The Internal Window
    InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
    LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
    // Assign the Button to the MainInternalWindow so it will be displayed
    // when the view is rendered.
    MainInternalWindow->pushToChildren(ExampleButton);
    MainInternalWindow->setLayout(MainInternalWindowLayout);
    MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
    MainInternalWindow->setPosition(Pnt2f(50,50));
    MainInternalWindow->setPreferredSize(Vec2f(300,300));
    MainInternalWindow->setTitle(std::string("Internal Window 1"));

    // Create The Internal Window
    InternalWindowRefPtr MainInternalWindow2 = OSG::InternalWindow::create();
    LayoutRefPtr MainInternalWindowLayout2 = OSG::FlowLayout::create();
    // Assign the Button to the MainInternalWindow so it will be displayed
    // when the view is rendered.
    MainInternalWindow2->pushToChildren(ExampleToggleButton);
    MainInternalWindow2->setLayout(MainInternalWindowLayout2);
    MainInternalWindow2->setBackgrounds(MainInternalWindowBackground);
    MainInternalWindow2->setPosition(Pnt2f(150,150));
    MainInternalWindow2->setPreferredSize(Vec2f(300,300));
    MainInternalWindow2->setTitle(std::string("Internal Window 2"));
    MainInternalWindow2->setIconable(false);
    MainInternalWindow2->setAllwaysOnTop(true);

    // Create the Drawing Surface
    UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
    TutorialDrawingSurface->setGraphics(TutorialGraphics);
    TutorialDrawingSurface->setEventProducer(TutorialWindow);

    TutorialDrawingSurface->openWindow(MainInternalWindow);
    TutorialDrawingSurface->openWindow(MainInternalWindow2);
    // Create the UI Foreground Object
    UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
    TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);
    mgr->setRoot(scene);

    // Add the UI Foreground Object to the Scene
    ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
    TutorialViewport->addForeground(TutorialUIForeground);

    // Show the whole Scene
    mgr->showAll();


    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
                               WinSize,
                               "37InternalWindow");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
开发者ID:danguilliams,项目名称:OpenSGToolbox,代码行数:101,代码来源:37InternalWindow.cpp

示例8: main

int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // Set up Window
    TutorialWindow = createNativeWindow();
    TutorialWindow->initWindow();

    TutorialWindow->setDisplayCallback(display);
    TutorialWindow->setReshapeCallback(reshape);

    TutorialKeyListener TheKeyListener;
    TutorialWindow->addKeyListener(&TheKeyListener);
    TutorialMouseListener TheTutorialMouseListener;
    TutorialMouseMotionListener TheTutorialMouseMotionListener;
    TutorialWindow->addMouseListener(&TheTutorialMouseListener);
    TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);


    //Particle System
    ParticleSystemRefPtr ExampleParticleSystem = OSG::ParticleSystem::create();
    ExampleParticleSystem->attachUpdateListener(TutorialWindow);

    PointParticleSystemDrawerRefPtr ExamplePointParticleSystemDrawer = OSG::PointParticleSystemDrawer::create();
    //NodeRefPtr ParticlePrototypeNode = makeTorus(1.0,4.0,16,16);
    //NodeRefPtr CollisionNode = makeBox(5.0,5.0,5.0,1,1,1);//makeSphere(4,10.0f);
    NodeRefPtr CollisionNode = makeSphere(2,4.0f);

    //Particle System Material
    PointChunkRefPtr PSPointChunk = PointChunk::create();
    PSPointChunk->setSize(5.0f);
    PSPointChunk->setSmooth(true);
    BlendChunkRefPtr PSBlendChunk = BlendChunk::create();
    PSBlendChunk->setSrcFactor(GL_SRC_ALPHA);
    PSBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);

    MaterialChunkRefPtr PSMaterialChunkChunk = MaterialChunk::create();
    PSMaterialChunkChunk->setAmbient(Color4f(1.0f,0.0f,0.0f,1.0f));
    PSMaterialChunkChunk->setDiffuse(Color4f(1.0f,0.0f,0.0f,1.0f));
    PSMaterialChunkChunk->setSpecular(Color4f(1.0f,0.0f,0.0f,1.0f));
    PSMaterialChunkChunk->setColorMaterial(GL_NONE);
    //PSMaterialChunkChunk->setLit(false);

    ChunkMaterialRefPtr PSMaterial = ChunkMaterial::create();
    PSMaterial->addChunk(PSPointChunk);
    PSMaterial->addChunk(PSMaterialChunkChunk);
    PSMaterial->addChunk(PSBlendChunk);

    ParticleSystemCoreRefPtr ParticleNodeCore = OSG::ParticleSystemCore::create();
    ParticleNodeCore->setSystem(ExampleParticleSystem);
    ParticleNodeCore->setDrawer(ExamplePointParticleSystemDrawer);
    ParticleNodeCore->setMaterial(PSMaterial);

    NodeRefPtr ParticleNode = OSG::Node::create();
    ParticleNode->setCore(ParticleNodeCore);

    //Generator
    //Attach the function objects to the Generator
    RateParticleGeneratorRefPtr ExampleGenerator= RateParticleGenerator::create();
    ExampleGenerator->setPositionDistribution(createPositionDistribution());
    ExampleGenerator->setLifespanDistribution(createLifespanDistribution());
    ExampleGenerator->setGenerationRate(20.0);
    ExampleGenerator->setVelocityDistribution(createVelocityDistribution());

    //Geometry Collision Affector
    GeometryCollisionParticleSystemAffectorRefPtr ExampleGeometryCollisionParticleSystemAffector = GeometryCollisionParticleSystemAffector::create();
    ExampleGeometryCollisionParticleSystemAffector->setCollisionNode(CollisionNode);

    TutorialParticleCollisionListener TheCollisionListener;
    ExampleGeometryCollisionParticleSystemAffector->addParticleGeometryCollisionListener(&TheCollisionListener);

    ExampleParticleSystem->pushToSystemAffectors(ExampleGeometryCollisionParticleSystemAffector);
    ExampleParticleSystem->pushToGenerators(ExampleGenerator);


    // Make Main Scene Node and add the Torus
    NodeRefPtr scene = OSG::Node::create();
    scene->setCore(OSG::Group::create());
    scene->addChild(ParticleNode);
    scene->addChild(CollisionNode);

    mgr->setRoot(scene);

    // Show the whole Scene
    mgr->showAll();


    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
                               WinSize,
                               "13CollisionGeometry");
//.........这里部分代码省略.........
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:101,代码来源:13GeometryCollision.cpp

示例9: main


//.........这里部分代码省略.........
    LookAndFeelManager::the()->getLookAndFeel()->init();

    /******************************************************

      Create the DefaultMutableComboBoxModel and
      add Elements to it (several Colors
      in this case).  These will be the data
      values shown in the ComboBox.

     ******************************************************/   

    DefaultMutableComboBoxModelRefPtr ExampleComboBoxModel = DefaultMutableComboBoxModel::create();
    ExampleComboBoxModel->addElement(boost::any(Color4f(1.0,0.0,0.0,1.0)));
    ExampleComboBoxModel->addElement(boost::any(Color4f(0.0,1.0,0.0,1.0)));
    ExampleComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,1.0,1.0)));
    ExampleComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,0.0,1.0)));
	ExampleComboBoxModel->addElement(boost::any(Color4f(1.0,1.0,1.0,1.0)));
	ExampleComboBoxModel->addElement(boost::any(std::string("More Colors")));


    /******************************************************

      Create an editable ComboBox.  A ComboBox 
      has a Model just like various other 
      Components.  

     ******************************************************/   

	ColorChooserComboBoxComponentGeneratorRefPtr TheColorChooserComboBoxComponentGenerator = ColorChooserComboBoxComponentGenerator::create();
	
    //Create the ComboBox
    ComboBoxRefPtr ExampleComboBox = ComboBox::create();

    // Set the Model created above to the ComboBox
    ExampleComboBox->setModel(ExampleComboBoxModel);
	ExampleComboBox->setCellGenerator(TheColorChooserComboBoxComponentGenerator);
	ExampleComboBox->setEditable(false);


    // Determine where the ComboBox starts
    ExampleComboBox->setSelectedIndex(0);


	// Create The Main InternalWindow
    // Create Background to be used with the Main InternalWindow
    ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
    MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

    LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();

    InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
    MainInternalWindow->pushToChildren(ExampleComboBox);
    MainInternalWindow->setLayout(MainInternalWindowLayout);
    MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
    MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
    MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
    MainInternalWindow->setDrawTitlebar(false);
    MainInternalWindow->setResizable(false);

    //Create the Drawing Surface
    UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
    TutorialDrawingSurface->setGraphics(graphics);
    TutorialDrawingSurface->setEventProducer(TutorialWindow);

    TutorialDrawingSurface->openWindow(MainInternalWindow);

    // Create the UI Foreground Object
    UIForegroundRefPtr foreground = OSG::UIForeground::create();

    foreground->setDrawingSurface(TutorialDrawingSurface);


    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the manager what to manage
    mgr->setWindow(TutorialWindow);
    mgr->setRoot(scene);

    // Add the UI Foreground Object to the Scene
    ViewportRefPtr viewport = mgr->getWindow()->getPort(0);
    viewport->addForeground(foreground);

    // Show the whole scene
    mgr->showAll();

    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
                               WinSize,
                               "33_2_ColorComboBox");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
开发者ID:achvas88,项目名称:VizTool,代码行数:101,代码来源:1_ColorComboBox.cpp

示例10: main


//.........这里部分代码省略.........
			of pixels between each row.


    ******************************************************/

    GridLayoutRefPtr MainInternalWindowLayout = OSG::GridLayout::create();

        MainInternalWindowLayout->setRows(3);
        MainInternalWindowLayout->setColumns(2);
        MainInternalWindowLayout->setHorizontalGap(4);
        MainInternalWindowLayout->setVerticalGap(4);


    /******************************************************
            
             Create and edit some Button Components.

			 Note that as with BoxLayout, Components
			 are resized to fit their respective
			 grid boxes.  Unless a MaxSize is set,
			 this will be the case.  This will
			 override even PreferredSizes (see
			 ExampleButton3).

    ******************************************************/

    ButtonRefPtr ExampleButton1 = OSG::Button::create();
    ButtonRefPtr ExampleButton2 = OSG::Button::create();
    ButtonRefPtr ExampleButton3 = OSG::Button::create();
    ButtonRefPtr ExampleButton4 = OSG::Button::create();
    ButtonRefPtr ExampleButton5 = OSG::Button::create();
    ButtonRefPtr ExampleButton6 = OSG::Button::create();

        ExampleButton1->setPreferredSize(Vec2f(50,50));
        ExampleButton1->setMaxSize(Vec2f(50,50));			//if MaxSize is commented out, this button then will revert to being the same size as the others in the grid.

         ExampleButton2->setPreferredSize(Vec2f(200,100));	//<----
															//    |
         ExampleButton3->setPreferredSize(Vec2f(50,100));		//Notice that even though these two differ in size they appear the same on the grid


    // Create The Main InternalWindow
    // Create Background to be used with the Main InternalWindow
    ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
        MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

    InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
       MainInternalWindow->pushToChildren(ExampleButton1);
       MainInternalWindow->pushToChildren(ExampleButton2);
       MainInternalWindow->pushToChildren(ExampleButton3);
       MainInternalWindow->pushToChildren(ExampleButton4);
       MainInternalWindow->pushToChildren(ExampleButton5);
       MainInternalWindow->pushToChildren(ExampleButton6);
       MainInternalWindow->setLayout(MainInternalWindowLayout);
       MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
	   MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
	   MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
	   MainInternalWindow->setDrawTitlebar(false);
	   MainInternalWindow->setResizable(false);
      
    // Create the Drawing Surface
    UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);
    
	TutorialDrawingSurface->openWindow(MainInternalWindow);

    // Create the UI Foreground Object
    UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);
    mgr->setRoot(scene);

    // Add the UI Foreground Object to the Scene
    ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
        TutorialViewport->addForeground(TutorialUIForeground);

    // Show the whole Scene
    mgr->showAll();

    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
            WinSize,
            "07GridLayout");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:101,代码来源:07GridLayout.cpp

示例11: main

int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // Set up Window
    TutorialWindow = createNativeWindow();
    TutorialWindow->initWindow();

    TutorialWindow->setDisplayCallback(display);
    TutorialWindow->setReshapeCallback(reshape);

    TutorialKeyListener TheKeyListener;
    TutorialWindow->addKeyListener(&TheKeyListener);
    TutorialMouseListener TheTutorialMouseListener;
    TutorialMouseMotionListener TheTutorialMouseMotionListener;
    TutorialWindow->addMouseListener(&TheTutorialMouseListener);
    TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);

    Distribution3DRefPtr PositionDistribution = createPositionDistribution();
    Distribution1DRefPtr LifespanDistribution = createLifespanDistribution();

    Pnt3f PositionReturnValue;
    Time LifespanReturnValue = -1;

    //Particle System
    ParticleSystemRefPtr ExampleParticleSystem = OSG::ParticleSystem::create();
    for(UInt32 i(0) ; i<200 ; ++i)//controls how many particles are created
    {
        if(PositionDistribution != NULL)
        {
            PositionReturnValue = Pnt3f(PositionDistribution->generate());
        }
        if(LifespanDistribution != NULL)
        {
            LifespanReturnValue = LifespanDistribution->generate();
        }

        ExampleParticleSystem->addParticle(
                                           PositionReturnValue,
                                           Vec3f(1.0f,0.0f,0.0f),
                                           Color4f(1.0,0.0,0.0,1.0), 
                                           Vec3f(1.0,1.0,1.0), 
                                           LifespanReturnValue, 
                                           Vec3f(0.0f,0.0f,0.0f), //Velocity
                                           Vec3f(0.0f,0.0f,0.0f)	//acceleration
                                          );
    }
    ExampleParticleSystem->attachUpdateListener(TutorialWindow);

    //NodeRefPtr ParticlePrototypeNode = makeTorus(1.0,4.0,16,16);
    NodeRefPtr ParticlePrototypeNode = SceneFileHandler::the()->read("Data/rocket.obj");
    if(ParticlePrototypeNode == NULL)
    {
        ParticlePrototypeNode = makeTorus(.5, 2, 16, 16);
    }
    //Particle System Node
    NodeParticleSystemCoreRefPtr NodeParticleNodeCore = OSG::NodeParticleSystemCore::create();
    NodeParticleNodeCore->setSystem(ExampleParticleSystem);
    NodeParticleNodeCore->setPrototypeNode(ParticlePrototypeNode);
    NodeParticleNodeCore->setNormalSource(NodeParticleSystemCore::NORMAL_VELOCITY);
    NodeParticleNodeCore->setUpSource(NodeParticleSystemCore::UP_STATIC);
    NodeParticleNodeCore->setUp(Vec3f(0.0f,1.0f,0.0f));

    NodeRefPtr ParticleNode = OSG::Node::create();
    ParticleNode->setCore(NodeParticleNodeCore);

    //Create an CollectiveGravityParticleSystemAffector
    CollectiveGravityParticleSystemAffectorRefPtr ExampleCollectiveGravityParticleSystemAffector = OSG::CollectiveGravityParticleSystemAffector::create();
    ExampleCollectiveGravityParticleSystemAffector->setParticleMass(10000000000.0f);

    ExampleParticleSystem->pushToSystemAffectors(ExampleCollectiveGravityParticleSystemAffector);


    // Make Main Scene Node and add the Torus
    NodeRefPtr scene = OSG::Node::create();
    scene->setCore(OSG::Group::create());
    scene->addChild(ParticleNode);

    mgr->setRoot(scene);

    // Show the whole Scene
    mgr->showAll();


    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
                               WinSize,
                               "12NodeParticleDrawer");

    //Enter main Loop
    TutorialWindow->mainLoop();
//.........这里部分代码省略.........
开发者ID:danguilliams,项目名称:OpenSGToolbox,代码行数:101,代码来源:12NodeParticleDrawer.cpp

示例12: main


//.........这里部分代码省略.........
    // Make Torus Node (creates Torus in background of scene)
    NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);

    // Make Main Scene Node and add the Torus
    NodeRefPtr scene = OSG::Node::create();
    scene->setCore(OSG::Group::create());
    scene->addChild(TorusGeometryNode);

    // Create the Graphics
    GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();

    // Initialize the LookAndFeelManager to enable default settings
    LookAndFeelManager::the()->getLookAndFeel()->init();


    /******************************************************

        Create and edit a CheckboxButton.

    	Note: the only function call shown
    	specific to	CheckboxButton is setSelected.
    	In DefaultLookAndFeel, the options
    	for changing the style of the CheckBox
    	are shown.  CheckboxButton also
    	inherits off Button so all features
    	of Button may be used.

    	-setSelected(bool): Determines if the
    		CheckboxButton is checked(true) or
    		not checked(false).

    ******************************************************/
    CheckboxButtonRefPtr ExampleCheckboxButton = OSG::CheckboxButton::create();
    ExampleCheckboxButton->setMinSize(Vec2f(50, 25));
    ExampleCheckboxButton->setMaxSize(Vec2f(300, 100));
    ExampleCheckboxButton->setPreferredSize(Vec2f(200, 50));
    ExampleCheckboxButton->setEnabled(true);
    ExampleCheckboxButton->setText("Checkbox Button");
    ExampleCheckboxButton->setAlignment(Vec2f(0.5,0.5));
    ExampleCheckboxButton->setSelected(true);


    // Create The Main InternalWindow
    // Create Background to be used with the Main InternalWindow
    ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
    MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

    LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();

    InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
    MainInternalWindow->pushToChildren(ExampleCheckboxButton);
    MainInternalWindow->setLayout(MainInternalWindowLayout);
    MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
    MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
    MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
    MainInternalWindow->setDrawTitlebar(false);
    MainInternalWindow->setResizable(false);

    // Create the Drawing Surface
    UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
    TutorialDrawingSurface->setGraphics(TutorialGraphics);
    TutorialDrawingSurface->setEventProducer(TutorialWindow);

    TutorialDrawingSurface->openWindow(MainInternalWindow);

    // Create the UI Foreground Object
    UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();

    TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);


    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);
    mgr->setRoot(scene);

    // Add the UI Foreground Object to the Scene
    ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
    TutorialViewport->addForeground(TutorialUIForeground);

    // Show the whole Scene
    mgr->showAll();


    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
                               WinSize,
                               "13CheckboxButton");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
开发者ID:danguilliams,项目名称:OpenSGToolbox,代码行数:101,代码来源:13CheckboxButton.cpp

示例13: main


//.........这里部分代码省略.........
    physHandler->pushToSpaces(physicsSpace);
    physHandler->setUpdateNode(rootNode);

    physHandler->attachUpdateProducer(TutorialWindow->editEventProducer());


    /************************************************************************/
    /* create spaces, geoms and bodys                                       */
    /************************************************************************/
    //create a group for our space
    GroupRefPtr spaceGroup;
    spaceGroupNode = makeCoredNode<Group>(&spaceGroup);
    //create the ground plane
    GeometryRefPtr plane;
    NodeRefPtr planeNode = makeBox(30.0, 30.0, 1.0, 1, 1, 1);
    plane = dynamic_cast<Geometry*>(planeNode->getCore());
    //and its Material
    SimpleMaterialRefPtr plane_mat = SimpleMaterial::create();
    plane_mat->setAmbient(Color3f(0.7,0.7,0.7));
    plane_mat->setDiffuse(Color3f(0.9,0.6,1.0));

    plane->setMaterial(plane_mat);



    //create Physical Attachments
    PhysicsBoxGeomRefPtr planeGeom = PhysicsBoxGeom::create();
    planeGeom->setLengths(Vec3f(30.0, 30.0, 1.0));
    //add geoms to space for collision
    planeGeom->setSpace(physicsSpace);


    //add Attachments to nodes...
    spaceGroupNode->addAttachment(physicsSpace);
    spaceGroupNode->addAttachment(physHandler);    
    spaceGroupNode->addAttachment(physicsWorld);
    spaceGroupNode->addChild(planeNode);


    planeNode->addAttachment(planeGeom);


    scene->addChild(spaceGroupNode);


    //Create Statistics Foreground
    SimpleStatisticsForegroundRefPtr PhysicsStatForeground = SimpleStatisticsForeground::create();
    PhysicsStatForeground->setSize(25);
    PhysicsStatForeground->setColor(Color4f(0,1,0,0.7));
    PhysicsStatForeground->addElement(PhysicsHandler::statPhysicsTime, 
                                      "Physics time: %.3f s");
    PhysicsStatForeground->addElement(PhysicsHandler::statCollisionTime, 
                                      "Collision time: %.3f s");
    PhysicsStatForeground->addElement(PhysicsHandler::statSimulationTime, 
                                      "Simulation time: %.3f s");
    PhysicsStatForeground->addElement(PhysicsHandler::statNCollisions, 
                                      "%d collisions");
    PhysicsStatForeground->addElement(PhysicsHandler::statNCollisionTests, 
                                      "%d collision tests");
    PhysicsStatForeground->addElement(PhysicsHandler::statNPhysicsSteps, 
                                      "%d simulation steps per frame");
    PhysicsStatForeground->setVerticalAlign(SimpleStatisticsForeground::Center);


    SimpleStatisticsForegroundRefPtr RenderStatForeground = SimpleStatisticsForeground::create();
    RenderStatForeground->setSize(25);
    RenderStatForeground->setColor(Color4f(0,1,0,0.7));
    RenderStatForeground->addElement(RenderAction::statDrawTime, "Draw FPS: %r.3f");
    RenderStatForeground->addElement(RenderAction::statNGeometries, 
                                     "%d Nodes drawn");





    // tell the manager what to manage
    mgr->setRoot  (rootNode);

    mgr->getWindow()->getPort(0)->addForeground(PhysicsStatForeground);
    mgr->getWindow()->getPort(0)->addForeground(RenderStatForeground);

    physHandler->setStatistics(PhysicsStatForeground->editCollector());
    mgr->getRenderAction()->setStatCollector(RenderStatForeground->editCollector());

    // show the whole rootNode
    mgr->showAll();

    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
                               WinSize,
                               "01SimplePhysics");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:101,代码来源:01SimplePhysics.cpp

示例14: main


//.........这里部分代码省略.........

    ParticleSystemCoreRefPtr SmokeParticleNodeCore = OSG::ParticleSystemCore::create();
    SmokeParticleNodeCore->setSystem(SmokeParticleSystem);
    SmokeParticleNodeCore->setDrawer(SmokeParticleSystemDrawer);
    SmokeParticleNodeCore->setMaterial(PSSmokeMaterial);

    NodeRefPtr SmokeParticleNode = OSG::Node::create();
    SmokeParticleNode->setCore(SmokeParticleNodeCore);
    //end/////////////////////

    //Shrapnel
    ShrapnelBurstGenerator = OSG::BurstParticleGenerator::create();
    NodeRefPtr ShrapnelParticlePrototypeNode = SceneFileHandler::the()->read("Data/Shrapnel.obj");

    NodeParticleSystemCoreRefPtr ShrapnelParticleNodeCore = OSG::NodeParticleSystemCore::create();
    ShrapnelParticleNodeCore->setSystem(ShrapnelParticleSystem);
    ShrapnelParticleNodeCore->setPrototypeNode(ShrapnelParticlePrototypeNode);

    //Attach the function objects to the Generator
    ShrapnelPositionDistribution = createShrapnelPositionDistribution();
    ShrapnelBurstGenerator->setPositionDistribution(ShrapnelPositionDistribution);
    ShrapnelBurstGenerator->setLifespanDistribution(createLifespanDistribution());
    ShrapnelBurstGenerator->setBurstAmount(50.0);
    ShrapnelBurstGenerator->setVelocityDistribution(createShrapnelVelocityDistribution());
    ShrapnelBurstGenerator->setAccelerationDistribution(createShrapnelAccelerationDistribution());

    NodeRefPtr ShrapnelParticleNode = OSG::Node::create();
    ShrapnelParticleNode->setCore(ShrapnelParticleNodeCore);
    //end/////////////////////

    //fireball
    FireballGenerator = OSG::BurstParticleGenerator::create();
    NodeRefPtr FireballParticlePrototypeNode = SceneFileHandler::the()->read("Data/bubble.obj");

    NodeParticleSystemCoreRefPtr FireballParticleNodeCore = OSG::NodeParticleSystemCore::create();
    FireballParticleNodeCore->setSystem(FireballParticleSystem);
    FireballParticleNodeCore->setPrototypeNode(FireballParticlePrototypeNode);
    //Attach the function objects to the Generator
    FireballPositionDistribution = createFireballPositionDistribution();
    FireballGenerator->setPositionDistribution(FireballPositionDistribution);
    FireballGenerator->setLifespanDistribution(createFireballLifespanDistribution());
    FireballGenerator->setBurstAmount(100.0);
    FireballGenerator->setVelocityDistribution(createFireballVelocityDistribution());
    FireballGenerator->setAccelerationDistribution(createFireballAccelerationDistribution());
    //Attach the function objects the Affectors
    FireballAgeSizeParticleAffector = OSG::AgeSizeParticleAffector::create();
    //ages
    FireballAgeSizeParticleAffector->editMFAges()->push_back(0.1);
    FireballAgeSizeParticleAffector->editMFAges()->push_back(0.2);
    FireballAgeSizeParticleAffector->editMFAges()->push_back(0.3);
    FireballAgeSizeParticleAffector->editMFAges()->push_back(0.5);
    FireballAgeSizeParticleAffector->editMFAges()->push_back(0.7);
    FireballAgeSizeParticleAffector->editMFAges()->push_back(0.8);
    FireballAgeSizeParticleAffector->editMFAges()->push_back(1.0);

    //sizes
    FireballAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(2.0,2.0,2.0));
    FireballAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(2.3,2.3,2.3));
    FireballAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(2.5,2.5,2.5));
    FireballAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(3.0,3.0,3.0));
    FireballAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(4.0,4.0,4.0));
    FireballAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(5.0,5.0,5.0));
    FireballAgeSizeParticleAffector->editMFSizes()->push_back(Vec3f(6.5,6.5,6.5));

    NodeRefPtr FireballParticleNode = OSG::Node::create();
    FireballParticleNode->setCore(FireballParticleNodeCore);
    //end/////////////////////


    // Make Main Scene Node 
    NodeRefPtr scene = OSG::Node::create();
    scene->setCore(OSG::Group::create());
    scene->addChild(RocketParticleNode);
    scene->addChild(SmokeParticleNode);
    scene->addChild(ShrapnelParticleNode);
    scene->addChild(FireballParticleNode);
    scene->addChild(EnvironmentNode);

    mgr->setRoot(scene);

    mgr->getNavigator()->set(Pnt3f(0.0,0.0,0.0), Pnt3f(0.0,0.0,-1.0), Vec3f(0.0,1.0,0.0));
    mgr->getNavigator()->setMotionFactor(1.0f);
    mgr->getCamera()->setNear(0.1f);
    mgr->getCamera()->setFar(1000.0f);


    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
                               WinSize,
                               "10RocketLauncher");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:101,代码来源:20RocketLauncher.cpp

示例15: main


//.........这里部分代码省略.........
        ExamplePanel1->setPreferredSize(Vec2f(400, 400));
        ExamplePanel1->pushToChildren(ExampleButton2);
        ExamplePanel1->pushToChildren(ExamplePanel3);
        ExamplePanel1->pushToChildren(ExamplePanel4);
        ExamplePanel1->setLayout(ExamplePanel1Layout);
        ExamplePanel1->setBackgrounds(ExamplePanelBackground);
        ExamplePanel1->setBorders(ExamplePanelBorder);

        ExamplePanel2->setPreferredSize(Vec2f(400, 400));
        ExamplePanel2->pushToChildren(ExampleButton3);
        ExamplePanel2->pushToChildren(ExamplePanel5);
        ExamplePanel2->pushToChildren(ExamplePanel6);
        ExamplePanel2->setLayout(ExamplePanel2Layout);
        ExamplePanel2->setBackgrounds(ExamplePanelBackground);
        ExamplePanel2->setBorders(ExamplePanelBorder);
    
        ExamplePanel3->pushToChildren(ExampleButton4);
        ExamplePanel3->pushToChildren(ExampleButton5);
        ExamplePanel3->setLayout(ExamplePanel3Layout);
        ExamplePanel3->setPreferredSize(Vec2f(125, 130));
        ExamplePanel3->setBackgrounds(ExampleSmallPanelBackground);
    
        ExamplePanel4->pushToChildren(ExampleButton6);
        ExamplePanel4->pushToChildren(ExampleButton7);
        ExamplePanel4->setLayout(ExamplePanel4Layout);
        ExamplePanel4->setPreferredSize(Vec2f(125, 130));
        ExamplePanel4->setBackgrounds(ExampleSmallPanelBackground);
        
        ExamplePanel5->pushToChildren(ExampleButton8);
        ExamplePanel5->pushToChildren(ExampleButton9);
        ExamplePanel5->setLayout(ExamplePanel5Layout);
        ExamplePanel5->setPreferredSize(Vec2f(125, 130));
        ExamplePanel5->setBackgrounds(ExampleSmallPanelBackground);
        
        ExamplePanel6->pushToChildren(ExampleButton10);
        ExamplePanel6->pushToChildren(ExampleButton11);
        ExamplePanel6->setLayout(ExamplePanel6Layout);
        ExamplePanel6->setPreferredSize(Vec2f(125, 130));
        ExamplePanel6->setBackgrounds(ExampleSmallPanelBackground);


    // Create The Main InternalWindow
    // Create Background to be used with the Main InternalWindow
    ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
        MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

    InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
       MainInternalWindow->setBorder(ExamplePanelBorder);
       MainInternalWindow->pushToChildren(ExampleLabel1);
       MainInternalWindow->pushToChildren(ExampleButton1);
       MainInternalWindow->pushToChildren(ExamplePanel1);
       MainInternalWindow->pushToChildren(ExamplePanel2);
       MainInternalWindow->setLayout(MainInternalWindowLayout);
       MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
	   MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
	   MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.8f,0.8f));
	   MainInternalWindow->setDrawTitlebar(false);
	   MainInternalWindow->setResizable(false);

    // Create the Drawing Surface
    UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);

	TutorialDrawingSurface->openWindow(MainInternalWindow);

    // Create the UI Foreground Object
    UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);
    mgr->setRoot(scene);

    // Add the UI Foreground Object to the Scene
    ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
        TutorialViewport->addForeground(TutorialUIForeground);

    // Show the whole Scene
    mgr->showAll();


    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
            WinSize,
            "12ComplexLayout");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
开发者ID:achvas88,项目名称:OpenSGToolbox,代码行数:101,代码来源:12ComplexLayout.cpp


注:本文中的WindowEventProducerRefPtr::getDesktopSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。