NAV (file format): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 111: Line 111:
</source>
</source>


===Approach Spot===
{{todo|Describe variables.}}
<source lang="cpp">
struct approachSpot_t {
uint approachHereId;
uint approachPrevId;
byte approachType;
uint approachNextId;
byte approachHow;
}
</source>
===Area-bind===
Area-binds are a structure type used in nav areas to determine the visibility between the parent area and another navigation area, based on area ID.
<source lang="cpp">struct nav_area_bind_t {
  unsigned int target_area_id; // Area ID of area.
  unsigned char AttributeBitField; // Attribute flag field that determines the visibility type.
};</source>
Area-binds were added in NAV version 16.
===Connection===
===Connection===
<source lang="cpp">
<source lang="cpp">
Line 118: Line 138:
};
};
</source>
</source>
===Hiding Spot===
===Hiding Spot===
Hiding spots are data structures used to determine points in a nav mesh that bots can hide at.
<source lang="cpp">
<source lang="cpp">
enum Attribute : unsigned char // Hiding Spot attribute values.
enum Attribute : unsigned char // Hiding Spot attribute values.
Line 130: Line 150:


struct hidingSpot_t {
struct hidingSpot_t {
unsigned int ID; // Identifier of hide spot.
unsigned int ID; // Identifier of hide spot. Added in NAV version 2.
float position[3]; // Position of the hiding spot.
float position[3]; // Position of the hiding spot. Added in NAV version 1.
Attribute Attributes; // Attributes
Attribute Attributes; // Attribute field. Added in NAV version 2.
};
};
</source>
</source>


{|
! Game !! Used For
|-
| {{game name|tf2|name=Team Fortress 2}} || Determines where Spy bots can lurk for targets.
|-
| {{game name|css|name=Counter-Strike: Source}} || Determines where bots can take cover and shoot at.
|-
| {{game name|csgo|name=Counter-Strike: Global Offensive}} || Determines where bots can take cover and shoot at.
|}
===Encounter Path===
===Encounter Path===
Encounter paths are structures used to determine routes to take to get to certain areas.
<source lang="cpp">
<source lang="cpp">
struct encounterPath_t {
struct encounterPath_t {
unsigned int EntryAreaID; // ID of the Area entered from.
unsigned int EntryAreaID; // ID of the Area entered from.
unsigned byte EntryDirection; // Direction of entry.
unsigned byte EntryDirection; // Direction of entry.
unsigned int DestAreaID; // Id of the Area destination.
unsigned int DestAreaID; // ID of the Area destination.
unsigned byte DestDirection; // Direction towards the destination area.
unsigned byte DestDirection; // Direction towards the destination area.


Line 148: Line 178:
};
};
</source>
</source>
{{important|Encounter paths are only used in {{game name|css|name=Counter-Strike: Source}} and {{game name|csgo|name=Counter-Strike: Global Offensive}}.}}
===Encounter Spot===
===Encounter Spot===
Encounter Spots (better termed waypoints) are data structures used in encounter paths to determine the order of area IDs in a route.
<source lang="cpp">
<source lang="cpp">
struct encounterSpot_t {
struct encounterSpot_t {
unsigned int OrderID; // Unknown.
unsigned int AreaID; // The Area ID to go to.
unsigned char ParametricDistance; // Parametric distance in bytes.
unsigned char ParametricDistance; // Parametric distance in bytes.
};
};
</source>
</source>
 
{{important|Encounter spots are only used in {{game name|css|name=Counter-Strike: Source}} and {{game name|csgo|name=Counter-Strike: Global Offensive}}.}}
===Approach Spot===
{{todo|Describe variables.}}
<source lang="cpp">
struct approachSpot_t {
uint approachHereId;
uint approachPrevId;
byte approachType;
uint approachNextId;
byte approachHow;
}
</source>
===Custom Data===
===Custom Data===
Some games store custom data in areas.
Some games store custom data in areas.

Revision as of 15:52, 17 November 2021

English (en)Translate (Translate)
Broom icon.png
This article or section needs to be updated to include current information regarding the subject because:
The information listed on the NAV file structure is too vague.
Remember to check for any notes left by the tagger at this article's talk page.
Nav Mesh
Not to be confused with AIN.

A NAV file is a map specific Navigation Mesh file that defines the walkable space in a level for bots in Source games. They usually reside in <game folder>/maps and can be integrated into BSPs in some Source games.[Clarify]

In Template:Game name and Template:Game name, the file is generated automatically when bots are played for the first time on a specific map.

Tip.pngTip:NAV creation is an open-source task available in the SDK.

File format

Todo: Add approach spot data.
Note.pngNote:This is reverse engineered data.

unsigned int magicNumber; // Magic number to check if the file is a .nav file
unsigned int version; // Version of the .nav file, for example GMod and TF2 has 16

if ( version >= 10 ) {
	unsigned int subVersion; // Sub version of the .nav file, for example GMod has 0, TF2 has 2. This is usedt
}

if ( version >= 4 ) {
	unsigned int saveBspSize; // Size of source bsp file to verify that the bsp hasn't changed
}

if ( version >= 14 ) {
	unsigned char isAnalyzed;
}

