Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wavebeem/sprconv

A python tool for decompiling and recompiling Quake sprites.
https://github.com/wavebeem/sprconv

Last synced: about 1 month ago
JSON representation

A python tool for decompiling and recompiling Quake sprites.

Awesome Lists containing this project

README

        

# SprConv

A python tool for decompiling and recompiling Quake sprites.

### Example usage:

Decompile sprite: `sprconv sprite.spr`

Compile sprite: `sprconv sprite.json`

Use in other scripts:

```python
from sprconv import sprite_from_json
from sprconv import json_from_sprite

sprite_from_json(json_filename)
json_from_sprite(sprite_filename)
```

### Example JSON script:

```json
{
"filename": "s_light.spr",
"version": 1,
"type": 2,
"bounding_radius": 22.627416610717773,
"beam_length": 0.0,
"sync_type": 0,
"frames": [
{
"type": 0,
"subframes": [
{
"filename": "s_light_0_0.png",
"origin": [-16, 16],
"interval": 0.1
}
]
}
]
}
```

### Versions:

- 1: Normal Quake. Input images must be paletted (8bpp).
- 32: Darkplaces. Input images must be RGBA (32bpp).

### Sprite types:

- 0: Parallel upright
- 1: Facing upright
- 2: Parallel
- 3: Oriented
- 4: Parallel oriented

### Sync types:

- 0: Synchronized
- 1: Random

### Frame types:

- 0: Single
- 1: Group
- 2: Angled (FTEQW only)

### Notes:

- "bounding_radius" is not used by most sourceports, so can safely be set to 0.
- I'm not sure what "beam_length" is used for in any version of Quake.
- "interval" is the length of time between subframes in Group frames.

## Todo:

- Half-Life sprite generation
- Replace "type" values with strings
- Replace "version" value with a string
- Calculate "beam_length" and "bounding_radius" if its not provided

## Runtime dependencies

- PIL (`python -m pip install Pillow`)

## Suggested installation

```sh
$ python3 -m venv .venv

# Powershell on Windows
$ .venv/Scripts/Activate.ps1
# Linux
$ . .venv/bin/activate

$ pip install -r requirements.txt

$ python source/sprconv
```

## Thirdparty

- [Kaitai Struct](https://kaitai.io/)

## License

MIT License

Copyright (c) 2023 erysdren (it/she/they)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.