void create3DObjects(void)
{
    // Make Object Nodes
    NodeRefPtr ExampleTorusGeo = makeTorus(90, 270, 16, 16);
    NodeRefPtr ExampleConeGeo = makeCone(150, 50, 16, true, true);
    NodeRefPtr ExampleSphereGeo = makeSphere(4, 100);
    NodeRefPtr ExampleBoxGeo = makeBox(100, 100, 100, 1, 1, 1);

    // AssignTextures

    dynamic_cast<Geometry*>(ExampleConeGeo->getCore())->setMaterial(createBlueMaterial());

    dynamic_cast<Geometry*>(ExampleSphereGeo->getCore())->setMaterial(createRedMaterial());

    dynamic_cast<Geometry*>(ExampleBoxGeo->getCore())->setMaterial(createGreenMaterial());

    // Preform transformations on them
    Matrix mat;

    
    // On Torus    
    mat.setTranslate(0.0,100.0,-200.0);
    TransformRefPtr TorusTranCore = Transform::create();
        TorusTranCore->setMatrix(mat);
    
    ExampleTorus = Node::create();
        ExampleTorus->setCore(TorusTranCore);
        ExampleTorus->addChild(ExampleTorusGeo);
    
    // On Sphere
    mat.setTranslate(250.0,0.0,0.0);

    TransformRefPtr SphereTranCore = Transform::create();
        SphereTranCore->setMatrix(mat);
    
    ExampleSphere = Node::create();
        ExampleSphere->setCore(SphereTranCore);
        ExampleSphere->addChild(ExampleSphereGeo);

    // On Cone
    mat.setTranslate(0.0,0.0,-250.0);

    TransformRefPtr ConeTranCore = Transform::create();
        ConeTranCore->setMatrix(mat);
    
    ExampleCone = Node::create();
        ExampleCone->setCore(ConeTranCore);
        ExampleCone->addChild(ExampleConeGeo);
        
    // On Box
    mat.setTranslate(250.0,250.0,0.0);

    TransformRefPtr ExampleBoxTranCore = Transform::create();
        ExampleBoxTranCore->setMatrix(mat);
    
    ExampleBox = Node::create();
        ExampleBox->setCore(ExampleBoxTranCore);
        ExampleBox->addChild(ExampleBoxGeo);

}
void initOGL()
{
    totalpoints = cross_section_sides * whole_torus_sides;
    makeTorus(whole_torus_sides, cross_section_sides, torus_radius, cross_section_radius);

    glViewport(0, 0, 800, 800);
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    glPointSize(2.0f);

    glMatrixMode(GL_PROJECTION);
    gluPerspective(120, 1.0f, 0.01, 100);

//	//comment when camera inside
//	glLoadIdentity();
//	glOrthof(-6, 6, -9, 9, -100, 100);

    glMatrixMode(GL_MODELVIEW);

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);

    glEnable(GL_TEXTURE_2D);
    glEnable(GL_DEPTH_TEST);
}
    virtual void started(const DialogEventPtr e)
    {
        if(DialogPtr::dcast(e->getSource()) == BDialogChildB)
        {
            NodePtr s = makeSphere(1,2);
            beginEditCP(scene, Node::ChildrenFieldMask);
                while(scene->getNChildren() > 0)
                {
                    scene->subChild(scene->getNChildren()-1);
                }
                scene->addChild(s);
            endEditCP(scene, Node::ChildrenFieldMask);
        }
        if(DialogPtr::dcast(e->getSource()) == BDialogChildA)
        {
            NodePtr s = makeBox(3,3,3,2,2,2);
            beginEditCP(scene, Node::ChildrenFieldMask);
                while(scene->getNChildren() > 0)
                {
                    scene->subChild(scene->getNChildren()-1);
                }
                scene->addChild(s);
            endEditCP(scene, Node::ChildrenFieldMask);
        }
        if(DialogPtr::dcast(e->getSource()) == ADialogChildA)
        {
            beginEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);
                MainInternalWindowBackground->setColor(Color4f(0.0,0.0,1.0,0.5));
            endEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);
        }
        if(DialogPtr::dcast(e->getSource()) == ADialogChildB)
        {
            beginEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);
                MainInternalWindowBackground->setColor(Color4f(1.0,0.0,0.0,0.5));
            endEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);
        }
        if(DialogPtr::dcast(e->getSource()) == End1 || DialogPtr::dcast(e->getSource()) == End2 || DialogPtr::dcast(e->getSource()) == End3 || DialogPtr::dcast(e->getSource()) == End4 )
        {
            TutorialWindowEventProducer->closeWindow();
        }
        if(DialogPtr::dcast(e->getSource()) == Restart1 || DialogPtr::dcast(e->getSource()) == Restart2 || DialogPtr::dcast(e->getSource()) == Restart3 || DialogPtr::dcast(e->getSource()) == Restart4)
        {
            beginEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);
                MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
            endEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);

            NodePtr s = makeTorus(.5, 2, 16, 16);
            beginEditCP(scene, Node::ChildrenFieldMask);
                while(scene->getNChildren() > 0)
                {
                    scene->subChild(scene->getNChildren()-1);
                }
                scene->addChild(s);
            endEditCP(scene, Node::ChildrenFieldMask);
        }
    }
Esempio n. 4
0
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // GLUT init
    int winid = setupGLUT(&argc, argv);

    // the connection between GLUT and OpenSG
    GLUTWindowPtr gwin= GLUTWindow::create();
    gwin->setId(winid);
    gwin->init();

    // create the scene

    NodePtr torus = makeTorus( .5, 2, 16, 32 );

    // create the transformation node
    // scenegraph nodes are split into 2 parts: the node and its core
    
    // 1. create the Node
    NodePtr scene = Node::create();
    
    // 2. create the core
    trans = Transform::create();
    
    // 3. associate the core with the node
 
    // OpenSG objects need to be informed when they are being changed, 
    // that's what beginEditCP() and endEditCP() do
    beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
    {
        scene->setCore(trans);
 
        // add the torus as a child
        scene->addChild(torus);
    }
    endEditCP  (scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
    

    // create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // tell the manager what to manage
    mgr->setWindow(gwin );
    mgr->setRoot  (scene);

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

    // GLUT main loop
    glutMainLoop();

    return 0;
}
Esempio n. 5
0
//////////////////////////////////////////////////////////////////////////
//! trimesh defined by filenode will be loaded
//////////////////////////////////////////////////////////////////////////
void buildTriMesh(void)
{
    NodeRefPtr tri = cloneTree(TriGeometryBase);
    if(tri!=NULL)
    {
        GeometryRefPtr triGeo = dynamic_cast<Geometry*>(tri->getCore()); 
        Matrix m;
        SimpleMaterialRefPtr tri_mat = SimpleMaterial::create();
        tri_mat->setAmbient(Color3f(0.1,0.1,0.2));
        tri_mat->setDiffuse(Color3f(1.0,0.1,0.7));

        triGeo->setMaterial(tri_mat);
        TransformRefPtr triTrans;
        NodeRefPtr triTransNode = makeCoredNode<Transform>(&triTrans);
        m.setIdentity();
        Real32 randX = (Real32)(rand()%10)-5.0;
        Real32 randY = (Real32)(rand()%10)-5.0;
        m.setTranslate(randX, randY, 18.0);
        triTrans->setMatrix(m);

        //create ODE data
        Vec3f GeometryBounds(calcMinGeometryBounds(triGeo));
        PhysicsBodyRefPtr triBody = PhysicsBody::create(physicsWorld);
        triBody->setPosition(Vec3f(randX, randY, 18.0));
        triBody->setLinearDamping(0.0001);
        triBody->setAngularDamping(0.0001);

        triBody->setBoxMass(1.0,GeometryBounds.x(), GeometryBounds.y(), GeometryBounds.z());
        PhysicsGeomRefPtr triGeom;
        if(true)
        {
            triGeom = PhysicsTriMeshGeom::create();
            triGeom->setBody(triBody);
            //add geom to space for collision
            triGeom->setSpace(physicsSpace);
            //set the geometryNode to fill the ode-triMesh
            NodeRefPtr TorusGeometryNode(makeTorus(0.55, 1.05, 6, 6));
            dynamic_pointer_cast<PhysicsTriMeshGeom>(triGeom)->setGeometryNode(TorusGeometryNode);
        }

        //add attachments
        tri->addAttachment(triGeom);
        triTransNode->addAttachment(triBody);
        //add to SceneGraph
        triTransNode->addChild(tri);
        spaceGroupNode->addChild(triTransNode);
    }
    else
    {
        SLOG << "Could not read MeshData!" << endLog;
    }

    commitChanges();
}
Esempio n. 6
0
//
// setup scene
//
static int doMain(int argc, char *argv[])
{
    preloadSharedObject("OSGFileIO");
    preloadSharedObject("OSGImageFileIO");

    osgInit(argc,argv);

    int winid = setupGLUT(&argc, argv);

    win = GLUTWindow::create();
    win->setGlutId(winid);
    win->init();

    if(argc < 2)
    {
        FWARNING(("No file given!\n"));
        FWARNING(("Supported file formats:\n"));

        std::list<const char*> suffixes;
        SceneFileHandler::the()->getSuffixList(suffixes);

        for(std::list<const char*>::iterator it  = suffixes.begin();
                                            it != suffixes.end();
                                        ++it)
        {
            FWARNING(("%s\n", *it));
        }

        scene = makeTorus(.5, 2, 16, 16);
    }
    else
    {
        scene = SceneFileHandler::the()->read(argv[1]);
    }

    commitChanges();

    mgr = SimpleSceneManager::create();

    mgr->setWindow(win);
    mgr->setRoot  (scene);

    GradientBackgroundUnrecPtr background = GradientBackground::create();
    background->addLine(Color3f(0,0,0), 0);
    background->addLine(Color3f(1,1,1), 1);

    Viewport* viewport = win->getPort(0);
    viewport->setBackground(background);

    mgr->showAll();

    return 0;
}
Esempio n. 7
0
 virtual void actionPerformed(const ActionEventPtr e)
  {
      TutorialSound->stop(TutorialSoundChannelID);
      std::cout << "Stop Action" << std::endl;
      NodePtr s = makeTorus(.5, 2, 16, 16);
      beginEditCP(scene, Node::ChildrenFieldMask);
          while(scene->getNChildren() > 0)
          {
              scene->subChild(scene->getNChildren()-1);
          }
          scene->addChild(s);
      endEditCP(scene, Node::ChildrenFieldMask);
      
      segUpdate = 0;
  }
