ModEnc is currently in Maintenance Mode: Changes could occur at any given moment, without advance warning.

Difference between revisions of "TMP"

From ModEnc
Jump to: navigation, search
(Expanded the article with known information.)
(Updates)
Line 7: Line 7:
 
==Tiles==
 
==Tiles==
  
Tiles are the diamond-shaped, single-[[cell]] pieces that make up a TMP file. Each tile is composed of two images: a normal image that covers the cell shape, plus an optional "extra" image perpendicular to the normal image. This extra image is essential for creating the illusion of a 3D-environment, as it allows for hiding terrain and objects behind it, thus creating a sense of depth, or the filling of space between tiles at different height levels.
+
Tiles are the diamond-shaped (within 48x24 pixels for TS and 60x30 pixels for RA2), single-[[cell]] pieces that make up a TMP file. Each tile is composed of a normal image that covers the cell shape, plus an optional "extra" image perpendicular to the normal image. This extra image is essential for creating the illusion of a 3D-environment, as it allows for hiding terrain and objects behind it, thus creating a sense of depth, or the filling of space between tiles at different height levels. Z-Data contain the information for layering the graphics.
  
 
In addition to graphics, each tile has several parameters that specify characteristics such as [[Height#In_Maps|height]], [[LandTypes|land type]] and slope type.
 
In addition to graphics, each tile has several parameters that specify characteristics such as [[Height#In_Maps|height]], [[LandTypes|land type]] and slope type.
Line 13: Line 13:
 
==File Format==
 
==File Format==
  
A TMP file consists of two parts, the file header and tile headers.
+
A TMP file consists of two header parts, the file header and tile headers.
  
 
  struct FileHeader
 
  struct FileHeader
Line 36: Line 36:
 
  unsigned int ExtraWidth;
 
  unsigned int ExtraWidth;
 
  unsigned int ExtraHeight;
 
  unsigned int ExtraHeight;
  unsigned char Bitfield; // three of the bits specify whether the tile has an extra image, Z data, and damaged art (applies only to bridges), respectively.
+
  unsigned char Bitfield;
 
  BYTE padding[3];
 
  BYTE padding[3];
 
  unsigned char Height;
 
  unsigned char Height;
 
  unsigned char LandType; // see [[LandTypes]]
 
  unsigned char LandType; // see [[LandTypes]]
 
  unsigned char SlopeType;
 
  unsigned char SlopeType;
  RGB LowRadarColor; // color to show on the radar for this tile at the lowest map [[Height#In_Maps|height]]
+
  RGB TopLeftRadarColor;
RGB HighRadarColor; // color to show on the radar for this tile at the highest map [[Height#In_Maps|height]]
+
RGB BottomRightRadarColor;
BYTE padding[3];
+
BYTE padding2[3];
}
+
};
 +
RGB
 +
{
 +
  unsigned char Red;
 +
  unsigned char Green;
 +
  unsigned char Blue;
 +
};
 +
 
 +
Bitfield - The 3 least significant bits out of the 8 bits are used as 0/1 flags for HasExtraData, HasZData and HasDamagedData respectively. Game checks these bits to process the extra-data or z-data or the damaged logic. If HasExtraData/HasZData bits are set to 0, game won't use its respective extra-data or z-data even if present. If the HasDamagedData bit is set to 0, game randomizes the tiles from its variants if present. Variants have filenames like clear01.tem, clear01a.tem, ... clear01g.tem. HasDamagedData bit is set to 1 for bridges, so that its tiles are not randomized. The remaining leading 5 bits out of the 8 bits are not used irrespective of the values present in those. For example, a byte value of 0xCB or 0x03 or 0x83 or 0x4B, all have the same result of binary xxxxx011 which means HasDamagedData bit is not set, HasZData bit is set and HasExtraData bit is set.
 +
 
 +
LandType/TerrainType{{fnl|2}} - Numbering used for land characteristics. 0, 1 or 13 is used for Clear. Ice uses 0 to 4. Tunnel is 5. Railroad is 6. Rock uses 7 or 8 (15 is also used as rock in cliff tiles). Water is 9. Beach is 10. Road uses 11 or 12. Rough is 14. Cliff is 15. Wall, Tiberium and Weeds don't have numbers but are processed based on its overlay placed on the cells.
 +
 
 +
Radar colors - The top-left radar color and bottom-right radar color being different, enhances the demarcation in the minimap where the adjacent tiles/terrain change in the map. These also give a sense of the light source being at top-left in the minimap.
 +
 
 +
Padding bytes are used as fillers, could have any value, typically assigned with 0xCD in original game tiles.
  
 
The graphics are encoded after the tile header.
 
The graphics are encoded after the tile header.
  
For more information on the file format, see [http://xhp.xwis.net/documents/TMP_TS_Format.html TMP documentation].
+
Older documentation reference, see [http://xhp.xwis.net/documents/TMP_TS_Format.html TMP documentation].
  
 
==TileSets==
 
==TileSets==
Line 55: Line 69:
  
 
A TileSet has a practical limit of 99 TMPs.
 
A TileSet has a practical limit of 99 TMPs.
 +
 +
Check [[IsoMapPack5]] to know how the tiles are stored in TS/RA2 maps.
  
 
==Footnotes==
 
==Footnotes==

Revision as of 11:28, 16 August 2019

TMP files are terrain files used in Tiberian Sun through Yuri's Revenge. They constitute the solid, mostly indestructible terrain upon which every other game object is layered. TMPs come in various shapes, each comprised of one or more tiles1. Furthermore, TMPs are divided into tilesets, which define certain attributes that each TMP in the set should have.

TMP files use the same theater-specific file extensions as TerrainTypes: .tem, .sno, etc.

The maximum tile size of a TMP file is 10x10 tiles.

Tiles

Tiles are the diamond-shaped (within 48x24 pixels for TS and 60x30 pixels for RA2), single-cell pieces that make up a TMP file. Each tile is composed of a normal image that covers the cell shape, plus an optional "extra" image perpendicular to the normal image. This extra image is essential for creating the illusion of a 3D-environment, as it allows for hiding terrain and objects behind it, thus creating a sense of depth, or the filling of space between tiles at different height levels. Z-Data contain the information for layering the graphics.

In addition to graphics, each tile has several parameters that specify characteristics such as height, land type and slope type.

File Format

A TMP file consists of two header parts, the file header and tile headers.

struct FileHeader
{
	unsigned int BlockWidth; // size in blocks
	unsigned int BlockHeight;
	unsigned int BlockImageWidth; // size of each block
	unsigned int BlockImageHeight;
};

Following the file header is an index of pointers to each tile header.

struct TileHeader
{
	signed int TileX; // tile offset
	signed int TileY;
	unsigned int ExtraDataOffset;
	unsigned int ZDataoffset;
	unsigned int ExtraZDataoffset;
	signed int ExtraX; // extra image offset
	signed int ExtraY;
	unsigned int ExtraWidth;
	unsigned int ExtraHeight;
	unsigned char Bitfield;
	BYTE padding[3];
	unsigned char Height;
	unsigned char LandType; // see LandTypes
	unsigned char SlopeType;
	RGB TopLeftRadarColor;
	RGB BottomRightRadarColor;
	BYTE padding2[3];
};
RGB 
{ 
 	unsigned char Red; 
 	unsigned char Green; 
 	unsigned char Blue; 
};

Bitfield - The 3 least significant bits out of the 8 bits are used as 0/1 flags for HasExtraData, HasZData and HasDamagedData respectively. Game checks these bits to process the extra-data or z-data or the damaged logic. If HasExtraData/HasZData bits are set to 0, game won't use its respective extra-data or z-data even if present. If the HasDamagedData bit is set to 0, game randomizes the tiles from its variants if present. Variants have filenames like clear01.tem, clear01a.tem, ... clear01g.tem. HasDamagedData bit is set to 1 for bridges, so that its tiles are not randomized. The remaining leading 5 bits out of the 8 bits are not used irrespective of the values present in those. For example, a byte value of 0xCB or 0x03 or 0x83 or 0x4B, all have the same result of binary xxxxx011 which means HasDamagedData bit is not set, HasZData bit is set and HasExtraData bit is set.

LandType/TerrainType2 - Numbering used for land characteristics. 0, 1 or 13 is used for Clear. Ice uses 0 to 4. Tunnel is 5. Railroad is 6. Rock uses 7 or 8 (15 is also used as rock in cliff tiles). Water is 9. Beach is 10. Road uses 11 or 12. Rough is 14. Cliff is 15. Wall, Tiberium and Weeds don't have numbers but are processed based on its overlay placed on the cells.

Radar colors - The top-left radar color and bottom-right radar color being different, enhances the demarcation in the minimap where the adjacent tiles/terrain change in the map. These also give a sense of the light source being at top-left in the minimap.

Padding bytes are used as fillers, could have any value, typically assigned with 0xCD in original game tiles.

The graphics are encoded after the tile header.

Older documentation reference, see TMP documentation.

TileSets

TileSets define certain characteristics to a group of TMP files, such as whether Tiberium/ore can grow on the tiles, or whether they can be deformed or burrowed through. Each TileSet has its own section in the theater control file.

A TileSet has a practical limit of 99 TMPs.

Check IsoMapPack5 to know how the tiles are stored in TS/RA2 maps.

Footnotes

1 Confusingly, both TMPs and the tiles that make up a TMP file are both referred to as "tiles" in different contexts.

2 Sometimes referred to as terrain type (not to be confused with TerrainTypes)