Ejemplo n.º 1
0
static void draw_tubes(t_map *map, sf::RenderWindow& window, Scaler& scaler)
{
	for (uint j = 0; j < map->rooms->size; j++)
	{
		t_room *room = (t_room*)array_get(map->rooms, j);
		for (uint i = 0; i < room->tubes->size; i++)
		{
			draw_tube(room, (t_room*)array_get(room->tubes, i), window, scaler);
			i++;
		}
	}
}
Ejemplo n.º 2
0
static void
generate_bottle (ModeInfo *mi)
{
  lavalite_configuration *bp = &bps[MI_SCREEN(mi)];
  int wire = MI_IS_WIREFRAME(mi);
  int faces = resolution * 1.5;
  Bool smooth = do_smooth;
  Bool have_texture = False;

  const lamp_geometry *top_slice = bp->model;
  const char *current_texture = 0;
  lamp_part last_part = 0;

  if (faces < 3)  faces = 3;
  else if (wire && faces > 20) faces = 20;
  else if (faces > 60) faces = 60;

  bp->bottle_poly_count = 0;

  glNewList (bp->bottle_list, GL_COMPILE);
  glPushMatrix();

  glRotatef (90, 1, 0, 0);
  glTranslatef (0, -0.5, 0);

  /* All parts of the lamp use the same specularity and shininess. */
  glMaterialfv (GL_FRONT, GL_SPECULAR,  lava_spec);
  glMateriali  (GL_FRONT, GL_SHININESS, lava_shininess);

  while (1)
    {
      const lamp_geometry *bot_slice = top_slice + 1;

      const char *texture = 0;
      GLfloat *color = 0;
      GLfloat t0, t1;

      glDisable (GL_LIGHT2);

      switch (top_slice->part)
        {
        case CAP:
        case BASE:
          texture = base_tex;
          color   = base_color;
          break;
        case BOTTLE:
          texture = fluid_tex;
          color   = fluid_color;
          if (!wire) glEnable (GL_LIGHT2);   /* light2 affects only fluid */
          break;
        default:
          abort();
          break;
        }

      have_texture = False;
      if (!wire && texture && texture != current_texture)
        {
          current_texture = texture;
          have_texture = load_texture (mi, current_texture);
        }
        
      /* Color the discs darker than the tube walls. */
      glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, foot_color);

      /* Do a top disc if this is the first slice of the CAP or BASE.
       */
      if ((top_slice->part == CAP  && last_part == 0) ||
          (top_slice->part == BASE && last_part == BOTTLE))
        bp->bottle_poly_count +=
          draw_disc (top_slice->radius, top_slice->elevation, faces,
                     True, wire);

      /* Do a bottom disc if this is the last slice of the CAP or BASE.
       */
      if ((top_slice->part == CAP  && bot_slice->part == BOTTLE) ||
          (top_slice->part == BASE && bot_slice->part == 0))
        {
          const lamp_geometry *sl = (bot_slice->part == 0
                                     ? top_slice : bot_slice);
          bp->bottle_poly_count +=
            draw_disc (sl->radius, sl->elevation, faces, False, wire);
        }

      if (bot_slice->part == 0)    /* done! */
        break;

      /* Do a tube or cone
       */
      glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color);

      t0 = top_slice->texture_elevation;
      t1 = bot_slice->texture_elevation;

      /* Restart the texture coordinates for the glass.
       */
      if (top_slice->part == BOTTLE)
        {
          Bool first_p = (top_slice[-1].part != BOTTLE);
          Bool last_p  = (bot_slice->part    != BOTTLE);
          if (first_p) t0 = 0;
          if (last_p)  t1 = 1;
        }

      bp->bottle_poly_count +=
        draw_tube (top_slice->radius, bot_slice->radius,
                   top_slice->elevation, bot_slice->elevation,
                   t0, t1,
                   faces,
                   (top_slice->part == BOTTLE),
                   smooth, wire);

      last_part = top_slice->part;
      top_slice++;
    }

  if (bp->style == ROCKET)
    {
      int i;
      for (i = 0; i < 3; i++)
        {
          glPushMatrix();
          glRotatef (120 * i, 0, 1, 0);
          glTranslatef (0.14, -0.05, 0);
          bp->bottle_poly_count += draw_wing (0.4, 0.95, 0.02, wire);
          glPopMatrix();
        }
      glTranslatef (0, -0.1, 0);  /* move floor down a little */
    }


  have_texture = !wire && load_texture (mi, table_tex);
  glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, table_color);
  bp->bottle_poly_count += draw_table (top_slice->elevation, wire);


  glPopMatrix ();
  glDisable (GL_TEXTURE_2D);   /* done with textured objects */
  glEndList ();
}