/* 
 * main
 *   DESCRIPTION: Play the adventure game.
 *   INPUTS: none (command line arguments are ignored)
 *   OUTPUTS: none
 *   RETURN VALUE: 0 on success, 3 in panic situations
 */
int
main ()
{
    game_condition_t game;  /* outcome of playing */

    /* Randomize for more fun (remove for deterministic layout). */
    srand (time (NULL));

    /* Provide some protection against fatal errors. */
    clean_on_signals ();

    if (!build_world ()) {PANIC ("can't build world");}
    init_game ();

    /* Perform sanity checks. */
    if (0 != sanity_check ()) {
	PANIC ("failed sanity checks");
    }

    /* Create status message thread. */
    if (0 != pthread_create (&status_thread_id, NULL, status_thread, NULL)) {
        PANIC ("failed to create status thread");
    }
    push_cleanup (cancel_status_thread, NULL); {

	/* Start mode X. */
	if (0 != set_mode_X (fill_horiz_buffer, fill_vert_buffer)) {
	    PANIC ("cannot initialize mode X");
	}
	push_cleanup ((cleanup_fn_t)clear_mode_X, NULL); {

	    /* Initialize the keyboard and/or Tux controller. */
	    if (0 != init_input ()) {
		PANIC ("cannot initialize input");
	    }
	    push_cleanup ((cleanup_fn_t)shutdown_input, NULL); {

		game = game_loop ();

	    } pop_cleanup (1);

	} pop_cleanup (1);

    } pop_cleanup (1);

    /* Print a message about the outcome. */
    switch (game) {
	case GAME_WON: printf ("You win the game!  CONGRATULATIONS!\n"); break;
	case GAME_QUIT: printf ("Quitter!\n"); break;
    }

    /* Return success. */
    return 0;
}
Beispiel #2
0
int main(){
  players.push_back(player(3,6,0,1));
  players.push_back(player(4,0,1,-1));
  players.push_back(player(3,0,0,1));
  players.push_back(player(0,6,0,-1));
  while (true){
    build_world();
    draw_world();
    sleep(1);
  }
  return 0;  
}
Beispiel #3
0
    bool do_init() {
        sdCharacterOverrideSetting("VERTICAL_SENSOR_EXTENSION_LENGTH", 16.0 / 40.0);

        world = sdWorldCreate();

        sdWorldSetCompileGeometryCallback(world, &KGLTGeometryRenderer::compile_geometry_callback, renderer_.get());
        sdWorldSetRenderGeometryCallback(world, &KGLTGeometryRenderer::render_geometry_callback, renderer_.get());

        build_world();

        window->camera->set_orthographic_projection(-10, 10, -10, 10);

        return true;
    }