Esempio n. 8
0
OSG_USING_NAMESPACE

int main(int argc, char *argv[])
{
    osgInit(argc, argv);

    QApplication app(argc, argv);

    std::string    sceneFileName;
    NodePtr        pRootNode;
    QNodeTreeView *pView         = new QNodeTreeView(NULL, "pView");

    if(argc < 2)
    {
        FWARNING(("No file given!\n"));
        FWARNING(("Supported file formats:\n"));

        std::list<const char*> suffixes;
        SceneFileHandler::the().getSuffixList(suffixes);

        for(std::list<const char*>::iterator it  = suffixes.begin();
                it != suffixes.end();
                ++it)
        {
            FWARNING(("%s\n", *it));
        }

        pRootNode = makeTorus(.5, 2, 16, 16);
    }
    else
    {
        pRootNode = SceneFileHandler::the().read(argv[1]);
    }

    if(pRootNode == NullFC)
    {
        SFATAL << "Failed to load scene from file." << endLog;
        exit(1);
    }

    pView->setRoot(pRootNode);

    app.setMainWidget(pView);

    pView->show();

    return app.exec();
}
Esempio n. 9
0
NodePtr makeScene()
{
    g_fb_chunk = FatBorderChunk::create();
    beginEditCP(g_fb_chunk);
    g_fb_chunk->activateWithStandardLighting();
    g_fb_chunk->setIgnore(true);
    endEditCP(g_fb_chunk);

    NodePtr root = makeCoredNode<Switch>();
    beginEditCP(root);
    root->addChild(makeTeapot());
    root->addChild(makeTorus());
    root->addChild(makeTrimmedCylinder());
    endEditCP(root);
    return root;
}
Esempio n. 10
0
//
// create an arbitrarly complex render scene
//
static NodeTransitPtr createStaticScene()
{
    NodeUnrecPtr root = makeCoredNode<Group>();

    typedef boost::mt19937 base_generator_type;
    static base_generator_type generator(0);
    static boost::uniform_01<float> value;
    static boost::variate_generator< base_generator_type, boost::uniform_01<float> > die(generator, value);

    for (int i = 0; i < max_tori; ++i) {
        NodeUnrecPtr scene = makeTorus(.5, 2, 32, 32);

        TransformUnrecPtr transformCore = Transform::create();
        Matrix mat;

        mat.setIdentity();

        float x = 500.f * die();
        float y = 500.f * die();
        float z = 500.f * die();

        float e1 = die();
        float e2 = die();
        float e3 = die();

        Vec3f v(e1,e2,e3);
        v.normalize();

        float a = TwoPi * die();

        Quaternion q(v, a);

        mat.setTranslate(x,y,z);
        mat.setRotate(q);

        transformCore->setMatrix(mat);

        NodeUnrecPtr trafo = makeNodeFor(transformCore);

        trafo->addChild(scene);

        root->addChild(trafo);
    }
    
    return NodeTransitPtr(root);
}
Esempio n. 11
0
int main( int argc, char **argv )
{
    osgInit(argc,argv);
    
    QApplication::setColorSpec( QApplication::CustomColor );
    QApplication a( argc, argv );

    if ( !QGLFormat::hasOpenGL() ) {
	qWarning( "This system has no OpenGL support. Exiting." );
	return -1;
    }
    
    OpenSGWidget w(QGLFormat(QGL::DoubleBuffer | QGL::DepthBuffer | QGL::Rgba |
                             QGL::DirectRendering));

    // create the scene
    NodePtr scene;
    
    if(argc > 1)
    {
        scene = Node::create();
        GroupPtr g = Group::create();
        
        beginEditCP(scene);
        scene->setCore(g);
        
        for(UInt16 i = 1; i < argc; ++i)
            scene->addChild(SceneFileHandler::the().read(argv[i]));
        
        endEditCP(scene);
    }
    else
    {
        scene = makeTorus(.5, 3, 16, 16);
    }

    w.getManager()->setRoot(scene);
    w.getManager()->showAll();

    w.show();
    return a.exec();
}
Esempio n. 12
0
NodeTransitPtr createTorus(void)
{
    // Make Object Nodes
    NodeRecPtr ExampleTorusGeo = makeTorus(90, 270, 16, 16);

    // Preform transformations on them
    Matrix mat;

    // On Torus    
    mat.setTranslate(0.0,100.0,-200.0);
    TransformRecPtr TorusTranCore = Transform::create();
    TorusTranCore->setMatrix(mat);

    NodeRecPtr ExampleTorus = Node::create();
    ExampleTorus->setCore(TorusTranCore);
    ExampleTorus->addChild(ExampleTorusGeo);
    ExampleTorus->setTravMask(0);

    return NodeTransitPtr(ExampleTorus);
}
Esempio n. 13
0
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 a Spinner Model.  This dictates 
          how the Spinner functions.
          -setMaximum(int): Determine the Maximum 
          value the Spinner can have.
          -setMinimum(int): Determine the Minimum 
          value the Spinner can have.
          -setStepSize(int): Determine the 
          incremental step size.
          -setValue(SharedFieldRecPtr(new SFInt32(int)):
          Determine initial starting value
          of the Spinner.

          Note: the StepSize can be changed 
          dynamically as done in this 
          Tutorial with ButtonSelectedListeners.

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

        //Int32SpinnerModelPtr TheModel(new Int32SpinnerModel());
        Int32SpinnerModelPtr TheModel(new Int32SpinnerModel());
        TheModel->setMaximum(100);
        TheModel->setMinimum(-100);
        TheModel->setStepSize(1);
        TheModel->setValue(boost::any(Int32(0)));

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

          Create a Spinner and and assign it a 
          Model.

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

        SpinnerRecPtr ExampleSpinner = Spinner::create();
        ExampleSpinner->setModel(TheModel);

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

          Create a RadioButtonPanel to allow
          for certain characteristics of the
          Spinner to be changed dynamically.
          See 14RadioButton for more 
          information about RadioButtons.

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

        RadioButtonRecPtr SingleIncrementButton = RadioButton::create();
        RadioButtonRecPtr DoubleIncrementButton = RadioButton::create();
        SingleIncrementButton->setText("Increment by 1");
        SingleIncrementButton->setPreferredSize(Vec2f(100, 50));
        SingleIncrementButton->connectButtonSelected(boost::bind(handleSingleIncbuttonSelected, _1,
                                                                 TheModel));

        DoubleIncrementButton->setText("Increment by 2");
        DoubleIncrementButton->setPreferredSize(Vec2f(100, 50));
        DoubleIncrementButton->connectButtonSelected(boost::bind(handleDoubleIncbuttonSelected, _1,
                                                                 TheModel));

        RadioButtonGroupRecPtr SelectionRadioButtonGroup = RadioButtonGroup::create();
        SelectionRadioButtonGroup->addButton(SingleIncrementButton);
        SelectionRadioButtonGroup->addButton(DoubleIncrementButton);
        SingleIncrementButton->setSelected(true);

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

        LayoutRecPtr MainInternalWindowLayout = FlowLayout::create();

        InternalWindowRecPtr MainInternalWindow = InternalWindow::create();
        MainInternalWindow->pushToChildren(SingleIncrementButton);
        MainInternalWindow->pushToChildren(DoubleIncrementButton);
        MainInternalWindow->pushToChildren(ExampleSpinner);
        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
        UIDrawingSurfaceRecPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);

        TutorialDrawingSurface->openWindow(MainInternalWindow);

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

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);


        // Tell the Manager what to manage
        sceneManager.setRoot(scene);

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

        // Show the whole Scene
        sceneManager.showAll();


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

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

    osgExit();

    return 0;
}
Esempio n. 14
0
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 BorderLayout and some
          BorderLayoutConstraints to be used 
          to set up CardLayout.

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

        BorderLayoutRecPtr MainInternalWindowLayout = BorderLayout::create();
        BorderLayoutConstraintsRecPtr ExampleButton1Constraints = BorderLayoutConstraints::create();
        BorderLayoutConstraintsRecPtr ExampleButton2Constraints = BorderLayoutConstraints::create();
        BorderLayoutConstraintsRecPtr ExampleButton7Constraints = BorderLayoutConstraints::create();
        BorderLayoutConstraintsRecPtr ExampleButton8Constraints = BorderLayoutConstraints::create();
        BorderLayoutConstraintsRecPtr ExampleCardPanelConstraints = BorderLayoutConstraints::create();

        ExampleButton1Constraints->setRegion(BorderLayoutConstraints::BORDER_EAST);

        ExampleButton2Constraints->setRegion(BorderLayoutConstraints::BORDER_WEST);

        ExampleButton7Constraints->setRegion(BorderLayoutConstraints::BORDER_NORTH);

        ExampleButton8Constraints->setRegion(BorderLayoutConstraints::BORDER_SOUTH);

        ExampleCardPanelConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER);

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

          Create CardLayout.  CardLayout shows 
          a single Component at a time, meaning
          it is not exactly practical to use it
          alone for a Layout.  This tutorial uses
          the BorderLayout to include a Panel in
          the Center Region, and within that Panel
          using a CardLayout.  A single card is 
          displayed at one time within a 
          ComponentContainer using CardLayout.

          CardLayout has four functions:
          next, previous, first, and last.

          ->next(CardContainerName): Causes 
          CardLayout to display the next card.
          ->previous(CardContainerName): Causes
          CardLayout to display the 
          previous card.
          ->first(CardContainerName): Causes
          CardLayout to display the
          first card.
          ->last(CardContainerName): Causes
          CardLayout to display the
          last card.

          These are most useful when combined with 
          Action, as shown at the top of 
          this Tutorial, to assign actions to the 
          Buttons or Components to allow the user 
          to cycle through the Card Layout and 
          view different ExampleCards.

          Note that CardContainerName is the name
          of the ComponentContainer which is using the
          CardLayout, while the begin/endEditCP
          is performed on the CardLayout itself.

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

        CardLayoutRecPtr ExampleCardLayout = CardLayout::create();
        PanelRecPtr ExampleCardPanel = Panel::create();

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

          Create Button Components to be used with 
          CardLayout to allow for interactivity.

         ******************************************************/
        ButtonRecPtr ExampleButton1 = Button::create();
        ButtonRecPtr ExampleButton2 = Button::create();
        ButtonRecPtr ExampleButton3 = Button::create();
        ButtonRecPtr ExampleButton4 = Button::create();
        ButtonRecPtr ExampleButton5 = Button::create();
        ButtonRecPtr ExampleButton6 = Button::create();    
        ButtonRecPtr ExampleButton7 = Button::create();
        ButtonRecPtr ExampleButton8 = Button::create();

        ExampleButton1->setText("Next Card");
        ExampleButton1->setConstraints(ExampleButton1Constraints);

        // Add Action
        ExampleButton1->connectActionPerformed(boost::bind(handleNextCardAction, _1,
                                                           ExampleCardLayout.get(),
                                                           ExampleCardPanel.get()));

        ExampleButton2->setText("Previous Card");
        ExampleButton2->setConstraints(ExampleButton2Constraints);

        // Add Action
        ExampleButton2->connectActionPerformed(boost::bind(handleBackCardAction, _1,
                                                           ExampleCardLayout.get(),
                                                           ExampleCardPanel.get()));

        ExampleButton3->setText("This");

        ExampleButton4->setText("is");

        ExampleButton5->setText("Card");

        ExampleButton6->setText("Layout");

        ExampleButton7->setText("First Card");
        ExampleButton7->setConstraints(ExampleButton7Constraints);

        // Add Action
        ExampleButton7->connectActionPerformed(boost::bind(handleFirstCardAction, _1,
                                                           ExampleCardLayout.get(),
                                                           ExampleCardPanel.get()));

        ExampleButton8->setText("Last Card");
        ExampleButton8->setConstraints(ExampleButton8Constraints);

        // Add Action
        ExampleButton8->connectActionPerformed(boost::bind(handleLastCardAction, _1,
                                                           ExampleCardLayout.get(),
                                                           ExampleCardPanel.get()));

        ExampleCardPanel->setLayout(ExampleCardLayout);
        ExampleCardPanel->pushToChildren(ExampleButton3);
        ExampleCardPanel->pushToChildren(ExampleButton4);
        ExampleCardPanel->pushToChildren(ExampleButton5);
        ExampleCardPanel->pushToChildren(ExampleButton6);
        ExampleCardPanel->setConstraints(ExampleCardPanelConstraints);




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

        InternalWindowRecPtr MainInternalWindow = InternalWindow::create();
        MainInternalWindow->pushToChildren(ExampleButton1);
        MainInternalWindow->pushToChildren(ExampleButton2);
        MainInternalWindow->pushToChildren(ExampleButton7);
        MainInternalWindow->pushToChildren(ExampleButton8);
        MainInternalWindow->pushToChildren(ExampleCardPanel);
        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
        UIDrawingSurfaceRecPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);

        TutorialDrawingSurface->openWindow(MainInternalWindow);

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

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);


        // Tell the Manager what to manage
        sceneManager.setRoot(scene);

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

        //Create the Documentation Foreground and add it to the viewport
        SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);

        // Show the whole Scene
        sceneManager.showAll();


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

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

    osgExit();

    return 0;
}
Esempio n. 15
0
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 a simple Font to be used with the PasswordField
        UIFontRecPtr ExampleFont = UIFont::create();
        ExampleFont->setSize(16);

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


          Create and edit a PasswordField.

          A PasswordField is a TextField 
          which allows for text to be
          entered secretly.

          -setEchoCar("char"): Determine
          which character replaces text in the 
          PasswordField.

          See 16TextField for more information.

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

        TextFieldRecPtr ExampleTextField = TextField::create();
        ExampleTextField->setText("");
        ExampleTextField->setEmptyDescText("username");
        ExampleTextField->setPreferredSize(Vec2f(130.0f,ExampleTextField->getPreferredSize().y()));

        PasswordFieldRecPtr ExamplePasswordField = PasswordField::create();

        ExamplePasswordField->setPreferredSize(Vec2f(130, ExamplePasswordField->getPreferredSize().y()));
        ExamplePasswordField->setTextColor(Color4f(0.0, 0.0, 0.0, 1.0));
        ExamplePasswordField->setSelectionBoxColor(Color4f(0.0, 0.0, 1.0, 1.0));
        ExamplePasswordField->setSelectionTextColor(Color4f(1.0, 1.0, 1.0, 1.0));
        //ExamplePasswordField->setText("Text");
        // "Text" will be replaced by "####" in the PasswordField
        ExamplePasswordField->setEchoChar("#");
        ExamplePasswordField->setEditable(true);
        ExamplePasswordField->setFont(ExampleFont);
        ExamplePasswordField->setSelectionStart(2);
        ExamplePasswordField->setSelectionEnd(3);
        ExamplePasswordField->setAlignment(Vec2f(0.0,0.5));

        ExamplePasswordField->setEmptyDescText("password");

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

        FlowLayoutRecPtr MainInternalWindowLayout = FlowLayout::create();
        MainInternalWindowLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);

        InternalWindowRecPtr MainInternalWindow = InternalWindow::create();
        MainInternalWindow->pushToChildren(ExampleTextField);
        MainInternalWindow->pushToChildren(ExamplePasswordField);
        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
        UIDrawingSurfaceRecPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);

        TutorialDrawingSurface->openWindow(MainInternalWindow);

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

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);


        // Tell the Manager what to manage
        sceneManager.setRoot(scene);

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

        //Create the Documentation Foreground and add it to the viewport
        SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);

        // Show the whole Scene
        sceneManager.showAll();

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

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

    osgExit();

    return 0;
}
Esempio n. 16
0
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 an Button Component and
          a simple Font.
          See 17Label_Font for more
          information about Fonts.

         ******************************************************/
        ButtonRecPtr ExampleButton = Button::create();

        UIFontRecPtr ExampleFont = UIFont::create();
        ExampleFont->setSize(16);

        ExampleButton->setMinSize(Vec2f(50, 25));
        ExampleButton->setMaxSize(Vec2f(200, 100));
        ExampleButton->setPreferredSize(Vec2f(100, 50));
        ExampleButton->setToolTipText("Button 1 ToolTip");

        ExampleButton->setText("Button 1");
        ExampleButton->setFont(ExampleFont);
        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).  

         ******************************************************/
        ToggleButtonRecPtr ExampleToggleButton = ToggleButton::create();

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


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

        // Create The Internal Window
        InternalWindowRecPtr MainInternalWindow = InternalWindow::create();
        LayoutRecPtr MainInternalWindowLayout = 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
        InternalWindowRecPtr MainInternalWindow2 = InternalWindow::create();
        LayoutRecPtr MainInternalWindowLayout2 = 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("Allways on top window"));
        MainInternalWindow2->setIconable(false);
        MainInternalWindow2->setAllwaysOnTop(true);

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

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


        // Tell the Manager what to manage
        sceneManager.setRoot(scene);

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

        // Show the whole Scene
        sceneManager.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;
}
Esempio n. 17
0
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);

    // 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 a simple Font to be used with the ExampleTextArea
    UIFontRefPtr ExampleFont = OSG::UIFont::create();
        ExampleFont->setSize(16);

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


        Create and edit the TextArea and determine its 
        characteristics.  A TextArea is a component 
        that allows you to enter text into the box via 
        keyboard input.  You can select text by    using 
        your mouse or pressing shift and the left and 
        right arrow keys.

        The only difference between a TextArea and
        TextField is that a TextArea can have 
        multiple lines of text 
        within it.

        -setTextColor(Color4f): Determine color of 
            text within TextArea.
        -setSelectionBoxColor(Color4f): Determine the
			color that highlighting around the 
			selected text appears.
        -setSelectionTextColor(Color4f): Determine the 
            color the selected text appears.
        -setText("TextToBeDisplayed"): Determine  
            initial text within TextArea.
        -setFont(FontName): Determine the Font 
			used within TextArea
        -setSelectionStart(StartCharacterNumber):
            Determine the character which the 
            selection will initially start after.
        -setSelectionEnd(EndCharacterNumber): 
            Determine the character which the 
            selection will end before.
        -setCaretPosition(Location): Determine the 
            location of the Caret within the TextArea.
			Note: this does not do too much
            currently because the only way 
            to cause the TextArea to gain focus is
            to click within it, causing the 
            Caret to move.
            
    ******************************************************/

    // Create a TextArea component
    TextAreaRefPtr ExampleTextArea = OSG::TextArea::create();

        ExampleTextArea->setPreferredSize(Vec2f(300, 200));
        ExampleTextArea->setMinSize(Vec2f(300, 200));
        ExampleTextArea->setTextColor(Color4f(0.0, 0.0, 0.0, 1.0));
        ExampleTextArea->setSelectionBoxColor(Color4f(0.0, 0.0, 1.0, 1.0));
        ExampleTextArea->setSelectionTextColor(Color4f(1.0, 1.0, 1.0, 1.0));
        // Determine the font and initial text
        ExampleTextArea->setText("What");
        ExampleTextArea->setFont(ExampleFont);
        // This will select the "a" from above
        ExampleTextArea->setSelectionStart(2);
        ExampleTextArea->setSelectionEnd(3);
        ExampleTextArea->setCaretPosition(2);
        //ExampleTextArea->setLineWrap(false);
        
    // Create a ScrollPanel
    ScrollPanelRefPtr TextAreaScrollPanel = ScrollPanel::create();
        TextAreaScrollPanel->setPreferredSize(Vec2f(200,200));
        TextAreaScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
    // Add the TextArea to the ScrollPanel so it is displayed
	TextAreaScrollPanel->setViewComponent(ExampleTextArea);

    
    // 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(TextAreaScrollPanel);
       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,
            "22TextArea");

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

    osgExit();

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

    TutorialWindowEventProducer = createDefaultWindowEventProducer();
    WindowPtr MainWindow = TutorialWindowEventProducer->initWindow();

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

    TutorialKeyListener TheKeyListener;
    TutorialWindowEventProducer->addKeyListener(&TheKeyListener);

    // Make Torus Node (creates Torus in background of scene)
    NodePtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);

    // Make Main Scene Node and add the Torus
    NodePtr scene = osg::Node::create();
    beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
        scene->setCore(osg::Group::create());
        scene->addChild(TorusGeometryNode);
    endEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);

    // Create the Graphics
    GraphicsPtr TutorialGraphics = osg::Graphics2D::create();

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

	//Create InventoryItems
	ExampleInventory = Inventory::create();
	GenericInventoryItemPtr ExampleItem1 = GenericInventoryItem::create();
	GenericInventoryItemPtr ExampleItem2 = GenericInventoryItem::create(); 
	GenericInventoryItemPtr ExampleItem3 = GenericInventoryItem::create(); 
	GenericInventoryItemPtr ExampleItem4 = GenericInventoryItem::create();
	GenericInventoryItemPtr ExampleItem5 = GenericInventoryItem::create();
	GenericInventoryItemPtr ExampleItem6 = GenericInventoryItem::create();
	GenericInventoryItemPtr ExampleItem7 = GenericInventoryItem::create();

	beginEditCP(ExampleItem1, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
		ExampleItem1->setName(std::string("David K"));
		ExampleItem1->setDetails(std::string("Major: Human Computer Interaction \nDegree: PhD \nDepartment: Computer Science \nCollege: LAS"));
	endEditCP(ExampleItem1, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);

	beginEditCP(ExampleItem2, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
		ExampleItem2->setName(std::string("Eve W"));
		ExampleItem2->setDetails(std::string("Department: Genetics Development and Cell Biology\n\nCollege: Agriculture"));
	endEditCP(ExampleItem2, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);

	beginEditCP(ExampleItem3, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
		ExampleItem3->setName(std::string("Will S"));
		ExampleItem3->setDetails(std::string("Major: Art And Design\nDegree: BFA\nDepartment: Art and Design\nCollege: Design"));
	endEditCP(ExampleItem3, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);

	beginEditCP(ExampleItem4, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
		ExampleItem4->setName(std::string("Eric L"));
		ExampleItem4->setDetails(std::string("Major: Software Engineering\nDegree: BS\nDepartment: Software Engineering\nCollege: Engineering"));
	endEditCP(ExampleItem4, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);

	beginEditCP(ExampleItem5, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
		ExampleItem5->setName(std::string("Jeffery F"));
		ExampleItem5->setDetails(std::string("Major: Integrated Studio Arts\nDegree: BFA\nDepartment: Art and Design\nCollege: Design"));
	endEditCP(ExampleItem5, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);

	beginEditCP(ExampleItem6, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
		ExampleItem6->setName(std::string("Tao L"));
		ExampleItem6->setDetails(std::string("Major: Computer Engineering\nDegree: PhD\nDepartment: Computer Engineering\nCollege: Engineering"));
	endEditCP(ExampleItem6, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);

	beginEditCP(ExampleItem7, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);
		ExampleItem7->setName(std::string("Daniel G"));
		ExampleItem7->setDetails(std::string("Major: Computer Engineering\nDegree: BS\nDepartment: Computer Engineering\nCollege: Engineering"));
	endEditCP(ExampleItem7, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask);

	ExampleInventory->addItem(ExampleItem1);
	ExampleInventory->addItem(ExampleItem2);
	ExampleInventory->addItem(ExampleItem3);
	ExampleInventory->addItem(ExampleItem4);
	ExampleInventory->addItem(ExampleItem5);
	ExampleInventory->addItem(ExampleItem6);
	ExampleInventory->addItem(ExampleItem7);



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

            Create a List.  A List has several 
			parts to it:
			-ListModel: Contains the data which is to be
			    displayed in the List.  Data is added
				as shown below
			-ListCellRenderer: Creates the Components to
				be used within the List (the default
				setting is to create Labels using 
				the desired text).
			-ListSelectionModel: Determines how
				the List may be selected.

			To add values to the list:
            
            First, create SFStrings and use the 
            .setValue("Value") function to set their
            values.  Then, use the .pushBack(&SFStringName)
            to add them to the List.

            Next, create the CellRenderer and ListSelectionModel
            defaults.

            Finally, actually create the List.  Set
            its Model, CellRenderer, and SelectionModel
            as shown below.  Finally, choose the
            type of display for the List (choices outlined
            below).

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

    // Add data to it
	ExampleListModel = InventoryListModel::create();
    beginEditCP(ExampleListModel, InventoryListModel::CurrentInventoryFieldMask);
	    ExampleListModel->setCurrentInventory(ExampleInventory);
    endEditCP(ExampleListModel, InventoryListModel::CurrentInventoryFieldMask);
    

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

            Create ListCellRenderer and 
			ListSelectionModel.  Most 
			often the defauls will be used.
			
			Note: the ListSelectionModel was
			created above and is referenced
			by the ActionListeners.

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


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

            Create List itself and assign its 
			Model, CellRenderer, and SelectionModel
			to it.
			-setOrientation(ENUM): Determine the
				Layout of the cells (Horizontal
				or Vertical).  Takes List::VERTICAL_ORIENTATION
				and List::HORIZONTAL_ORIENTATION arguments.

    ******************************************************/    
    ExampleList = List::create();
	beginEditCP(ExampleList, List::PreferredSizeFieldMask | List::OrientationFieldMask | List::ModelFieldMask);
        ExampleList->setPreferredSize(Vec2f(200, 300));
        ExampleList->setOrientation(List::VERTICAL_ORIENTATION);
        //ExampleList->setOrientation(List::HORIZONTAL_ORIENTATION);
		ExampleList->setModel(ExampleListModel);
    endEditCP(ExampleList, List::PreferredSizeFieldMask | List::OrientationFieldMask | List::ModelFieldMask);

    ExampleList->setSelectionModel(ExampleListSelectionModel);
	InventoryListListener TheInventoryListListener;
    ExampleList->getSelectionModel()->addListSelectionListener(&TheInventoryListListener);


	// Create The Main InternalWindow
    // Create Background to be used with the Main InternalWindow
    ColorLayerPtr MainInternalWindowBackground = osg::ColorLayer::create();
    beginEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);
        MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
    endEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);

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

            Determine the SelectionModel
            -SINGLE_SELECTION lets you select ONE item
                via a single mouse click
            -SINGLE_INTERVAL_SELECTION lets you select
                one interval via mouse and SHIFT key
            -MULTIPLE_INTERVAL_SELECTION lets you select
                via mouse, and SHIFT and CONTRL keys

            Note: this tutorial is currently set up
            to allow for this to be changed via 
			TogggleButtons with ActionListeners attached 
            to them so this code is commented out.

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

    //SelectionModel.setMode(DefaultListSelectionModel::SINGLE_SELECTION);
    //SelectionModel.setMode(DefaultListSelectionModel::SINGLE_INTERVAL_SELECTION);
    //SelectionModel.setMode(DefaultListSelectionModel::MULTIPLE_INTERVAL_SELECTION);

    // Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
    ScrollPanelPtr ExampleScrollPanel = ScrollPanel::create();
	beginEditCP(ExampleScrollPanel, ScrollPanel::PreferredSizeFieldMask | ScrollPanel::HorizontalResizePolicyFieldMask | ScrollPanel::BackgroundFieldMask);
        ExampleScrollPanel->setPreferredSize(Vec2f(200,100));
		ExampleScrollPanel->setBackgrounds(MainInternalWindowBackground);
        ExampleScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
        //ExampleScrollPanel->setVerticalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
    endEditCP(ExampleScrollPanel, ScrollPanel::PreferredSizeFieldMask | ScrollPanel::HorizontalResizePolicyFieldMask | ScrollPanel::BackgroundFieldMask);
    ExampleScrollPanel->setViewComponent(ExampleList);

    // Create MainFramelayout
    FlowLayoutPtr MainInternalWindowLayout = osg::FlowLayout::create();
    beginEditCP(MainInternalWindowLayout, FlowLayout::OrientationFieldMask | FlowLayout::MajorAxisAlignmentFieldMask | FlowLayout::MinorAxisAlignmentFieldMask);
	MainInternalWindowLayout->setOrientation(FlowLayout::HORIZONTAL_ORIENTATION);
        MainInternalWindowLayout->setMajorAxisAlignment(0.5f);
        MainInternalWindowLayout->setMinorAxisAlignment(0.5f);
    endEditCP(MainInternalWindowLayout, FlowLayout::OrientationFieldMask | FlowLayout::MajorAxisAlignmentFieldMask | FlowLayout::MinorAxisAlignmentFieldMask);
    
    

	DetailsWindow = osg::TextArea::create();
	beginEditCP(DetailsWindow, TextArea::PreferredSizeFieldMask);
		DetailsWindow->setPreferredSize(Pnt2f(200,100));
		DetailsWindow->setMinSize(Vec2f(200,100));
    endEditCP(DetailsWindow, TextArea::PreferredSizeFieldMask);

    InternalWindowPtr MainInternalWindow = osg::InternalWindow::create();
	beginEditCP(MainInternalWindow, InternalWindow::ChildrenFieldMask | InternalWindow::LayoutFieldMask | InternalWindow::BackgroundsFieldMask | InternalWindow::AlignmentInDrawingSurfaceFieldMask | InternalWindow::ScalingInDrawingSurfaceFieldMask | InternalWindow::DrawTitlebarFieldMask | InternalWindow::ResizableFieldMask);
       MainInternalWindow->getChildren().push_back(ExampleScrollPanel);
       MainInternalWindow->getChildren().push_back(DetailsWindow);
       MainInternalWindow->setLayout(MainInternalWindowLayout);
       MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
	   MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
	   MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.7f,0.5f));
	   MainInternalWindow->setDrawTitlebar(false);
	   MainInternalWindow->setResizable(false);
    endEditCP(MainInternalWindow, InternalWindow::ChildrenFieldMask | InternalWindow::LayoutFieldMask | InternalWindow::BackgroundsFieldMask | InternalWindow::AlignmentInDrawingSurfaceFieldMask | InternalWindow::ScalingInDrawingSurfaceFieldMask | InternalWindow::DrawTitlebarFieldMask | InternalWindow::ResizableFieldMask);

    // Create the Drawing Surface
    UIDrawingSurfacePtr TutorialDrawingSurface = UIDrawingSurface::create();
    beginEditCP(TutorialDrawingSurface, UIDrawingSurface::GraphicsFieldMask | UIDrawingSurface::EventProducerFieldMask);
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindowEventProducer);
    endEditCP(TutorialDrawingSurface, UIDrawingSurface::GraphicsFieldMask | UIDrawingSurface::EventProducerFieldMask);
    
	TutorialDrawingSurface->openWindow(MainInternalWindow);

    // Create the UI Foreground Object
    UIForegroundPtr TutorialUIForeground = osg::UIForeground::create();

    beginEditCP(TutorialUIForeground, UIForeground::DrawingSurfaceFieldMask);
        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
    endEditCP(TutorialUIForeground, UIForeground::DrawingSurfaceFieldMask);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

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

    // Add the UI Foreground Object to the Scene
    ViewportPtr TutorialViewport = mgr->getWindow()->getPort(0);
    beginEditCP(TutorialViewport, Viewport::ForegroundsFieldMask);
        TutorialViewport->getForegrounds().push_back(TutorialUIForeground);
    beginEditCP(TutorialViewport, Viewport::ForegroundsFieldMask);

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

    Vec2f WinSize(TutorialWindowEventProducer->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindowEventProducer->getDesktopSize() - WinSize) *0.5);
    TutorialWindowEventProducer->openWindow(WinPos,
            WinSize,
            "09Inventory");

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


    osgExit();

    return 0;
}
// Initialize WIN32 & OpenSG and set up the scene
int main(int argc, char **argv)
{
    preloadSharedObject("OSGTBFileIO");

    // 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);

        //Attach to events
        TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager));
        TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager));
        TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
        TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager));
        TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1));

        // create the scene
        NodeUnrecPtr scene = makeTorus(1.0, 2.0, 16, 16);
        sceneManager.setRoot  (scene);

        //Create the Documentation
        SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);

        // show the whole scene
        sceneManager.showAll();

        //Load Sound Definitions
        FCFileType::FCPtrStore NewContainers;
        NewContainers = FCFileHandler::the()->read(BoostPath("Data/04SoundData.xml"));

        FCFileType::FCPtrStore::iterator Itor;
        for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
        {
            //Get Sounds
            if( (*Itor)->getType().isDerivedFrom(Sound::getClassType()))
            {
                Sounds.push_back(dynamic_pointer_cast<Sound>(*Itor));
                Sounds.back()->connectSoundPlayed  (boost::bind(handleSoundPlayed,   _1));
                Sounds.back()->connectSoundStopped (boost::bind(handleSoundStopped,  _1));
                Sounds.back()->connectSoundPaused  (boost::bind(handleSoundPaused,   _1));
                Sounds.back()->connectSoundUnpaused(boost::bind(handleSoundUnpaused, _1));
                Sounds.back()->connectSoundLooped  (boost::bind(handleSoundLooped,   _1));
            }
            //Get Sound Groups
            if( (*Itor)->getType().isDerivedFrom(SoundGroup::getClassType()))
            {
                SoundGroups.push_back(dynamic_pointer_cast<SoundGroup>(*Itor));
            }
        }

        //Initialize the Sound Manager
        SoundManager::the()->attachUpdateProducer(TutorialWindow);
        SoundManager::the()->setCamera(sceneManager.getCamera());

        Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
        Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
        TutorialWindow->openWindow(WinPos,
                                   WinSize,
                                   "04 XML Sound Loading Window");

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

    }
    osgExit();
    return 0;
}
Esempio n. 20
0
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 a simple Font to be used with the TextField
        UIFontRecPtr sampleFont = UIFont::create();
        sampleFont->setSize(16);

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


          Create and edit the TextField.  A TextField is 
          a Component which allows a single line of text
          to be displayed.  Text can be entered via the
          keyboard, and selected with arrow keys or
          the Mouse.

          -setTextColor(Color4f): Determine the 
          Text Color.
          setSelectionBoxColor(Color4f): Determine
          the Color of highlighting around
          selected Text.
          -setSelectionTextColor(Color4f): Determine
          the Color of selected Text.
          -setText("TextToBeDisplayed"): Determine
          initial Text within TextField.
          -setFont(FontName): Determine the Font
          used within TextField.
          -setSelectionStart(StartCharacterNumber):
          Determine the character with which  
          the selection will initially start.
          -setSelectionEnd(EndCharacterNumber): 
          Determine the character which the
          selection ends before.
          -setAlignment(float): Determine 
          the alignment of the text.  
          The float is a percentage is from the 
          top of the text [0.0-1.0].  Note: be 
          sure to visually verify this, as due
          to font size and line size this does
          not always place it exactly
          at the percentage point.

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

        // Create a TextField component
        TextFieldRecPtr ExampleTextField = TextField::create();

        ExampleTextField->setPreferredSize(Vec2f(100, 50));
        ExampleTextField->setTextColor(Color4f(0.0, 0.0, 0.0, 1.0));
        ExampleTextField->setSelectionBoxColor(Color4f(0.0, 0.0, 1.0, 1.0));
        ExampleTextField->setSelectionTextColor(Color4f(1.0, 1.0, 1.0, 1.0));
        ExampleTextField->setText("What");
        ExampleTextField->setFont(sampleFont);
        // The next two functions will select the "a" from above
        ExampleTextField->setSelectionStart(2);
        ExampleTextField->setSelectionEnd(3);
        ExampleTextField->setAlignment(Vec2f(0.0,0.5));

        // Create another TextField Component
        TextFieldRecPtr ExampleTextField2 = TextField::create();
        ExampleTextField2->setText("");
        ExampleTextField2->setEmptyDescText("Write in me, please");
        ExampleTextField2->setPreferredSize(Vec2f(200.0f,ExampleTextField2->getPreferredSize().y()));


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

        LayoutRecPtr MainInternalWindowLayout = FlowLayout::create();

        InternalWindowRecPtr MainInternalWindow = InternalWindow::create();
        MainInternalWindow->pushToChildren(ExampleTextField);
        MainInternalWindow->pushToChildren(ExampleTextField2);
        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
        UIDrawingSurfaceRecPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);

        TutorialDrawingSurface->openWindow(MainInternalWindow);

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

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);


        // Tell the Manager what to manage
        sceneManager.setRoot(scene);

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

        // Show the whole Scene
        sceneManager.showAll();


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

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

    osgExit();

    return 0;
}
Esempio n. 21
0
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

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

        // Create the SimpleSceneManager helper
        SimpleSceneManagerRefPtr sceneManager = SimpleSceneManager::create();
        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();

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

          Creates RadioButton components and
          edit them.  The RadioButton class
          inherits from the Button class.

          Radio Buttons are special ToggleButtons.  
          When they are selected, any RadioButton in 
          the same group is deselected, so there can
          only be one option selected.

          Advanced options for RadioButton can
          be found in the DefaultLookAndFeel.cpp
          file found in OSGUserInterface/Source Files/
          LookAndFeel (options for changing the
          RadioButton style, etc).

         ******************************************************/
        RadioButtonRecPtr ExampleRadioButton1 = RadioButton::create();
        RadioButtonRecPtr ExampleRadioButton2 = RadioButton::create();
        RadioButtonRecPtr ExampleRadioButton3 = RadioButton::create();

        ExampleRadioButton1->setAlignment(Vec2f(0.0,0.5));
        ExampleRadioButton1->setPreferredSize(Vec2f(100, 50));
        ExampleRadioButton1->setText("Option 1");

        ExampleRadioButton2->setAlignment(Vec2f(0.0,0.5));
        ExampleRadioButton2->setPreferredSize(Vec2f(100, 50));
        ExampleRadioButton2->setText("Option 2");

        ExampleRadioButton3->setAlignment(Vec2f(0.0,0.5));
        ExampleRadioButton3->setPreferredSize(Vec2f(100, 50));
        ExampleRadioButton3->setText("Option 3");

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

          Create and populate a group of RadioButtons.
          Defining the group allows you to pick which 
          RadioButtons are tied together so that only one 
          can be selected.

          Each RadioButtonGroup can only have ONE
          RadioButton selected at a time, and by 
          selecting this RadioButton, will deselect
          all other RadioButtons in the RadioButtonGroup.

         ******************************************************/
        RadioButtonGroupRecPtr ExampleRadioButtonGroup = RadioButtonGroup::create();

        ExampleRadioButtonGroup->addButton(ExampleRadioButton1);
        ExampleRadioButtonGroup->addButton(ExampleRadioButton2);
        ExampleRadioButtonGroup->addButton(ExampleRadioButton3);

        ExampleRadioButtonGroup->setSelectedButton(ExampleRadioButton2);

        FlowLayoutRecPtr MainInternalWindowLayout = FlowLayout::create();

        MainInternalWindowLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
        MainInternalWindowLayout->setMajorAxisAlignment(0.5f);
        MainInternalWindowLayout->setMinorAxisAlignment(0.5f);

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

        InternalWindowRecPtr MainInternalWindow = InternalWindow::create();
        MainInternalWindow->pushToChildren(ExampleRadioButton1);
        MainInternalWindow->pushToChildren(ExampleRadioButton2);
        MainInternalWindow->pushToChildren(ExampleRadioButton3);
        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
        UIDrawingSurfaceRecPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);

        TutorialDrawingSurface->openWindow(MainInternalWindow);

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

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);


        // Tell the Manager what to manage
        sceneManager->setRoot(scene);

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

        //Create the Documentation Foreground and add it to the viewport
        SimpleScreenDoc TheSimpleScreenDoc(sceneManager, TutorialWindow);

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

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

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

    osgExit();

    return 0;
}
Esempio n. 22
0
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 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).

         ******************************************************/
        CheckboxButtonRecPtr ExampleCheckboxButton = 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
        ColorLayerRecPtr MainInternalWindowBackground = ColorLayer::create();
        MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

        LayoutRecPtr MainInternalWindowLayout = FlowLayout::create();

        InternalWindowRecPtr MainInternalWindow = 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
        UIDrawingSurfaceRecPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);

        TutorialDrawingSurface->openWindow(MainInternalWindow);

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

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);



        // Tell the Manager what to manage
        sceneManager.setRoot(scene);

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

        // Show the whole Scene
        sceneManager.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;
}
Esempio n. 23
0
/*
 * Build the lattice display lists 
 */
