Example #1
0
/** \brief reads a room light definition.
  *
  * intensity1 gets converted, so it matches the 0-32768 range introduced in TR3.
  * intensity2 and fade2 are introduced in TR2 and are set to intensity1 and fade1 for TR1.
  */
void TR_Level::read_tr_room_light(SDL_RWops * const src, tr5_room_light_t & light)
{
    read_tr_vertex32(src, light.pos);
    // read and make consistent
    float data = read_bitu16(src);
    data = data < 0.0f || data > 8191.0f ? 0.0f : data;
    
    light.intensity1 = (8191 - data);
    
    light.fade1 = read_bitu32(src);
    // only in TR2
    light.intensity2 = light.intensity1;

    light.intensity = light.intensity1 / 8191.0f;

    if(light.intensity == 0.0f || light.intensity > 1.0f)
        light.intensity = 1.0f;

    light.fade2 = light.fade1;

    light.r_outer = light.fade1;
    light.r_inner = light.fade1 / 2;

    light.light_type = 0x01; // Point light

    // all white
    light.color.r = 0xff;
    light.color.g = 0xff;
    light.color.b = 0xff;
}
Example #2
0
/** \brief reads a room light definition.
  *
  * intensity1 gets converted, so it matches the 0-32768 range introduced in TR3.
  * intensity2 and fade2 are introduced in TR2 and are set to intensity1 and fade1 for TR1.
  */
void TR_Level::read_tr_room_light(SDL_RWops * const src, tr5_room_light_t & light)
{
    read_tr_vertex32(src, light.pos);
    // read and make consistent
    light.intensity1 = (8191 - read_bitu16(src)) << 2;
    light.fade1 = read_bitu32(src);
    // only in TR2
    light.intensity2 = light.intensity1;

    light.intensity = light.intensity1;
    light.intensity /= 4096.0f;

    if(light.intensity > 1.0f)
        light.intensity = 1.0f;

    light.fade2 = light.fade1;

    light.r_outer = light.fade1;
    light.r_inner = light.fade1 / 2;

    light.light_type = 0x01; // Point light

    // all white
    light.color.r = 0xff;
    light.color.g = 0xff;
    light.color.b = 0xff;
}
Example #3
0
void TR_Level::read_tr3_room_staticmesh(SDL_RWops * const src, tr2_room_staticmesh_t & room_static_mesh)
{
	read_tr_vertex32(src, room_static_mesh.pos);
	room_static_mesh.rotation = (float)read_bitu16(src) / 16384.0f * -90;
	room_static_mesh.intensity1 = read_bit16(src);
	room_static_mesh.intensity2 = read_bit16(src);
	room_static_mesh.object_id = read_bitu16(src);
}
Example #4
0
void TR_Level::read_tr3_item(SDL_RWops * const src, tr2_item_t & item)
{
	item.object_id = read_bit16(src);
	item.room = read_bit16(src);
	read_tr_vertex32(src, item.pos);
	item.rotation = (float)read_bitu16(src) / 16384.0f * -90;
	item.intensity1 = read_bitu16(src);
	item.intensity2 = read_bitu16(src);
	item.flags = read_bitu16(src);
}
Example #5
0
/// \brief reads an item definition.
void TR_Level::read_tr_item(SDL_RWops * const src, tr2_item_t & item)
{
    item.object_id = read_bit16(src);
    item.room = read_bit16(src);
    read_tr_vertex32(src, item.pos);
    item.rotation = (float)read_bitu16(src) / 16384.0f * -90;
    item.intensity1 = read_bitu16(src);
    if (item.intensity1 >= 0)
        item.intensity1 = (8191 - item.intensity1) << 2;
    item.intensity2 = item.intensity1;
    item.ocb = 0;   // Not present in TR1!
    item.flags = read_bitu16(src);
}
Example #6
0
/** \brief reads a room staticmesh definition.
  *
  * rotation gets converted to float and scaled appropiatly.
  * intensity1 gets converted, so it matches the 0-32768 range introduced in TR3.
  * intensity2 is introduced in TR2 and is set to intensity1 for TR1.
  */
