Exemplo n.º 1
0
//Indentify regions where geo_scale is negative.  These will be ocean.
void TerraformOceans ()
{

  int     x, y;
  Region  r;
  bool    is_ocean;
  
  //define the oceans at the edge of the world
  for (x = 0; x < WORLD_GRID; x++) {
    for (y = 0; y < WORLD_GRID; y++) {
      r = WorldRegionGet (x, y);
      is_ocean = false;
      if (r.geo_scale <= 0.0f) 
        is_ocean = true;
      if (x == 0 || y == 0 || x == WORLD_GRID - 1 || y == WORLD_GRID - 1) 
        is_ocean = true;
      if (is_ocean) {
        r.geo_bias = -10.0f;
        r.geo_detail = 0.3f;
        r.moisture = 1.0f;
        r.geo_water = 0.0f;
        r.flags_shape = REGION_FLAG_NOBLEND;
        r.color_atmosphere = glRgba (0.7f, 0.7f, 1.0f);
        r.climate = CLIMATE_OCEAN;
        sprintf (r.title, "%s Ocean", get_direction_name (x, y));
        WorldRegionSet (x, y, r);
      }        
    }
  }

}
static GstCaps *
gst_video_rate_divider_transform_caps (GstBaseTransform * trans,
                               GstPadDirection direction, GstCaps * caps)
{
  GstVideoRateDivider *videorate = GST_VIDEO_RATE_DIVIDER (trans);
  GstCaps *ret;
  GstStructure *s, *s2;
  gint rate_numerator, rate_denominator;

  ret = gst_caps_copy (caps);

  /* Any caps simply return */
  if (gst_caps_is_any (caps))
    {
      GST_DEBUG_OBJECT (trans,
        "transform caps: %" GST_PTR_FORMAT " (direction = %s) ANY",
                        caps, get_direction_name(direction));
      return ret;
    }

  s = gst_caps_get_structure (ret, 0);
  gst_structure_get_fraction (s, "framerate",
                              &rate_numerator, &rate_denominator);
  GST_DEBUG_OBJECT (trans,
      "transform caps: %" GST_PTR_FORMAT " (direction = %s framerate = %d/%d)",
                    caps, get_direction_name(direction), rate_numerator, rate_denominator);

  s2 = gst_structure_copy (s);

  if (direction == GST_PAD_SINK)
    {
      /* correct input flow framerate */
      /* store inpute framerate */
      videorate->from_rate_numerator = rate_numerator;
      videorate->from_rate_denominator = rate_denominator;

      gst_caps_remove_structure (ret, 0);
      gst_structure_set (s2, "framerate", GST_TYPE_FRACTION,
          rate_numerator, rate_denominator * videorate->factor, NULL);
      gst_caps_merge_structure (ret, s2);
    }

  return ret;
}
Exemplo n.º 3
0
//Find existing ocean regions and place costal regions beside them.
void TerraformCoast ()
{

  int             x, y;
  Region          r;
  int             pass;
  unsigned        i;
  unsigned        cliff_grid;
  bool            is_coast;
  bool            is_cliff;
  vector<GLcoord> queue;
  GLcoord         current;

  cliff_grid = WORLD_GRID / 8;
  //now define the coast 
  for (pass = 0; pass < 2; pass++) {
    queue.clear ();
    for (x = 0; x < WORLD_GRID; x++) {
      for (y = 0; y < WORLD_GRID; y++) {
        r = WorldRegionGet (x, y);
        //Skip already assigned places
        if (r.climate != CLIMATE_INVALID)
          continue;
        is_coast = false;
        //On the first pass, we add beach adjoining the sea
        if (!pass && is_climate_present (x, y, 1, CLIMATE_OCEAN)) 
          is_coast = true;
        //One the second pass, we add beach adjoining the beach we added on the previous step
        if (pass && is_climate_present (x, y, 1, CLIMATE_COAST)) 
          is_coast = true;
        if (is_coast) {
          current.x = x;
          current.y = y;
          queue.push_back (current);
        }
      }
    }
    //Now we're done scanning the map.  Run through our list and make the new regions.
    for (i = 0; i < queue.size (); i++) {
      current = queue[i];
      r = WorldRegionGet (current.x, current.y);
      is_cliff = (((current.x / cliff_grid) + (current.y / cliff_grid)) % 2) != 0;
      if (!pass) 
        sprintf (r.title, "%s beach", get_direction_name (current.x, current.y));
      else
        sprintf (r.title, "%s coast", get_direction_name (current.x, current.y));
      //beaches are low and partially submerged
      r.geo_detail = 5.0f + Entropy (current.x, current.y) * 10.0f;
      if (!pass) {
        r.geo_bias = -r.geo_detail * 0.5f;
        if (is_cliff)
          r.flags_shape |= REGION_FLAG_BEACH_CLIFF;
        else
          r.flags_shape |= REGION_FLAG_BEACH;
      } else 
        r.geo_bias = 0.0f;
      r.cliff_threshold = r.geo_detail * 0.25f;
      r.moisture = 1.0f;
      r.geo_water = 0.0f;
      r.flags_shape |= REGION_FLAG_NOBLEND;
      r.climate = CLIMATE_COAST;
      WorldRegionSet (current.x, current.y, r);
    }
  }


}