void makeLatticeObjects ()
{
	int i, d = 0;
	float thick = (float)dThick * 0.001f;

	list_base = glGenLists(NUMOBJECTS);

	for (i = 1; i <= NUMOBJECTS; i++) {
		glNewList (list_base + i, GL_COMPILE);

		if (dTexture >= 2)
			glBindTexture (GL_TEXTURE_2D, texture_id[0]);

		if (d < dDensity) {
			glPushMatrix ();

			setMaterialAttribs();

			glTranslatef (-0.25f, -0.25f, -0.25f);

			if (rsRandi (2))
				glRotatef (180.0f, 1, 0, 0);

			makeTorus (dSmooth, dLongitude, dLatitude, 0.36f - thick, thick);

			glPopMatrix ();
		}

		d = (d + 37) % 100;

		if (d < dDensity) {
			glPushMatrix ();

			setMaterialAttribs();

			glTranslatef (0.25f, -0.25f, -0.25f);

			if (rsRandi (2))
				glRotatef (90.0f, 1, 0, 0);
			else
				glRotatef (-90.0f, 1, 0, 0);

			makeTorus (dSmooth, dLongitude, dLatitude, 0.36f - thick, thick);

			glPopMatrix ();
		}

		d = (d + 37) % 100;

		if (d < dDensity) {
			glPushMatrix ();

			setMaterialAttribs();

			glTranslatef (0.25f, -0.25f, 0.25f);

			if (rsRandi (2))
				glRotatef (90.0f, 0, 1, 0);
			else
				glRotatef (-90.0f, 0, 1, 0);

			makeTorus (dSmooth, dLongitude, dLatitude, 0.36f - thick, thick);

			glPopMatrix ();
		}

		d = (d + 37) % 100;

		if (d < dDensity) {
			glPushMatrix ();

			setMaterialAttribs();

			glTranslatef (0.25f, 0.25f, 0.25f);

			if (rsRandi (2))
				glRotatef (180.0f, 1, 0, 0);

			makeTorus (dSmooth, dLongitude, dLatitude, 0.36f - thick, thick);

			glPopMatrix ();
		}

		d = (d + 37) % 100;

		if (d < dDensity) {
			glPushMatrix ();

			setMaterialAttribs();

			glTranslatef (-0.25f, 0.25f, 0.25f);

			if (rsRandi (2))
				glRotatef (90.0f, 1, 0, 0);
			else
				glRotatef (-90.0f, 1, 0, 0);

			makeTorus (dSmooth, dLongitude, dLatitude, 0.36f - thick, thick);

			glPopMatrix ();
		}

		d = (d + 37) % 100;
		if (d < dDensity) {
			glPushMatrix ();

			setMaterialAttribs();

			glTranslatef (-0.25f, 0.25f, -0.25f);

			if (rsRandi (2))
				glRotatef (90.0f, 0, 1, 0);
			else
				glRotatef (-90.0f, 0, 1, 0);

			makeTorus (dSmooth, dLongitude, dLatitude, 0.36f - thick, thick);

			glPopMatrix ();
		}

		glEndList ();

		d = (d + 37) % 100;
	}
}
Esempio n. 24
0
// Initialize WIN32 & OpenSG and set up the scene
int main(int argc, char **argv)
{
    std::cout << "\n\nKEY COMMANDS:" << std::endl
        << "space   Play/Pause the playing sounds" << std::endl
        << "1       Play Pop Sound" << std::endl
        << "2       Play Click Sound" << std::endl
        << "CTRL-Q  Exit\n\n" << std::endl;

    // 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);

        //Attach to events
        TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager));
        TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager));
        TutorialWindow->connectMouseMoved(boost::bind(mouseMoved, _1, &sceneManager));
        TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
        TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager));
 
        // create the scene
        NodeUnrecPtr scene = makeTorus(1.0, 2.0, 16, 16);

        //Initialize the Sound Manager
        SoundManager::the()->attachUpdateProducer(TutorialWindow);
        SoundManager::the()->setCamera(sceneManager.getCamera());

        //Create Pop Sound
        SoundRecPtr ZapSound = SoundManager::the()->createSound();
        ZapSound->setFile(BoostPath("./Data/zap.wav"));
        ZapSound->setVolume(1.0);
        ZapSound->setStreaming(false);
        ZapSound->setLooping(1);

        //Attach Sound Events
        ZapSound->connectSoundPlayed  (boost::bind(handleSoundPlayed,   _1));
        ZapSound->connectSoundStopped (boost::bind(handleSoundStopped,  _1));
        ZapSound->connectSoundPaused  (boost::bind(handleSoundPaused,   _1));
        ZapSound->connectSoundUnpaused(boost::bind(handleSoundUnpaused, _1));
        ZapSound->connectSoundLooped  (boost::bind(handleSoundLooped,   _1));

        //Create Click Sound
        SoundRecPtr ClickSound = SoundManager::the()->createSound();
        ClickSound->setFile(BoostPath("./Data/click.wav"));
        ClickSound->setVolume(1.0);
        ClickSound->setStreaming(false);
        ClickSound->setLooping(0);

        //Attach Sound Events
        ClickSound->connectSoundPlayed  (boost::bind(handleSoundPlayed,   _1));
        ClickSound->connectSoundStopped (boost::bind(handleSoundStopped,  _1));
        ClickSound->connectSoundPaused  (boost::bind(handleSoundPaused,   _1));
        ClickSound->connectSoundUnpaused(boost::bind(handleSoundUnpaused, _1));
        ClickSound->connectSoundLooped  (boost::bind(handleSoundLooped,   _1));

        TutorialWindow->connectKeyTyped(boost::bind(&KeyTypedHandler::keyTyped,
                                                    _1,
                                                    ZapSound.get(),
                                                    ClickSound.get()));

        // tell the manager what to manage
        sceneManager.setRoot  (scene);

        // show the whole scene
        sceneManager.showAll();


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

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

    }
    osgExit();
    return 0;
}
Esempio n. 25
0
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();


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

          Creates some Button components
          and edit their Text.

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

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

        ExampleButton1->setText("This");

        ExampleButton2->setText("is a");

        ExampleButton3->setText("sample");

        ExampleButton4->setText("two");

        ExampleButton5->setText("ExamplePanel");

        ExampleButton6->setText("layout");


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

          Create some Flow and BoxLayouts to be
          used with the Main Frame and two
          Panels.

         ******************************************************/
        FlowLayoutRecPtr MainInternalWindowLayout = FlowLayout::create();
        FlowLayoutRecPtr ExamplePanel1Layout = FlowLayout::create();
        FlowLayoutRecPtr ExamplePanel2Layout = FlowLayout::create();

        ExamplePanel1Layout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);


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

          Create two Backgrounds to be used with
          Panels and MainInternalWindow.

         ******************************************************/
        ColorLayerRecPtr MainInternalWindowBackground = ColorLayer::create();
        ColorLayerRecPtr ExamplePanelBackground = ColorLayer::create();

        MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

        ExamplePanelBackground->setColor(Color4f(0.0,0.0,0.0,1.0));

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

          Create a Border to be used with
          the two Panels.

         ******************************************************/
        LineBorderRecPtr ExamplePanelBorder = LineBorder::create();
        ExamplePanelBorder->setColor(Color4f(0.9, 0.9, 0.9, 1.0));
        ExamplePanelBorder->setWidth(3);


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

          Create MainInternalWindow and two Panel Components and
          edit their characteristics.

          -setPreferredSize(Vec2f): Determine the
          size of the Panel.
          -pushToChildren(ComponentName):
          Adds a Component to the
          ComponentContainer as a Child (meaning it
          will be displayed within it).
          -setLayout(LayoutName): Determines the
          Layout of the ComponentContainer.

         ******************************************************/
        InternalWindowRecPtr MainInternalWindow = InternalWindow::create();
        PanelRecPtr ExamplePanel1 = Panel::create();
        PanelRecPtr ExamplePanel2 = Panel::create();

        // Edit Panel1, Panel2
        ExamplePanel1->setPreferredSize(Vec2f(200, 200));
        ExamplePanel1->pushToChildren(ExampleButton1);
        ExamplePanel1->pushToChildren(ExampleButton2);
        ExamplePanel1->pushToChildren(ExampleButton3);
        ExamplePanel1->setLayout(ExamplePanel1Layout);
        ExamplePanel1->setBackgrounds(ExamplePanelBackground);
        ExamplePanel1->setBorders(ExamplePanelBorder);

        ExamplePanel2->setPreferredSize(Vec2f(200, 200));
        ExamplePanel2->pushToChildren(ExampleButton4);
        ExamplePanel2->pushToChildren(ExampleButton5);
        ExamplePanel2->pushToChildren(ExampleButton6);
        ExamplePanel2->setLayout(ExamplePanel2Layout);
        ExamplePanel2->setBackgrounds(ExamplePanelBackground);
        ExamplePanel2->setBorders(ExamplePanelBorder);

        // Create The Main InternalWindow
        MainInternalWindow->pushToChildren(ExamplePanel1);
        MainInternalWindow->pushToChildren(ExamplePanel2);
        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);
        MainInternalWindow->setAllInsets(5);

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

        TutorialDrawingSurface->openWindow(MainInternalWindow);

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

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);


        // Tell the Manager what to manage
        sceneManager.setRoot(scene);

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

        // Show the whole Scene
        sceneManager.showAll();


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

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

    osgExit();

    return 0;
}
Esempio n. 26
0
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    TutorialWindow = createNativeWindow();
    TutorialWindow->initWindow();

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

    TutorialKeyListener TheKeyListener;
    TutorialWindow->addKeyListener(&TheKeyListener);

    // 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();

    GradientBackgroundRefPtr TheBackground = GradientBackground::create();
    TheBackground->addLine(Color3f(1.0,0.0,0.0), 0.0);
    TheBackground->addLine(Color3f(0.0,1.0,0.0), 0.2);
    TheBackground->addLine(Color3f(0.0,0.0,1.0), 0.4);
    TheBackground->addLine(Color3f(0.0,1.0,1.0), 0.6);
    TheBackground->addLine(Color3f(1.0,1.0,0.0), 0.8);
    TheBackground->addLine(Color3f(1.0,1.0,1.0), 1.0);

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

            Create a List.  A List has several 
			parts to it:
			-ListModel: Contains the data which is to be
			    displayed in the List.  Data is added
				as shown below
			-ListCellRenderer: Creates the Components to
				be used within the List (the default
				setting is to create Labels using 
				the desired text).
			-ListSelectionModel: Determines how
				the List may be selected.

			To add values to the list:
            
            First, create SFStrings and use the 
            .setValue("Value") function to set their
            values.  Then, use the .pushBack(&SFStringName)
            to add them to the List.

            Next, create the CellRenderer and ListSelectionModel
            defaults.

            Finally, actually create the List.  Set
            its Model, CellRenderer, and SelectionModel
            as shown below.  Finally, choose the
            type of display for the List (choices outlined
            below).

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

    // Add data to it
	ExampleListModel = MFieldListModel::create();
    ExampleListModel->setContainer(TheBackground);
    ExampleListModel->setFieldId(GradientBackground::ColorFieldId);

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

            Create ListCellRenderer and 
			ListSelectionModel.  Most 
			often the defauls will be used.
			
			Note: the ListSelectionModel was
			created above and is referenced
			by the ActionListeners.

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


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

            Create List itself and assign its 
			Model, CellRenderer, and SelectionModel
			to it.
			-setOrientation(ENUM): Determine the
				Layout of the cells (Horizontal
				or Vertical).  Takes List::VERTICAL_ORIENTATION
				and List::HORIZONTAL_ORIENTATION arguments.

    ******************************************************/    
    ExampleList = List::create();
        ExampleList->setPreferredSize(Vec2f(200, 300));
        ExampleList->setOrientation(List::VERTICAL_ORIENTATION);
        //ExampleList->setOrientation(List::HORIZONTAL_ORIENTATION);
		ExampleList->setModel(ExampleListModel);

    ExampleList->setSelectionModel(ExampleListSelectionModel);


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

            Determine the SelectionModel
            -SINGLE_SELECTION lets you select ONE item
                via a single mouse click
            -SINGLE_INTERVAL_SELECTION lets you select
                one interval via mouse and SHIFT key
            -MULTIPLE_INTERVAL_SELECTION lets you select
                via mouse, and SHIFT and CONTRL keys

            Note: this tutorial is currently set up
            to allow for this to be changed via 
			TogggleButtons with ActionListeners attached 
            to them so this code is commented out.

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

    //SelectionModel.setMode(DefaultListSelectionModel::SINGLE_SELECTION);
    //SelectionModel.setMode(DefaultListSelectionModel::SINGLE_INTERVAL_SELECTION);
    //SelectionModel.setMode(DefaultListSelectionModel::MULTIPLE_INTERVAL_SELECTION);

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

    // Create MainFramelayout
    FlowLayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
    MainInternalWindowLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
    MainInternalWindowLayout->setMajorAxisAlignment(0.5f);
    MainInternalWindowLayout->setMinorAxisAlignment(0.5f);

    LabelRefPtr ListLabel = Label::create();
    ListLabel->setText("Background Colors List");
    ListLabel->setPreferredSize(Vec2f(200.0f, ListLabel->getPreferredSize().y()));

    // 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(ListLabel);
    MainInternalWindow->pushToChildren(ExampleScrollPanel);
    MainInternalWindow->setLayout(MainInternalWindowLayout);
    MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
    MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
    MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.7f,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);
    TutorialViewport->setBackground(TheBackground);

    // 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,
            "44MFieldList");

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

    osgExit();

    return 0;
}
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    {
        // Set up Window
        WindowEventProducerRecPtr TutorialWindow = createNativeWindow();

        //Initialize Window
        TutorialWindow->initWindow();

        SimpleSceneManager sceneManager;
        TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
        TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));

        // Tell the Manager what to manage
        sceneManager.setWindow(TutorialWindow);

        //Attach to events
        TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager));
        TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager));
        TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
        TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager));

        BoostPath FilePath("../Animation/Data/Nanobot.dae");
        if(argc >= 2)
        {
            FilePath = BoostPath(argv[1]);
            if(!boost::filesystem::exists(FilePath))
            {
                std::cerr << "Could not load file: "<< FilePath.string()
                          << ", because no such files exists."<< std::endl;
                FilePath = BoostPath("../Animation/Data/Nanobot.dae");
            }
        }

        NodeRefPtr LoadedRoot;
        std::vector<AnimationRecPtr> LoadedAnimations;

        FCFileType::FCPtrStore ObjStore;
        try
        {
            ObjStore = FCFileHandler::the()->read(FilePath);
        }
        catch(std::exception &ex)
        {
            std::cerr << "Failed to load file: " << FilePath.string() << ", error:"
                     << ex.what()                        << std::endl;
            return -1;
        }
        for(FCFileType::FCPtrStore::iterator StorItor(ObjStore.begin());
            StorItor != ObjStore.end();
            ++StorItor)
        {
            //Animations
            if((*StorItor)->getType().isDerivedFrom(Animation::getClassType()))
            {
                LoadedAnimations.push_back(dynamic_pointer_cast<Animation>(*StorItor));
                LoadedAnimations.back()->attachUpdateProducer(TutorialWindow);
                LoadedAnimations.back()->start();
            }
            //Root Node
            if((*StorItor)->getType() == Node::getClassType() &&
                    dynamic_pointer_cast<Node>(*StorItor)->getParent() == NULL)
            {
                LoadedRoot = dynamic_pointer_cast<Node>(*StorItor);
            }
        }

        if(LoadedRoot == NULL)
        {
            LoadedRoot = SceneFileHandler::the()->read(FilePath.string().c_str());
        }

        if(LoadedRoot == NULL)
        {
            LoadedRoot= makeTorus(.5, 2, 32, 32);
        }

        //Make the fog node
        PostShaderStageRecPtr PostShaderStageCore = PostShaderStage::create();
        PostShaderStageCore->clearPasses();
        PostShaderStageCore->addPass("", generateNoEffectProg());


        DirectionalLightRecPtr SceneLightCore = DirectionalLight::create();
        SceneLightCore->setAmbient(Color4f(0.2f, 0.2f, 0.2f, 1.0f));
        SceneLightCore->setDiffuse(Color4f(0.8f, 0.8f, 0.8f, 1.0f));
        SceneLightCore->setSpecular(Color4f(1.0f, 1.0f, 1.0f, 1.0f));

        NodeRefPtr SceneLight = makeNodeFor(SceneLightCore);
        SceneLight->addChild(LoadedRoot);

        NodeRefPtr PostShaderStageNode = makeNodeFor(PostShaderStageCore);
        PostShaderStageNode->addChild(SceneLight);

        //Make Main Scene Node
        NodeRefPtr scene = makeCoredNode<Group>();

        scene->addChild(PostShaderStageNode);

        // tell the manager what to manage
        sceneManager.setRoot  (scene);
        SceneLightCore->setBeacon(sceneManager.getCamera()->getBeacon());

        //Create the Documentation Foreground and add it to the viewport
        SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);

        // show the whole scene
        sceneManager.showAll();

        sceneManager.getWindow()->getPort(0)->setTravMask(1);
        RenderOptionsRecPtr ViewportRenderOptions = RenderOptions::create();
        ViewportRenderOptions->setRenderProperties(0x0);
        ViewportRenderOptions->setRenderProperties(RenderPropertiesPool::the()->getFrom1("Default"));
        ViewportRenderOptions->setRenderProperties(0x01);

        sceneManager.getWindow()->getPort(0)->setRenderOptions(ViewportRenderOptions);

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

        TutorialWindow->connectKeyPressed(boost::bind(keyPressed, _1,
                                                      TutorialWindow.get(),
                                                      PostShaderStageCore.get()));

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

    }

    osgExit();

    return 0;
}
Esempio n. 28
0
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

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

        // Create the SimpleSceneManager helper
        SimpleSceneManagerRefPtr sceneManager = SimpleSceneManager::create();
        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 Components to add to MenuBar
          Menus.  Each MenuBar has multiple Menus 
          which contain multiple MenuItems.

          -setAcceleratorKey(KeyEventDetails::KEY_*): This
          links the key "*" as a shortcut to 
          selecting the item it is attached to.
          An example of this would be Q with 
          Control+Q causing programs to quit.
          -setAcceleratorModifiers(KeyEventDetails::KEY_MODIFIER_*):
          This adds the "*" key as another 
          requirement to cause the item to be
          selected.  Things such as "CONTROL" are 
          likely to be used here (as mentioned 
          above, both Control and Q are specified).

