Skip to content
Gaspar edited this page Feb 28, 2024 · 27 revisions

Overview

goldsrcmap is a Python library designed for parsing, manipulating, and generating GoldSrc Engine map files (.map).


Installation

  1. PIP method

https://pypi.org/project/goldsrcmap/

pip install goldsrcmap

  1. Manual method

/Mapping/Scripting/format
/Mapping/Scripting/utils
/Mapping/Scripting/__init__.py
/Mapping/Scripting/goldsrcmap.py

Usage

  1. PIP method

  • Import goldsrcmap library:
import goldsrcmap as gsm

# your code
  1. Manual method

  • Ensure that you have the src content in your working directory /Scripting/.
  • Create the python file in /Scripting/
/Scripting/your_script.py
  • Import goldsrcmap.py module:
import goldsrcmap as gsm

# your code

Examples

https://github.com/G2Pavon/goldsrcmap/wiki/Examples

https://github.com/G2Pavon/goldsrcmapextensions W.I.P


Data Structure

You can access to map through Python classes.

The principal class is Map, which store all entities (worldspawn, brush entities and point entities) defining the map in a Python list.

Each entity is an instance of the Entity class, which stores entity key-values pairs properties in a Python dict and brushes (if is worldspawn or brush entity) in a Python list.

A brush is an instance of the Brush class, which stores the brush faces in a Python list.

A brush face is an instace of the Face class, which stores the hyperplane as an instance of the Plane class and the texture definitions as an instance of the Texture class.

The Texture class has attributes such as texture name, uv axis as instances of the Vector3 class, uv offset/shift, uv rotation and uv scale.

The Plane is defined by three Point instances.

goldsrcmap_diagram

Class Map

Attribute Description
entities List of Entity objects.

More info: https://github.com/G2Pavon/goldsrcmap/wiki/Map


Class Entity

Attribute Description
properties Dictionary containing properties of the entity.
brushes List of Brush objects.

More info: https://github.com/G2Pavon/goldsrcmap/wiki/Entity


Class Brush

Attribute Description
faces List of Face objects.

More info: https://github.com/G2Pavon/goldsrcmap/wiki/Brush


Class Face

Attribute Description
plane Plane object.
texture Texture object.

More info: https://github.com/G2Pavon/goldsrcmap/wiki/Face


Class Texture

Attribute Description
name String representing the texture name.
u_axis Vector3 object representing the texture axis.
u_offset Float values for texture offset.
v_axis Vector3 object representing the texture axis.
v_offset Float values for texture offset.
rotation Float value indicating texture rotation.
u_scale Float values for texture scaling.
v_scale Float values for texture scaling.

More info: https://github.com/G2Pavon/goldsrcmap/wiki/Texture


Class Plane

Attribute Description
p1 Point object representing first point of the plane
p2 Point object representing second point of the plane
p3 Point object representing third point of the plane

Class Point

Attribute Description
x Float representing the x coordinate
y Float representing the y coordinate
z Float representing the z coordinate

Class Vector3

Attribute Description
x Float representing the x coordinate
y Float representing the y coordinate
z Float representing the z coordinate

Class Edge

Attribute Description
start Point endpoint of the line segment
end Point endpoint of the line segment

Benchmark

Map loading benchmark on a low end netbook:

Intel Celeron N4020 (2) @ 2.800GHz

Memory: 3730MiB

Time (s) Size (MB) Map Game
0.176 0.833 kz_monte image
0.130 0.853 kz_navidad image
0.192 1.048 cnd_overblock image
0.362 1.622 cnd_obscure image
0.639 3.329 kz_frostbite image
0.779 3.415 kz_citadel image
0.920 3.807 kzarg_Imponente image
0.868 4.099 kz_gigablockier_pub image
2.107 7.792 kz_1man_game_ez image
2.192 8.810 muj_to_Shad0ws image
6.133 14.831 ad_magna Icon
5.758 19.821 shib3 Icon
10.353 26.496 shib5 Icon
11.655 50.973 ad_heresp2 Icon

image


References:

https://developer.valvesoftware.com/wiki/MAP_(file_format)

https://github.com/stefanha/map-files/blob/master/MAPFiles.pdf

Inspiration:

https://github.com/surf-gorange/PyVMF