Example #1
0
static Lib3dsBool
layer_fog_read(Lib3dsLayerFog *fog, Lib3dsIo *io)
{
  Lib3dsChunk c;
  Lib3dsWord chunk;
  Lib3dsBool have_lin=LIB3DS_FALSE;

  if (!lib3ds_chunk_read_start(&c, LIB3DS_LAYER_FOG, io)) {
    return(LIB3DS_FALSE);
  }
  fog->near_y=lib3ds_io_read_float(io);
  fog->far_y=lib3ds_io_read_float(io);
  fog->density=lib3ds_io_read_float(io);
  fog->flags=lib3ds_io_read_dword(io);
  lib3ds_chunk_read_tell(&c, io);
  
  while ((chunk=lib3ds_chunk_read_next(&c, io))!=0) {
    switch (chunk) {
      case LIB3DS_LIN_COLOR_F:
        lib3ds_io_read_rgb(io, fog->col);
        have_lin=LIB3DS_TRUE;
        break;
      case LIB3DS_COLOR_F:
        lib3ds_io_read_rgb(io, fog->col);
        break;
      default:
        lib3ds_chunk_unknown(chunk);
    }
  }
  
  lib3ds_chunk_read_end(&c, io);
  return(LIB3DS_TRUE);
}
static void
solid_bgnd_read(Lib3dsBackground *background, Lib3dsIo *io) {
    Lib3dsChunk c;
    uint16_t chunk;
    int have_lin = FALSE;

    lib3ds_chunk_read_start(&c, CHK_SOLID_BGND, io);

    while ((chunk = lib3ds_chunk_read_next(&c, io)) != 0) {
        switch (chunk) {
            case CHK_LIN_COLOR_F:
                lib3ds_io_read_rgb(io, background->solid_color);
                have_lin = TRUE;
                break;

            case CHK_COLOR_F:
                lib3ds_io_read_rgb(io, background->solid_color);
                break;

            default:
                lib3ds_chunk_unknown(chunk, io);
        }
    }

    lib3ds_chunk_read_end(&c, io);
}
Example #3
0
static Lib3dsBool
solid_bgnd_read(Lib3dsBackground *background, Lib3dsIo *io)
{
  Lib3dsChunk c;
  Lib3dsWord chunk;
  Lib3dsBool have_lin=LIB3DS_FALSE;
          
  (void)have_lin;

  if (!lib3ds_chunk_read_start(&c, LIB3DS_SOLID_BGND, io)) {
    return(LIB3DS_FALSE);
  }

  while ((chunk=lib3ds_chunk_read_next(&c, io))!=0) {
    switch (chunk) {
      case LIB3DS_LIN_COLOR_F:
        lib3ds_io_read_rgb(io, background->solid.col);
        have_lin=LIB3DS_TRUE;
        break;
      case LIB3DS_COLOR_F:
        lib3ds_io_read_rgb(io, background->solid.col);
        break;
      default:
        lib3ds_chunk_unknown(chunk);
    }
  }
  
  lib3ds_chunk_read_end(&c, io);
  return(LIB3DS_TRUE);
}
static void
layer_fog_read(Lib3dsAtmosphere *at, Lib3dsIo *io)
{
    Lib3dsChunk c;
    uint16_t    chunk;
    int         have_lin = FALSE;

    lib3ds_chunk_read_start(&c, CHK_LAYER_FOG, io);

    at->layer_fog_near_y  = lib3ds_io_read_float(io);
    at->layer_fog_far_y   = lib3ds_io_read_float(io);
    at->layer_fog_density = lib3ds_io_read_float(io);
    at->layer_fog_flags   = lib3ds_io_read_dword(io);
    lib3ds_chunk_read_tell(&c, io);

    while ((chunk = lib3ds_chunk_read_next(&c, io)) != 0)
    {
        switch (chunk)
        {
        case CHK_LIN_COLOR_F:
            lib3ds_io_read_rgb(io, at->layer_fog_color);
            have_lin = TRUE;
            break;

        case CHK_COLOR_F:
            lib3ds_io_read_rgb(io, at->layer_fog_color);
            break;

        default:
            lib3ds_chunk_unknown(chunk, io);
        }
    }

    lib3ds_chunk_read_end(&c, io);
}
Example #5
0
static Lib3dsBool
v_gradient_read(Lib3dsBackground *background, Lib3dsIo *io)
{
  Lib3dsChunk c;
  Lib3dsWord chunk;
  int index[2];
  Lib3dsRgb col[2][3];
  int have_lin=0;
  

  if (!lib3ds_chunk_read_start(&c, LIB3DS_V_GRADIENT, io)) {
    return(LIB3DS_FALSE);
  }
  background->gradient.percent=lib3ds_io_read_float(io);
  lib3ds_chunk_read_tell(&c, io);

  index[0]=index[1]=0;
  while ((chunk=lib3ds_chunk_read_next(&c, io))!=0) {
    switch (chunk) {
      case LIB3DS_COLOR_F:
        lib3ds_io_read_rgb(io, col[0][index[0]]);
        index[0]++;
        break;
      case LIB3DS_LIN_COLOR_F:
        lib3ds_io_read_rgb(io, col[1][index[1]]);
        index[1]++;
        have_lin=1;
        break;
      default:
        lib3ds_chunk_unknown(chunk);
    }
  }
  {
    int i;
    for (i=0; i<3; ++i) {
      background->gradient.top[i]=col[have_lin][0][i];
      background->gradient.middle[i]=col[have_lin][1][i];
      background->gradient.bottom[i]=col[have_lin][2][i];
    }
  }
  lib3ds_chunk_read_end(&c, io);
  return(LIB3DS_TRUE);
}
static void
v_gradient_read(Lib3dsBackground *background, Lib3dsIo *io) {
    Lib3dsChunk c;
    uint16_t chunk;
    int index[2];
    float col[2][3][3];
    int have_lin = 0;

    lib3ds_chunk_read_start(&c, CHK_V_GRADIENT, io);

    background->gradient_percent = lib3ds_io_read_float(io);
    lib3ds_chunk_read_tell(&c, io);

    index[0] = index[1] = 0;
    while ((chunk = lib3ds_chunk_read_next(&c, io)) != 0) {
        switch (chunk) {
            case CHK_COLOR_F:
                lib3ds_io_read_rgb(io, col[0][index[0]]);
                index[0]++;
                break;

            case CHK_LIN_COLOR_F:
                lib3ds_io_read_rgb(io, col[1][index[1]]);
                index[1]++;
                have_lin = 1;
                break;

            default:
                lib3ds_chunk_unknown(chunk, io);
        }
    }
    {
        int i;
        for (i = 0; i < 3; ++i) {
            background->gradient_top[i] = col[have_lin][0][i];
            background->gradient_middle[i] = col[have_lin][1][i];
            background->gradient_bottom[i] = col[have_lin][2][i];
        }
    }
    lib3ds_chunk_read_end(&c, io);
}