Note: These shortcuts will be shown in the list
with the MenuItem they are attached to.

-setMnemonicKey(KeyEventDetails::KEY_****): sets the key
"****" to be underlined within the Menu
itself


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

        // Creates MenuItems as in 25PopupMenu
        MenuItemRecPtr NewMenuItem = MenuItem::create();
        MenuItemRecPtr OpenMenuItem = MenuItem::create();
        MenuItemRecPtr CloseMenuItem = MenuItem::create();
        MenuItemRecPtr ExitMenuItem = MenuItem::create();
        MenuItemRecPtr UndoMenuItem = MenuItem::create();
        MenuItemRecPtr RedoMenuItem = MenuItem::create();

        //Edits MenuItems
        NewMenuItem->setText("New ...");
        NewMenuItem->setAcceleratorKey(KeyEventDetails::KEY_N);
        NewMenuItem->setAcceleratorModifiers(KeyEventDetails::KEY_MODIFIER_COMMAND);
        NewMenuItem->setMnemonicKey(KeyEventDetails::KEY_N);

        OpenMenuItem->setText("Open ...");
        OpenMenuItem->setAcceleratorKey(KeyEventDetails::KEY_P);
        OpenMenuItem->setAcceleratorModifiers(KeyEventDetails::KEY_MODIFIER_COMMAND);
        OpenMenuItem->setMnemonicKey(KeyEventDetails::KEY_P);

        CloseMenuItem->setText("Close ...");
        CloseMenuItem->setAcceleratorKey(KeyEventDetails::KEY_W);
        CloseMenuItem->setAcceleratorModifiers(KeyEventDetails::KEY_MODIFIER_COMMAND);
        CloseMenuItem->setMnemonicKey(KeyEventDetails::KEY_C);

        ExitMenuItem->setText("Quit");
        ExitMenuItem->setAcceleratorKey(KeyEventDetails::KEY_Q);
        ExitMenuItem->setAcceleratorModifiers(KeyEventDetails::KEY_MODIFIER_COMMAND);
        ExitMenuItem->setMnemonicKey(KeyEventDetails::KEY_Q);

        UndoMenuItem->setText("Undo");
        UndoMenuItem->setAcceleratorKey(KeyEventDetails::KEY_Z);
        UndoMenuItem->setAcceleratorModifiers(KeyEventDetails::KEY_MODIFIER_COMMAND);
        UndoMenuItem->setMnemonicKey(KeyEventDetails::KEY_U);
        RedoMenuItem->setText("Redo");
        RedoMenuItem->setEnabled(false);
        RedoMenuItem->setMnemonicKey(KeyEventDetails::KEY_R);

        // Create a function connection to ExitMenuItem
        // This is defined above, and will cause the program to quit
        // when that MenuItem is selected or Control + Q hit 
        ExitMenuItem->connectActionPerformed(boost::bind(handleQuitAction, _1,
                                                         TutorialWindow.get()));

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

          Create Menu Components to add to MenuBar
          and adds above Components to them.  

          Note: setAcceleratorKey,
          setAcceleratorModifiers, and setMnemnoicKey
          all apply to Menus in addition to MenuItems.

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

        // Create a File menu and adds its MenuItems
        MenuRecPtr FileMenu = Menu::create();
        FileMenu->addItem(NewMenuItem);
        FileMenu->addItem(OpenMenuItem);
        FileMenu->addItem(CloseMenuItem);
        FileMenu->addSeparator();
        FileMenu->addItem(ExitMenuItem);

        // Labels the File Menu
        FileMenu->setText("File");
        FileMenu->setMnemonicKey(KeyEventDetails::KEY_F);

        // Creates an Edit menu and adds its MenuItems
        MenuRecPtr EditMenu = Menu::create();
        EditMenu->addItem(UndoMenuItem);
        EditMenu->addItem(RedoMenuItem);

        // Labels the Edit Menu
        EditMenu->setText("Edit");
        EditMenu->setMnemonicKey(KeyEventDetails::KEY_E);

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

          Create MainMenuBar and adds the Menus
          created above to it.

          Also creates several Backgrounds
          to improve MenuBar overall look.
          Both the MenuBar and Menu can have
          Backgrounds; the set up currently
          is to have EmptyBackgrounds in 
          each Menu allowing a single
          overall MenuBar Background which
          is given to the MenuBar itself.

          This can be easily changed by adding
          different Backgrounds to the 
          File and Edit Menus.

          Note: The MenuBar is added to the
          MainFrame below.

         ******************************************************/
        // Creates two Backgrounds

        MenuBarRecPtr MainMenuBar = MenuBar::create();
        // Adds the two Menus to the MainMenuBar
        MainMenuBar->addMenu(FileMenu);
        MainMenuBar->addMenu(EditMenu);

        // Create two Labels
        LabelRecPtr ExampleLabel1 = Label::create();
        LabelRecPtr ExampleLabel2 = Label::create();

        ExampleLabel1->setText("Look up in the corner!");
        ExampleLabel1->setPreferredSize(Vec2f(150, 25));    

        ExampleLabel2->setText("Hit Control + Z");
        ExampleLabel2->setPreferredSize(Vec2f(150, 25));    

        // Create The Main InternalWindow
        // Create Background to be used with the Main InternalWindow
        EmptyLayerRecPtr MainInternalWindowBackground = EmptyLayer::create();
        EmptyBorderRecPtr MainInternalWindowBorder = EmptyBorder::create();

        LayoutRecPtr MainInternalWindowLayout = FlowLayout::create();

        InternalWindowRecPtr MainInternalWindow = InternalWindow::create();
        MainInternalWindow->pushToChildren(ExampleLabel1);
        MainInternalWindow->pushToChildren(ExampleLabel2);
        MainInternalWindow->setLayout(MainInternalWindowLayout);
        MainInternalWindow->setMenuBar(MainMenuBar);
        MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
        MainInternalWindow->setBorders(MainInternalWindowBorder);
        MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
        MainInternalWindow->setScalingInDrawingSurface(Vec2f(1.0f,1.0f));
        MainInternalWindow->setDrawTitlebar(false);
        MainInternalWindow->setResizable(false);

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

        TutorialDrawingSurface->openWindow(MainInternalWindow);

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

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);



        // Tell the Manager what to manage
        sceneManager->setRoot(scene);

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

        //Create the Documentation Foreground and add it to the viewport
        SimpleScreenDoc TheSimpleScreenDoc(sceneManager, TutorialWindow);

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


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

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

    osgExit();

    return 0;
}
Esempio n. 29
0
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 a RotatedComponent.
          -setAngle(Angle, in radians): Determine
          the angle the Component initially
          is rotated.
          -setInternalComponent(Component): 
          Determine what Component will
          be rotated.
          -setResizePolicy(RotatedComponent::ENUM):
          Takes NO_RESIZING, RESIZE_TO_MIN, or
          RESIZE_TO_MAX arguments.

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

        RotatedComponentRecPtr TheRotatedComponent = RotatedComponent::create();
        // Define PI
        Real32 PI(3.14159);
        TheRotatedComponent->setAngle(PI/4);
        ComponentRecPtr InnerPanel = createPanel();
        TheRotatedComponent->setInternalComponent(InnerPanel);
        TheRotatedComponent->setResizePolicy(RotatedComponent::RESIZE_TO_MIN);

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

          Create a ToggleButton which can 
          be used to start and stop the 
          Button from rotating.

            Note: due to the way FlowLayout works
            you will notice that this ToggleButton
            will move as well.  In cases where
            a Rotating Component is used, an 
            alternate Layout may be preferred
            to prevent other Components from 
            moving as well.  This is 
            intentionally left this way to 
            illustrate why this might be the case.
            A SplitPanel with fixed divider for 
            example would prevent the ToggleButton
            from moving, while still allowing the 
            Panel to move freely.

         ******************************************************/    
        ToggleButtonRecPtr RotateControlButton = ToggleButton::create();
        RotateControlButton->setText("Start Rotating");
        RotateControlButton->setPreferredSize(Vec2f(100.0f, 29.0f));

        RotateControlButton->connectButtonSelected(boost::bind(handleButtonSelected, _1,
                                                               TutorialWindow.get(),
                                                               TheRotatedComponent.get()));
        RotateControlButton->connectButtonDeselected(boost::bind(handleButtonDeselected, _1,
                                                                 TutorialWindow.get(),
                                                                 TheRotatedComponent.get()));

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

        LayoutRecPtr MainInternalWindowLayout = FlowLayout::create();

        InternalWindowRecPtr MainInternalWindow = InternalWindow::create();
        MainInternalWindow->pushToChildren(TheRotatedComponent);
        MainInternalWindow->pushToChildren(RotateControlButton);
        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
        UIDrawingSurfaceRecPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);

        TutorialDrawingSurface->openWindow(MainInternalWindow);

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

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);


        // Tell the Manager what to manage
        sceneManager.setRoot(scene);

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

        //Create the Documentation Foreground and add it to the viewport
        SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);

        // Show the whole Scene
        sceneManager.showAll();

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

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

    osgExit();

    return 0;
}
Esempio n. 30
0
// Initialize WIN32 & OpenSG and set up the scene
int main(int argc, char **argv)
{
    std::cout << "\n\nKEY COMMANDS:" << std::endl
              << "1-9     Play Sounds 1-9" << std::endl
              << "p       Pause Sounds" << std::endl
              << "u       Unpause Sounds" << std::endl
              << "-       Decrease Sound Group Volume" << std::endl
              << "=       Increase Sound Group Volume" << std::endl
              << "CTRL-Q  Exit\n\n" << std::endl;
    // OSG init
    osgInit(argc,argv);
    
    TheWindowEventProducer = createNativeWindow();
    TheWindowEventProducer->initWindow();
    
    TheWindowEventProducer->setDisplayCallback(display);
    TheWindowEventProducer->setReshapeCallback(reshape);

    //Attach Mouse Listener
    TutorialMouseListener TheTutorialMouseListener;
    MouseEventConnection = TheWindowEventProducer->addMouseListener(&TheTutorialMouseListener);
    //Attach Key Listener
    TutorialKeyListener TheTutorialKeyListener;
    TheWindowEventProducer->addKeyListener(&TheTutorialKeyListener);
    //Attach MouseMotion Listener
    TutorialMouseMotionListener TheTutorialMouseMotionListener;
    TheWindowEventProducer->addMouseMotionListener(&TheTutorialMouseMotionListener);
    

    // create the scene
    NodeUnrecPtr scene = makeTorus(1.0, 2.0, 16, 16);

    // create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // tell the manager what to manage
    mgr->setWindow(TheWindowEventProducer );
    mgr->setRoot  (scene);

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

    //Load Sound Definitions
	FCFileType::FCPtrStore NewContainers;
    NewContainers = FCFileHandler::the()->read(BoostPath("Data/04SoundData.xml"));

    FCFileType::FCPtrStore::iterator Itor;
    TutorialSoundListener TheSoundListerner;
    for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
    {
        //Get Sounds
        if( (*Itor)->getType().isDerivedFrom(Sound::getClassType()))
        {
            Sounds.push_back(dynamic_pointer_cast<Sound>(*Itor));
            dynamic_pointer_cast<Sound>(*Itor)->addSoundListener(&TheSoundListerner);
        }
        //Get Sound Groups
        if( (*Itor)->getType().isDerivedFrom(SoundGroup::getClassType()))
        {
            SoundGroups.push_back(dynamic_pointer_cast<SoundGroup>(*Itor));
        }
    }

    //Initialize the Sound Manager
    SoundManager::the()->attachUpdateProducer(TheWindowEventProducer);
    SoundManager::the()->setCamera(mgr->getCamera());

    Vec2f WinSize(TheWindowEventProducer->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TheWindowEventProducer->getDesktopSize() - WinSize) *0.5);
    TheWindowEventProducer->openWindow(WinPos,
            WinSize,
            "04 XML Sound Loading Window");

    //Enter main loop
    TheWindowEventProducer->mainLoop();

    osgExit();
    return 0;
}