コード例 #1
0
int main(int argc, char **argv)
{
    g_error1 = 0.01f;
    g_error2 = g_error1;

    processArgs( argc, argv );

    OSG::osgInit(argc,argv);
    // GLUT init
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);

    int winid = glutCreateWindow("OpenSG");

    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);

    {
        OSG::GLUTWindowRefPtr gwin = OSG::GLUTWindow::create();
        gwin->setGlutId(winid);

        gwin->init();

        // create the scene
        OSG::NodeRefPtr scene;
        scene = makeScene( );

        if ( scene == NULL )
        {
            std::cerr<<"makeScene returned NullFC, exiting..."<<std::endl;
            return -1;
        }

        // create the SimpleSceneManager helper
        mgr = new OSG::SimpleSceneManager;

        // create the window and initial camera/viewport
        mgr->setWindow( gwin );
        // tell the manager what to manage
        mgr->setRoot  ( scene );

        // show the whole scene
        mgr->showAll();
        mgr->redraw();
        OSG::SolidBackgroundRefPtr bgr = OSG::SolidBackground::create();
        bgr->setColor( OSG::Color3f( 0.7f, 0.7f, 0.7f ));
        mgr->getWindow()->getPort(0)->setBackground( bgr );
    }

    // GLUT main loop
    glutMainLoop();

    return 0;
}
コード例 #2
0
ファイル: amt.cpp プロジェクト: AdriCS/osgWorks-mirror
int
main( int argc,
      char ** argv )
{
    osg::ref_ptr< osg::Group > root = new osg::Group;
    root->addChild( makeScene() );
    osgDB::writeNodeFile( *root, "testamt.osg" );

    root->addChild( osgDB::readNodeFile( "cow.osg" ) );


    osgViewer::Viewer viewer;
    viewer.setUpViewInWindow( 10, 30, 800, 600 );
    viewer.setSceneData( root.get() );

    return( viewer.run() );
}
コード例 #3
0
ファイル: main.cpp プロジェクト: ngordon17/RayTracer
Image draw(float width, float height) {
    IntersectRecord record;
    vector<Shape*> shapes = makeScene();
    vector<Lighting*> lights = makeLighting();
    
    Image im(width, height);
    Camera cam(Vector3(0, 0, 0), Vector3(0, 0, -1), Vector3(0, 1, 0), 0.0, -2.0, 2.0, -2.0, 2.0, 3, width, height);
    
    //for each pixel
    for (int i = 0; i < width; i++) {
        for (int j = 0; j < height; j++) {
            Ray r = cam.getRay(i, j, 0, 0);
            Color radiance = traceRay(r, shapes, lights, 0.0001f, 100000.0f, 0, 5);
            im.set(i, j, radiance);
        }
    }
    return im;
}
コード例 #4
0
int main(int argc, char **argv)
{
    printf("Press the keys '1', '2' and '3' in order to switch between "
           "the different example objects.\n");
    printf("Press key 'f' to toggle FatBorder rendering.\n");

    osgInit(argc,argv);
    // GLUT init
    glutInit(&argc, argv);
    glutInitWindowSize(800,600);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);

    int winid = glutCreateWindow("OpenSG");

    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);
    GLUTWindowPtr gwin = GLUTWindow::create();
    beginEditCP(gwin);
    {
        gwin->setId(winid);
    }
    endEditCP(gwin);
    gwin->init();

    // create the scene
//    NodePtr scene;
    g_scene = makeScene( );

    setModel(0);
//    scene = makeTeapot( );

    if ( g_scene == NullFC )
    {
        std::cerr<<"makeScene returned NullFC, exiting..."<<std::endl;
        return -1;
    }

    // create the SimpleSceneManager helper
    g_mgr = new SimpleSceneManager;

    // create the window and initial camera/viewport
    g_mgr->setWindow( gwin );
    // tell the manager what to manage
    g_mgr->setRoot  ( g_scene );

    // show the whole scene
    g_mgr->showAll();
    g_mgr->redraw();
    SolidBackgroundPtr bgr = SolidBackground::create();
    beginEditCP( bgr );
    bgr->setColor( Color3f( 1.0, 1.0, 1.0 ));
    endEditCP( bgr );
    g_mgr->getWindow()->getPort(0)->setBackground( bgr );

    // GLUT main loop
    glutMainLoop();

    return 0;
}