Main Page   Compound List   File List   Compound Members  

tr_types.h

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;        // Index into FloorData[]
00115         bitu16 box_index;       // Index into Boxes[]/Zones[] (-1 if none)
00116         bitu8 room_below;       // The number of the room below this one (-1 or 255 if none)
00117         bit8 floor;             // Absolute height of floor (multiply by 256 for world coordinates)
00118         bitu8 room_above;       // The number of the room above this one (-1 or 255 if none)
00119         bit8 ceiling;           // Absolute height of ceiling (multiply by 256 for world coordinates)
00120 } tr_room_sector_t;
00121 
00124 typedef struct {
00125         tr5_vertex_t pos;       // world coords
00126         tr2_colour_t color;     // three bytes rgb values 
00127         bitu16 intensity1;      // Light intensity
00128         bitu16 intensity2;      // Almost always equal to Intensity1 [absent from TR1 data files]
00129         bitu32 fade1;           // Falloff value 1
00130         bitu32 fade2;           // Falloff value 2 [absent from TR1 data files]
00131         bitu8 light_type;       // same as D3D (i.e. 2 is for spotlight) 
00132         bitu8 unknown;          // always 0xff? 
00133         float in;
00134         float out;
00135         float length;
00136         float cutoff;
00137         tr5_vertex_t dir;       // direction
00138         tr5_vertex_t pos2;      // world coords
00139         tr5_vertex_t dir2;      // direction
00140 } tr5_room_light_t;
00141 
00144 typedef struct {
00145         bit16 vertex;           // offset into vertex list
00146         bit16 texture;          // offset into sprite texture list
00147 } tr_room_sprite_t;
00148 
00151 typedef struct {
00152         bitu16 num_vertices;    // number of vertices in this layer (4 bytes)
00153         bitu16 unknown_l1;
00154         bitu16 unknown_l2;
00155         bitu16 num_rectangles;  // number of rectangles in this layer (2 bytes)
00156         bitu16 num_triangles;   // number of triangles in this layer (2 bytes)
00157         bitu16 unknown_l3;
00158         bitu16 unknown_l4;
00159         //  The following 6 floats (4 bytes each) define the bounding box for the layer
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;    // where this vertex lies (relative to tr2_room_info::x/z)
00178         bit16 lighting1;
00179         bitu16 attributes;      // A set of flags for special rendering effects [absent from TR1 data files]
00180         // 0x8000 something to do with water surface
00181         // 0x4000 under water lighting modulation and
00182         // movement if viewed from above water surface
00183         // 0x2000 water/quicksand surface movement
00184         // 0x0010 "normal"
00185         bit16 lighting2;        // Almost always equal to Lighting1 [absent from TR1 data files]
00186         // TR5 -->
00187         tr5_vertex_t normal;
00188         tr5_colour_t colour;    // vertex color ARGB format (4 bytes)
00189 } tr5_room_vertex_t;
00190 
00193 typedef struct {
00194         tr5_vertex_t pos;       // world coords
00195         float rotation;         // high two bits (0xC000) indicate steps of
00196         // 90 degrees (e.g. (Rotation >> 14) * 90)
00197         bit16 intensity1;       // Constant lighting; -1 means use mesh lighting
00198         bit16 intensity2;       // Like Intensity 1, and almost always the same value [absent from TR1 data files]
00199         bitu16 object_id;       // which StaticMesh item to draw
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;      // number of layers (pieces) this room (4 bytes)
00210         std::vector < tr5_room_layer_t > layers;        // [NumStaticMeshes]list of static meshes
00211         bitu32 num_vertices;    // number of vertices in the following list
00212         std::vector < tr5_room_vertex_t > vertices;     // [NumVertices] list of vertices (relative coordinates)
00213         bitu32 num_rectangles;  // number of textured rectangles
00214         std::vector < tr4_face4_t > rectangles; // [NumRectangles] list of textured rectangles
00215         bitu32 num_triangles;   // number of textured triangles
00216         std::vector < tr4_face3_t > triangles;  // [NumTriangles] list of textured triangles
00217         bitu32 num_sprites;     // number of sprites
00218         std::vector < tr_room_sprite_t > sprites;       // [NumSprites] list of sprites
00219         bitu16 num_portals;     // number of visibility portals to other rooms
00220         std::vector < tr_room_portal_t > portals;       // [NumPortals] list of visibility portals
00221         bitu16 num_zsectors;    // "width" of sector list
00222         bitu16 num_xsectors;    // "height" of sector list
00223         std::vector < tr_room_sector_t > sector_list;   // [NumXsectors * NumZsectors] list of sectors
00224         // in this room
00225         bit16 intensity1;       // This and the next one only affect externally-lit objects
00226         bit16 intensity2;       // Almost always the same value as AmbientIntensity1 [absent from TR1 data files]
00227         bit16 light_mode;       // (present only in TR2: 0 is normal, 1 is flickering(?), 2 and 3 are uncertain)
00228         bitu16 num_lights;      // number of point lights in this room
00229         std::vector < tr5_room_light_t > lights;        // [NumLights] list of point lights
00230         bitu16 num_static_meshes;       // number of static meshes
00231         std::vector < tr2_room_staticmesh_t > static_meshes;    // [NumStaticMeshes]list of static meshes
00232         bit16 alternate_room;   // number of the room that this room can alternate
00233         // with (e.g. empty/filled with water is implemented as an empty room that alternates with a full room)
00234         bitu16 flags;
00235         // flag bits: 0x0001 - room is filled with water,
00236         // 0x0020 - Lara's ponytail gets blown
00237         // by the wind;
00238         // TR1 has only the water flag and the extra
00239         // unknown flag 0x0100.
00240         // TR3 most likely has flags for "is raining", "is snowing", "water is cold", and "is
00241         // filled by quicksand", among others.
00242         tr2_colour_t fog_colour;        // Present in TR3-TR4 only
00243         tr5_colour_t light_colour;      // Present in TR5 only
00244 
00245         // TR5 only -->
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;    // This is usually close to the mesh's centroid, and appears to be the center of a sphere used for collision testing.
00266         bit32 collision_size;   // This appears to be the radius of that aforementioned collisional sphere.
00267         bit16 num_vertices;     // number of vertices in this mesh
00268         std::vector < tr5_vertex_t > vertices;  //[NumVertices]; // list of vertices (relative coordinates)
00269         bit16 num_normals;      // If positive, number of normals in this mesh.
00270         // If negative, number of vertex lighting elements (* (-1))
00271         bit16 num_lights;       // Engine internal for above
00272         std::vector < tr5_vertex_t > normals;   //[NumNormals]; // list of normals (if NumNormals is positive)
00273         std::vector < bit16 >lights;    //[-NumNormals]; // list of light values (if NumNormals is negative)
00274         bit16 num_textured_rectangles;  // number of textured rectangles in this mesh
00275         std::vector < tr4_face4_t > textured_rectangles;        //[NumTexturedRectangles]; // list of textured rectangles
00276         bit16 num_textured_triangles;   // number of textured triangles in this mesh
00277         std::vector < tr4_face3_t > textured_triangles; //[NumTexturedTriangles]; // list of textured triangles
00278         // the rest is not present in TR4
00279         bit16 num_coloured_rectangles;  // number of coloured rectangles in this mesh
00280         std::vector < tr4_face4_t > coloured_rectangles;        //[NumColouredRectangles]; // list of coloured rectangles
00281         bit16 num_coloured_triangles;   // number of coloured triangles in this mesh
00282         std::vector < tr4_face3_t > coloured_triangles; //[NumColouredTriangles]; // list of coloured triangles
00283 } tr4_mesh_t;
00284 
00287 typedef struct {                // 32 bytes
00288         bitu32 object_id;       // Object Identifier (matched in Items[])
00289         bitu16 mesh;            // mesh (offset into MeshPointers[])
00290         tr5_vertex_t visibility_box[2];
00291         tr5_vertex_t collision_box[2];
00292         bitu16 flags;           // Meaning uncertain; it is usually 2, and is 3 for objects Lara can travel through,
00293         // like TR2's skeletons and underwater vegetation
00294 } tr_staticmesh_t;
00295 
00306 typedef struct {                // 4 bytes
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 {                // 18 bytes
00355         bitu32 object_id;       // Item Identifier (matched in Items[])
00356         bitu16 num_meshes;      // number of meshes in this object
00357         bitu16 starting_mesh;   // stating mesh (offset into MeshPointers[])
00358         bitu32 mesh_tree_index; // offset into MeshTree[]
00359         bitu32 frame_offset;    // byte offset into Frames[] (divide by 2 for Frames[i])
00360         bitu32 frame_index;
00361         bitu16 animation_index; // offset into Animations[]
00362 } tr_moveable_t;
00363 
00366 typedef struct {                // 24 bytes [TR1: 22 bytes]
00367         bit16 object_id;        // Object Identifier (matched in Moveables[], or SpriteSequences[], as appropriate)
00368         bit16 room;             // which room contains this item
00369         tr5_vertex_t pos;       // world coords
00370         float rotation;         // ((0xc000 >> 14) * 90) degrees
00371         bit16 intensity1;       // (constant lighting; -1 means use mesh lighting)
00372         bit16 intensity2;       // Like Intensity1, and almost always with the same value. [absent from TR1 data files]
00373         bitu16 flags;           // 0x0100 indicates "initially invisible", 0x3e00 is Activation Mask
00374         // 0x3e00 indicates "open" or "activated";  these can be XORed with
00375         // related FloorData::FDlist fields (e.g. for switches)
00376 } tr2_item_t;
00377 
00380 typedef struct {                // 16 bytes
00381         bitu16 tile;
00382         bitu8 x;                // TR4 unknown
00383         bitu8 y;                // TR4 unknown
00384         bitu16 width;           // TR1/2/3 actually (Width * 256) + 255
00385         // TR4 = (real_width-1) * 256   
00386         bitu16 height;          // TR1/2/3 actually (Height * 256) + 255
00387         // TR4 = (real_height-1) * 256  
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 {                // 8 bytes
00397         bit32 object_id;        // Item identifier (matched in Items[])
00398         bit16 length;           // negative of "how many sprites are in this sequence"
00399         bit16 offset;           // where (in sprite texture list) this sequence starts
00400 } tr_sprite_sequence_t;
00401 
00410 typedef struct {                // 32 bytes TR1/2/3 40 bytes TR4
00411         bitu32 frame_offset;    // byte offset into Frames[] (divide by 2 for Frames[i])
00412         bitu8 frame_rate;       // Engine ticks per frame
00413         bitu8 frame_size;       // number of bit16's in Frames[] used by this animation
00414         bitu16 state_id;
00415 
00416         bit16 unknown;
00417         bit16 speed;
00418         bit16 accel_lo;
00419         bit16 accel_hi;
00420 
00421         bit16 unknown2;         // new in TR4 -->
00422         bit16 speed2;           // not really sure what these mean.
00423         bit16 accel_lo2;
00424         bit16 accel_hi2;        // <-- TR4
00425 
00426         bitu16 frame_start;     // first frame in this animation
00427         bitu16 frame_end;       // last frame in this animation (numframes = (End - Start) + 1)
00428         bitu16 next_animation;
00429         bitu16 next_frame;
00430 
00431         bitu16 num_state_changes;
00432         bitu16 state_change_offset;     // offset into StateChanges[]
00433         bitu16 num_anim_commands;       // How many of them to use.
00434         bitu16 anim_command;    // offset into AnimCommand[]
00435 } tr_animation_t;
00436 
00443 typedef struct {                // 6 bytes
00444         bitu16 state_id;
00445         bitu16 num_anim_dispatches;     // number of ranges (seems to always be 1..5)
00446         bitu16 anim_dispatch;   // Offset into AnimDispatches[]
00447 } tr_state_change_t;
00448 
00455 typedef struct {                // 8 bytes
00456         bit16 low;              // Lowest frame that uses this range
00457         bit16 high;             // Highest frame (+1?) that uses this range
00458         bit16 next_animation;   // Animation to dispatch to
00459         bit16 next_frame;       // Frame offset to dispatch to
00460 } tr_anim_dispatch_t;
00461 
00471 typedef struct {                // 2 bytes
00472         bit16 value;
00473 } tr_anim_command_t;
00474 
00477 typedef struct {                // 8 bytes [TR1: 20 bytes] In TR1, the first four are bit32's instead of bitu8's, and are not scaled.
00478         bitu32 zmin;            // sectors (* 1024 units)
00479         bitu32 zmax;
00480         bitu32 xmin;
00481         bitu32 xmax;
00482         bit16 true_floor;       // Y value (no scaling)
00483         bit16 overlap_index;    // index into Overlaps[]. The high bit is sometimes set; this
00484         // occurs in front of swinging doors and the like.
00485 } tr_box_t;
00486 
00494 typedef struct {
00495         bit32 x;                // absolute X position of sound source (world coordinates)
00496         bit32 y;                // absolute Y position of sound source (world coordinates)
00497         bit32 z;                // absolute Z position of sound source (world coordinates)
00498         bitu16 sound_id;        // internal sound index
00499         bitu16 flags;           // 0x40, 0x80, or 0xc0
00500 } tr_sound_source_t;
00501 
00504 typedef struct {                // 8 bytes
00505         bit16 sample;           // (index into SampleIndices)
00506         bit16 volume;
00507         bit16 sound_range;      // sound range? (distance at which this sound can be heard?)
00508         bit16 flags;            // Bits 8-15: priority?, Bits 2-7: number of sound
00509         // samples in this group, Bits 0-1: channel number?
00510 } tr_sound_details_t;
00511 
00520 typedef struct {                // 4 bytes
00521         bit8 xcoordinate;       // 1 if Xpixel is the low value, -1 if Xpixel is the high value in the object texture
00522         bitu8 xpixel;
00523         bit8 ycoordinate;       // 1 if Ypixel is the low value, -1 if Ypixel is the high value in the object texture
00524         bitu8 ypixel;
00525 } tr4_object_texture_vert_t;
00526 
00532 typedef struct {                // 38 bytes TR4 - 20 in TR1/2/3
00533         bitu16 transparency_flags;      // 0 means that a texture is all-opaque, and that transparency
00534         // information is ignored.
00535         // 1 means that transparency information is used. In 8-bit colour,
00536         // index 0 is the transparent colour, while in 16-bit colour, the
00537         // top bit (0x8000) is the alpha channel (1 = opaque, 0 = transparent).
00538         // 2 (only in TR3) means that the opacity (alpha) is equal to the intensity;
00539         // the brighter the colour, the more opaque it is. The intensity is probably calculated
00540         // as the maximum of the individual color values.
00541         bitu8 tile;             // index into textile list
00542         bitu8 tile_flags;
00543         bitu16 flags;           // TR4
00544         tr4_object_texture_vert_t vertices[4];  // the four corners of the texture
00545         bitu32 unknown1;        // TR4
00546         bitu32 unknown2;        // TR4
00547         bitu32 x_size;          // TR4
00548         bitu32 y_size;          // TR4
00549 } tr4_object_texture_t;
00550 
00553 typedef struct {
00554         bit16 num_texture_ids;  // Actually, this is the number of texture ID's - 1.
00555         std::vector < bit16 >texture_ids;       //[NumTextureIDs + 1]; // offsets into ObjectTextures[], in animation order.
00556 } tr_animated_textures_t;       //[NumAnimatedTextures];
00557 
00560 typedef struct {
00561         bit32 x;
00562         bit32 y;
00563         bit32 z;
00564         bit16 room;
00565         bitu16 unknown1;        // correlates to Boxes[]? Zones[]?
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;       // the objectID from the AI object (AI_FOLLOW is 402)
00586         bitu16 room;
00587         bit32 x;
00588         bit32 y;
00589         bit32 z;
00590         bitu16 ocb;
00591         bitu16 flags;           // The trigger flags (button 1-5, first button has value 2)
00592         bit32 angle;
00593 } tr4_ai_object_t;
00594 
00597 typedef struct {
00598         bit16 roty;             // rotation about Y axis, +/- 32767 == +/- 180 degrees
00599         bit16 rotz;             // rotation about Z axis, +/- 32767 == +/- 180 degrees
00600         bit16 rotz2;            // seems to work a lot like rotZ;  I haven't yet been able to
00601         // differentiate them
00602         bit16 posz;             // camera position relative to something (target? Lara? room
00603         // origin?).  pos* are _not_ in world coordinates.
00604         bit16 posy;             // camera position relative to something (see posZ)
00605         bit16 posx;             // camera position relative to something (see posZ)
00606         bit16 unknown;          // changing this can cause a runtime error
00607         bit16 rotx;             // rotation about X axis, +/- 32767 == +/- 180 degrees
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;

Generated on Sun Sep 8 17:37:29 2002 for vt by doxygen1.2.17