예제 #1
0
파일: combine.c 프로젝트: rtennill/scmtiff
static int addfile(scm **V, int C, const char *name)
{
    static int n = 0;
    static int c = 0;

    scm *s;

    if ((s = scm_ifile(name)))
    {
        if ((n == 0            && c == 0) ||
            (n == scm_get_n(s) && c == scm_get_c(s)))
        {
            n = scm_get_n(s);
            c = scm_get_c(s);

            if ((scm_scan_catalog(s)))
            {
                V[C] = s;
                return ++C;
            }
        }
        else apperr("SCM TIFF '%s' has size %d chan %d."
                            " Expected size %d chan %d.",
                    name, scm_get_n(s), scm_get_c(s), n, c);

        scm_close(s);
    }
    return C;
}
예제 #2
0
파일: query.c 프로젝트: rlk/scmtiff
int query(int argc, char **argv)
{
    long long total = 0;

    // Iterate over all input file arguments.

    for (int argi = 0; argi < argc; argi++)
    {
        long long size   = 0;
        long long length = 0;
        long long leaves = 0;
        scm *s;

        if ((s = scm_ifile(argv[argi])))
        {
            if (scm_read_catalog(s))
            {
                length = scm_get_length(s);

                for (long long i = 0; i < length; i++)
                {
                    if (isleaf(s, i))
                    {
                        leaves += 1;
                        size += (long long) s->n
                              * (long long) s->n
                              * (long long) s->c
                              * (long long) s->b / 8;
                    }
                }
            }
            scm_close(s);
            printf("%s pixels: %d channels: %d bits: %d pages: %lld leaves: %lld bytes: %lld\n", argv[argi], s->n, s->c, s->b, length, leaves, size);
        }

        total += size;
    }
    printf("total bytes: %lld\n", total);

    return 0;
}
예제 #3
0
파일: combine.c 프로젝트: rtennill/scmtiff
int combine(int argc, char **argv, const char *o, const char *m)
{
    scm **V = NULL;
    int   C = 0;
    int   O = 0;

    const char *out = o ? o : "out.tif";

    if (m)
    {
        if      (strcmp(m, "sum")   == 0) O = 0;
        else if (strcmp(m, "max")   == 0) O = 1;
        else if (strcmp(m, "avg")   == 0) O = 2;
        else if (strcmp(m, "blend") == 0) O = 3;
    }

    if ((V = (scm **) calloc((size_t) argc, sizeof (scm *))))
    {
        for (int i = 0; i < argc; ++i)
            C = addfile(V, C, argv[i]);

        if (C)
        {
            int n = scm_get_n(V[0]);
            int c = scm_get_c(V[0]);
            int b = scm_get_b(V[0]);
            int g = scm_get_g(V[0]);

            scm *s;

            if ((s = scm_ofile(out, n, c, b, g)))
            {
                process(s, V, C, O);
                scm_close(s);
            }
        }
    }
    return 0;
}
void
GameSession::init()
{
  loops = 0;
  deltas = 0.0;

  start_time = CL_System::get_time ();
  frames = 0;

  collision_mgr       = new CollisionManager();
  buildingtypemanager = new BuildingTypeManager();

  // Load helper functions
  // FIXME: These functions need a better place
  scm_c_primitive_load(path_manager.complete("feuerkraft.scm").c_str());
  scm_c_primitive_load(path_manager.complete("input.scm").c_str());
  
  // Deserialize the game world
  {
    std::cout << "<<<<<<<<<<<<< Parsing map <<<<<<<<<<<<<" << std::endl;
    SCM fdes = scm_open_file (scm_makfrom0str(filename.c_str()), 
                              scm_makfrom0str("r"));
    SCM lst = scm_read (fdes);
    scm_close (fdes);

    // unstable Testing stuff
    //OutputWorldBuilder builder;
    //SexprWorldReader(lst, &builder).run();

    // Now we create the real world
    world = new GameWorld(lst);
    std::cout << ">>>>>>>>>>>>> Parsing map >>>>>>>>>>>>>" << std::endl;
  }
  // End: Test of parsing code

  // The all mighty soldier that the player controlls
  Soldier* soldier = new Soldier(AList());
  soldier->set_position(FloatVector2d (500, 1100));

  {
    Soldier* soldier = new Soldier(AList());
    soldier->set_position(FloatVector2d (1400, 1500));
    SoldierAI* ai = new SoldierAI(soldier);
    world->add(soldier);
    AIManager::instance()->add(ai);
  }

  {
    Soldier* soldier = new Soldier(AList());
    soldier->set_position(FloatVector2d (1300, 1600));
    SoldierAI* ai = new SoldierAI(soldier);
    world->add(soldier);
    AIManager::instance()->add(ai);
  }

  world->add(new RobotTank(660, 1245, 0, 100.0f));
  world->add(new Helicopter(AList()
                            .set_float("x-pos", 600)
                            .set_float("y-pos", 1245)
                            .set_int("type", 0)));
  world->add(new Helicopter(AList()
                            .set_float("x-pos", 600)
                            .set_float("y-pos", 1445)
                            .set_int("type", 1)));
  world->add(new Helicopter(AList()
                            .set_float("x-pos", 660)
                            .set_float("y-pos", 1645)
                            .set_int("type", 2)));

  world->add(new Tank(FloatVector2d (650, 1245), 5, "feuerkraft/tank", "feuerkraft/turret", "feuerkraft/fire2"));
  world->add(new Tank(FloatVector2d (750, 1245), 5, "feuerkraft/tank", "feuerkraft/turret", "feuerkraft/fire2"));
  world->add(new Tank(FloatVector2d (850, 1245), 5, "feuerkraft/tank", "feuerkraft/turret", "feuerkraft/fire2"));

  {
    Tank* tank = new Tank(FloatVector2d (450, 1245), 5, "feuerkraft/tank", "feuerkraft/turret", "feuerkraft/fire2");
    world->add(tank);
    AIManager::instance()->add(new VehicleRoboAI(tank));
  }

  {
    Tank* tank = new Tank(FloatVector2d (0, 1245), 5, "feuerkraft/tank2", "feuerkraft/turret", "feuerkraft/fire2");
    world->add(tank);
    AIManager::instance()->add(new VehicleRoboAI(tank));
  }

  {
    Tank* tank = new Tank(FloatVector2d (-100, 1245), 5, "feuerkraft/tank", "feuerkraft/turret2", "feuerkraft/fire2");
    world->add(tank);
    AIManager::instance()->add(new VehicleRoboAI(tank));
  }

  {
    Tank* tank = new Tank(FloatVector2d (560, 1245), 5, "feuerkraft/tank2", "feuerkraft/turret2", "feuerkraft/fire2");
    world->add(tank);
    VehiclePathAI* ai = new VehiclePathAI(tank);

    ai->drive_to(FloatVector2d(200, 200));
    ai->drive_to(FloatVector2d(500, 200));
    ai->drive_to(FloatVector2d(500, 500));
    ai->drive_to(FloatVector2d(1500, 500));
    ai->drive_to(FloatVector2d(1500, 300));

    AIManager::instance()->add(ai);
  }

  world->add(new Background (resources->get_sprite("feuerkraft/sand"), -10.0f));
  world->add(soldier);

  player = new Player(soldier);
  view   = new View(0, 0, CL_Display::get_width(), CL_Display::get_height(), new PlayerViewUpdater(player));
  DisplayManager::init();
}