00001 #ifdef _MSC_VER
00002 #pragma warning (disable:4786)
00003 #endif
00004
00005 #include <vector>
00006
00007 typedef signed char bit8;
00008 typedef unsigned char bitu8;
00009 typedef signed short bit16;
00010 typedef unsigned short bitu16;
00011 typedef signed int bit32;
00012 typedef unsigned int bitu32;
00013
00015 typedef struct {
00016 bitu8 r;
00017 bitu8 g;
00018 bitu8 b;
00019 bitu8 a;
00020 } tr2_colour_t;
00021
00023 typedef struct {
00024 float r;
00025 float g;
00026 float b;
00027 float a;
00028 } tr5_colour_t;
00029
00031 typedef struct {
00032 float x;
00033 float y;
00034 float z;
00035 } tr5_vertex_t;
00036
00038 typedef struct {
00039 bitu16 vertices[3];
00040 bitu16 texture;
00045 bitu16 lighting;
00049 } tr4_face3_t;
00050
00052 typedef struct {
00053 bitu16 vertices[4];
00054 bitu16 texture;
00059 bitu16 lighting;
00065 } tr4_face4_t;
00066
00071 typedef struct {
00072 bitu8 pixels[256][256];
00073 } tr_textile8_t;
00074
00083 typedef struct {
00084 bitu16 pixels[256][256];
00085 } tr2_textile16_t;
00086
00091 typedef struct {
00092 bitu32 pixels[256][256];
00093 } tr4_textile32_t;
00094
00097 typedef struct {
00098 bitu16 adjoining_room;
00099 tr5_vertex_t normal;
00103 tr5_vertex_t vertices[4];
00109 } tr_room_portal_t;
00110
00113 typedef struct {
00114 bitu16 fd_index;
00115 bitu16 box_index;
00116 bitu8 room_below;
00117 bit8 floor;
00118 bitu8 room_above;
00119 bit8 ceiling;
00120 } tr_room_sector_t;
00121
00124 typedef struct {
00125 tr5_vertex_t pos;
00126 tr2_colour_t color;
00127 bitu16 intensity1;
00128 bitu16 intensity2;
00129 bitu32 fade1;
00130 bitu32 fade2;
00131 bitu8 light_type;
00132 bitu8 unknown;
00133 float in;
00134 float out;
00135 float length;
00136 float cutoff;
00137 tr5_vertex_t dir;
00138 tr5_vertex_t pos2;
00139 tr5_vertex_t dir2;
00140 } tr5_room_light_t;
00141
00144 typedef struct {
00145 bit16 vertex;
00146 bit16 texture;
00147 } tr_room_sprite_t;
00148
00151 typedef struct {
00152 bitu16 num_vertices;
00153 bitu16 unknown_l1;
00154 bitu16 unknown_l2;
00155 bitu16 num_rectangles;
00156 bitu16 num_triangles;
00157 bitu16 unknown_l3;
00158 bitu16 unknown_l4;
00159
00160 float bounding_box_x1;
00161 float bounding_box_y1;
00162 float bounding_box_z1;
00163 float bounding_box_x2;
00164 float bounding_box_y2;
00165 float bounding_box_z2;
00166 bit16 unknown_l6a;
00167 bit16 unknown_l6b;
00168 bit16 unknown_l7a;
00169 bit16 unknown_l7b;
00170 bit16 unknown_l8a;
00171 bit16 unknown_l8b;
00172 } tr5_room_layer_t;
00173
00176 typedef struct {
00177 tr5_vertex_t vertex;
00178 bit16 lighting1;
00179 bitu16 attributes;
00180
00181
00182
00183
00184
00185 bit16 lighting2;
00186
00187 tr5_vertex_t normal;
00188 tr5_colour_t colour;
00189 } tr5_room_vertex_t;
00190
00193 typedef struct {
00194 tr5_vertex_t pos;
00195 float rotation;
00196
00197 bit16 intensity1;
00198 bit16 intensity2;
00199 bitu16 object_id;
00200 } tr2_room_staticmesh_t;
00201
00204 typedef struct {
00205 float x;
00206 float z;
00207 float y_bottom;
00208 float y_top;
00209 bitu32 num_layers;
00210 std::vector < tr5_room_layer_t > layers;
00211 bitu32 num_vertices;
00212 std::vector < tr5_room_vertex_t > vertices;
00213 bitu32 num_rectangles;
00214 std::vector < tr4_face4_t > rectangles;
00215 bitu32 num_triangles;
00216 std::vector < tr4_face3_t > triangles;
00217 bitu32 num_sprites;
00218 std::vector < tr_room_sprite_t > sprites;
00219 bitu16 num_portals;
00220 std::vector < tr_room_portal_t > portals;
00221 bitu16 num_zsectors;
00222 bitu16 num_xsectors;
00223 std::vector < tr_room_sector_t > sector_list;
00224
00225 bit16 intensity1;
00226 bit16 intensity2;
00227 bit16 light_mode;
00228 bitu16 num_lights;
00229 std::vector < tr5_room_light_t > lights;
00230 bitu16 num_static_meshes;
00231 std::vector < tr2_room_staticmesh_t > static_meshes;
00232 bit16 alternate_room;
00233
00234 bitu16 flags;
00235
00236
00237
00238
00239
00240
00241
00242 tr2_colour_t fog_colour;
00243 tr5_colour_t light_colour;
00244
00245
00246 bitu16 unknown_r1;
00247 bitu16 unknown_r2;
00248 bit16 unknown_r3;
00249 bitu32 unknown_r4;
00250 bitu32 unknown_r5;
00251 bitu32 unknown_r6;
00252 float room_x;
00253 float room_z;
00254 bitu16 unknown_r7a;
00255 bitu16 unknown_r7b;
00256 bitu32 unknown_r8;
00257 bitu32 unknown_r9;
00258 float room_y_bottom;
00259 float room_y_top;
00260 } tr5_room_t;
00261
00264 typedef struct {
00265 tr5_vertex_t centre;
00266 bit32 collision_size;
00267 bit16 num_vertices;
00268 std::vector < tr5_vertex_t > vertices;
00269 bit16 num_normals;
00270
00271 bit16 num_lights;
00272 std::vector < tr5_vertex_t > normals;
00273 std::vector < bit16 >lights;
00274 bit16 num_textured_rectangles;
00275 std::vector < tr4_face4_t > textured_rectangles;
00276 bit16 num_textured_triangles;
00277 std::vector < tr4_face3_t > textured_triangles;
00278
00279 bit16 num_coloured_rectangles;
00280 std::vector < tr4_face4_t > coloured_rectangles;
00281 bit16 num_coloured_triangles;
00282 std::vector < tr4_face3_t > coloured_triangles;
00283 } tr4_mesh_t;
00284
00287 typedef struct {
00288 bitu32 object_id;
00289 bitu16 mesh;
00290 tr5_vertex_t visibility_box[2];
00291 tr5_vertex_t collision_box[2];
00292 bitu16 flags;
00293
00294 } tr_staticmesh_t;
00295
00306 typedef struct {
00307 bitu32 flags;
00308 tr5_vertex_t offset;
00309 } tr_meshtree_t;
00310
00344 typedef struct {
00345 tr5_vertex_t bbox_low;
00346 tr5_vertex_t bbox_high;
00347 tr5_vertex_t offset;
00348 std::vector < tr5_vertex_t > rotations;
00349 bit32 byte_offset;
00350 } tr_frame_t;
00351
00354 typedef struct {
00355 bitu32 object_id;
00356 bitu16 num_meshes;
00357 bitu16 starting_mesh;
00358 bitu32 mesh_tree_index;
00359 bitu32 frame_offset;
00360 bitu32 frame_index;
00361 bitu16 animation_index;
00362 } tr_moveable_t;
00363
00366 typedef struct {
00367 bit16 object_id;
00368 bit16 room;
00369 tr5_vertex_t pos;
00370 float rotation;
00371 bit16 intensity1;
00372 bit16 intensity2;
00373 bitu16 flags;
00374
00375
00376 } tr2_item_t;
00377
00380 typedef struct {
00381 bitu16 tile;
00382 bitu8 x;
00383 bitu8 y;
00384 bitu16 width;
00385
00386 bitu16 height;
00387
00388 bit16 left_side;
00389 bit16 top_side;
00390 bit16 right_side;
00391 bit16 bottom_side;
00392 } tr_sprite_texture_t;
00393
00396 typedef struct {
00397 bit32 object_id;
00398 bit16 length;
00399 bit16 offset;
00400 } tr_sprite_sequence_t;
00401
00410 typedef struct {
00411 bitu32 frame_offset;
00412 bitu8 frame_rate;
00413 bitu8 frame_size;
00414 bitu16 state_id;
00415
00416 bit16 unknown;
00417 bit16 speed;
00418 bit16 accel_lo;
00419 bit16 accel_hi;
00420
00421 bit16 unknown2;
00422 bit16 speed2;
00423 bit16 accel_lo2;
00424 bit16 accel_hi2;
00425
00426 bitu16 frame_start;
00427 bitu16 frame_end;
00428 bitu16 next_animation;
00429 bitu16 next_frame;
00430
00431 bitu16 num_state_changes;
00432 bitu16 state_change_offset;
00433 bitu16 num_anim_commands;
00434 bitu16 anim_command;
00435 } tr_animation_t;
00436
00443 typedef struct {
00444 bitu16 state_id;
00445 bitu16 num_anim_dispatches;
00446 bitu16 anim_dispatch;
00447 } tr_state_change_t;
00448
00455 typedef struct {
00456 bit16 low;
00457 bit16 high;
00458 bit16 next_animation;
00459 bit16 next_frame;
00460 } tr_anim_dispatch_t;
00461
00471 typedef struct {
00472 bit16 value;
00473 } tr_anim_command_t;
00474
00477 typedef struct {
00478 bitu32 zmin;
00479 bitu32 zmax;
00480 bitu32 xmin;
00481 bitu32 xmax;
00482 bit16 true_floor;
00483 bit16 overlap_index;
00484
00485 } tr_box_t;
00486
00494 typedef struct {
00495 bit32 x;
00496 bit32 y;
00497 bit32 z;
00498 bitu16 sound_id;
00499 bitu16 flags;
00500 } tr_sound_source_t;
00501
00504 typedef struct {
00505 bit16 sample;
00506 bit16 volume;
00507 bit16 sound_range;
00508 bit16 flags;
00509
00510 } tr_sound_details_t;
00511
00520 typedef struct {
00521 bit8 xcoordinate;
00522 bitu8 xpixel;
00523 bit8 ycoordinate;
00524 bitu8 ypixel;
00525 } tr4_object_texture_vert_t;
00526
00532 typedef struct {
00533 bitu16 transparency_flags;
00534
00535
00536
00537
00538
00539
00540
00541 bitu8 tile;
00542 bitu8 tile_flags;
00543 bitu16 flags;
00544 tr4_object_texture_vert_t vertices[4];
00545 bitu32 unknown1;
00546 bitu32 unknown2;
00547 bitu32 x_size;
00548 bitu32 y_size;
00549 } tr4_object_texture_t;
00550
00553 typedef struct {
00554 bit16 num_texture_ids;
00555 std::vector < bit16 >texture_ids;
00556 } tr_animated_textures_t;
00557
00560 typedef struct {
00561 bit32 x;
00562 bit32 y;
00563 bit32 z;
00564 bit16 room;
00565 bitu16 unknown1;
00566 } tr_camera_t;
00567
00570 typedef struct {
00571 bit32 x1;
00572 bit32 y1;
00573 bit32 z1;
00574 bit32 x2;
00575 bit32 y2;
00576 bitu8 index1;
00577 bitu8 index2;
00578 bitu16 unknown[5];
00579 bit32 id;
00580 } tr4_extra_camera_t;
00581
00584 typedef struct {
00585 bitu16 object_id;
00586 bitu16 room;
00587 bit32 x;
00588 bit32 y;
00589 bit32 z;
00590 bitu16 ocb;
00591 bitu16 flags;
00592 bit32 angle;
00593 } tr4_ai_object_t;
00594
00597 typedef struct {
00598 bit16 roty;
00599 bit16 rotz;
00600 bit16 rotz2;
00601
00602 bit16 posz;
00603
00604 bit16 posy;
00605 bit16 posx;
00606 bit16 unknown;
00607 bit16 rotx;
00608 } tr_cinematic_frame_t;
00609
00612 typedef struct {
00613 bitu8 map[32 * 256];
00614 } tr_lightmap_t;
00615
00618 typedef struct {
00619 tr2_colour_t colour[256];
00620 } tr2_palette_t;