Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TR5.spec 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
  2. #############################################################################
  3. #
  4. # TR5 File Format?
  5. # rgbold, Turbo Pascal, and Mongoose spec merge
  6. #
  7. # NOTES:
  8. # I use ISO style types to be more clear, not word sizes
  9. #
  10. # Int : unsigned short : bitu16
  11. # Dword : unsigned int : bitu32
  12. #
  13. # Some other markers? I think these may be:
  14. #
  15. # 58 50 50 FF "XPP." | "PPX"
  16. # 58 50 48 FF "XPH." | "HPX"
  17. # 50 50 48 FF "PPH." | "PPH"
  18. #
  19. # They appear in a patern like:
  20. # ALEX
  21. # XPP XPP ...
  22. # ALEX
  23. #
  24. #
  25. # - Mongoose
  26. #
  27. # Room Vertices are 28 bytes each
  28. # 3 floats representing the x,y,z values of vertex
  29. # 3 floats probably the vertex normals
  30. # 1 DWORD probably diffuse color for the vertex
  31. #
  32. # Rectangles are same old format of V0,V1,V2,V3,Texture, followed by
  33. # Int unknown, usually zero.
  34. # Texture needs to be masked with 0xfff (high 4 bits are flags)
  35. #
  36. # Triangles are same old format of V0,V1,V2,Texture, followed by
  37. # Int unknown, usually zero.
  38. # Texture needs to be masked with 0xfff (high 4 bits are flags)
  39. #
  40. # TR5 uses D3D extensively. The light format is a prime example. The last
  41. # byte in the light field before the CDCDCD is the light type which in
  42. # D3d is 1,2, or 3 for point, spot, or directional lights respectively.
  43. # Also somewhere in the unknowns must be the fog values.
  44. #
  45. # Sound Map is now 900 bytes
  46. #
  47. # Before SoundSources is a new field for Flyby_Camera data
  48. # bitu32 Number_of_FBCameras
  49. # followed by data for each camera. Data field is 40 bytes.
  50. # [Andy had previously stated NumXYZ as a new field incorrectly.
  51. # His NumXYZ field was the SoundSources in normal structure format]
  52. #
  53. #
  54. # Cinematic Frames now 24 bytes
  55. #
  56. # There are no colored rectangles or triangles in mesh data.
  57. # Mesh Rectangles and Triangles now same format as room rects and tris,
  58. # MeshRects: v0,v1,v2,v3,texture,int unknown
  59. # MeshTris: v0,v1,v2,texture,int unknown
  60. # Texture Objects now preceeded by TEX/0 (4bytes)
  61. # Object Textures now 38 bytes vice 20
  62. # Tile is now a bitu32 vice bitu16 seems need to mask with 0xff as other
  63. # bits are flags. Seems bit15 set means triangle.
  64. # In the texture coords now 0 is used for low value vice 1
  65. # The extra 16 bytes at the end of ObjectTexture structure are 4 Dword
  66. # coords, UV?.
  67. # Attributes using 1 or 2 for transparent. 2 used for 2 sided textures
  68. # (water surface,etc)
  69. #
  70. #
  71. # Animation now 40 vice 32 bytes. extra 8 seem to be zero right before
  72. # /after the old 8 unknowns
  73. #
  74. # "SPR" 3 byte ascii before sprite textures
  75. #
  76. # As TR4 there are no 8bit or 16 bit palettes (no colored rects or tris)
  77. # No lightmap
  78. # No 8bit textures
  79. # 3 blocks of zlib compressed textures (32bit,16bit,sprite/misc)before
  80. # level data.
  81. # Level data not compressed.
  82. #
  83. # Following level data are Riff Wave Formats.
  84. #
  85. # Lara 2 meshes as TR4, skin and joints.
  86. #
  87. # also , I was just reading thru the rectanges and triangles and
  88. # thought the vertices always followed right after but appears
  89. # that sometimes there is a 'pad' int of 0xCDCD.
  90. #
  91. #
  92. # Also as Michiel has just posted the Object Textures for TR5 are
  93. # 40bytes, sorry about that.
  94. # - Roy
  95. #
  96. #############################################################################
  97. uint32 version; // Will be "TR4\0" for valid header
  98. // Textures /////////////////
  99. bitu16 num_room_textures
  100. bitu16 number of num_other_textures
  101. bitu16 number of num_bump_map_textures
  102. bitu32 UncompressedSize1
  103. bitu32 CompressedSize1
  104. TextureBlock1
  105. bitu32 UncompressedSize2
  106. bitu32 CompressedSize2
  107. TextureBlock2
  108. bitu32 UncompressedSize3
  109. bitu32 CompressedSize3
  110. TextureBlock3
  111. /// Follows after textures
  112. 32 bytes unknown //mostly zero
  113. bitu32 SizeData // size of file to Riffs
  114. bitu32 SizeData // repeat of above
  115. bitu32 Unknown // seems always zero
  116. bitu32 NumberRooms // number of rooms this level
  117. { Following Repeats for each Room in level
  118. bitu32 "XELA" (someone named Alex or "dirX Enhanced Level Archive"
  119. bitu32 size //size to next XELA block
  120. bitu32 CDCDCDCD
  121. Block1 60 bytes
  122. {
  123. bitu32 ublock1 //mostly: start of "XELA" +216 + ublock1 = FD end,
  124. but have seen 0xffffffff. Better using next data
  125. and compute FD size the old way of X*Z*8
  126. bitu32 ublock2 // start of "XELA" + 216 + ublock2 = FD start
  127. bitu32 ublock3 // unknown
  128. bitu32 ublock4 // possibly start of "XELA" + 216 + ublock4 = end portals
  129. bitu32 Room X // room's x position in world coords
  130. bitu32 unknown1 // always seems to be 0000
  131. bitu32 Room Z // room's z position in world coords
  132. bitu32 Ybottom // room's y bottom positon in world coords
  133. bitu32 Ytop // room's y top positon in world coords
  134. Int NumZSectors // number of z sectors
  135. Int NumXSectors // number of x sectors
  136. tr2_color4 // 4 bytes color info rgba
  137. Int NumLights
  138. Int NumStaticMeshes
  139. bitu32 Unknown2 // seems always 0x0001
  140. bitu32 Unknown3 // seems always 0x7fff
  141. bitu32 Unknown4 // seems always 0x7fff
  142. }close 60 byte block
  143. bitu32 CDCDCDCD
  144. bitu32 CDCDCDCD
  145. 20 byte block
  146. {
  147. 6 bytes 0xff
  148. Int Room_Flag //room attributes (rain,etc)
  149. Int unknown5
  150. 10 bytes 0x00
  151. } close 20 byte block
  152. bitu32 CDCDCDCD
  153. 16 byte block
  154. {
  155. unknown 16 bytes
  156. }close 16 byte block
  157. bitu32 CDCDCDCD
  158. bitu32 CDCDCDCD
  159. bitu32 CDCDCDCD
  160. bitu32 CDCDCDCD
  161. bitu32 Unknown6
  162. bitu32 CDCDCDCD
  163. 56 byte block
  164. {
  165. bitu32 NumberTriangles
  166. bitu32 NumberRectangles
  167. bitu32 Unknown7 // always 0x0000 ??
  168. bitu32 LightSize // number lights times 88 bytes
  169. bitu32 NumberLights
  170. bitu32 NumUnknown_36_byte_struct
  171. bitu32 Unknown9
  172. bitu32 Unknown10
  173. bitu32 NumberLayers //TR5 'layers' room pieces
  174. bitu32 Unknown11 // start of "XELA" + 216 + Unknown11 = start of
  175. layer
  176. info
  177. bitu32 Unknown12 // start of "XELA" + 216 + Unknown12 = start of
  178. vertices
  179. bitu32 Unknown13 // start of "XELA" + 216 + Unknown13 = start of
  180. rect/tri
  181. bitu32 Unknown14 // same as Unknown13???
  182. bitu32 Unknown15 // start of vertices + Unknown15 = start of next
  183. "XELA"
  184. }close 56 byte block
  185. bitu32 CDCDCDCD
  186. bitu32 CDCDCDCD
  187. bitu32 CDCDCDCD
  188. bitu32 CDCDCDCD
  189. // Lights //////////////////////////
  190. if lights then 85 bytes light data followed by CDCDCD for each light
  191. // Unknown /////////////////////////
  192. if NumUnknown_36_byte_struct then read them too
  193. // Sectors /////////////////////////
  194. Sector Data (sectors times 8 bytes) normal sector data structure
  195. // Portals /////////////////////////
  196. Int NumberDoors
  197. NumberDoors times 32 bytes (normal portal structure)
  198. Int CDCD
  199. // Static meshes //////////////////
  200. if StaticMeshes than numberofstatics times 20 bytes each (normal
  201. structure)
  202. // Layers ////////////////////////
  203. Layer Data blocks. 56 bytes each.
  204. {
  205. bitu32 NumberVertices
  206. Int Unknown16
  207. Int NumberRectangles
  208. Int NumberTriangles
  209. unknown 46 bytes // was 48 in older docs
  210. }close Layer Data block
  211. following the Layer Data block are:
  212. rectangles for Layer1 // see format under NOTES
  213. triangles for Layer1 // see format under NOTES
  214. rectangles for Layer2
  215. triangles for Layer2
  216. ...and so on untill all layers are done
  217. after the rectangle and triangle information are the room vertices
  218. which are described under NOTES
  219. }Close Rooms Loop