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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770
  1. /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
  2. /*================================================================
  3. *
  4. * Project : OpenRaider
  5. * Author : Mongoose
  6. * Website : http://www.westga.edu/~stu7440/
  7. * Email : stu7440@westga.edu
  8. * Object : OpenRaider
  9. * License : GPL, See file COPYING for details
  10. * Comments: Loads TR 1, 2, 3, and 4 maps, meshes, and textures
  11. *
  12. * WARNING: No endian routines as of yet
  13. *
  14. * Define ZLIB_SUPPORT to build TR4 support
  15. *
  16. * This file was generated using Mongoose's C++
  17. * template generator script. <stu7440@westga.edu>
  18. *
  19. *-- History ------------------------------------------------
  20. *
  21. * 2003.05.13:
  22. * Mongoose - New API, maintance cost was becoming so high
  23. * it was needed to sort out methods in groups
  24. * like my newer source code -- of course some
  25. * methods were altered or removed ( clean up )
  26. *
  27. * 2003.05.19:
  28. * Mongoose - I'm now using Roy's documented TR5 structures, so
  29. * I can fill in my blanks and share common structures
  30. * with other TR5 pak loaders using it - I've removed
  31. * most of my old TR5 test code - it may have been more
  32. * correct for DX lights ( not sure ) it's still in CVS
  33. *
  34. * 2003.05.13:
  35. * Mongoose - New API, maintance cost was becoming so high
  36. * it was needed to sort out methods in groups
  37. * like my newer source code -- of course some
  38. * methods were altered or removed ( clean up )
  39. *
  40. * 2001.06.19:
  41. * Mongoose - New texture API for the new TR4/TR5 bump map
  42. * support, also purged textile exposure
  43. *
  44. *
  45. * 2001.05.21:
  46. * Mongoose - Added to project OpenRaider, more documentation
  47. * than Freyja version I wrote ( 3d modeler )
  48. *
  49. * TR4 texel and texture fixes
  50. *
  51. * Runtime debug output toggle
  52. *
  53. *
  54. * 2000.05.13:
  55. * Mongoose - Added gcc and VC++ pragmas for packing
  56. *
  57. * id style typedefs for structs
  58. *
  59. * Heavy clean up and ported to C++
  60. *
  61. * I saved yuri's notes as best I could and
  62. * reformatted and corrected as needed.
  63. *
  64. * Mongoose - Created, based on:
  65. * tr_view's tr2io.c by Yuri Zhivago, PhD,
  66. * TR Rosetta Stone ( TombRaider pak format specs )
  67. ================================================================*/
  68. #ifndef __OPENRAIDER_MONGOOSE_TOMBRAIDER_H_
  69. #define __OPENRAIDER_MONGOOSE_TOMBRAIDER_H_
  70. #ifdef WIN32
  71. // Have to remove GCC packing, by removing in preprocessor
  72. #define __attribute__(packed)
  73. // MSVC++ pragma to pack structs
  74. #define TR2_H 1
  75. #pragma pack(push, tr2_h, 1)
  76. #endif
  77. //#include "TombRaider1.h"
  78. typedef enum
  79. {
  80. TR_VERSION_UNKNOWN,
  81. TR_VERSION_1,
  82. TR_VERSION_2,
  83. TR_VERSION_3,
  84. TR_VERSION_4,
  85. TR_VERSION_5
  86. } tr2_version_type;
  87. typedef enum
  88. {
  89. TR_FREAD_NORMAL = 0,
  90. TR_FREAD_COMPRESSED
  91. } tr_fread_mode_t;
  92. typedef enum
  93. {
  94. tombraiderLight_typeDirectional = 1,
  95. tombraiderLight_typeSpot = 2,
  96. tombraiderLight_typePoint = 3
  97. } tombraiderLightType;
  98. typedef enum
  99. {
  100. tombraiderLight_useCutoff = 1,
  101. tombraiderLight_useAttenuation = 2
  102. } tombraiderLightFlags;
  103. typedef enum
  104. {
  105. tombraiderRoom_underWater = 1
  106. } tombraiderRoomFlags;
  107. typedef enum
  108. {
  109. tombraiderSector_wall = 1
  110. } tombraiderSectorFlags;
  111. typedef enum
  112. {
  113. tombraiderFace_Alpha = 1,
  114. tombraiderFace_Colored = 2,
  115. tombraiderFace_PartialAlpha = 4
  116. } tombraiderFace_Flags;
  117. #define TR_SOUND_FOOTSTEP0 1
  118. #define TR_SOUND_F_PISTOL 12
  119. #define TR_SOUND_F_PISTOL 12
  120. enum TR4_Objects
  121. {
  122. TR4_LARA = 0,
  123. TR4_PISTOLS_ANIM = 1,
  124. TR4_UZI_ANIM = 2,
  125. TR4_SHOTGUN_ANIM = 3,
  126. TR4_CROSSBOW_ANIM = 4,
  127. TR4_GRENADE_GUN_ANIM = 5,
  128. TR4_SIXSHOOTER_ANIM = 6,
  129. TR4_FLARE_ANIM = 7,
  130. TR4_LARA_SKIN = 8,
  131. TR4_LARA_SKIN_JOINTS = 9,
  132. TR4_LARA_SCREAM = 10,
  133. TR4_LARA_CROSSBOW_LASER = 11,
  134. TR4_LARA_REVOLVER_LASER = 12,
  135. TR4_LARA_HOLSTERS = 13,
  136. TR4_LARA_HOLSTERS_PISTOLS = 14,
  137. TR4_LARA_HOLSTERS_UZIS = 15,
  138. TR4_LARA_HOLSTERS_SIXSHOOTER = 16,
  139. TR4_LARA_SPEECH_HEAD1 = 17,
  140. TR4_LARA_SPEECH_HEAD2 = 18,
  141. TR4_LARA_SPEECH_HEAD3 = 19,
  142. TR4_LARA_SPEECH_HEAD4 = 20
  143. };
  144. #define TR_ANIAMTION_RUN 0
  145. #define TR_ANIAMTION_STAND 11
  146. #define TR_ANIAMTION_TURN_L 12
  147. #define TR_ANIAMTION_TURN_R 13
  148. #define TR_ANIAMTION_HIT_WALL_FRONT 53
  149. #define TR_ANIAMTION_SWIM_IDLE 87
  150. #define TR_ANIAMTION_SWIM 86
  151. #define TR_ANIAMTION_SWIM_L 143
  152. #define TR_ANIAMTION_SWIM_R 144
  153. #define TR_ANIAMTION_GRAB_LEDGE 96
  154. #define TR_ANIAMTION_PULLING_UP 97
  155. /*---------------------------------------------------------------
  156. * Basic 24-bit colour structure
  157. * (although it appears that only 6 bits
  158. * per colour are actually used, making it 18-bit colour)
  159. ---------------------------------------------------------------*/
  160. typedef struct tr2_colour_s
  161. {
  162. unsigned char r;
  163. unsigned char g;
  164. unsigned char b;
  165. } __attribute__ ((packed)) tr2_colour_t;
  166. /*--------------------------------------------------------------
  167. * Basic vertex structure.
  168. * Note that all vertices are relative coordinates;
  169. * each mesh (room, object, etc.) has its own offset by
  170. * which the vertex coordinates are translated.
  171. --------------------------------------------------------------*/
  172. typedef struct tr2_vertex_s
  173. {
  174. short x;
  175. short y;
  176. short z;
  177. } __attribute__ ((packed)) tr2_vertex_t;
  178. /*--------------------------------------------------------------
  179. * A rectangular (quad) face definition.
  180. * Four vertices (the values are indices into the
  181. * appropriate vertex list) and a texture (an index
  182. * into the texture list) or colour (index into 8-bit palette).
  183. *
  184. * I've seen a few coloured polygons where Texture is
  185. * greater than 255, but ANDing the value with 0xFF
  186. * seems to produce acceptable results.
  187. --------------------------------------------------------------*/
  188. typedef struct tr2_quad_s /* was tr2_face4 */
  189. {
  190. unsigned short vertices[4];
  191. unsigned short texture;
  192. } __attribute__ ((packed)) tr2_quad_t;
  193. typedef struct tr4_quad_s
  194. {
  195. unsigned short vertices[4]; // The 4 vertices of a quad
  196. unsigned short texture; // Object-texture index
  197. unsigned short lighting; // transparency flag & strength of
  198. // the hilight
  199. // Bit 0: if set, alpha channel = intensity (same meaning that when the Attribute field of tr2_object_texture is 2. Cf TRosetta stone document)
  200. // Bit 1-7: strength of the hilight. In TR4, objects can exhibit some kind of light reflection when seen from some particular angles. These bits give the strength of this effect: the more bigger the value is, the more visible is the effect.
  201. } __attribute__ ((packed)) tr4_quad_t;
  202. /*--------------------------------------------------------------
  203. * A triangular face definition.
  204. * Three vertices (the values are indices into the
  205. * appropriate vertex list) and a texture (an index into the
  206. * texture list) or colour (index into palette).
  207. *
  208. * In the case of a colour, (Texture & 0xff) is the index
  209. * into the 8-bit palette, while (Texture >> 8) is
  210. * the index into the 16-bit palette.
  211. --------------------------------------------------------------*/
  212. typedef struct tr2_tri_s /* was tr2_face3 */
  213. {
  214. unsigned short vertices[3];
  215. unsigned short texture;
  216. } __attribute__ ((packed)) tr2_tri_t;
  217. typedef struct tr4_tri_s
  218. {
  219. unsigned short vertices[3]; // The 3 vertices of a tri
  220. unsigned short texture; // Object-texture index
  221. unsigned short lighting; // transparency flag & strength of
  222. // the hilight
  223. } __attribute__ ((packed)) tr4_tri_t;
  224. /*--------------------------------------------------------------
  225. * An 8-bit texture tile (65536 bytes).
  226. *
  227. * Each byte represents a pixel whose colour
  228. * is in the 8-bit palette.
  229. --------------------------------------------------------------*/
  230. typedef struct tr2_textile8_s
  231. {
  232. unsigned char tile[256 * 256];
  233. } __attribute__ ((packed)) tr2_textile8_t;
  234. /*--------------------------------------------------------------
  235. * A 16-bit texture tile (131072 bytes).
  236. *
  237. * Each word represents a pixel
  238. * whose colour is of the form ARGB, MSB-to-LSB:
  239. *
  240. * 1-bit transparency (0: transparent, 1: opaque)
  241. * 5-bit red channel
  242. * 5-bit green channel
  243. * 5-bit blue channel
  244. --------------------------------------------------------------*/
  245. typedef struct tr2_textile16_s
  246. {
  247. unsigned short tile[256 * 256];
  248. } __attribute__ ((packed)) tr2_textile16_t;
  249. /* --------------------------------------------------------------
  250. * 32bit textiles
  251. * BGRA with 4bytes each channel
  252. --------------------------------------------------------------*/
  253. typedef struct tr2_textile32_s
  254. {
  255. unsigned int tile[256 * 256];
  256. } __attribute__ ((packed)) tr2_textile32_t;
  257. /*--------------------------------------------------------------
  258. * The "header" of a room.
  259. * + X/Z indicate the base position of the room
  260. * mesh in world coordinates.
  261. * + YLowest and yHighest indicate the lowest and
  262. * + Highest points in this room
  263. * (even though their actual values appear to
  264. * be reversed, since a "high" point will have a
  265. * smaller value than a "low" point).
  266. *
  267. * When positioning objects/items, as well as the room meshes
  268. * themselves, y is always 0-relative (not room-relative).
  269. --------------------------------------------------------------*/
  270. typedef struct tr2_room_info_s
  271. {
  272. int x; // X-offset of room (world coordinates)
  273. int z; // Z-offset of room (world coordinates)
  274. int y_bottom; // Y-offset of lowest point in room (world coordinates)
  275. // (actually highest value)
  276. int y_top; // Y-offset of highest point in room (world coordinates)
  277. // (actually lowest value)
  278. } __attribute__ ((packed)) tr2_room_info_t;
  279. /*--------------------------------------------------------------
  280. * Portal structure.
  281. * This defines every viable exit from a given "room".
  282. *
  283. * Note that "rooms" are really just areas. They aren't
  284. * necessarily enclosed. The door structure below defines
  285. * areas of egress, not the actual moveable mesh,
  286. * texture, and action (if any).
  287. --------------------------------------------------------------*/
  288. typedef struct tr2_room_portal_s
  289. {
  290. unsigned short adjoining_room; // Which room this "door" leads to
  291. tr2_vertex_t normal; // Which way the "door" faces
  292. tr2_vertex_t vertices[4]; // The corners of the "door"
  293. } __attribute__ ((packed)) tr2_room_portal_t;
  294. /*--------------------------------------------------------------
  295. * Room sector structure.
  296. *
  297. * Sectors are 1024 * 1024 (world coordinates). Floor and
  298. * Ceiling are signed number of 256 units of height
  299. * (relative to 0), e.g. Floor 0x04 corresponds to
  300. * Y = 1024 in world coordinates.
  301. *
  302. * Note: this implies that, while X and Z can be quite large,
  303. * Y is constrained to -32768..32512. Floor/Ceiling value of
  304. * 0x81 indicates impenetrable wall.
  305. *
  306. * Floor values are used by the game engine to determine what
  307. * objects Lara can traverse and how.
  308. *
  309. * Relative steps of 1 (-256) can be walked up;
  310. * steps of 2..7 (-512..-1792) can/must be climbed;
  311. * steps larger than 7 (-2048..-32768) cannot be climbed (too tall)
  312. *
  313. * In TR3, BoxIndex is more complicated. Only bits 4-14 are the
  314. * "real" index; bits 0-3 are most likely some kind of flag,
  315. * such as what kind of footstep sound to make (wood, metal, snow).
  316. * Furthermore, there is a special value of the "real" index,
  317. * 2047, or 0x7ff.
  318. *
  319. * RoomAbove and RoomBelow indicate what neighboring rooms are
  320. * in these directions; if RoomAbove is not "none", then the
  321. * ceiling is a collisional portal to that room, while if
  322. * RoomBelow is not "none", then the floor is a collisional
  323. * portal to that room.
  324. --------------------------------------------------------------*/
  325. typedef struct tr2_room_sector_s
  326. {
  327. unsigned short fd_index; // Index into FloorData[]
  328. unsigned short box_index; // Index into Boxes[]/Zones[] ( -1 if none )
  329. unsigned char room_below; // The number of the room below this one
  330. // ( -1 or 255 if none )
  331. char floor; // Absolute height of floor
  332. // ( Multiply by 256 for world coordinates )
  333. unsigned char room_above; // The number of the room above this one
  334. // ( -1 or 255 if none )
  335. char ceiling; // Absolute height of ceiling
  336. // ( Multiply by 256 for world coordinates )
  337. } __attribute__ ((packed)) tr2_room_sector_t;
  338. /*--------------------------------------------------------------
  339. * Room lighting structure.
  340. * X/Y/Z are in world coordinates.
  341. * Lighting values seem to range from 0..8192.
  342. --------------------------------------------------------------*/
  343. typedef struct tr2_room_light_s
  344. {
  345. int x;
  346. int y;
  347. int z;
  348. unsigned short intensity1;
  349. unsigned short intensity2;
  350. unsigned int fade1;
  351. unsigned int fade2;
  352. } __attribute__ ((packed)) tr2_room_light_t;
  353. typedef struct tr4_room_light_s
  354. {
  355. int xPosition; // world coords
  356. int yPosition; // world coords
  357. int zPosition; // world coords
  358. tr2_colour_t color; // three bytes rgb values
  359. unsigned char lightType; // same as D3D (i.e. 2 is for spotlight)
  360. unsigned char unknown; // always 0xff?
  361. unsigned char intensity;
  362. float in;
  363. float out;
  364. float length;
  365. float cutoff;
  366. float xDir, yDir, zDir; // direction?
  367. } __attribute__ ((packed)) tr4_room_light_t;
  368. /*--------------------------------------------------------------
  369. * Room vertex structure.
  370. * This defines the vertices within a room.
  371. --------------------------------------------------------------*/
  372. typedef struct tr2_vertex_room_s
  373. {
  374. tr2_vertex_t vertex;
  375. // Following 3 entries
  376. short lighting1; // Values range from 0 to 32767,
  377. // 0 = total darkness. (TR3)
  378. // I think the values ranged from
  379. // 0 to 8192 in TR1/2, 0=total brightness
  380. unsigned short attributes; // 0x8000 Something to do with water surface
  381. // 0x4000 Under water lighting modulation
  382. // and movement if viewed from
  383. // above water surface
  384. // 0x2000 Water/quicksand surface movement
  385. // 0x1fef Nothing?
  386. // 0x0010 Everything?
  387. short lighting2; // Seems to be the same as lighting1
  388. } __attribute__ ((packed)) tr2_vertex_room_t;
  389. /*--------------------------------------------------------------
  390. * Sprite structure
  391. --------------------------------------------------------------*/
  392. typedef struct tr2_room_sprite_s
  393. {
  394. short vertex; // offset into vertex list
  395. short texture; // offset into texture list
  396. } __attribute__ ((packed)) tr2_room_sprite_t;
  397. /*--------------------------------------------------------------
  398. * Room mesh structure.
  399. * This is the geometry of the "room," including
  400. * walls, floors, rocks, water, etc. It does _not_ include
  401. * objects that Lara can interact with (keyboxes,
  402. * moveable blocks, moveable doors, etc.)
  403. --------------------------------------------------------------*/
  404. typedef struct tr2_room_data_s
  405. {
  406. short num_vertices; // number of vertices in the following list
  407. tr2_vertex_room_t *vertices; // list of vertices (relative coordinates)
  408. short num_rectangles; // number of textured rectangles
  409. tr2_quad_t *rectangles; // list of textured rectangles
  410. short num_triangles; // number of textured triangles
  411. tr2_tri_t *triangles; // list of textured triangles
  412. short num_sprites; // number of sprites
  413. tr2_room_sprite_t *sprites; // list of sprites
  414. } __attribute__ ((packed)) tr2_room_data_t;
  415. /*--------------------------------------------------------------
  416. * Room static mesh data.
  417. * Positions and IDs of static meshes
  418. * (e.g. skeletons, spiderwebs, furniture)
  419. --------------------------------------------------------------*/
  420. typedef struct tr2_room_staticmesh_s
  421. {
  422. int x; // absolute position in world coordinates
  423. int y;
  424. int z;
  425. unsigned short rotation; // high two bits (0xc000)
  426. // indicate steps of 90 degrees
  427. unsigned short intensity1;
  428. unsigned short intensity2;
  429. unsigned short object_id; // which StaticMesh item to draw
  430. } __attribute__ ((packed)) tr2_room_staticmesh_t;
  431. /*--------------------------------------------------------------
  432. * Room structure.
  433. * Here's where all the room data come together.
  434. --------------------------------------------------------------*/
  435. typedef struct tr2_room_s
  436. {
  437. tr2_room_info_t info; // where the room exists, in world coordinates
  438. unsigned int num_data_words; // number of data words (bitu16)
  439. unsigned char *data; // the raw data from which the rest
  440. // of this is derived
  441. tr2_room_data_t room_data; // the room mesh
  442. unsigned short num_portals; // number of visibility portals
  443. // that leave this room
  444. tr2_room_portal_t *portals; // list of visibility portals
  445. unsigned short num_zsectors; // width of sector list
  446. unsigned short num_xsectors; // height of sector list
  447. tr2_room_sector_t *sector_list;// list of sectors in this room
  448. short intensity1;
  449. short intensity2;
  450. short light_mode;
  451. unsigned short num_lights; // number of lights in this room
  452. tr2_room_light_t *lights; // list of lights
  453. unsigned short num_static_meshes; // number of static meshes
  454. tr2_room_staticmesh_t *static_meshes; // static meshes
  455. short alternate_room;
  456. short flags; // 0x0001 - room is filled with water
  457. // 0x0020 - Lara's ponytail
  458. // gets blown by the wind
  459. tr2_colour_t room_light_colour; // TR3 ONLY!
  460. tr4_room_light_t *tr4Lights; // TR4 ONLY!
  461. } __attribute__ ((packed)) tr2_room_t;
  462. /*--------------------------------------------------------------
  463. * Animation structure.
  464. --------------------------------------------------------------*/
  465. typedef struct tr2_animation_s
  466. {
  467. unsigned int frame_offset; // byte offset into Frames[]
  468. // (divide by 2 for Frames[i])
  469. unsigned char frame_rate; // "ticks" per frame
  470. unsigned char frame_size; // number of words in Frames[]
  471. // used by this animation
  472. short state_id;
  473. short unknown1;
  474. short unknown2;
  475. short unknown3;
  476. short unknown4;
  477. unsigned short frame_start; // first frame in this animation
  478. unsigned short frame_end; // last frame in this animation
  479. // (numframes = (End - Start) + 1)
  480. unsigned short next_animation;
  481. unsigned short next_frame;
  482. unsigned short num_state_changes;
  483. unsigned short state_change_offset; // offset into StateChanges[]
  484. unsigned short num_anim_commands;
  485. unsigned short anim_command; // offset into AnimCommands[]
  486. } __attribute__ ((packed)) tr2_animation_t;
  487. // Data for an animation structure (40 bytes vice 32 in TR1/2/3)
  488. typedef struct tr4_animation_s
  489. {
  490. unsigned int frame_offset;// same meaning than in TR3
  491. unsigned char frame_rate;// same meaning than in TR3
  492. unsigned char frame_size;// same meaning than in TR3
  493. unsigned short state_id;// same meaning than in TR3
  494. short unknown;// same meaning than in TR3
  495. short speed;// same meaning than in TR3
  496. unsigned short accel_lo;// same meaning than in TR3
  497. short accel_hi;// same meaning than in TR3
  498. unsigned char unknown2[8];// new in TR4
  499. unsigned short frame_start;// same meaning than in TR3
  500. unsigned short frame_end;// same meaning than in TR3
  501. unsigned short next_animation;// same meaning than in TR3
  502. unsigned short next_frame;// same meaning than in TR3
  503. unsigned short num_state_changes;// same meaning than in TR3
  504. unsigned short state_change_offset;// same meaning than in TR3
  505. unsigned short num_anim_commands;// same meaning than in TR3
  506. unsigned short anim_command;// same meaning than in TR3
  507. } __attribute__ ((packed)) tr4_animation_t;
  508. /*--------------------------------------------------------------
  509. * State Change structure
  510. --------------------------------------------------------------*/
  511. typedef struct tr2_state_change_s
  512. {
  513. unsigned short state_id;
  514. unsigned short num_anim_dispatches; // number of dispatches
  515. // (seems to always be 1..5)
  516. unsigned short anim_dispatch; // Offset into AnimDispatches[]
  517. } __attribute__ ((packed)) tr2_state_change_t;
  518. /*--------------------------------------------------------------
  519. * Animation Dispatch structure
  520. --------------------------------------------------------------*/
  521. typedef struct tr2_anim_dispatch_s
  522. {
  523. short low;
  524. short high;
  525. short next_animation;
  526. short next_frame;
  527. } __attribute__ ((packed)) tr2_anim_dispatch_t;
  528. /*--------------------------------------------------------------
  529. * AnimCommand structure
  530. --------------------------------------------------------------*/
  531. typedef struct tr2_anim_command_s
  532. {
  533. short value;
  534. } __attribute__ ((packed)) tr2_anim_command_t;
  535. /*--------------------------------------------------------------
  536. * MeshTree structure
  537. *
  538. * MeshTree[] is actually groups of four ints. The first one is a
  539. * "flags" word; bit 1 (0x0002) indicates "make previous mesh an
  540. * anchor (e.g. PUSH)"; bit 0 (0x0001) indicates "return to previous
  541. * anchor (e.g. POP)".
  542. * The next three ints are X, Y, Z offsets from the last mesh position.
  543. --------------------------------------------------------------*/
  544. typedef struct tr2_meshtree_s
  545. {
  546. int flags; // 0x0001 = POP, 0x0002 = PUSH
  547. int x;
  548. int y;
  549. int z;
  550. } __attribute__ ((packed)) tr2_meshtree_t;
  551. /*--------------------------------------------------------------
  552. * Moveable structure. This defines a list of contiguous meshes that
  553. * comprise one object, e.g. in WALL.TR2,
  554. * moveable[0] = Lara (StartingMesh 0, NumMeshes 15),
  555. * moveable[13] = Tiger (StartingMesh 215, NumMeshes 27)
  556. * moveable[15] = Spikes (StartingMesh 249, NumMeshes 1)
  557. * moveable[16] = Boulder (StartingMesh 250, NumMeshes 1)
  558. * moveable[20] = Rolling Blade (StartingMesh 254, NumMeshes 1)
  559. --------------------------------------------------------------*/
  560. typedef struct tr2_moveable_s
  561. {
  562. unsigned int object_id; // Item Identifier
  563. unsigned short num_meshes; // number of meshes in this object
  564. unsigned short starting_mesh; // first mesh
  565. unsigned int mesh_tree; // offset into MeshTree[]
  566. unsigned int frame_offset; // byte offset into Frames[]
  567. // (divide by 2 for Frames[i])
  568. unsigned short animation; // offset into Animations[]
  569. } __attribute__ ((packed)) tr2_moveable_t;
  570. /*--------------------------------------------------------------
  571. * StaticMesh structure.
  572. *
  573. * This defines meshes that don't move (e.g. skeletons
  574. * lying on the floor, spiderwebs, etc.)
  575. --------------------------------------------------------------*/
  576. typedef struct tr2_staticmesh_s
  577. {
  578. unsigned int object_id; // Item Identifier
  579. unsigned short starting_mesh; // first mesh
  580. tr2_vertex_t bounding_box[2][2];
  581. unsigned short flags;
  582. } __attribute__ ((packed)) tr2_staticmesh_t;
  583. /*--------------------------------------------------------------
  584. * Object texture vertex structure.
  585. *
  586. * Maps coordinates into texture tiles.
  587. --------------------------------------------------------------*/
  588. typedef struct tr2_object_texture_vert_s
  589. {
  590. unsigned char xcoordinate;
  591. unsigned char xpixel;
  592. unsigned char ycoordinate;
  593. unsigned char ypixel;
  594. } __attribute__ ((packed)) tr2_object_texture_vert_t;
  595. /*--------------------------------------------------------------
  596. * Object texture structure.
  597. --------------------------------------------------------------*/
  598. typedef struct tr2_object_texture_s
  599. {
  600. unsigned short transparency_flags; // 0: Opaque
  601. // 1: Use transparency
  602. // 2: Use partial transparency
  603. // [grayscale intensity :: transparency]
  604. unsigned short tile; // index into textile list
  605. tr2_object_texture_vert_t vertices[4]; // the four corners of the texture
  606. } __attribute__ ((packed)) tr2_object_texture_t;
  607. /*--------------------------------------------------------------
  608. * Sprite texture structure.
  609. --------------------------------------------------------------*/
  610. typedef struct tr2_sprite_texture_s
  611. {
  612. unsigned short tile;
  613. unsigned char x;
  614. unsigned char y;
  615. unsigned short width; // actually, (width * 256) + 255
  616. unsigned short height; // actually, (height * 256) + 255
  617. short left_side;
  618. short top_side;
  619. short right_side;
  620. short bottom_side;
  621. } __attribute__ ((packed)) tr2_sprite_texture_t;
  622. /*--------------------------------------------------------------
  623. * Sprite Sequence structure
  624. --------------------------------------------------------------*/
  625. typedef struct tr2_sprite_sequence_s
  626. {
  627. int object_id; // Item identifier (same numbering as in tr2_moveable)
  628. short negative_length; // negative of "how many sprites are in this sequence"
  629. short offset; // where (in sprite texture list) this sequence starts
  630. } __attribute__ ((packed)) tr2_sprite_sequence_t;
  631. /*--------------------------------------------------------------
  632. * Mesh structure.
  633. *
  634. * The mesh list contains the mesh info for Lara (in all her
  635. * various incarnations), blocks, enemies (tigers, birds, bad guys),
  636. * moveable blocks, zip line handles, boulders, spinning blades,
  637. * you name it.
  638. *
  639. * If NumNormals is negative, Normals[] represent vertex
  640. * lighting values (one per vertex).
  641. --------------------------------------------------------------*/
  642. typedef struct tr2_mesh_s
  643. {
  644. tr2_vertex_t centre; // this seems to describe the
  645. // approximate geometric centre
  646. // of the mesh (possibly the centre of gravity?)
  647. // (relative coordinates, just like the vertices)
  648. int collision_size; // radius of collisional sphere
  649. short num_vertices; // number of vertices in this mesh
  650. tr2_vertex_t *vertices; // list of vertices (relative coordinates)
  651. short num_normals; // number of normals in this mesh
  652. // (should always equal NumVertices)
  653. tr2_vertex_t *normals; // list of normals (NULL if NumNormals < 0)
  654. short *mesh_lights; // if NumNormals < 0
  655. short num_textured_rectangles; // number of textured rectangles
  656. tr2_quad_t *textured_rectangles; // list of textured rectangles
  657. short num_textured_triangles; // number of textured triangles in this mesh
  658. tr2_tri_t *textured_triangles; // list of textured triangles
  659. short num_coloured_rectangles; // number of coloured rectangles
  660. tr2_quad_t *coloured_rectangles; // list of coloured rectangles
  661. short num_coloured_triangles; // number of coloured triangles in this mesh
  662. tr2_tri_t *coloured_triangles; // list of coloured triangles
  663. } __attribute__ ((packed)) tr2_mesh_t;
  664. /*--------------------------------------------------------------
  665. * Frame structure.
  666. *
  667. * Frames indicates how composite meshes are positioned and rotated.
  668. * They work in conjunction with Animations[] and Bone2[].
  669. *
  670. * A given frame has the following format:
  671. * short BB1x, BB1y, BB1z // bounding box (low)
  672. * short BB2x, BB2y, BB2z // bounding box (high)
  673. * short OffsetX, OffsetY, OffsetZ // starting offset for this moveable
  674. * (TR1 ONLY: short NumValues // number of angle sets to follow)
  675. * (TR2/3: NumValues is implicitly NumMeshes (from moveable))
  676. *
  677. * What follows next is a list of angle sets. In TR2/3, an angle set can
  678. * specify either one or three axes of rotation. If either of the high two
  679. * bits (0xc000) of the first angle unsigned short are set, it's one axis:
  680. * only one unsigned short,
  681. * low 10 bits (0x03ff),
  682. * scale is 0x100 == 90 degrees;
  683. * the high two bits are interpreted as follows:
  684. * 0x4000 == X only, 0x8000 == Y only,
  685. * 0xC000 == Z only.
  686. *
  687. * If neither of the high bits are set, it's a three-axis rotation. The next
  688. * 10 bits (0x3ff0) are the X rotation, the next 10 (including the following
  689. * unsigned short) (0x000f, 0xfc00) are the Y rotation,
  690. * the next 10 (0x03ff) are the Z rotation, same scale as
  691. * before (0x100 == 90 degrees).
  692. *
  693. * Rotations are performed in Y, X, Z order.
  694. * TR1 ONLY: All angle sets are two words and interpreted like the two-word
  695. * sets in TR2/3, EXCEPT that the word order is reversed.
  696. --------------------------------------------------------------*/
  697. typedef struct tr2_frame_s
  698. {
  699. tr2_vertex_t vector[3];
  700. int num_words;
  701. unsigned short *words;
  702. } __attribute__ ((packed)) tr2_frame_t;
  703. /*--------------------------------------------------------------
  704. * Item structure
  705. --------------------------------------------------------------*/
  706. typedef struct tr2_item_s
  707. {
  708. short object_id;
  709. short room;
  710. int x;
  711. int y;
  712. int z;
  713. short angle;
  714. short intensity1;
  715. short intensity2;
  716. short flags; // 0x0100 indicates "inactive" or "invisible"
  717. } __attribute__ ((packed)) tr2_item_t;
  718. /*--------------------------------------------------------------
  719. * SoundSource structure
  720. --------------------------------------------------------------*/
  721. typedef struct tr2_sound_source_s
  722. {
  723. int x; // position of sound source
  724. int y;
  725. int z;
  726. unsigned short sound_id; // internal sound index
  727. unsigned short flags; // 0x40, 0x80, or 0xc0
  728. } __attribute__ ((packed)) tr2_sound_source_t;
  729. /*--------------------------------------------------------------
  730. * Boxes structure
  731. --------------------------------------------------------------*/
  732. typedef struct tr2_boxes_s
  733. {
  734. unsigned char zmin; // sectors (* 1024 units)
  735. unsigned char zmax;
  736. unsigned char xmin;
  737. unsigned char xmax;
  738. short true_floor; // Y value (no scaling)
  739. short overlap_index; // index into Overlaps[]
  740. } __attribute__ ((packed)) tr2_box_t;
  741. /*--------------------------------------------------------------
  742. * AnimatedTexture structure
  743. * - really should be simple short[], since it's variable length
  744. --------------------------------------------------------------*/
  745. typedef struct tr2_animated_texture_s
  746. {
  747. short num_texture_ids; // Number of Texture IDs - 1
  748. short *texture_list; // list of textures to cycle through
  749. } __attribute__ ((packed)) tr2_animated_texture_t;
  750. /*--------------------------------------------------------------
  751. * Camera structure
  752. --------------------------------------------------------------*/
  753. typedef struct tr2_camera_s
  754. {
  755. int x;
  756. int y;
  757. int z;
  758. short room;
  759. unsigned short unknown1; // correlates to Boxes[]?
  760. } __attribute__ ((packed)) tr2_camera_t;
  761. // Data for a flyby camera (40 bytes)
  762. typedef struct tr4_extra_camera_s
  763. {
  764. int pos[6]; // Positions ? (x1,y1,z1,x2,y2,z2) roatations?
  765. unsigned char index[2]; // A pair of indices
  766. unsigned short unknown[5];// ??
  767. int id ;// Index of something
  768. } __attribute__ ((packed)) tr4_extra_camera_t;
  769. /*--------------------------------------------------------------
  770. * Sound sample structure
  771. --------------------------------------------------------------*/
  772. typedef struct tr2_sound_details_s
  773. {
  774. short sample;
  775. short volume;
  776. short sound_range;
  777. short flags; // bits 8-15: priority?, 2-7: number of sound samples
  778. // in this group, bits 0-1: channel number
  779. } __attribute__ ((packed)) tr2_sound_details_t;
  780. /*--------------------------------------------------------------
  781. * Cutscene Camera structure
  782. --------------------------------------------------------------*/
  783. typedef struct tr2_cinematic_frame_s
  784. {
  785. short roty; // Rotation about Y axis, +/-32767 ::= +/- 180 degrees
  786. short rotz; // Rotation about Z axis, +/-32767 ::= +/- 180 degrees
  787. short rotz2; // Rotation about Z axis (why two?),
  788. // +/-32767 ::= +/- 180 degrees
  789. short posz; // Z position of camera, relative to something
  790. short posy; // Y position of camera, relative to something
  791. short posx; // X position of camera, relative to something
  792. short unknown1;
  793. short rotx; // Rotation about X axis, +/-32767 ::= +/- 180 degrees
  794. } __attribute__ ((packed)) tr2_cinematic_frame_t;
  795. /*--------------------------------------------------------------
  796. * Used to read TR4 AI data
  797. * this field replaces the bitu16 NumCinematicFrames of TR1/2/3 levels
  798. * Data for a AI object (24 bytes)
  799. --------------------------------------------------------------*/
  800. typedef struct tr4_ai_object_s
  801. {
  802. unsigned short int object_id; // the objectID from the AI object
  803. // (AI_FOLLOW is 402)
  804. unsigned short int room;
  805. int x, y, a;
  806. unsigned short int ocb;
  807. unsigned short int flags; // The trigger flags
  808. // (button 1-5, first button has value 2)
  809. int angle; // rotation
  810. } __attribute__ ((packed)) tr4_ai_object_t;
  811. /*--------------------------------------------------------------
  812. * Used to read packed TR4 texels
  813. --------------------------------------------------------------*/
  814. typedef struct tr4_object_texture_s
  815. {
  816. unsigned short attribute; // same meaning than in TR3
  817. unsigned short tile; // same meaning than in TR3
  818. unsigned short flags;// new in TR4
  819. tr2_object_texture_vert_t vertices[4];// same meaning than in TR3
  820. unsigned int unknown1, unknown2; // new in TR4: x & y offset in something
  821. unsigned int xsize,ysize;// new in TR4: width-1 & height-1 of the object texture
  822. } __attribute__ ((packed)) tr4_object_texture_t;
  823. typedef struct tr5_room_layer_s // (56 bytes)
  824. {
  825. u_int32_t numLayerVertices; // number of vertices in this layer (4 bytes)
  826. u_int16_t unknownL1; // unknown (2 bytes)
  827. u_int16_t numLayerRectangles; // number of rectangles in this layer (2 bytes)
  828. u_int16_t numLayerTriangles; // number of triangles in this layer (2 bytes)
  829. u_int16_t unknownL2; // appears to be the number of 2 sided textures in this layer, however is sometimes 1 off (2 bytes)
  830. u_int16_t filler; // always 0 (2 bytes)
  831. u_int16_t filler2; // always 0 (2 bytes)
  832. // The following 6 floats (4 bytes each)
  833. // define the bounding box for the layer
  834. float layerBoundingBoxX1;
  835. float layerBoundingBoxY1;
  836. float layerBoundingBoxZ1;
  837. float layerBoundingBoxX2;
  838. float layerBoundingBoxY2;
  839. float layerBoundingBoxZ2;
  840. u_int32_t filler3; // always 0 (4 bytes)
  841. u_int32_t unknownL6; // unknown (4 bytes)
  842. u_int32_t unknownL7; // unknown (4 bytes)
  843. u_int32_t unknownL8; // unknown. Always the same throughout the level. (4 bytes)
  844. } tr5_room_layer_t;
  845. typedef struct tr5_face4_s // (12 bytes)
  846. {
  847. u_int16_t vertices[4]; // the values are the indices into the appropriate layer vertice list. (2 bytes each)
  848. u_int16_t texture; // the texture number for this face. Needs to be masked with 0xFFF as the high 4 bits are flags.(2 bytes)
  849. u_int16_t unknownF4; // unknown (2 bytes)
  850. } tr5_face4_t;
  851. typedef struct tr5_face3_s // (10 bytes)
  852. {
  853. u_int16_t vertices[3]; // the values are the indices into the appropriate layer vertice list (2 bytes each)
  854. u_int16_t texture; // the texture number for this face. Needs to be masked with 0xFFF as the high 4 bits are flags (2 bytes)
  855. u_int16_t unknownF3; // unknown (2 bytes)
  856. } tr5_face3_t;
  857. typedef struct tr5_vertex_s // (28 bytes)
  858. {
  859. float x; // x of vertex (4 bytes)
  860. float y; // y of vertex (4 bytes)
  861. float z; // z of vertex (4 bytes)
  862. float nx; // x of vertex normal (4 bytes)
  863. float ny; // y of vertex normal (4 bytes)
  864. float nz; // z of vertex normal (4 bytes)
  865. u_int32_t vColor; // vertex color ARGB format (4 bytes)
  866. } tr5_vertex_t;
  867. typedef struct tr5_room_geometry_s
  868. {
  869. // This is to help store and manage TR5 layer based polgons for rooms
  870. tr5_face4_t *quads;
  871. tr5_face3_t *tris;
  872. tr5_vertex_t *verts;
  873. } tr5_room_geometry_t;
  874. typedef struct tr5_light_s // (88 bytes)
  875. {
  876. /* Maybe wrong: The first three floats specify the position of the light
  877. in world coordinates
  878. The sun type light should not use these but seems to have a
  879. large x value (9 million, give or take)
  880. a zero y value, and a small z value (4 - 20) in the original TR5 levels
  881. */
  882. float x; // x position of light (4 bytes)
  883. float y; // y position of light (4 bytes)
  884. float z; // z position of light (4 bytes)
  885. // The next three specify the color of the light
  886. float red; // color of red spectrum (4 bytes)
  887. float green; // color of green spectrum (4 bytes)
  888. float blue; // color of blue spectrum (4 bytes)
  889. u_int32_t seperator; // not used 0xCDCDCDCD (4 bytes)
  890. /* At this point the following info diverges dependant
  891. on which type of light being used:
  892. 0 = sun, 1 = light, 2 = spot, 3 = shadow
  893. The sun type doesn't use the next two.
  894. For the spot type these are the hotspot and falloff angle cosines
  895. For the light and shadow types these are the TR units
  896. for the hotspot/falloff (1024=1sector)
  897. */
  898. float input; // cosine of the IN value for light / size of IN value (4 bytes)
  899. float output; // cosine of the OUT value for light / size of OUT value (4 bytes)
  900. // The next two are only used by the spot type light
  901. float radInput; // (IN radians) * 2 (4 bytes)
  902. float radOutput; // (OUT radians) * 2 (4 bytes)
  903. // The next is also only used by the spot type light
  904. float range; // Range of light (4 bytes)
  905. /* The final 3 floats are used only by the 'sun' and 'spot' type lights.
  906. They describe the directional vector of the light.
  907. This can be obtained by :
  908. if both x and y LightDirectionVectorX = cosX * sinY
  909. LightDirectionVectorY = sinX
  910. LightDirectionVectorZ = cosX * cosY
  911. */
  912. float directionVectorX; // light direction (4 bytes)
  913. float directionVectorY; // light direction (4 bytes)
  914. float directionVectorZ; // light direction (4 bytes)
  915. // The next six values repeat some of the previous information in long data types vice floats
  916. int32_t x2; // x position of light (4 bytes)
  917. int32_t y2; // y position of light (4 bytes)
  918. int32_t z2; // z position of light (4 bytes)
  919. // 16384 = 1.0 for the rotations ( 1/16384 )
  920. int32_t directionVectorX2; // light direction (4 bytes)
  921. int32_t directionVectorY2; // light direction (4 bytes)
  922. int32_t directionVectorZ2; // light direction (4 bytes)
  923. // The next char specifies the type of light as specified above
  924. u_int8_t lightType; // type of light. (1 byte)
  925. u_int8_t seperator2[3]; // 0xCDCDCD (3 bytes)
  926. } tr5_light_t;
  927. // [ FIRST NUMBER IS OFFSET IN BYTES FROM START OF ROOM STRUCTURE]
  928. typedef struct tr5_room_s
  929. {
  930. u_int32_t checkXELA; // "XELA" (4 bytes)
  931. u_int32_t roomDataSize; /* size of the following data ( use this vice
  932. 'walking thru' to get next room) (4 bytes) */
  933. u_int32_t seperator; // 0xCDCDCDCD (4 bytes)
  934. u_int32_t endSDOffset; /* usually this number + 216 will give you the
  935. offset from the start of the room data to the end
  936. of the Sector Data. HOWEVER have seen where this
  937. bitu32 is equal to -1 so it is better to use the
  938. following bitu32 and + 216 +
  939. ((NumXSectors * NumZSectors)*8) if you need
  940. to obtain this information. (4 bytes) */
  941. u_int32_t startSDOffset; /* this number + 216 will give you the offset from
  942. the start of the room to the start of the
  943. sector data. (4 bytes) */
  944. u_int32_t seperator2; // will either be 0x00000000 or 0xCDCDCDCD (4 bytes)
  945. u_int32_t endPortalOffset; /* this number + 216 will give you the offset
  946. from the start of the room to the end of the
  947. portal data. (4 bytes) */
  948. int32_t x; // X position of room ( world coordinates) (4 bytes)
  949. int32_t seperator3; // 0x00000000 (4 bytes)
  950. int32_t z; // Z position of room (world coordinates) (4 bytes)
  951. int32_t yBottom; // lowest point in room (4 bytes)
  952. int32_t yTop; // highest point in room (4 bytes)
  953. u_int16_t numZSectors; // sector table width (2 bytes)
  954. u_int16_t numXSectors; // sector table height (2 bytes)
  955. u_int32_t roomAmbientColor; // ARGB format (blue is least significant byte) (4 bytes)
  956. u_int16_t numRoomLights; // number of lights in this room (2 bytes)
  957. u_int16_t numStaticMeshes; // number of static meshes in this room (2 bytes)
  958. u_int16_t unknownR1; // usually 0x0001 however high byte is sometimes non zero (2 bytes)
  959. u_int16_t unknownR2; // usually 0x0000 however low byte is sometimes non zero (2 bytes)
  960. u_int32_t filler; // always 0x00007FFF (4 bytes)
  961. u_int32_t filler2; // always 0x00007FFF (4 bytes)
  962. u_int32_t seperator4; // 0xCDCDCDCD (4 bytes)
  963. u_int32_t seperator5; // 0xCDCDCDCD (4 bytes)
  964. unsigned char seperator6[6]; // 6 bytes 0xFF
  965. u_int16_t roomFlag; // 0x01 = water, 0x20 = wind, others unknown (2 bytes)
  966. u_int16_t unknownR5; // unknown (2 bytes)
  967. unsigned char seperator7[10]; // 10 bytes 0x00
  968. u_int32_t seperator8; // 0xCDCDCDCD (4 bytes)
  969. u_int32_t unknownR6; // unknown (4 bytes)
  970. float roomX; // X position of room in world coordinates * If null room then this data will be 0xCDCDCDCD (4 bytes)
  971. u_int32_t seperator9; // 0x00000000 or 0xCDCDCDCD if null room. (4 bytes)
  972. float roomZ; // Z position of room in world coordinates * If null room then will be bitu32 0xCDCDCDCD (4 bytes)
  973. u_int32_t seperator10; // 0xCDCDCDCD (4 bytes)
  974. u_int32_t seperator11; // 0xCDCDCDCD (4 bytes)
  975. u_int32_t seperator12; // 0xCDCDCDCD (4 bytes)
  976. u_int32_t seperator13; // 0xCDCDCDCD (4 bytes)
  977. u_int32_t seperator14; // 0x00000000 unless null room then 0xCDCDCDCD (4 bytes)
  978. u_int32_t seperator15; // 0xCDCDCDCD (4 bytes)
  979. u_int32_t numRoomTriangles; // total number of triangles this room (4 bytes)
  980. u_int32_t numRoomRectangles; // total number of rectangles this room (4 bytes)
  981. u_int32_t seperator16; // 0x00000000 (4 bytes)
  982. u_int32_t lightSize; // size of light data (number of lights * 88) (4 bytes)
  983. u_int32_t numTotalRoomLights; // total number of lights this room (4 bytes)
  984. u_int32_t unknownR7; // unknown, usually equals 0, 1, 2, or 3 (4 bytes)
  985. int32_t unknownR8; // usually equals room yTop. Sometimes a few blocks off. If null room then 0xCDCDCDCD
  986. int32_t lyBottom; // equals room yBottom. If null room then 0xCDCDCDCD (4 bytes)
  987. u_int32_t numLayers; // number of layers (pieces) this room (4 bytes)
  988. u_int32_t layerOffset; // this number + 216 will give you an offset from the start of the room data to the start of the layer data (4 bytes)
  989. u_int32_t verticesOffset; // this number + 216 will give you an offset from the start of the room data to the start of the verex data (4 bytes)
  990. u_int32_t polyOffset; // this number + 216 will give you an offset from the start of the room data to the start of the rectangle/triangle data (4 bytes)
  991. u_int32_t polyOffset2; // same as above ? (4 bytes)
  992. u_int32_t verticesSize; // size of vertices data block (4 bytes)
  993. u_int32_t seperator17; // 0xCDCDCDCD (4 bytes)
  994. u_int32_t seperator18; // 0xCDCDCDCD (4 bytes)
  995. u_int32_t seperator19; // 0xCDCDCDCD (4 bytes)
  996. u_int32_t seperator20; // 0xCDCDCDCD (4 bytes)
  997. tr5_light_t *lights; //[LightSize]; // data for the lights (88 bytes * NumRoomLights)
  998. tr2_room_sector_t *sectors; //Data[(NumXSectors * NumZSectors) * 8]; // normal sector data structure
  999. u_int16_t numDoors; // number of portals (2 bytes)
  1000. tr2_room_portal_t *doors;//[NumDoors]; // normal portal structure (32 bytes * NumDoors)
  1001. u_int16_t seperator21; // 0xCDCD (2 bytes)
  1002. tr2_room_staticmesh_t *meshes; //[NumStaticMeshes]; // normal room static mesh structure (20 bytes * NumRoomStaticMeshes)
  1003. tr5_room_layer_t *layers; // [NumLayers]; // data for the room layers (pieces) (56 bytes * NumLayers)
  1004. tr5_room_geometry_t *faces; //[NumRoomRectangles + NumRoomTriangles];
  1005. /* Data for the room polys (face4 and face3).
  1006. Structured as first layers rectangles then triangles, followed by the
  1007. next layers rectangles and triangles, etc., until all layers are done.
  1008. (12 bytes each rectangle. 10 bytes each triangle) */
  1009. tr5_vertex_t *vertices; //[VerticesSize];
  1010. /* data for the room vertices. Structured as vertices for the first layer,
  1011. then vertices for the second layer, etc., until all layers are done.
  1012. (28 bytes each vertex. */
  1013. } tr5_room_t;
  1014. typedef struct tr5_object_texture_vertex_s // (4 bytes)
  1015. {
  1016. u_int8_t xCoordinate; // 0 if Xpixel is the low value, 255 if Xpixel is the high value in the object texture (1 byte)
  1017. u_int8_t xPixel; // (1 byte)
  1018. u_int8_t yCoordinate; // 0 if Ypixel is the low value, 255 if Ypixel is the high value in the object texture (1 byte)
  1019. u_int8_t yPixel; // (1 byte)
  1020. } tr5_object_texture_vertex_t;
  1021. typedef struct tr5_object_texture_s // (40 bytes)
  1022. {
  1023. u_int16_t attribute; //0, 1, or 2 (2 means 2 sided) (2 bytes)
  1024. u_int32_t tile; // need to mask with 0xFF as other bits are flags. ie int15_t seems to indicate triangle (4 bytes)
  1025. tr5_object_texture_vertex_t vertices[4]; // Vertices[4] (16 bytes)
  1026. u_int32_t uv1; // unknown how used (4 bytes)
  1027. u_int32_t uv2; // unknown how used (4 bytes)
  1028. u_int32_t xSize; // unknown how used, x size (4 bytes)
  1029. u_int32_t ySize; // unknown how used, y size (4 bytes)
  1030. u_int16_t seperator; // always 0x0000 (2 bytes)
  1031. } tr5_object_texture_t;
  1032. typedef struct tr5_flyby_camera_s // (40 bytes)
  1033. {
  1034. int32_t cameraX; // x position of camera in world coordinates (4 bytes)
  1035. int32_t cameraY; // y position of camera in world coordinates (4 bytes)
  1036. int32_t cameraZ; // z position of camera in world coordinates (4 bytes)
  1037. int32_t targetX; // x position of aiming point in world coords (4 bytes)
  1038. int32_t targetY; // y position of aiming point in world coords (4 bytes)
  1039. int32_t targetZ; // z position of aiming point in world coords (4 bytes)
  1040. int8_t sequence; // sequence # of camera (1 byte)
  1041. int8_t cameraNumber; // camera # (1 byte)
  1042. u_int16_t fov; // fov of camera ( .0054945 for each degree ) (2 bytes)
  1043. u_int16_t roll; // roll of camera ( .0054945 for each degree ) (2 bytes)
  1044. u_int16_t timer; // timer number (2 bytes)
  1045. u_int16_t speed; // ( .000015259 each ) (2 bytes)
  1046. u_int16_t flags; // ( see your handy TRLE manual for the specs ) (2 bytes)
  1047. u_int32_t room; // room number (4 bytes)
  1048. } tr5_flyby_camera_t;
  1049. typedef struct tr5_moveable_s // ( 20 bytes ) ( same as old structure but has u_int16_t filler at the end )
  1050. {
  1051. u_int32_t objectId; // object identifier ( matched in Items[] )
  1052. u_int16_t numMeshes; // number of meshes in this object
  1053. u_int16_t startingMesh; // starting mesh ( offset into MeshPointers[] )
  1054. u_int32_t meshTree; // offset into MeshTree[] )
  1055. u_int32_t frameOffset; // byte offset into Frames[] ( divide by 2 for Frames[i] )
  1056. u_int16_t animation; // offset into Animations[]
  1057. u_int16_t filler; // always equal to 65519 ( 0xFFEF )
  1058. } tr5_moveable_t;
  1059. typedef struct tr5_mesh_s
  1060. {
  1061. tr2_vertex_t center; // relative coordinates of mesh centre (6 bytes)
  1062. u_int8_t unknown1[4]; // unknown (4 bytes)
  1063. int16_t numVertices; // number of vertices to follow (2 bytes)
  1064. tr2_vertex_t *vertices; //[NumVertices]; // list of vertices (NumVertices * 6 bytes)
  1065. int16_t numNormals; // number of normals to follow (2 bytes)
  1066. tr2_vertex_t *normals; //[NumNormals]; // list of normals (NumNormals * 6 bytes) (becomes Lights if NumNormals < 0; 2 bytes)
  1067. int16_t numTexturedRectangles; // number of textured rectangles to follow (2 bytes)
  1068. tr5_face4_t *texturedRectangles; //[NumTexturedRectangles]; // list of textured rectangles (NumTexturedRectangles * 12 bytes)
  1069. int16_t numTexturedTriangles; // number of textured triangles to follow (2 bytes)
  1070. tr5_face3_t *texturedTriangles; //[NumTexturedTriangles]; // list of textured triangles (NumTexturedTriangles * 10 bytes)
  1071. } tr5_mesh_t;
  1072. typedef struct tr5_animation_s // ( 40 bytes ) ( same as old structure but has 8 bytes before FrameStart )
  1073. {
  1074. u_int32_t FrameOffset; // byte offset into Frames[] ( divide by 2 for Frames[i] )
  1075. u_int8_t FrameRate; // Engine ticks per frame
  1076. u_int8_t FrameSize; // number of int16_t's in Frames[] used by this animation
  1077. u_int16_t StateId; //
  1078. int16_t Unknown;
  1079. int16_t Speed; // Evengi Popov found this but I never seen what he said it was for
  1080. u_int16_t AccelLo; // same as above
  1081. int16_t AccelHi; // same as above
  1082. u_int8_t AUnknown[8]; // Unknown
  1083. u_int16_t FrameStart; // first frame in this animation
  1084. u_int16_t FrameEnd; // last frame in this animation ( numframes = ( End - Start) + 1 )
  1085. u_int16_t NextAnimation;
  1086. u_int16_t NextFrame;
  1087. u_int16_t NumStateChanges;
  1088. u_int16_t StateChangeOffset; // offset into StateChanges[]
  1089. u_int16_t NumAnimCommands; // how many of them to use
  1090. u_int16_t AnimCommand; // offset into AnimCommand[]
  1091. } tr5_animation_t;
  1092. typedef struct tr5_cinematic_frame_s
  1093. {
  1094. unsigned int unknown[24];
  1095. } tr5_cinematic_frame_t;
  1096. #ifdef WIN32
  1097. #pragma pack(pop, tr2_h, 1)
  1098. #endif
  1099. class TombRaider
  1100. {
  1101. public:
  1102. ////////////////////////////////////////////////////////////
  1103. // Constructors
  1104. ////////////////////////////////////////////////////////////
  1105. TombRaider();
  1106. /*------------------------------------------------------
  1107. * Pre :
  1108. * Post : Constructs an object of TombRaider
  1109. *
  1110. *-- History ------------------------------------------
  1111. *
  1112. * 2000.05.13:
  1113. * Mongoose - Created
  1114. ------------------------------------------------------*/
  1115. ~TombRaider();
  1116. /*------------------------------------------------------
  1117. * Pre : TombRaider object is allocated
  1118. * Post : Deconstructs an object of TombRaider
  1119. *
  1120. *-- History ------------------------------------------
  1121. *
  1122. * 2000.05.13:
  1123. * Mongoose - Created
  1124. ------------------------------------------------------*/
  1125. ////////////////////////////////////////////////////////////
  1126. // Wash me -- not part of cleaned API
  1127. ////////////////////////////////////////////////////////////
  1128. int NumRooms();
  1129. /*------------------------------------------------------
  1130. * Pre :
  1131. * Post :
  1132. *
  1133. *-- History ------------------------------------------
  1134. *
  1135. * 2000.05.13:
  1136. * Mongoose - Created
  1137. ------------------------------------------------------*/
  1138. int NumMoveables();
  1139. /*------------------------------------------------------
  1140. * Pre :
  1141. * Post :
  1142. *
  1143. *-- History ------------------------------------------
  1144. *
  1145. * 2000.05.13:
  1146. * Mongoose - Created
  1147. ------------------------------------------------------*/
  1148. int NumTextures();
  1149. /*------------------------------------------------------
  1150. * Pre :
  1151. * Post :
  1152. *
  1153. *-- History ------------------------------------------
  1154. *
  1155. * 2000.05.13:
  1156. * Mongoose - Created
  1157. ------------------------------------------------------*/
  1158. int NumSpecialTextures();
  1159. /*------------------------------------------------------
  1160. * Pre :
  1161. * Post : Returns number of "special" textures/images
  1162. *
  1163. *-- History ------------------------------------------
  1164. *
  1165. * 2001.06.19:
  1166. * Mongoose - Created
  1167. ------------------------------------------------------*/
  1168. int NumAnimations();
  1169. /*------------------------------------------------------
  1170. * Pre :
  1171. * Post :
  1172. *
  1173. *-- History ------------------------------------------
  1174. *
  1175. * 2000.05.13:
  1176. * Mongoose - Created
  1177. ------------------------------------------------------*/
  1178. unsigned int NumFrames();
  1179. /*------------------------------------------------------
  1180. * Pre :
  1181. * Post :
  1182. *
  1183. *-- History ------------------------------------------
  1184. *
  1185. * 2000.05.13:
  1186. * Mongoose - Created
  1187. ------------------------------------------------------*/
  1188. int NumStaticMeshes();
  1189. /*------------------------------------------------------
  1190. * Pre :
  1191. * Post :
  1192. *
  1193. *-- History ------------------------------------------
  1194. *
  1195. * 2000.05.13:
  1196. * Mongoose - Created
  1197. ------------------------------------------------------*/
  1198. int NumSprites();
  1199. /*------------------------------------------------------
  1200. * Pre :
  1201. * Post :
  1202. *
  1203. *-- History ------------------------------------------
  1204. *
  1205. * 2000.05.13:
  1206. * Mongoose - Created
  1207. ------------------------------------------------------*/
  1208. int NumSpriteSequences();
  1209. /*------------------------------------------------------
  1210. * Pre :
  1211. * Post :
  1212. *
  1213. *-- History ------------------------------------------
  1214. *
  1215. * 2001.06.06:
  1216. * Mongoose - Created
  1217. ------------------------------------------------------*/
  1218. int NumItems();
  1219. /*------------------------------------------------------
  1220. * Pre :
  1221. * Post :
  1222. *
  1223. *-- History ------------------------------------------
  1224. *
  1225. * 2001.06.06:
  1226. * Mongoose - Created
  1227. ------------------------------------------------------*/
  1228. tr2_version_type Engine();
  1229. /*------------------------------------------------------
  1230. * Pre :
  1231. * Post :
  1232. *
  1233. *-- History ------------------------------------------
  1234. *
  1235. * 2000.05.13:
  1236. * Mongoose - Created
  1237. ------------------------------------------------------*/
  1238. unsigned short *Frame();
  1239. /*------------------------------------------------------
  1240. * Pre :
  1241. * Post :
  1242. *
  1243. *-- History ------------------------------------------
  1244. *
  1245. * 2000.05.13:
  1246. * Mongoose - Created
  1247. ------------------------------------------------------*/
  1248. tr2_animation_t *Animation();
  1249. /*------------------------------------------------------
  1250. * Pre :
  1251. * Post :
  1252. *
  1253. *-- History ------------------------------------------
  1254. *
  1255. * 2000.05.13:
  1256. * Mongoose - Created
  1257. ------------------------------------------------------*/
  1258. tr2_item_t *Item();
  1259. /*------------------------------------------------------
  1260. * Pre :
  1261. * Post :
  1262. *
  1263. *-- History ------------------------------------------
  1264. *
  1265. * 2000.05.13:
  1266. * Mongoose - Created
  1267. ------------------------------------------------------*/
  1268. tr2_object_texture_t *ObjectTextures();
  1269. /*------------------------------------------------------
  1270. * Pre :
  1271. * Post :
  1272. *
  1273. *-- History ------------------------------------------
  1274. *
  1275. * 2000.05.13:
  1276. * Mongoose - Created
  1277. ------------------------------------------------------*/
  1278. unsigned int getNumBoxes();
  1279. /*------------------------------------------------------
  1280. * Pre :
  1281. * Post : returns number of boxes
  1282. *
  1283. *-- History ------------------------------------------
  1284. *
  1285. * 200?.??.??:
  1286. * Mongoose - Created
  1287. ------------------------------------------------------*/
  1288. tr2_box_t *Box();
  1289. /*------------------------------------------------------
  1290. * Pre :
  1291. * Post :
  1292. *
  1293. *-- History ------------------------------------------
  1294. *
  1295. * 2000.05.13:
  1296. * Mongoose - Created
  1297. ------------------------------------------------------*/
  1298. tr2_mesh_t *Mesh();
  1299. /*------------------------------------------------------
  1300. * Pre :
  1301. * Post :
  1302. *
  1303. *-- History ------------------------------------------
  1304. *
  1305. * 2000.05.13:
  1306. * Mongoose - Created
  1307. ------------------------------------------------------*/
  1308. int getNumAnimsForMoveable(int moveable_index);
  1309. /*------------------------------------------------------
  1310. * Pre : moveable_id is valid
  1311. * Post : Returns number of animations for a moveable
  1312. *
  1313. *-- History ------------------------------------------
  1314. *
  1315. * 2002.08.15:
  1316. * Mongoose - Using signed values now ( like it should have )
  1317. *
  1318. * 2002.04.04:
  1319. * Mongoose - Created, based on TRViewer algorithm
  1320. ------------------------------------------------------*/
  1321. tr2_staticmesh_t *StaticMesh();
  1322. /*------------------------------------------------------
  1323. * Pre :
  1324. * Post :
  1325. *
  1326. *-- History ------------------------------------------
  1327. *
  1328. * 2000.05.13:
  1329. * Mongoose - Created
  1330. ------------------------------------------------------*/
  1331. tr2_moveable_t *Moveable();
  1332. /*------------------------------------------------------
  1333. * Pre :
  1334. * Post :
  1335. *
  1336. *-- History ------------------------------------------
  1337. *
  1338. * 2000.05.13:
  1339. * Mongoose - Created
  1340. ------------------------------------------------------*/
  1341. tr2_meshtree_t *MeshTree();
  1342. /*------------------------------------------------------
  1343. * Pre :
  1344. * Post :
  1345. *
  1346. *-- History ------------------------------------------
  1347. *
  1348. * 2000.05.13:
  1349. * Mongoose - Created
  1350. ------------------------------------------------------*/
  1351. tr2_sprite_texture_t *Sprite();
  1352. /*------------------------------------------------------
  1353. * Pre :
  1354. * Post : Returns the sprite array
  1355. *
  1356. *-- History ------------------------------------------
  1357. *
  1358. * 2001.06.02:
  1359. * Mongoose - Created
  1360. ------------------------------------------------------*/
  1361. tr2_sprite_sequence_t *SpriteSequence();
  1362. /*------------------------------------------------------
  1363. * Pre :
  1364. * Post :
  1365. *
  1366. *-- History ------------------------------------------
  1367. *
  1368. * 2001.06.06:
  1369. * Mongoose - Created
  1370. ------------------------------------------------------*/
  1371. unsigned char *SpecialTexTile(int texture);
  1372. /*------------------------------------------------------
  1373. * Pre : texture is valid index into tex_special list
  1374. *
  1375. * Post : Makes a 32bit RGBA image from a stexture/bmap
  1376. * and returns it. Returns NULL on error.
  1377. *
  1378. *-- History ------------------------------------------
  1379. *
  1380. * 2001.06.19:
  1381. * Mongoose - Created
  1382. ------------------------------------------------------*/
  1383. void Texture(int texture, unsigned char **image, unsigned char **bumpmap);
  1384. /*------------------------------------------------------
  1385. * Pre : texture is valid textile index
  1386. * Post : Returns copies of texture and it's bumpmap
  1387. * if found, otherwise returns NULL
  1388. *
  1389. *-- History ------------------------------------------
  1390. *
  1391. * 2001.06.19:
  1392. * Mongoose - Created
  1393. ------------------------------------------------------*/
  1394. unsigned int *Palette16();
  1395. /*------------------------------------------------------
  1396. * Pre :
  1397. * Post :
  1398. *
  1399. *-- History ------------------------------------------
  1400. *
  1401. * 2000.05.13:
  1402. * Mongoose - Created
  1403. ------------------------------------------------------*/
  1404. unsigned char *Palette8();
  1405. /*------------------------------------------------------
  1406. * Pre :
  1407. * Post :
  1408. *
  1409. *-- History ------------------------------------------
  1410. *
  1411. * 2000.05.13:
  1412. * Mongoose - Created
  1413. ------------------------------------------------------*/
  1414. tr2_room_t *Room();
  1415. /*------------------------------------------------------
  1416. * Pre :
  1417. * Post :
  1418. *
  1419. *-- History ------------------------------------------
  1420. *
  1421. * 2000.05.13:
  1422. * Mongoose - Created
  1423. ------------------------------------------------------*/
  1424. int checkMime(char *filename);
  1425. /*------------------------------------------------------
  1426. * Pre :
  1427. * Post : Returns 0 if TombRaider pak file
  1428. *
  1429. *-- History ------------------------------------------
  1430. *
  1431. * 2003.07.05:
  1432. * Mongoose - Created
  1433. ------------------------------------------------------*/
  1434. int Load(char *filename, void (*percent)(int));
  1435. /*------------------------------------------------------
  1436. * Pre : filename is valid string and points
  1437. * to vaild TombRaider 1-5 pak
  1438. *
  1439. * Post : Loads TombRaider 1-5 pak into memory
  1440. * and does some processing
  1441. *
  1442. * Returns 0 on sucess, and less than 0 on error
  1443. *
  1444. * At 10% all textures are loaded
  1445. * the exact figure '10' will always be passed to
  1446. * allow for texture caching while meshes load
  1447. * for TR4
  1448. *
  1449. *-- History ------------------------------------------
  1450. *
  1451. * 2002.01.02:
  1452. * Mongoose - New callback for percent loaded feedback
  1453. *
  1454. * 2000.05.13:
  1455. * Mongoose - Created
  1456. ------------------------------------------------------*/
  1457. ////////////////////////////////////////////////////////////
  1458. // Public Accessors
  1459. ////////////////////////////////////////////////////////////
  1460. float adjustTexel(unsigned char texel, char offset);
  1461. /*------------------------------------------------------
  1462. * Pre : Passed the correct coor/pixel pair from
  1463. * object texture
  1464. *
  1465. * Post : Makes a clamped 0.0 to 1.0 texel from coord pair
  1466. *
  1467. *-- History ------------------------------------------
  1468. *
  1469. * 2001.06.21:
  1470. * Mongoose - Created
  1471. ------------------------------------------------------*/
  1472. void computeRotationAngles(unsigned short **frame,
  1473. unsigned int *frame_offset,
  1474. unsigned int *angle_offset,
  1475. float *x, float *y, float *z);
  1476. /*------------------------------------------------------
  1477. * Pre : Given moveable animation data
  1478. * Post : Returns computed angles in x,y,z pointers
  1479. *
  1480. *-- History ------------------------------------------
  1481. *
  1482. * 2002.04.05:
  1483. * Mongoose - Created
  1484. ------------------------------------------------------*/
  1485. void computeUV(tr2_object_texture_vert_t *st, float *u, float *v);
  1486. /*------------------------------------------------------
  1487. * Pre : Args are valid pointers
  1488. * Post : Returns computed UV in u and v
  1489. *
  1490. *-- History ------------------------------------------
  1491. *
  1492. * 2002.04.05:
  1493. * Mongoose - Created
  1494. ------------------------------------------------------*/
  1495. int getBumpMapCount();
  1496. /*------------------------------------------------------
  1497. * Pre :
  1498. * Post : Returns number of bump maps in loaded pak
  1499. *
  1500. *-- History ------------------------------------------
  1501. *
  1502. * 2002.12.24:
  1503. * Mongoose - Created
  1504. ------------------------------------------------------*/
  1505. void getColor(int index, float color[4]);
  1506. /*------------------------------------------------------
  1507. * Pre :
  1508. * Post :
  1509. *
  1510. *-- History ------------------------------------------
  1511. *
  1512. * 2000.05.30:
  1513. * Mongoose - Created
  1514. ------------------------------------------------------*/
  1515. tr2_version_type getEngine();
  1516. /*------------------------------------------------------
  1517. * Pre :
  1518. * Post :
  1519. *
  1520. *-- History ------------------------------------------
  1521. *
  1522. * 2003.05.24:
  1523. * Mongoose - Obsoloetes Engine() method, name change
  1524. *
  1525. * 2000.05.13:
  1526. * Mongoose - Created
  1527. ------------------------------------------------------*/
  1528. void getMeshCollisionInfo(unsigned int meshIndex,
  1529. float center[3], float *radius);
  1530. /*------------------------------------------------------
  1531. * Pre : float Center[3], float radius allocated
  1532. *
  1533. * Post : Returns Center and radius of collision sphere
  1534. * for mesh[index]
  1535. *
  1536. *-- History ------------------------------------------
  1537. *
  1538. * 2003.05.16:
  1539. * Mongoose - Created
  1540. ------------------------------------------------------*/
  1541. int getMeshCount();
  1542. /*------------------------------------------------------
  1543. * Pre :
  1544. * Post : Returns SIGNED mesh count ( TR encoded < 0 errs )
  1545. *
  1546. *-- History ------------------------------------------
  1547. *
  1548. * 2000.05.13:
  1549. * Mongoose - Created
  1550. ------------------------------------------------------*/
  1551. void getMeshColoredRectangle(unsigned int meshIndex,
  1552. unsigned int faceIndex,
  1553. int index[6], float color[4]);
  1554. /*------------------------------------------------------
  1555. * Pre : This method interface may change later
  1556. *
  1557. * Pass allocated index[6], color[4] ( RGBA )
  1558. *
  1559. * Post : This method is made to let you fill arrays or
  1560. * create single faces, their may be an allocating
  1561. * version that passes back arrays later
  1562. *
  1563. * Returns Quads/Rects as 2 triangles, because
  1564. * returning quads would be too trival =)
  1565. *
  1566. *-- History ------------------------------------------
  1567. *
  1568. * 2000.05.16:
  1569. * Mongoose - Created, based on method from OpenRaider
  1570. ------------------------------------------------------*/
  1571. void getMeshColoredTriangle(unsigned int meshIndex,
  1572. unsigned int faceIndex,
  1573. int index[3], float color[4]);
  1574. /*------------------------------------------------------
  1575. * Pre : This method interface may change later
  1576. *
  1577. * Pass allocated index[3], color[4] ( RGBA )
  1578. *
  1579. * Post : This method is made to let you fill arrays or
  1580. * create single faces, their may be an allocating
  1581. * version that passes back arrays later
  1582. *
  1583. *-- History ------------------------------------------
  1584. *
  1585. * 2000.05.16:
  1586. * Mongoose - Created, based on method from OpenRaider
  1587. ------------------------------------------------------*/
  1588. void getMeshTexturedRectangle(unsigned int meshIndex,
  1589. unsigned int faceIndex,
  1590. int index[6], float st[12], int *texture,
  1591. unsigned short *transparency);
  1592. /*------------------------------------------------------
  1593. * Pre : This method interface may change later
  1594. *
  1595. * Pass allocated index[6], st[12], texture,
  1596. * and transparency
  1597. *
  1598. * Post : This method is made to let you fill arrays or
  1599. * create single faces, their may be an allocating
  1600. * version that passes back arrays later
  1601. *
  1602. * Returns Quads/Rects as 2 triangles, because
  1603. * returning quads would be too trival =)
  1604. *
  1605. *-- History ------------------------------------------
  1606. *
  1607. * 2000.05.16:
  1608. * Mongoose - Created, based on method from OpenRaider
  1609. ------------------------------------------------------*/
  1610. void getMeshTexturedTriangle(unsigned int meshIndex,
  1611. unsigned int faceIndex,
  1612. int index[3], float st[6], int *texture,
  1613. unsigned short *transparency);
  1614. /*------------------------------------------------------
  1615. * Pre : This method interface may change later
  1616. *
  1617. * Pass allocated index[3], st[6], texture,
  1618. * and transparency
  1619. *
  1620. * Post : This method is made to let you fill arrays or
  1621. * create single faces, their may be an allocating
  1622. * version that passes back arrays later
  1623. *
  1624. *-- History ------------------------------------------
  1625. *
  1626. * 2000.05.16:
  1627. * Mongoose - Created, based on method from OpenRaider
  1628. ------------------------------------------------------*/
  1629. int getMeshTexturedTriangleCount(unsigned int meshIndex);
  1630. int getMeshColoredTriangleCount(unsigned int meshIndex);
  1631. int getMeshTexturedRectangleCount(unsigned int meshIndex);
  1632. int getMeshColoredRectangleCount(unsigned int meshIndex);
  1633. /*------------------------------------------------------
  1634. * Pre : This method interface may change later
  1635. * Post : Get face counts for a given mesh
  1636. *
  1637. *-- History ------------------------------------------
  1638. *
  1639. * 2003.05.16:
  1640. * Mongoose - Created
  1641. ------------------------------------------------------*/
  1642. void getMeshVertexArrays(unsigned int meshIndex,
  1643. unsigned int *vertexCount, float **verts,
  1644. unsigned int *normalCount, float **norms,
  1645. unsigned int *colorCount, float **colors);
  1646. /*------------------------------------------------------
  1647. * Pre : Given mesh index
  1648. *
  1649. * Post : Returns allocated vertex, normal, and color arrays,
  1650. * and their element counts,
  1651. *
  1652. * Colors has been changed to be an intesity for now
  1653. *
  1654. * verts - XYX, norms - IJK, colors - I
  1655. *
  1656. *-- History ------------------------------------------
  1657. *
  1658. * 2003.05.13:
  1659. * Mongoose - Created, based on method from OpenRaider
  1660. ------------------------------------------------------*/
  1661. int getRoomBox(unsigned int roomIndex, unsigned int index,
  1662. float *xyzA, float *xyzB, float *xyzC, float *xyzD);
  1663. /*------------------------------------------------------
  1664. * Pre :
  1665. * Post : Returns a single collision box from room ( unified )
  1666. *
  1667. *-- History ------------------------------------------
  1668. *
  1669. * 2003.05.24:
  1670. * Mongoose - Created
  1671. ------------------------------------------------------*/
  1672. unsigned int getRoomBoxCount(unsigned int roomIndex);
  1673. /*------------------------------------------------------
  1674. * Pre :
  1675. * Post : Returns number of collision boxes in room ( unified )
  1676. *
  1677. *-- History ------------------------------------------
  1678. *
  1679. * 2003.05.24:
  1680. * Mongoose - Created
  1681. ------------------------------------------------------*/
  1682. void getRoomInfo(unsigned int index,
  1683. unsigned int *flags, float pos[3],
  1684. float bboxMin[3], float bboxMax[3]);
  1685. /*------------------------------------------------------
  1686. * Pre :
  1687. * Post :
  1688. *
  1689. *-- History ------------------------------------------
  1690. *
  1691. * 2003.05.24:
  1692. * Mongoose - Created
  1693. ------------------------------------------------------*/
  1694. int getRoomLight(unsigned int roomIndex, unsigned int index,
  1695. float pos[4], float color[4], float dir[3],
  1696. float *attenuation, float *cutoffAngle,
  1697. unsigned int *type, unsigned int *flags);
  1698. /*------------------------------------------------------
  1699. * Pre : All parms are allocated
  1700. * Post : Returns a single light from a room ( unified )
  1701. *
  1702. *-- History ------------------------------------------
  1703. *
  1704. * 2003.05.19:
  1705. * Mongoose - Created
  1706. ------------------------------------------------------*/
  1707. unsigned int getRoomLightCount(unsigned int roomIndex);
  1708. /*------------------------------------------------------
  1709. * Pre :
  1710. * Post : Returns number of lights in room ( unified )
  1711. *
  1712. *-- History ------------------------------------------
  1713. *
  1714. * 2003.05.24:
  1715. * Mongoose - Created
  1716. ------------------------------------------------------*/
  1717. int getRoomModel(unsigned int roomIndex, unsigned int index,
  1718. int *modelIndex, float pos[3], float *yaw);
  1719. /*------------------------------------------------------
  1720. * Pre : All parms are allocated
  1721. * Post : Returns a single model info from a room ( unified )
  1722. *
  1723. *-- History ------------------------------------------
  1724. *
  1725. * 2003.05.19:
  1726. * Mongoose - Created
  1727. ------------------------------------------------------*/
  1728. unsigned int getRoomModelCount(unsigned int roomIndex);
  1729. /*------------------------------------------------------
  1730. * Pre :
  1731. * Post : Returns number of room models in room ( unified )
  1732. *
  1733. *-- History ------------------------------------------
  1734. *
  1735. * 2003.05.24:
  1736. * Mongoose - Created
  1737. ------------------------------------------------------*/
  1738. int getRoomPortal(unsigned int roomIndex, unsigned int index,
  1739. int *adjoiningRoom, float normal[3], float vertices[12]);
  1740. /*------------------------------------------------------
  1741. * Pre :
  1742. * Post : Returns a single portal from room ( unified )
  1743. *
  1744. *-- History ------------------------------------------
  1745. *
  1746. * 2003.05.24:
  1747. * Mongoose - Created
  1748. ------------------------------------------------------*/
  1749. unsigned int getRoomPortalCount(unsigned int roomIndex);
  1750. /*------------------------------------------------------
  1751. * Pre :
  1752. * Post : Returns number of portals from room ( unified )
  1753. *
  1754. *-- History ------------------------------------------
  1755. *
  1756. * 2003.05.24:
  1757. * Mongoose - Created
  1758. ------------------------------------------------------*/
  1759. void getRoomRectangle(unsigned int roomIndex, unsigned int rectangleIndex,
  1760. unsigned int *indices, float *texCoords, int *texture,
  1761. unsigned int *flags);
  1762. /*------------------------------------------------------
  1763. * Pre :
  1764. * Post : Gets rectangle data with texCoords for non-matching
  1765. * vertex/uv for each vertex in TombRaider room ( unified )
  1766. *
  1767. *-- History ------------------------------------------
  1768. *
  1769. * 2003.05.24:
  1770. * Mongoose - Created
  1771. ------------------------------------------------------*/
  1772. unsigned int getRoomRectangleCount(unsigned int roomIndex);
  1773. /*------------------------------------------------------
  1774. * Pre :
  1775. * Post : Returns number of rectangles from room ( unified )
  1776. *
  1777. *-- History ------------------------------------------
  1778. *
  1779. * 2003.05.24:
  1780. * Mongoose - Created
  1781. ------------------------------------------------------*/
  1782. int getRoomSector(unsigned int roomIndex, unsigned int index,
  1783. unsigned int *flags, float *ceiling, float *floor,
  1784. int *floorDataIndex, int *boxIndex,
  1785. int *roomBelow, int *roomAbove);
  1786. /*------------------------------------------------------
  1787. * Pre :
  1788. * Post : Returns a single sector from room ( unified )
  1789. *
  1790. *-- History ------------------------------------------
  1791. *
  1792. * 2003.05.24:
  1793. * Mongoose - Created
  1794. ------------------------------------------------------*/
  1795. unsigned int getRoomSectorCount(unsigned int roomIndex,
  1796. unsigned int *zSectorsCount,
  1797. unsigned int *xSectorsCount);
  1798. /*------------------------------------------------------
  1799. * Pre :
  1800. * Post : Returns number of sectors in room ( unified )
  1801. * zSectorsCount - width of sector list
  1802. * xSectorsCount - height of sector list
  1803. *
  1804. *-- History ------------------------------------------
  1805. *
  1806. * 2003.05.24:
  1807. * Mongoose - Created
  1808. ------------------------------------------------------*/
  1809. void getRoomSprite(unsigned int roomIndex, unsigned int index,
  1810. float scale, int *texture,
  1811. float *pos, float *vertices, float *texcoords);
  1812. /*------------------------------------------------------
  1813. * Pre :
  1814. * Post :
  1815. *
  1816. *-- History ------------------------------------------
  1817. *
  1818. * 2003.05.19:
  1819. * Mongoose - Created
  1820. ------------------------------------------------------*/
  1821. unsigned int getRoomSpriteCount(unsigned int roomIndex);
  1822. /*------------------------------------------------------
  1823. * Pre :
  1824. * Post : Returns number of sprites in room ( unified )
  1825. *
  1826. *-- History ------------------------------------------
  1827. *
  1828. * 2003.05.24:
  1829. * Mongoose - Created
  1830. ------------------------------------------------------*/
  1831. void getRoomTriangle(unsigned int roomIndex, unsigned int triangleIndex,
  1832. unsigned int *indices, float *texCoords, int *texture,
  1833. unsigned int *flags);
  1834. /*------------------------------------------------------
  1835. * Pre :
  1836. * Post : Gets triangle data with texCoords for non-matching
  1837. * vertex/uv for each vertex in TombRaider room ( unified )
  1838. *
  1839. *-- History ------------------------------------------
  1840. *
  1841. * 2003.05.24:
  1842. * Mongoose - Created
  1843. ------------------------------------------------------*/
  1844. void getRoomTriangles(unsigned int index, int textureOffset,
  1845. unsigned int *count, unsigned int **indices,
  1846. float **texCoords, int **textures,
  1847. unsigned int **flags);
  1848. /*------------------------------------------------------
  1849. * Pre :
  1850. * Post : Gets triangle data with texCoords for non-matching
  1851. * vertex/uv for each vertex in TombRaider room
  1852. *
  1853. * This is used with room vertices, colors, etc
  1854. * to do partial array rendering, since the texcoords
  1855. * will never match vertices ( Tomb Raider is textile based )
  1856. *
  1857. *-- History ------------------------------------------
  1858. *
  1859. * 2003.05.24:
  1860. * Mongoose - Created
  1861. ------------------------------------------------------*/
  1862. void getRoomTriangles(unsigned int roomIndex, int textureOffset,
  1863. unsigned int *count,
  1864. unsigned int **indices, float **vertices,
  1865. float **texCoords, float **colors,
  1866. int **textures, unsigned int **flags);
  1867. /*------------------------------------------------------
  1868. * Pre :
  1869. * Post : Gets triangle data with duplicated
  1870. * vertex/color/normal data for each face vertex
  1871. * to match the textile based texcoords
  1872. *
  1873. * This uses more memory, but lets you do direct
  1874. * array rendering with OpenGL, D3D, etc
  1875. *
  1876. *-- History ------------------------------------------
  1877. *
  1878. * 2003.05.24:
  1879. * Mongoose - Created
  1880. ------------------------------------------------------*/
  1881. unsigned int getRoomTriangleCount(unsigned int roomIndex);
  1882. /*------------------------------------------------------
  1883. * Pre :
  1884. * Post : Returns number of triangles from room ( unified )
  1885. *
  1886. *-- History ------------------------------------------
  1887. *
  1888. * 2003.05.24:
  1889. * Mongoose - Created
  1890. ------------------------------------------------------*/
  1891. void getRoomVertex(unsigned int roomIndex, unsigned int vertexIndex,
  1892. float *xyz, float *rgba);
  1893. /*------------------------------------------------------
  1894. * Pre : Given room index and vertex index and
  1895. * xyz is allocated float[3]
  1896. * rbga is allocated float[4]
  1897. *
  1898. * Post : Returns vertex position xyz and color rbga
  1899. *
  1900. *-- History ------------------------------------------
  1901. *
  1902. * 2003.05.13:
  1903. * Mongoose - Created, based on method from OpenRaider
  1904. ------------------------------------------------------*/
  1905. void getRoomVertexArrays(unsigned int roomIndex,
  1906. unsigned int *vertexCount, float **vertices,
  1907. unsigned int *normalCount, float **normals,
  1908. unsigned int *colorCount, float **colors);
  1909. /*------------------------------------------------------
  1910. * Pre : Given room index
  1911. *
  1912. * Post : Returns allocated vertex and color arrays,
  1913. * and their element counts ( unified )
  1914. *
  1915. *-- History ------------------------------------------
  1916. *
  1917. * 2003.05.24:
  1918. * Mongoose - Unified API
  1919. *
  1920. * 2003.05.13:
  1921. * Mongoose - Created, based on method from OpenRaider
  1922. ------------------------------------------------------*/
  1923. unsigned int getRoomVertexCount(unsigned int roomIndex);
  1924. /*------------------------------------------------------
  1925. * Pre :
  1926. * Post : Returns number of lights in room ( unified )
  1927. *
  1928. *-- History ------------------------------------------
  1929. *
  1930. * 2003.05.24:
  1931. * Mongoose - Created
  1932. ------------------------------------------------------*/
  1933. int getSkyModelId();
  1934. /*------------------------------------------------------
  1935. * Pre :
  1936. * Post : Returns moveable id of sky mesh or -1 if none
  1937. *
  1938. *-- History ------------------------------------------
  1939. *
  1940. * 2001.05.28:
  1941. * Mongoose - Created
  1942. ------------------------------------------------------*/
  1943. void getSprites();
  1944. void getSoundSample(unsigned int index,
  1945. unsigned int *bytes, unsigned char **data);
  1946. /*------------------------------------------------------
  1947. * Pre :
  1948. * Post : Returns a copy of a sound sample and
  1949. * its byte size by it's sound sample index
  1950. *
  1951. *-- History ------------------------------------------
  1952. *
  1953. * 2003.05.10:
  1954. * Mongoose - Created
  1955. ------------------------------------------------------*/
  1956. unsigned int getSoundSamplesCount();
  1957. /*------------------------------------------------------
  1958. * Pre :
  1959. * Post : Returns number of sound samples loaded
  1960. *
  1961. *-- History ------------------------------------------
  1962. *
  1963. * 2003.05.10:
  1964. * Mongoose - Created
  1965. ------------------------------------------------------*/
  1966. bool isMeshValid(int index);
  1967. /*------------------------------------------------------
  1968. * Pre :
  1969. * Post : Returns true if mesh is valid
  1970. *
  1971. *-- History ------------------------------------------
  1972. *
  1973. * 2003.05.16:
  1974. * Mongoose - Created
  1975. ------------------------------------------------------*/
  1976. bool isRoomValid(int index);
  1977. /*------------------------------------------------------
  1978. * Pre :
  1979. * Post : Returns true if room is valid ( TRC support )
  1980. *
  1981. *-- History ------------------------------------------
  1982. *
  1983. * 2003.05.24:
  1984. * Mongoose - Created
  1985. ------------------------------------------------------*/
  1986. ////////////////////////////////////////////////////////////
  1987. // Public Mutators
  1988. ////////////////////////////////////////////////////////////
  1989. int loadSFX(char *filename);
  1990. /*------------------------------------------------------
  1991. * Pre :
  1992. * Post : Loads an external sound pak for TR2 and TR3
  1993. * games. Returns < 0 if error.
  1994. *
  1995. *-- History ------------------------------------------
  1996. *
  1997. * 2003.05.12:
  1998. * Mongoose - Created
  1999. ------------------------------------------------------*/
  2000. void reset();
  2001. /*------------------------------------------------------
  2002. * Pre :
  2003. * Post :
  2004. *
  2005. *-- History ------------------------------------------
  2006. *
  2007. * 2003.05.13:
  2008. * Mongoose - New API, was Clear()
  2009. *
  2010. * 2000.05.13:
  2011. * Mongoose - Created
  2012. ------------------------------------------------------*/
  2013. void setDebug(bool toggle);
  2014. /*------------------------------------------------------
  2015. * Pre :
  2016. * Post :
  2017. *
  2018. *-- History ------------------------------------------
  2019. *
  2020. * 2000.05.13:
  2021. * Mongoose - Created
  2022. ------------------------------------------------------*/
  2023. void setRoomVertexLightingFactor(float f);
  2024. /*------------------------------------------------------
  2025. * Pre :
  2026. * Post : Sets lighting factor for each vertex color per
  2027. * room in TR3 paks
  2028. *
  2029. *-- History ------------------------------------------
  2030. *
  2031. * 2003.05.13:
  2032. * Mongoose - Created
  2033. ------------------------------------------------------*/
  2034. void setTexelScalingFactor(float f);
  2035. /*------------------------------------------------------
  2036. * Pre :
  2037. * Post : Sets scaling for sprite texel alignment, etc
  2038. *
  2039. *-- History ------------------------------------------
  2040. *
  2041. * 2003.05.22:
  2042. * Mongoose - Created
  2043. ------------------------------------------------------*/
  2044. private:
  2045. ////////////////////////////////////////////////////////////
  2046. // Private Accessors
  2047. ////////////////////////////////////////////////////////////
  2048. void extractMeshes(unsigned char *mesh_data,
  2049. unsigned int num_mesh_pointers,
  2050. unsigned int *mesh_pointers);
  2051. /*------------------------------------------------------
  2052. * Pre :
  2053. * Post :
  2054. *
  2055. *-- History ------------------------------------------
  2056. *
  2057. * 2000.05.13:
  2058. * Mongoose - Created
  2059. ------------------------------------------------------*/
  2060. int Fread(void *buffer, size_t size, size_t count, FILE *f);
  2061. /*------------------------------------------------------
  2062. * Pre :
  2063. * Post :
  2064. *
  2065. *-- History ------------------------------------------
  2066. *
  2067. * 2000.05.13:
  2068. * Mongoose - Created
  2069. ------------------------------------------------------*/
  2070. void getRiffData(unsigned int *bytes, unsigned char **data);
  2071. /*------------------------------------------------------
  2072. * Pre :
  2073. * Post : Returns a copy of the sound samples and
  2074. * their size
  2075. *
  2076. *-- History ------------------------------------------
  2077. *
  2078. * 2003.05.10:
  2079. * Mongoose - Created
  2080. ------------------------------------------------------*/
  2081. void getRiffDataTR4(unsigned int index,
  2082. unsigned int *bytes, unsigned char **data);
  2083. /*------------------------------------------------------
  2084. * Pre :
  2085. * Post : Returns a copy of a TR4 sound sample
  2086. * and its size by it's sound sample index
  2087. *
  2088. *-- History ------------------------------------------
  2089. *
  2090. * 2003.05.10:
  2091. * Mongoose - Created
  2092. ------------------------------------------------------*/
  2093. int getRiffOffsets(unsigned char *riffData, unsigned int riffDataBytes,
  2094. unsigned int **offsets, unsigned int numOffsets);
  2095. /*------------------------------------------------------
  2096. * Pre :
  2097. * Post : Returns an array of offsets for a contigous
  2098. * RIFF data stream in chunks.
  2099. *
  2100. * Offsets will be allocated with enough space
  2101. * to hold expected number of offsets.
  2102. * ( Should be known number, otherwise not
  2103. * all RIFFs will be parsed. )
  2104. *
  2105. * Returns number of RIFFs found
  2106. *
  2107. *-- History ------------------------------------------
  2108. *
  2109. * 2003.05.12:
  2110. * Mongoose - Created
  2111. ------------------------------------------------------*/
  2112. unsigned char *getTexTile(int texture);
  2113. /*------------------------------------------------------
  2114. * Pre : texture is valid index into textile list
  2115. *
  2116. * Post : Makes a 32bit RGBA image from a textile
  2117. * and returns it. Returns NULL on error.
  2118. *
  2119. * This handles all selection and conversion
  2120. * including alpha layering flags now.
  2121. *
  2122. *-- History ------------------------------------------
  2123. *
  2124. * 2001.05.28:
  2125. * Mongoose - Created
  2126. ------------------------------------------------------*/
  2127. int loadTR5(FILE *f, void (*percent)(int));
  2128. /*------------------------------------------------------
  2129. * Pre : f is a valid FILE and percent is allocated
  2130. * Post : Loads a TR5 pak into memory
  2131. *
  2132. * At 10% all textures are loaded
  2133. * the exact figure '10' will always be passed to
  2134. * allow for texture caching while meshes load
  2135. *
  2136. *-- History ------------------------------------------
  2137. *
  2138. * 2002.01.02:
  2139. * Mongoose - New callback for percent loaded feedback
  2140. *
  2141. * 2001.06.18:
  2142. * Mongoose - Created
  2143. ------------------------------------------------------*/
  2144. void print(const char *methodName, const char *s, ...);
  2145. /*------------------------------------------------------
  2146. * Pre :
  2147. * Post :
  2148. *
  2149. *-- History ------------------------------------------
  2150. *
  2151. * 2003.05.13:
  2152. * Mongoose - New API clean up
  2153. *
  2154. * 2000.05.13:
  2155. * Mongoose - Created
  2156. ------------------------------------------------------*/
  2157. void printDebug(const char *methodName, const char *s, ...);
  2158. /*------------------------------------------------------
  2159. * Pre :
  2160. * Post :
  2161. *
  2162. *-- History ------------------------------------------
  2163. *
  2164. * 2003.05.13:
  2165. * Mongoose - New API clean up
  2166. *
  2167. * 2000.05.13:
  2168. * Mongoose - Created
  2169. ------------------------------------------------------*/
  2170. ////////////////////////////////////////////////////////////
  2171. // Private Mutators
  2172. ////////////////////////////////////////////////////////////
  2173. bool mReset; /* Guard multiple calls to reset() */
  2174. bool mDebug; /* Debug output toggle */
  2175. unsigned int mPakVersion; /* TombRaider pak file header version */
  2176. tr2_version_type mEngineVersion; /* TombRaider engine version */
  2177. tr2_colour_t _palette8[256]; /* 8-bit palette */
  2178. unsigned int _palette16[256]; /* 16-bit palette */
  2179. unsigned int _num_textiles; /* Total number of texture tiles */
  2180. unsigned short _num_room_textures; /* Num textures only for room use? */
  2181. unsigned short _num_misc_textures; /* Num of textures for misc use? */
  2182. unsigned short _num_bump_map_textures; /* Num of textures that are
  2183. bump map, texture pairs */
  2184. tr2_textile8_t *_textile8; /* 8-bit (palettised) textiles */
  2185. tr2_textile16_t *_textile16; /* 16-bit (ARGB) textiles */
  2186. tr2_textile32_t *_textile32; /* 32-bit (BGRA) textiles */
  2187. unsigned int _num_tex_special; /* Special textures and bump maps count */
  2188. unsigned char *_tex_special; /* Special textures and bump maps */
  2189. unsigned int _unknown_t; /* 32-bit unknown
  2190. (always 0 in real TR2 levels) */
  2191. unsigned short _num_rooms; /* Number of rooms in this level */
  2192. tr2_room_t *_rooms; /* List of rooms (TR1,TR2,TR3,TR4) */
  2193. tr5_room_t *mRoomsTR5; /* Rooms ( TR5 / TRC ) Only */
  2194. unsigned int _num_floor_data; /* Num of words of floor data
  2195. this level */
  2196. unsigned short *_floor_data; /* Floor data */
  2197. int mMeshCount; /* Number of meshes this level */
  2198. tr2_mesh_t *mMeshes; /* list of meshes */
  2199. unsigned int _num_animations; /* number of animations this level */
  2200. tr2_animation_t *_animations; /* list of animations */
  2201. unsigned int _num_state_changes; /* number of structures(?) this level */
  2202. tr2_state_change_t *_state_changes; /* list of structures */
  2203. unsigned int _num_anim_dispatches; /* number of ranges(?) this level */
  2204. tr2_anim_dispatch_t *_anim_dispatches; /* list of ranges */
  2205. unsigned int _num_anim_commands; /* number of Bone1s this level */
  2206. tr2_anim_command_t *_anim_commands; /* list of Bone1s */
  2207. unsigned int _num_mesh_trees; /* number of Bone2s this level */
  2208. tr2_meshtree_t *_mesh_trees; /* list of Bone2s */
  2209. unsigned int _num_frames; /* num of words of frame data this level */
  2210. unsigned short *_frames; /* frame data */
  2211. unsigned int _num_moveables; /* number of moveables this level */
  2212. tr2_moveable_t *_moveables; /* list of moveables */
  2213. u_int32_t numMoveablesTR5;
  2214. tr5_moveable_t *moveablesTR5;
  2215. u_int32_t numAnimationsTR5;
  2216. tr5_animation_t *animationsTR5;
  2217. u_int32_t numObjectTexturesTR5;
  2218. tr5_object_texture_t *objectTexturesTR5;
  2219. u_int32_t numCinematicFramesTR5;
  2220. tr5_cinematic_frame_t *cinematicFramesTR5;
  2221. u_int32_t numFlyByCamerasTR5;
  2222. tr5_flyby_camera_t *flyByCamerasTR5;
  2223. unsigned int _num_static_meshes; /* number of static meshes this level */
  2224. tr2_staticmesh_t *_static_meshes; /* static meshes */
  2225. unsigned int _num_object_textures; /* number of object textures this level */
  2226. tr2_object_texture_t *_object_textures; /* list of object textures */
  2227. unsigned int _num_sprite_textures; /* num of sprite textures this level */
  2228. tr2_sprite_texture_t *_sprite_textures; /* list of sprite textures */
  2229. unsigned int _num_sprite_sequences; /* num of sprite sequences this level */
  2230. tr2_sprite_sequence_t *_sprite_sequences; /* sprite sequence data */
  2231. int _num_cameras; /* Number of Cameras */
  2232. tr2_camera_t *_cameras; /* cameras */
  2233. int _num_sound_sources; /* Number of Sounds */
  2234. tr2_sound_source_t *_sound_sources; /* sounds */
  2235. int _num_boxes; /* Number of Boxes */
  2236. tr2_box_t *_boxes; /* boxes - looks like
  2237. struct { unsigned short value[4]; }
  2238. - value[0..2] might be a vector;
  2239. value[3] seems to be index into
  2240. Overlaps[] */
  2241. int _num_overlaps; /* Number of Overlaps */
  2242. short *_overlaps; /* Overlaps -
  2243. looks like ushort; 0x8000 is flag
  2244. of some sort appears to be an
  2245. offset into Boxes[] and/or
  2246. Boxes2[] */
  2247. short *_zones; /* Boxes2 */
  2248. int _num_animated_textures; /* Number of AnimTextures */
  2249. short *_animated_textures; /* Animtextures */
  2250. int _num_items; /* Number of Items */
  2251. tr2_item_t *_items; /* Items */
  2252. unsigned char *_light_map; /* Colour-light maps */
  2253. unsigned int _num_cinematic_frames; /* Number of cut-scene frames */
  2254. tr2_cinematic_frame_t *_cinematic_frames; /* Cut-scene frames */
  2255. short _num_demo_data; /* Number of Demo Data */
  2256. unsigned char *_demo_data; /* Demo data */
  2257. float mRoomVertexLightingFactor;
  2258. float mTexelScale;
  2259. // Sound data
  2260. short *mSoundMap; /* Sound map */
  2261. int mNumSoundDetails; /* Number of SampleModifiers */
  2262. tr2_sound_details_t *mSoundDetails; /* Sample modifiers */
  2263. int mNumSampleIndices; /* Number of Sample Indices */
  2264. int *mSampleIndices; /* Sample indices */
  2265. unsigned int *mSampleIndicesTR5;
  2266. bool mRiffAlternateLoaded; /* Is a TR2,TR3 SFX loaded? */
  2267. unsigned int *mRiffAlternateOffsets; /* After parsing this will
  2268. hold byte offsets for TR2,TR3
  2269. RIFFs in the buffered SFX */
  2270. int mRiffDataSz; /* Byte size of a loaded SFX */
  2271. unsigned char *mRiffData; /* SFX RIFF data in chunks */
  2272. unsigned int mNumTR4Samples;
  2273. unsigned char **mTR4Samples;
  2274. unsigned int *mTR4SamplesSz;
  2275. // For packed Fread emu/wrapper
  2276. unsigned char *mCompressedLevelData; /* Buffer used to emulate fread
  2277. with uncompressed libz data */
  2278. unsigned int mCompressedLevelDataOffset; /* Offset into buffer */
  2279. unsigned int mCompressedLevelSize; /* Size of buffer */
  2280. tr_fread_mode_t mFreadMode; /* Fread mode file|buffer */
  2281. };
  2282. #endif