Exemple #1
0
void
print_info()
{
  fontgl_printf(font, 0, 0, 0, "%.2f FPS",  framework_get_fps());
  fontgl_printf(font, 0, 20, 0, "cam <pos> x:%.2f y:%.2f z:%.2f", camfps->pos.x, camfps->pos.y,camfps->pos.z);
  fontgl_printf(font, 0, 40, 0, "cam <look> x:%.2f y:%.2f z:%.2f", camfps->look_at.x, camfps->look_at.y,camfps->look_at.z);
  fontgl_printf(font, 0, 80, 0, "Speed factor: %.2f", speed_factor);

  /* Frutum tests */
  {
    frustum2d ftm2d;
    bbox2d bb;

    bbox2d_set(&bb, -500, 500, 500, -500);
    frustum_to_frustum2d(&ftm2d, &camfps->ftm);

    if(frustum2d_bbox_is_into(&ftm2d, &bb))
      fontgl_printf(font, 0, 100, 0, "You are in the map.");
    else
      fontgl_printf(font, 0, 100, 0, "You are'nt in the map.");

    if(frustum_point_is_into(&camfps->ftm, 0, 0, 0))
      fontgl_printf(font, 0, 60, 0, "You see (0,0)");
    else
      fontgl_printf(font, 0, 60, 0, "You don't see (0,0)");
  }

}
Exemple #2
0
/* Really create the quadtree */
static quadtree_node do_create(float tlx, float tly, float brx, float bry, unsigned int level)
{
  quadtree_node root;
  float midx = (brx+tlx)/2.0f;
  float midy = (bry+tly)/2.0f;

  if(level == 0)
    return NULL;

  root = calloc(1, sizeof(struct s_quadtree_node));
  bbox2d_set(&root->box, tlx, tly, brx, bry);

  root->childs[0] = do_create(tlx, tly, midx, midy, level-1);
  root->childs[1] = do_create(midx, tly, brx, midy, level-1);
  root->childs[2] = do_create(tlx, midy, midx, bry, level-1);
  root->childs[3] = do_create(midx, midy, brx, bry, level-1);

  return root;
}