void TR_Level::read_tr_room_staticmesh(SDL_RWops * const src, tr2_room_staticmesh_t & room_static_mesh)
{
    read_tr_vertex32(src, room_static_mesh.pos);
    room_static_mesh.rotation = (float)read_bitu16(src) / 16384.0f * -90;
    room_static_mesh.intensity1 = read_bit16(src);
    room_static_mesh.object_id = read_bitu16(src);
    // make consistent
    if (room_static_mesh.intensity1 >= 0)
        room_static_mesh.intensity1 = (8191 - room_static_mesh.intensity1) << 2;
    // only in TR2
    room_static_mesh.intensity2 = room_static_mesh.intensity1;

    room_static_mesh.tint.b = room_static_mesh.tint.g = room_static_mesh.tint.r = (room_static_mesh.intensity2 / 16384.0f);
    room_static_mesh.tint.a = 1.0f;
}
Example #7
0
void TR_Level::read_tr5_room_light(SDL_RWops * const src, tr5_room_light_t & light)
{
    uint32_t temp;

    read_tr4_vertex_float(src, light.pos);
    //read_tr_colour(src, light.color);
    light.color.r = read_float(src) * 255.0;    // r
    light.color.g = read_float(src) * 255.0;    // g
    light.color.b = read_float(src) * 255.0;    // b
    light.color.a = read_float(src) * 255.0;    // a
    light.color.a = 1.0f;
/*
    if ((temp != 0) && (temp != 0xCDCDCDCD))
        throw TR_ReadError("read_tr5_room_light: seperator1 has wrong value");
*/
    light.r_inner = read_float(src);
    light.r_outer = read_float(src);
    read_float(src);    // rad_input
    read_float(src);    // rad_output
    read_float(src);    // range
    read_tr4_vertex_float(src, light.dir);
    read_tr_vertex32(src, light.pos2);
    read_tr_vertex32(src, light.dir2);
    light.light_type = read_bitu8(src);
    temp = read_bitu8(src);
    if (temp != 0xCD)
        Sys_extWarn("read_tr5_room_light: seperator2 has wrong value");

    temp = read_bitu8(src);
    if (temp != 0xCD)
        Sys_extWarn("read_tr5_room_light: seperator3 has wrong value");

    temp = read_bitu8(src);
    if (temp != 0xCD)
        Sys_extWarn("read_tr5_room_light: seperator4 has wrong value");
}
Example #8
0
void TR_Level::read_tr3_room_staticmesh(SDL_RWops *const src, tr2_room_staticmesh_t & room_static_mesh)
{
    read_tr_vertex32(src, room_static_mesh.pos);
    room_static_mesh.rotation = (float)read_bitu16(src) / 16384.0f * -90;
    room_static_mesh.intensity1 = read_bit16(src);
    room_static_mesh.intensity2 = read_bit16(src);
    room_static_mesh.object_id = read_bitu16(src);

    room_static_mesh.tint.r = ((room_static_mesh.intensity1 & 0x001F)        ) / 62.0f;

    room_static_mesh.tint.g = ((room_static_mesh.intensity1 & 0x03E0) >> 5   ) / 62.0f;

    room_static_mesh.tint.b = ((room_static_mesh.intensity1 & 0x7C00) >> 10  ) / 62.0f;
    room_static_mesh.tint.a = 1.0f;
}
Example #9
0
void TR_Level::read_tr3_room_light(SDL_RWops * const src, tr5_room_light_t & light)
{
    read_tr_vertex32(src, light.pos);
    light.color.r = read_bitu8(src);
    light.color.g = read_bitu8(src);
    light.color.b = read_bitu8(src);
    light.color.a = read_bitu8(src);
    light.fade1 = read_bitu32(src);
    light.fade2 = read_bitu32(src);

    light.intensity = 1.0f;

    light.r_outer = (float)light.fade1;
    light.r_inner = (float)light.fade1 / 2.0;

    light.light_type = 0x01; // Point light
}