Skip to content
Gaspar edited this page Jan 15, 2024 · 27 revisions

Overview

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


Installation

pip install goldsrcmap not implemented

Add src (https://github.com/G2Pavon/goldsrcmap/tree/main/src) content to your working directory e.g. /Mapping/Scripting/:

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

Usage

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

# your code

Examples

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


Data Structure

You can access to map objects through python classes.

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

Each entity is an instance of Entity class, which store entity properties key-values as a python dict and brushes (if is worldspawn or brush entity) as a python list.

A brush is an instance of Brush class, which store the brush faces as a python list.

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

The Texture class has attributes like: texture name, uv axis as an instance of Vector3, 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
Clone this wiki locally