if ( version >= 5 ) {
	// Places data. This is the "Mid", "Banana", etc stuff that is used in this nav mesh
	unsigned short count;

	for( int i = 0; i < count; ++i ) {
		unsigned short len; // length of the name
		char name[len]; // The name. Maximum len is 256
	}

	if ( version > 11 ) {
		unsigned char m_hasUnnamedAreas;
	}
}

{
	// PreLoadAreas( count )
	// This is by default is completely unused, it is left for mods to store custom data
	// Assuming that the data is per nav area
	//for( int i = 0; i < count; ++i ) {

	//}
}

unsigned int areaCount; // number of CNavAreas
area_t area[areaCount]; // Area Data

if ( version >= 6 ) {
	unsigned int count; // number of CNavAreas

	for( i = 0; i < count; ++i ) {
		// Ladder data
	}
}

{
	// Load Custom Data
	// Again, by default this is unused
}

Area

Todo: Add visibility data.
struct area_t {
	unsigned int ID;
	union Attributes {
		unsigned char; // In NAV versions ≤ 8
		unsigned short; // In NAV versions < 13
		unsigned int;
	};
	float nwCorner[3]; // North-West corner vector.
	float seCorner[3]; // South-East corner vector.
	float NorthEastZ; // Z coordinate of North-East corner.
	float SouthWestZ; // Z coordinate of South-West corner.

	connectionData_t connectionData[4]; // Connection data in NESW (North, East, South, West) order.

	unsigned char hidingSpotCount; // Amount of hiding spots.
	hidingSpot_t hidingSpots[hidingSpotCount]; // Hiding spot data.

	/* Approach spots were removed in version 15.
	unsigned char approachSpotCount; // Amount of approach spots
	approachSpot_t approachSpotData[approachSpotCount]; // Approach spot data.
	*/

	unsigned int encounterPathCount; // Amount of encounter paths.
	encounterPath_t encounterPaths[encounterPathCount]; // Encounter path data.
	unsigned short PlaceID; // ID of place.
	// Ladder data stored in order of vertical direction (up then down).
	struct ladderData_t {
		unsigned int ladderCount; // Amount of ladder Ids.
		unsigned int ladderIDs[ladderCount]; // Ladder IDs
	} ladderData[2];
	float EarliestOccupyTimes[2]; // Earliest occupy times for teams.
	float LightIntensity[4]; // Light Intensities for each corner.

	// Insert visibility data.

	unsigned int InheritVisibilityFromAreaID; // Inherit visibility from area.

	void* customData; // Game-specific data.
}

Approach Spot

Todo: Describe variables.
struct approachSpot_t {
	uint approachHereId; 
	uint approachPrevId;
	byte approachType;
	uint approachNextId;
	byte approachHow;
}

Area-bind

Area-binds are a structure type used in nav areas to determine the visibility between the parent area and another navigation area, based on area ID.

struct nav_area_bind_t {
  unsigned int target_area_id; // Area ID of area.
  unsigned char AttributeBitField; // Attribute flag field that determines the visibility type.
};

Area-binds were added in NAV version 16.

Connection

struct connectionData_t {
	unsigned int count; // Amount of connections.
	unsigned int AreaIDs[count]; // List of area IDs that each connection points to.
};

Hiding Spot

Hiding spots are data structures used to determine points in a nav mesh that bots can hide at.

enum Attribute : unsigned char // Hiding Spot attribute values.
{
	IN_COVER = 0x01, // In a corner with good hard cover nearby
	GOOD_SNIPER_SPOT = 0x02, // Had at least one decent sniping corridor
	IDEAL_SNIPER_SPOT = 0x04, // Can see either very far, or a large area, or both
	EXPOSED	= 0x08 // Spot in the open, usually on a ledge or cliff
};

struct hidingSpot_t {
	unsigned int ID; // Identifier of hide spot. Added in NAV version 2.
	float position[3]; // Position of the hiding spot. Added in NAV version 1.
	Attribute Attributes; // Attribute field. Added in NAV version 2.
};
Game Used For
Template:Game name Determines where Spy bots can lurk for targets.
Template:Game name Determines where bots can take cover and shoot at.
Template:Game name Determines where bots can take cover and shoot at.

Encounter Path

Encounter paths are structures used to determine routes to take to get to certain areas.

struct encounterPath_t {
	unsigned int EntryAreaID; // ID of the Area entered from.
	unsigned byte EntryDirection; // Direction of entry.
	unsigned int DestAreaID; // ID of the Area destination.
	unsigned byte DestDirection; // Direction towards the destination area.

	unsigned char encounterSpotCount; // Amount of encounter spots.
	encounterSpot_t encounterSpots[encounterSpotCount]; // Encounter spots.
};
Icon-Important.pngImportant:Encounter paths are only used in Template:Game name and Template:Game name.

Encounter Spot

Encounter Spots (better termed waypoints) are data structures used in encounter paths to determine the order of area IDs in a route.

struct encounterSpot_t {
	unsigned int AreaID; // The Area ID to go to.
	unsigned char ParametricDistance; // Parametric distance in bytes.
};
Icon-Important.pngImportant:Encounter spots are only used in Template:Game name and Template:Game name.

Custom Data

Some games store custom data in areas.

Custom Area Data
Version (and subversion) Data Label
16 unsigned int TF2 specific attributes.

Versions Used By Games

Game Version Subversion
Template:Game name 16 2

See also