Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
trs:room_geometry [2017/02/04 17:34]
stohrendorf ↷ Links adapted because of a move operation
trs:room_geometry [2017/06/04 19:11]
zdimension [TR5 Room Structure]
Line 157: Line 157:
 ''<​nowiki>​X/​Y/​Z</​nowiki>'' ​ are in world coordinates. ''<​nowiki>​Intensity1/​Intensity2</​nowiki>'' ​ are almost always equal. This lighting only affects //​externally-lit// ​ objects. Tomb Raider 1 has only the first of the paired ''<​nowiki>​Intensity</​nowiki>'' ​ and ''<​nowiki>​Fade</​nowiki>'' ​ values. ''<​nowiki>​X/​Y/​Z</​nowiki>'' ​ are in world coordinates. ''<​nowiki>​Intensity1/​Intensity2</​nowiki>'' ​ are almost always equal. This lighting only affects //​externally-lit// ​ objects. Tomb Raider 1 has only the first of the paired ''<​nowiki>​Intensity</​nowiki>'' ​ and ''<​nowiki>​Fade</​nowiki>'' ​ values.
  
-''<​nowiki>​Intensity1</​nowiki>'' ​ ranges from 0 (dark) to 0x1FFF (bright). However, some rooms occasionally have some lights with intensity greater than 0x1FFF (for example, look at room #9, 2nd light in ''<​nowiki>​level1.phd</​nowiki>''​). ''<​nowiki>​Fade1</​nowiki>'' ​ is the maximum distance the light shines on, and ranges from 0 to 0x7FFF.+''<​nowiki>​Intensity1</​nowiki>'' ​ ranges from ''​0'' ​(dark) to ''​0x1FFF'' ​(bright). However, some rooms occasionally have some lights with intensity greater than ''​0x1FFF'' ​(for example, look at room #9, 2nd light in ''<​nowiki>​level1.phd</​nowiki>''​). ''<​nowiki>​Fade1</​nowiki>'' ​ is the maximum distance the light shines on, and ranges from ''​0'' ​to ''​0x7FFF''​.
  
 === TR2 Room Lighting === === TR2 Room Lighting ===
Line 176: Line 176:
 </​code>​ </​code>​
  
-''<​nowiki>​Intensity2</​nowiki>'' ​ and ''<​nowiki>​Fade2</​nowiki>'' ​ values are seemingly not used. ''<​nowiki>​Intensity1</​nowiki>'' ​ can go very well beyond 0x1FFF, right to 0x7FFF (ultra bright light). Above 0x7FFF, it is always black, so the number is pseudo-signed (negative values are always treated as zero).+''<​nowiki>​Intensity2</​nowiki>'' ​ and ''<​nowiki>​Fade2</​nowiki>'' ​ values are seemingly not used. ''<​nowiki>​Intensity1</​nowiki>'' ​ can go very well beyond ​''​0x1FFF''​, right to ''​0x7FFF'' ​(ultra bright light). Above ''​0x7FFF''​, it is always black, so the number is pseudo-signed (negative values are always treated as zero).
  
 === TR3 Room Lighting === === TR3 Room Lighting ===
Line 192: Line 192:
 </​code>​ </​code>​
  
-''<​nowiki>​Intensity</​nowiki>'' ​ is the power of the light and ranges mainly from 0 (low power) to 0x1FFF (high power). Though, values greater than 0x1FFF do exist and their meanings are unknown. ''<​nowiki>​Fade</​nowiki>'' ​ is the distance max the light can shine on. Range is mainly from 0 to 0x7FFF, but negative values do exist and their meanings are unknown.+''<​nowiki>​Intensity</​nowiki>'' ​ is the power of the light and ranges mainly from ''​0'' ​(low power) to ''​0x1FFF'' ​(high power). Though, values greater than ''​0x1FFF'' ​do exist and their meanings are unknown. ''<​nowiki>​Fade</​nowiki>'' ​ is the distance max the light can shine on. Range is mainly from ''​0'' ​to ''​0x7FFF''​, but negative values do exist and their meanings are unknown.
  
 === TR4 Room Lighting === === TR4 Room Lighting ===
Line 276: Line 276:
 ''<​nowiki>​dx</​nowiki>'',​ ''<​nowiki>​dy</​nowiki>'' ​ and ''<​nowiki>​dz</​nowiki>'' ​ values are used only by the //​sun// ​ and //​spot// ​ type lights. They describe the directional vector of the light. This can be obtained by: ''<​nowiki>​dx</​nowiki>'',​ ''<​nowiki>​dy</​nowiki>'' ​ and ''<​nowiki>​dz</​nowiki>'' ​ values are used only by the //​sun// ​ and //​spot// ​ type lights. They describe the directional vector of the light. This can be obtained by:
  
-  * if both ''<​nowiki>​x</​nowiki>'' ​ and ''<​nowiki>​y</​nowiki>'' ​ $\text{LightDirectionVectorX} = \cos(X) ​\sin(Y)$+  * if both ''<​nowiki>​x</​nowiki>'' ​ and ''<​nowiki>​y</​nowiki>'' ​ $\text{LightDirectionVectorX} = \cos(X) ​\times ​\sin(Y)$
   * $\text{LightDirectionVectorY} = \sin(X)$   * $\text{LightDirectionVectorY} = \sin(X)$
-  * $\text{LightDirectionVectorZ} = \cos(X) ​\cos(Y)$+  * $\text{LightDirectionVectorZ} = \cos(X) ​\times ​\cos(Y)$
  
 ''<​nowiki>​x2</​nowiki>'',​ ''<​nowiki>​y2</​nowiki>'',​ ''<​nowiki>​z2</​nowiki>'',​ ''<​nowiki>​dx2</​nowiki>'',​ ''<​nowiki>​dy2</​nowiki>'' ​ and ''<​nowiki>​dz2</​nowiki>'' ​ values repeat previous corresponding information in long data types instead of floats. ''<​nowiki>​x2</​nowiki>'',​ ''<​nowiki>​y2</​nowiki>'',​ ''<​nowiki>​z2</​nowiki>'',​ ''<​nowiki>​dx2</​nowiki>'',​ ''<​nowiki>​dy2</​nowiki>'' ​ and ''<​nowiki>​dz2</​nowiki>'' ​ values repeat previous corresponding information in long data types instead of floats.
Line 434: Line 434:
 In ''<​nowiki>​Rotation</​nowiki>'' ​ field, high two bits (''<​nowiki>​0xC000</​nowiki>''​) indicate steps of 90 degrees (e.g. ''​%%(Rotation >> 14) * 90%%''​). However, when parsing this value, no extra bitshifting is needed, as you can simply interpret it using this formula: In ''<​nowiki>​Rotation</​nowiki>'' ​ field, high two bits (''<​nowiki>​0xC000</​nowiki>''​) indicate steps of 90 degrees (e.g. ''​%%(Rotation >> 14) * 90%%''​). However, when parsing this value, no extra bitshifting is needed, as you can simply interpret it using this formula:
  
-<code cpp> +$RealRotation ​= Rotation ​\div 16384 \times ​-90$
-float Real_Rotation ​(float)Rotation ​16384.0f * -90+
-</​code>​+
  
 === TR2 Room Static Mesh Structure === === TR2 Room Static Mesh Structure ===
Line 582: Line 580:
     tr_room_portal Portals[NumPortals]; ​ // List of visibility portals     tr_room_portal Portals[NumPortals]; ​ // List of visibility portals
  
-    uint16_t NumZsectors; ​                                 // ``Width'' ​of sector list +    uint16_t NumZsectors; ​                                 // "Width" ​of sector list 
-    ​uint16&#​95;​t ​NumXsectors; ​                                 // ``Height'' ​of sector list+    ​uint16_t ​NumXsectors; ​                                 // "Height" ​of sector list
     tr_room_sector SectorList[NumXsectors * NumZsectors]; ​ // List of sectors in this room     tr_room_sector SectorList[NumXsectors * NumZsectors]; ​ // List of sectors in this room
  
Line 689: Line 687:
 ''<​nowiki>​RoomColour</​nowiki>'' ​ replaces ''<​nowiki>​AmbientIntensity</​nowiki>'' ​ and ''<​nowiki>​AmbientIntensity2</​nowiki>'' ​ values from [[trs:​room_geometry#​tr2_room|[tr2_room]]] structure. Note it’s //not in [[trs:​fundamentals#​tr_colour4|[tr_colour4]]] format//, because colour order is reversed. It should be treated as ARGB, where A is unused. ''<​nowiki>​RoomColour</​nowiki>'' ​ replaces ''<​nowiki>​AmbientIntensity</​nowiki>'' ​ and ''<​nowiki>​AmbientIntensity2</​nowiki>'' ​ values from [[trs:​room_geometry#​tr2_room|[tr2_room]]] structure. Note it’s //not in [[trs:​fundamentals#​tr_colour4|[tr_colour4]]] format//, because colour order is reversed. It should be treated as ARGB, where A is unused.
  
-''<​nowiki>​AlternateGroup</​nowiki>'' ​ was introduced in TR4 to solve long-existing engine limitation, which flipped //all alternate rooms at once// ​ (see [[trs:​floordata#​trigfunc_0x03|//flipmap// trigger action]] description in [[trs:​floordata#​trigger_actions|Trigger actions]] section). Since TR4, engine only flips rooms which have similar index in room’s ''<​nowiki>​AlternateGroup</​nowiki>'' ​ field and trigger operand.+''<​nowiki>​AlternateGroup</​nowiki>'' ​ was introduced in TR4 to solve long-existing engine limitation, which flipped //all alternate rooms at once// ​ (see [[trs:​floordata#​trigfunc_0x03|flipmap trigger action]] description in [[trs:​floordata#​trigger_actions|Trigger actions]] section). Since TR4, engine only flips rooms which have similar index in room’s ''<​nowiki>​AlternateGroup</​nowiki>'' ​ field and trigger operand.
  
 ==== TR5 Room Structure ==== ==== TR5 Room Structure ====
Line 799: Line 797:
 ''<​nowiki>​RoomDataSize</​nowiki>'' ​ is a handy value determining the size of the following data. You can use this value to quickly //parse thru// ​ to the next room. ''<​nowiki>​RoomDataSize</​nowiki>'' ​ is a handy value determining the size of the following data. You can use this value to quickly //parse thru// ​ to the next room.
  
-''<​nowiki>​EndSDOffset</​nowiki>'':​ usually this number ''<​nowiki>​+216</​nowiki>'' ​ will give you the offset from the start of the room data to the end of the ''<​nowiki>​SectorData</​nowiki>'' ​ section. However, it is known that this uint32_t could be equal to ''<​nowiki>​0xFFFFFFFF</​nowiki>'',​ so to calculate the end of ''<​nowiki>​SectorData</​nowiki>'',​ it is better to use the following value ''<​nowiki>​StartSDOffset + 216 + ((NumXSectors ​NumZSectors)*8)</​nowiki>''​, if you need to obtain this information.+''<​nowiki>​EndSDOffset</​nowiki>'':​ usually this number ''<​nowiki>​+216</​nowiki>'' ​ will give you the offset from the start of the room data to the end of the ''<​nowiki>​SectorData</​nowiki>'' ​ section. However, it is known that this uint32_t could be equal to ''<​nowiki>​0xFFFFFFFF</​nowiki>'',​ so to calculate the end of ''<​nowiki>​SectorData</​nowiki>'',​ it is better to use the following value $StartSDOffset + 216 + ((NumXSectors ​\times ​NumZSectors) ​\times ​8)$, if you need to obtain this information.
  
 ''<​nowiki>​StartSDOffset</​nowiki>'':​ This number ''<​nowiki>​+216</​nowiki>'' ​ will give you the offset from the start of the room to the start of the ''<​nowiki>​SectorData</​nowiki>'' ​ section. ''<​nowiki>​StartSDOffset</​nowiki>'':​ This number ''<​nowiki>​+216</​nowiki>'' ​ will give you the offset from the start of the room to the start of the ''<​nowiki>​SectorData</​nowiki>'' ​ section.
trs/room_geometry.txt · Last modified: 2019/05/21 22:41 (external edit)
Back to top
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0