Beispiel #4
0
int main(int, char **)
{
    // construct the viewer.
    osgViewer::Viewer viewer;
    
    osg::Group *root = new osg::Group;
    build_world(root);
   
    // add the stats handler
    viewer.addEventHandler(new osgViewer::StatsHandler);

    // add a viewport to the viewer and attach the scene graph.
    viewer.setSceneData(root);
        
    return viewer.run();
}
Beispiel #5
0
int main(int, char **)
{
    // construct the viewer.
    osgViewer::Viewer viewer;

    // register the pick handler
    viewer.addEventHandler(new PickHandler());

    osg::Group *root = new osg::Group;
    build_world(root);

    osgUtil::Optimizer optimizer;
    optimizer.optimize(root);

    // add a viewport to the viewer and attach the scene graph.
    viewer.setSceneData(root);

    return viewer.run();
}
Beispiel #6
0
int main(int argc, char* argv[])
{
  /* Initialize the graphics system */
  graphicsInit(&argc, argv);

  if(!netClient)
  {
    if (testWorld == 1)
      build_test_world();
    else
    {
      build_world();
      place_mobs();
    }
  }

  trimout();
  /* starts the graphics processing loop */
  glutMainLoop();
  
  return 0; 
}
int main(int argc, char *argv[])
{
    // use an ArgumentParser object to manage the program arguments.
    osg::ArgumentParser arguments(&argc, argv);

    // set up the usage document, in case we need to print out how to use this program.
    arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
    arguments.getApplicationUsage()->setDescription(arguments.getApplicationName() + " is a simple browser that allows you to apply osgFX effects to models interactively.");
    arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName() + " [options] filename ...");
    arguments.getApplicationUsage()->addCommandLineOption("-h or --help", "Display this information");
    arguments.getApplicationUsage()->addKeyboardMouseBinding("Left", "Apply previous effect");
    arguments.getApplicationUsage()->addKeyboardMouseBinding("Right", "Apply next effect");
    arguments.getApplicationUsage()->addKeyboardMouseBinding("Del", "Enable or disable osgFX");
    arguments.getApplicationUsage()->addKeyboardMouseBinding("Return", "Show or hide the effect information panel");
    arguments.getApplicationUsage()->addKeyboardMouseBinding("x", "Save the scene graph with current effect applied");


    // construct the viewer.
    osgViewer::Viewer viewer;

    // if user request help write it out to cout.
    if (arguments.read("-h") || arguments.read("--help")) {
        arguments.getApplicationUsage()->write(std::cout);
        return 1;
    }

    osgViewer::Viewer::ThreadingModel threading = osgViewer::Viewer::SingleThreaded;
    while (arguments.read("--SingleThreaded")) threading = osgViewer::Viewer::SingleThreaded;
    while (arguments.read("--CullDrawThreadPerContext")) threading = osgViewer::Viewer::CullDrawThreadPerContext;
    while (arguments.read("--DrawThreadPerContext")) threading = osgViewer::Viewer::DrawThreadPerContext;
    while (arguments.read("--CullThreadPerCameraDrawThreadPerContext")) threading = osgViewer::Viewer::CullThreadPerCameraDrawThreadPerContext;

    viewer.setThreadingModel(threading);

    // setup stencil buffer for Outline f/x.
    osg::DisplaySettings::instance()->setMinimumNumStencilBits(1);
    unsigned int clearMask = viewer.getCamera()->getClearMask();
    viewer.getCamera()->setClearMask(clearMask | GL_STENCIL_BUFFER_BIT);
    viewer.getCamera()->setClearStencil(0);

    // any option left unread are converted into errors to write out later.
    arguments.reportRemainingOptionsAsUnrecognized();

    // report any errors if they have occurred when parsing the program arguments.
    if (arguments.errors()) {
        arguments.writeErrorMessages(std::cout);
        return 1;
    }

    // read the scene from the list of file specified commandline args.
    osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);

    // if not loaded assume no arguments passed in, try use default mode instead.
    if (!loadedModel) loadedModel = osgDB::readRefNodeFile("dumptruck.osgt");

    if (!loadedModel)
    {
        std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
        return 1;
    }

    // optimize the scene graph, remove redundant nodes and state etc.
    osgUtil::Optimizer optimizer;
    optimizer.optimize(loadedModel.get());

    // set up a transform to rotate the model
    osg::ref_ptr<osg::MatrixTransform> xform = new osg::MatrixTransform;
    rotate_cb = new RotateCallback;
    xform->setUpdateCallback(rotate_cb);
    xform->addChild(loadedModel.get());

    osg::ref_ptr<osg::Light> light = new osg::Light;
    light->setLightNum(0);
    light->setDiffuse(osg::Vec4(1, 1, 1, 1));
    light->setSpecular(osg::Vec4(1, 1, 0.8f, 1));
    light->setAmbient(osg::Vec4(0.2f, 0.2f, 0.2f, 0.2f));
    light->setPosition(osg::Vec4(1, -1, 1, 0));

    osg::ref_ptr<osg::LightSource> root = new osg::LightSource;
    root->setLight(light.get());
    root->setLocalStateSetModes();

    build_world(root.get(), xform.get(), viewer);

    // set the scene to render
    viewer.setSceneData(root.get());

    return viewer.run();
}
Beispiel #8
0
init_data()
{
    char                *directory, filename[128];
    FILE      		*infile;
    static Ppoint 	text_loc = { 0.65, 0.03 };
    static char  	text[]   = "PALEOMAPPER";
    static Ppoint3 	xhair1[] = { 0.0, -0.07, 1.0, 0.0,  0.07, 1.0 };
    static Ppoint3 	xhair2[] = { -0.07, 0.0, 1.0, 0.07, 0.0, 1.0 };
    int			i,j;


    *filename = '\0';

    strcat(filename,GRIDFILE);

	printf("Filename: %s \n",filename);

    if ((infile = fopen(filename,"r")) == NULL) {
        if ((infile = fopen(GRIDFILE,"r")) == NULL) {
            printf("Error opening %s\n",GRIDFILE);
            exit(1);
	}
    }
    build_world(OUTLINE,infile);
    fclose(infile);


/***  I'm redoing the plot pole structure here.  ***/

    glNewList(POLE,GL_COMPILE);
	glBegin(GL_LINE_STRIP);
			glVertex3f(0.0, -0.07, 1.0);
			glVertex3f(0.0,  0.07, 1.0);
	glEnd();
	glBegin(GL_LINE_STRIP);
			glVertex3f(-0.07, 0.0, 1.0);
			glVertex3f(0.07, 0.0, 1.0 );
	glEnd();
    glEndList();

/***  Initializing the Poles   ***/

    for(i=0; i<5; i++)
    {
	pole_lat[i] = pole_lon[i] = 0.0;
    }

/***  Initialize the Rotations  ***/

  for(j=0; j<5; j++)

    for(i=0; i<MAX_SETS; i++)
    {
	rot_angle[j][i] = 0.0;
	rot_x[j][i] = 0.0;
	rot_y[j][i] = 0.0;
	rot_z[j][i] = 0.0;
    }

/***  Initialize the Lith Pick Toggle buttons  ***/

  for(j=0;j<27;j++)
	lithstat[j]=TRUE;
  for(j=0;j<9;j++)
	lithenv[j]=TRUE;

/***  Make the lithofacies Icons ***/

  make_lith_icon();

}