OpenRCT2-ObjectCommon 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openrct2_object_common/__init__.py +13 -0
- openrct2_object_common/blender/__init__.py +9 -0
- openrct2_object_common/blender/lights.py +52 -0
- openrct2_object_common/blender/modal.py +160 -0
- openrct2_object_common/cli.py +79 -0
- openrct2_object_common/config.py +188 -0
- openrct2_object_common/objectjson.py +34 -0
- openrct2_object_common/parkobj.py +88 -0
- openrct2_object_common/placement.py +57 -0
- openrct2_object_common/py.typed +0 -0
- openrct2_objectcommon-0.1.0.dist-info/METADATA +121 -0
- openrct2_objectcommon-0.1.0.dist-info/RECORD +14 -0
- openrct2_objectcommon-0.1.0.dist-info/WHEEL +4 -0
- openrct2_objectcommon-0.1.0.dist-info/licenses/LICENSE +339 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Shared scaffolding for OpenRCT2 object generators: config parsing/validation,
|
|
3
|
+
CLI flow, model placement, object.json headers, and `.parkobj` assembly. Sits
|
|
4
|
+
between the renderer (`openrct2-x7-renderer`) and the generators, so the vehicle
|
|
5
|
+
and scenery tools share one config layer and one packaging path.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
__version__ = version("OpenRCT2-ObjectCommon")
|
|
12
|
+
except PackageNotFoundError: # pragma: no cover - source tree without an install
|
|
13
|
+
__version__ = "0.0.0"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Blender add-on helpers shared by the vehicle and scenery add-ons.
|
|
3
|
+
|
|
4
|
+
``lights`` has no ``bpy`` dependency (it only reads attribute-bearing items), so
|
|
5
|
+
it imports anywhere. ``modal`` imports ``bpy`` and is meant to run inside Blender
|
|
6
|
+
only -- import it directly (``from openrct2_object_common.blender.modal import
|
|
7
|
+
RenderModalBase``) rather than eagerly here, so ``lights`` stays usable without
|
|
8
|
+
Blender installed.
|
|
9
|
+
"""
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Build the renderer's lighting rig from add-on UI items.
|
|
3
|
+
|
|
4
|
+
The default rig is the renderer's own ``default_lights()`` (re-exported here), so
|
|
5
|
+
the add-ons no longer hand-copy the nine-light list -- a single source shared
|
|
6
|
+
with the CLI. ``lights_from_items`` reads any sequence of objects exposing
|
|
7
|
+
``type`` / ``shadow`` / ``direction`` / ``strength`` (a Blender ``PropertyGroup``
|
|
8
|
+
collection, but nothing here imports ``bpy``), falling back to the default rig
|
|
9
|
+
when the collection is empty.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from collections.abc import Iterable, Sequence
|
|
13
|
+
from typing import Any, Protocol
|
|
14
|
+
|
|
15
|
+
import numpy as np
|
|
16
|
+
from openrct2_x7_renderer.constants import LightType
|
|
17
|
+
from openrct2_x7_renderer.lights import default_lights
|
|
18
|
+
from openrct2_x7_renderer.types import Light
|
|
19
|
+
|
|
20
|
+
__all__ = ["LIGHT_TYPE_MAP", "default_lights", "lights_from_items", "normalize_direction"]
|
|
21
|
+
|
|
22
|
+
# The light types the add-on UI exposes (hemisphere lights are CLI/config only).
|
|
23
|
+
LIGHT_TYPE_MAP = {"diffuse": LightType.DIFFUSE, "specular": LightType.SPECULAR}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class _LightItem(Protocol):
|
|
27
|
+
type: str
|
|
28
|
+
shadow: bool
|
|
29
|
+
direction: Any # 3-element sequence (bpy float vector)
|
|
30
|
+
strength: float
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def normalize_direction(v: Sequence[float]) -> np.ndarray:
|
|
34
|
+
"""A light direction as a unit ``(3,)`` float64 vector; a zero vector is
|
|
35
|
+
returned unchanged (the renderer rejects it later)."""
|
|
36
|
+
arr = np.array(v, dtype=np.float64)
|
|
37
|
+
n = np.linalg.norm(arr)
|
|
38
|
+
return arr / n if n > 0 else arr
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def lights_from_items(items: Iterable[_LightItem]) -> list[Light]:
|
|
42
|
+
"""Build a light rig from UI items, or the default rig when ``items`` is empty."""
|
|
43
|
+
rig = [
|
|
44
|
+
Light(
|
|
45
|
+
type=LIGHT_TYPE_MAP[item.type],
|
|
46
|
+
shadow=int(item.shadow),
|
|
47
|
+
direction=normalize_direction(list(item.direction)),
|
|
48
|
+
intensity=item.strength,
|
|
49
|
+
)
|
|
50
|
+
for item in items
|
|
51
|
+
]
|
|
52
|
+
return rig or default_lights()
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"""Shared modal operator for add-ons that render off the main thread.
|
|
2
|
+
|
|
3
|
+
The render (the renderer-bound work) is an opaque, blocking call, so it runs in
|
|
4
|
+
a worker thread while a modal timer drives a status-bar readout. The build phase
|
|
5
|
+
(reading bpy data into the core object) stays on the main thread.
|
|
6
|
+
|
|
7
|
+
NOTE: no ``from __future__ import annotations`` -- subclasses declare bpy
|
|
8
|
+
properties as annotations and PEP 563 would stringify them and break add-on
|
|
9
|
+
registration.
|
|
10
|
+
|
|
11
|
+
This module imports ``bpy`` and is meant to run inside Blender only; install the
|
|
12
|
+
package's ``blender`` extra (``pip install OpenRCT2-ObjectCommon[blender]``) when
|
|
13
|
+
type-checking or testing it outside Blender.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import threading
|
|
17
|
+
import time
|
|
18
|
+
import traceback
|
|
19
|
+
from typing import Any
|
|
20
|
+
|
|
21
|
+
from bpy.types import Operator
|
|
22
|
+
|
|
23
|
+
_SPINNER_FRAMES = "|/-\\"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class RenderModalBase(Operator):
|
|
27
|
+
"""Scaffolding for operators that run a blocking render off the main thread
|
|
28
|
+
while showing a status-bar readout.
|
|
29
|
+
|
|
30
|
+
Subclasses provide the four hooks below. ``_build`` / ``_prepare`` /
|
|
31
|
+
``_on_success`` run on the main thread and may touch ``context`` and bpy
|
|
32
|
+
data; ``_render`` runs in the worker thread and must touch only ``self``
|
|
33
|
+
(values it needs from ``context`` are stashed in ``_prepare``).
|
|
34
|
+
|
|
35
|
+
Progress is *indeterminate* (a cycling spinner) unless ``_render`` reports
|
|
36
|
+
real units via :meth:`set_progress`, in which case the status line shows a
|
|
37
|
+
percentage instead.
|
|
38
|
+
|
|
39
|
+
Subclass hooks:
|
|
40
|
+
``_status_verb`` label shown in the status bar.
|
|
41
|
+
``_clean_error_types`` build-error exception types whose message
|
|
42
|
+
is already user-facing (reported as-is,
|
|
43
|
+
not wrapped with ``_invalid_prefix``).
|
|
44
|
+
``_build(context)`` read bpy data into the core object(s);
|
|
45
|
+
returns an opaque payload for the others.
|
|
46
|
+
``_prepare(context, payload)`` stash per-run state on ``self`` (lights,
|
|
47
|
+
output paths) -- main thread.
|
|
48
|
+
``_render(payload)`` the blocking work -- worker thread.
|
|
49
|
+
``_on_success(context)`` post-render UI; returns an operator result.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
_status_verb = "Working"
|
|
53
|
+
_invalid_prefix = "Invalid object"
|
|
54
|
+
_clean_error_types: tuple[type[Exception], ...] = ()
|
|
55
|
+
|
|
56
|
+
# -- hooks ---------------------------------------------------------------
|
|
57
|
+
|
|
58
|
+
def _build(self, context) -> Any: # pragma: no cover - subclass hook
|
|
59
|
+
raise NotImplementedError
|
|
60
|
+
|
|
61
|
+
def _prepare(self, context, payload) -> None: # pragma: no cover - subclass hook
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
def _render(self, payload) -> None: # pragma: no cover - subclass hook
|
|
65
|
+
raise NotImplementedError
|
|
66
|
+
|
|
67
|
+
def _on_success(self, context): # pragma: no cover - subclass hook
|
|
68
|
+
raise NotImplementedError
|
|
69
|
+
|
|
70
|
+
# -- worker-facing -------------------------------------------------------
|
|
71
|
+
|
|
72
|
+
def set_progress(self, done: int, total: int) -> None:
|
|
73
|
+
"""Report determinate progress from ``_render`` (worker thread). Plain
|
|
74
|
+
int writes; the modal timer reads them to repaint. No lock needed for
|
|
75
|
+
single-word assignments."""
|
|
76
|
+
self._done_units = done
|
|
77
|
+
self._total_units = total
|
|
78
|
+
|
|
79
|
+
# -- operator flow -------------------------------------------------------
|
|
80
|
+
|
|
81
|
+
def execute(self, context):
|
|
82
|
+
build_start = time.monotonic()
|
|
83
|
+
try:
|
|
84
|
+
payload = self._build(context)
|
|
85
|
+
except self._clean_error_types as e:
|
|
86
|
+
self.report({"ERROR"}, str(e))
|
|
87
|
+
return {"CANCELLED"}
|
|
88
|
+
except Exception as e:
|
|
89
|
+
self.report({"ERROR"}, f"{self._invalid_prefix}: {e}")
|
|
90
|
+
return {"CANCELLED"}
|
|
91
|
+
self._build_secs = int(time.monotonic() - build_start)
|
|
92
|
+
|
|
93
|
+
self._prepare(context, payload)
|
|
94
|
+
self._error: str | None = None
|
|
95
|
+
self._finished = False
|
|
96
|
+
self._start_time = time.monotonic()
|
|
97
|
+
self._spinner_step = 0
|
|
98
|
+
self._done_units = 0
|
|
99
|
+
self._total_units = 0
|
|
100
|
+
|
|
101
|
+
def worker():
|
|
102
|
+
try:
|
|
103
|
+
self._render(payload)
|
|
104
|
+
except Exception:
|
|
105
|
+
self._error = traceback.format_exc()
|
|
106
|
+
finally:
|
|
107
|
+
self._finished = True
|
|
108
|
+
|
|
109
|
+
self._thread = threading.Thread(target=worker, daemon=True)
|
|
110
|
+
self._thread.start()
|
|
111
|
+
|
|
112
|
+
wm = context.window_manager
|
|
113
|
+
wm.progress_begin(0, 1)
|
|
114
|
+
context.window.cursor_modal_set("WAIT")
|
|
115
|
+
self._set_status(context)
|
|
116
|
+
self._timer = wm.event_timer_add(0.1, window=context.window)
|
|
117
|
+
wm.modal_handler_add(self)
|
|
118
|
+
return {"RUNNING_MODAL"}
|
|
119
|
+
|
|
120
|
+
def modal(self, context, event):
|
|
121
|
+
if event.type == "TIMER":
|
|
122
|
+
if self._finished:
|
|
123
|
+
return self._finish(context)
|
|
124
|
+
self._spinner_step += 1
|
|
125
|
+
self._set_status(context)
|
|
126
|
+
return {"PASS_THROUGH"}
|
|
127
|
+
|
|
128
|
+
def _set_status(self, context) -> None:
|
|
129
|
+
elapsed = int(time.monotonic() - self._start_time)
|
|
130
|
+
# Only mention the build time when it was non-trivial (animated / large
|
|
131
|
+
# builds); a static build is instant and "(build 0s)" would be noise.
|
|
132
|
+
build = f" (build {self._build_secs}s)" if self._build_secs else ""
|
|
133
|
+
wm = context.window_manager
|
|
134
|
+
if self._total_units > 0:
|
|
135
|
+
pct = int(100 * self._done_units / self._total_units)
|
|
136
|
+
context.workspace.status_text_set(
|
|
137
|
+
f"{self._status_verb}... {pct}% {elapsed}s{build}"
|
|
138
|
+
)
|
|
139
|
+
wm.progress_update(self._done_units / self._total_units)
|
|
140
|
+
else:
|
|
141
|
+
glyph = _SPINNER_FRAMES[self._spinner_step % len(_SPINNER_FRAMES)]
|
|
142
|
+
context.workspace.status_text_set(
|
|
143
|
+
f"{glyph} {self._status_verb}... {elapsed}s{build}"
|
|
144
|
+
)
|
|
145
|
+
wm.progress_update((self._spinner_step % 20) / 20.0)
|
|
146
|
+
|
|
147
|
+
def _finish(self, context):
|
|
148
|
+
wm = context.window_manager
|
|
149
|
+
wm.event_timer_remove(self._timer)
|
|
150
|
+
wm.progress_end()
|
|
151
|
+
context.window.cursor_modal_restore()
|
|
152
|
+
context.workspace.status_text_set(None)
|
|
153
|
+
self._thread.join()
|
|
154
|
+
if self._error:
|
|
155
|
+
print(self._error)
|
|
156
|
+
self.report(
|
|
157
|
+
{"ERROR"}, f"{self._status_verb} failed; see the system console for details."
|
|
158
|
+
)
|
|
159
|
+
return {"CANCELLED"}
|
|
160
|
+
return self._on_success(context)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Shared command-line scaffolding for object generators.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import sys
|
|
7
|
+
from collections.abc import Callable
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
from openrct2_x7_renderer.lights import default_lights, load_lights
|
|
12
|
+
from openrct2_x7_renderer.ray_trace import Context
|
|
13
|
+
from openrct2_x7_renderer.remap import load_remap_overrides
|
|
14
|
+
from openrct2_x7_renderer.types import Light
|
|
15
|
+
|
|
16
|
+
from .config import LoadError, parse_config
|
|
17
|
+
|
|
18
|
+
TEST_ZOOM = 0.125
|
|
19
|
+
|
|
20
|
+
RenderFn = Callable[[argparse.Namespace, dict[str, Any], list[Light]], None]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def parse_cli_args(prog: str, argv: list[str] | None) -> argparse.Namespace:
|
|
24
|
+
"""Parse the flags shared by both generators: `--test` / `--skip-render`
|
|
25
|
+
(mutually exclusive) and a single config-file `input` path."""
|
|
26
|
+
parser = argparse.ArgumentParser(prog=prog)
|
|
27
|
+
group = parser.add_mutually_exclusive_group()
|
|
28
|
+
group.add_argument("--test", action="store_true", help="single-viewpoint render to test/")
|
|
29
|
+
group.add_argument(
|
|
30
|
+
"--skip-render", action="store_true", help="reuse previously rendered sprites"
|
|
31
|
+
)
|
|
32
|
+
parser.add_argument("input", type=Path)
|
|
33
|
+
return parser.parse_args(argv)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def output_directory_of(root: dict[str, Any]) -> Path:
|
|
37
|
+
"""The config's `output_directory`, or the current directory if unset."""
|
|
38
|
+
out = root.get("output_directory")
|
|
39
|
+
return Path(out) if isinstance(out, str) else Path(".")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def make_context(
|
|
43
|
+
lights: list[Light],
|
|
44
|
+
units_per_tile: float,
|
|
45
|
+
test: bool,
|
|
46
|
+
root: dict[str, Any] | None = None,
|
|
47
|
+
) -> Context:
|
|
48
|
+
"""Build a render Context whose camera scale is driven by the object's
|
|
49
|
+
configured `units_per_tile`. Test mode scales ``upt`` down by ``TEST_ZOOM``
|
|
50
|
+
(0.125×), zooming in to show material detail in a single-viewpoint preview.
|
|
51
|
+
|
|
52
|
+
In test mode, when ``root`` (the parsed config) is supplied, an optional
|
|
53
|
+
``test_remap_colors`` block is read and applied to ``render_view`` output so
|
|
54
|
+
the preview shows repaint colours instead of the raw remap windows. Outside
|
|
55
|
+
test mode the overrides are ignored, so real renders keep their remap
|
|
56
|
+
windows intact for OpenRCT2 to repaint."""
|
|
57
|
+
upt = TEST_ZOOM * units_per_tile if test else units_per_tile
|
|
58
|
+
overrides = load_remap_overrides(root) if (test and root is not None) else {}
|
|
59
|
+
return Context(lights=lights, dither=True, upt=upt, remap_overrides=overrides)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def run_cli(prog: str, argv: list[str] | None, render: RenderFn) -> int:
|
|
63
|
+
"""Run the shared CLI flow and return a process exit code.
|
|
64
|
+
|
|
65
|
+
Parses the args, reads the config, resolves the lights (the config's
|
|
66
|
+
`lights` block if present, else the default rig), then hands off to
|
|
67
|
+
`render`. Any failure is reported on stderr and yields exit code 1.
|
|
68
|
+
"""
|
|
69
|
+
args = parse_cli_args(prog, argv)
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
root = parse_config(args.input)
|
|
73
|
+
lights = load_lights(root["lights"]) if "lights" in root else default_lights()
|
|
74
|
+
render(args, root, lights)
|
|
75
|
+
except (LoadError, OSError, ValueError, RuntimeError) as e:
|
|
76
|
+
print(f"Error: {e}", file=sys.stderr)
|
|
77
|
+
return 1
|
|
78
|
+
|
|
79
|
+
return 0
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Generic config parsing + validation helpers shared by the generators' loaders.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"LoadError",
|
|
7
|
+
"as_array_or_wrap",
|
|
8
|
+
"load_meshes",
|
|
9
|
+
"load_preview",
|
|
10
|
+
"optional_bool",
|
|
11
|
+
"optional_int",
|
|
12
|
+
"optional_number",
|
|
13
|
+
"optional_string",
|
|
14
|
+
"optional_string_list",
|
|
15
|
+
"parse_config",
|
|
16
|
+
"read_vector3",
|
|
17
|
+
"require_int",
|
|
18
|
+
"require_number",
|
|
19
|
+
"require_string",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
import json
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
from typing import Any
|
|
25
|
+
|
|
26
|
+
import numpy as np
|
|
27
|
+
from openrct2_x7_renderer.image import read_png
|
|
28
|
+
from openrct2_x7_renderer.mesh import Mesh, load_mesh
|
|
29
|
+
from openrct2_x7_renderer.types import IndexedImage, LoadError
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def parse_config(path: Path | str) -> dict[str, Any]:
|
|
33
|
+
"""Parse a JSON or YAML config file into a dict (chosen by extension)."""
|
|
34
|
+
p = Path(path)
|
|
35
|
+
text = p.read_text()
|
|
36
|
+
if p.suffix.lower() in (".yaml", ".yml"):
|
|
37
|
+
try:
|
|
38
|
+
import yaml
|
|
39
|
+
except ImportError:
|
|
40
|
+
raise LoadError(
|
|
41
|
+
"PyYAML is required to load .yaml configs (pip install pyyaml)"
|
|
42
|
+
) from None
|
|
43
|
+
root = yaml.safe_load(text)
|
|
44
|
+
else:
|
|
45
|
+
root = json.loads(text)
|
|
46
|
+
if not isinstance(root, dict):
|
|
47
|
+
raise LoadError("Config root is not an object")
|
|
48
|
+
return root
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def require_string(obj: dict[str, Any], key: str) -> str:
|
|
52
|
+
"""Return the string at ``obj[key]``, raising LoadError if absent or not a string."""
|
|
53
|
+
v = obj.get(key)
|
|
54
|
+
if not isinstance(v, str):
|
|
55
|
+
raise LoadError(f'Property "{key}" not found or is not a string')
|
|
56
|
+
return v
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def optional_string(obj: dict[str, Any], key: str, default: str = "") -> str:
|
|
60
|
+
"""Return the string at ``obj[key]``, or ``default`` if the key is absent."""
|
|
61
|
+
v = obj.get(key)
|
|
62
|
+
if v is None:
|
|
63
|
+
return default
|
|
64
|
+
if not isinstance(v, str):
|
|
65
|
+
raise LoadError(f'Property "{key}" is not a string')
|
|
66
|
+
return v
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def optional_string_list(obj: dict[str, Any], key: str) -> list[str]:
|
|
70
|
+
"""Return the value at ``obj[key]`` coerced to a list of strings.
|
|
71
|
+
|
|
72
|
+
A single string is wrapped in a list; an absent key returns ``[]``.
|
|
73
|
+
"""
|
|
74
|
+
v = obj.get(key)
|
|
75
|
+
if v is None:
|
|
76
|
+
return []
|
|
77
|
+
if isinstance(v, str):
|
|
78
|
+
return [v]
|
|
79
|
+
if not isinstance(v, list) or any(not isinstance(x, str) for x in v):
|
|
80
|
+
raise LoadError(f'Property "{key}" is not a string or array of strings')
|
|
81
|
+
return list(v)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def require_int(obj: dict[str, Any], key: str) -> int:
|
|
85
|
+
"""Return the integer at ``obj[key]``, raising LoadError if absent, non-int, or a bool."""
|
|
86
|
+
v = obj.get(key)
|
|
87
|
+
if not isinstance(v, int) or isinstance(v, bool):
|
|
88
|
+
raise LoadError(f'Property "{key}" not found or is not an integer')
|
|
89
|
+
return v
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def optional_int(obj: dict[str, Any], key: str, default: int) -> int:
|
|
93
|
+
"""Return the integer at ``obj[key]``, or ``default`` if the key is absent."""
|
|
94
|
+
v = obj.get(key)
|
|
95
|
+
if v is None:
|
|
96
|
+
return default
|
|
97
|
+
if not isinstance(v, int) or isinstance(v, bool):
|
|
98
|
+
raise LoadError(f'Property "{key}" is not an integer')
|
|
99
|
+
return v
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def require_number(obj: dict[str, Any], key: str) -> float:
|
|
103
|
+
"""Return the number at ``obj[key]`` as float, raising LoadError if absent or non-numeric."""
|
|
104
|
+
v = obj.get(key)
|
|
105
|
+
if not isinstance(v, (int, float)) or isinstance(v, bool):
|
|
106
|
+
raise LoadError(f'Property "{key}" not found or is not a number')
|
|
107
|
+
return float(v)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def optional_number(obj: dict[str, Any], key: str, default: float) -> float:
|
|
111
|
+
"""Return the number at ``obj[key]`` as float, or ``default`` if the key is absent."""
|
|
112
|
+
v = obj.get(key)
|
|
113
|
+
if v is None:
|
|
114
|
+
return default
|
|
115
|
+
if not isinstance(v, (int, float)) or isinstance(v, bool):
|
|
116
|
+
raise LoadError(f'Property "{key}" is not a number')
|
|
117
|
+
return float(v)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def optional_bool(obj: dict[str, Any], key: str, default: bool = False) -> bool:
|
|
121
|
+
"""Return the boolean at ``obj[key]``, or ``default`` if the key is absent."""
|
|
122
|
+
v = obj.get(key)
|
|
123
|
+
if v is None:
|
|
124
|
+
return default
|
|
125
|
+
if not isinstance(v, bool):
|
|
126
|
+
raise LoadError(f'Property "{key}" is not a boolean')
|
|
127
|
+
return v
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def read_vector3(arr: Any) -> np.ndarray:
|
|
131
|
+
"""Parse a 3-element list into a float64 ``(3,)`` array, raising LoadError on bad input."""
|
|
132
|
+
if not isinstance(arr, list) or len(arr) != 3:
|
|
133
|
+
raise LoadError("Vector must be an array of 3 numbers")
|
|
134
|
+
try:
|
|
135
|
+
return np.array([float(x) for x in arr], dtype=np.float64)
|
|
136
|
+
except (ValueError, TypeError) as e:
|
|
137
|
+
raise LoadError(f"Vector element is not a number: {e}") from e
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def as_array_or_wrap(value: Any) -> list[Any]:
|
|
141
|
+
"""Return ``value`` as-is if it is a non-empty list, or wrap a scalar in a one-element list."""
|
|
142
|
+
if value is None:
|
|
143
|
+
raise LoadError("Missing value")
|
|
144
|
+
if isinstance(value, list):
|
|
145
|
+
if len(value) == 0:
|
|
146
|
+
raise LoadError("Empty array")
|
|
147
|
+
return value
|
|
148
|
+
return [value]
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def load_meshes(root: dict[str, Any], base_dir: Path | None = None) -> list[Mesh]:
|
|
152
|
+
"""Load every OBJ listed under the config's `meshes` array.
|
|
153
|
+
|
|
154
|
+
Relative mesh paths are resolved against *base_dir* (typically the
|
|
155
|
+
directory containing the config file). When *base_dir* is ``None``
|
|
156
|
+
the paths are used as-is (resolved against CWD).
|
|
157
|
+
"""
|
|
158
|
+
mesh_paths = root.get("meshes")
|
|
159
|
+
if not isinstance(mesh_paths, list):
|
|
160
|
+
raise LoadError('Property "meshes" does not exist or is not an array')
|
|
161
|
+
meshes: list[Mesh] = []
|
|
162
|
+
for path in mesh_paths:
|
|
163
|
+
if not isinstance(path, str):
|
|
164
|
+
raise LoadError("Mesh path is not a string")
|
|
165
|
+
resolved = Path(path) if base_dir is None or Path(path).is_absolute() else base_dir / path
|
|
166
|
+
meshes.append(load_mesh(resolved))
|
|
167
|
+
return meshes
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def load_preview(root: dict[str, Any], base_dir: Path | None = None) -> IndexedImage | None:
|
|
171
|
+
"""Load the optional `preview` PNG referenced by the config, if any.
|
|
172
|
+
|
|
173
|
+
Relative preview paths are resolved against *base_dir*.
|
|
174
|
+
"""
|
|
175
|
+
preview_path = root.get("preview")
|
|
176
|
+
if preview_path is None:
|
|
177
|
+
return None
|
|
178
|
+
if not isinstance(preview_path, str):
|
|
179
|
+
raise LoadError('Property "preview" is not a string')
|
|
180
|
+
resolved = (
|
|
181
|
+
Path(preview_path)
|
|
182
|
+
if base_dir is None or Path(preview_path).is_absolute()
|
|
183
|
+
else base_dir / preview_path
|
|
184
|
+
)
|
|
185
|
+
try:
|
|
186
|
+
return read_png(resolved)
|
|
187
|
+
except (OSError, ValueError) as e:
|
|
188
|
+
raise LoadError(f"Unable to open image file {preview_path}: {e}") from e
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The object.json fields every OpenRCT2 object shares.
|
|
3
|
+
|
|
4
|
+
`id`, `originalId`, `version`, `authors`, and `objectType` are identical across
|
|
5
|
+
rides and all three scenery kinds; each generator's ``build_*_json`` opens with
|
|
6
|
+
this header, then fills in its kind-specific ``properties`` / ``strings``.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from collections.abc import Iterable
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
__all__ = ["object_json_header"]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def object_json_header(
|
|
16
|
+
obj_id: str,
|
|
17
|
+
*,
|
|
18
|
+
object_type: str,
|
|
19
|
+
original_id: str = "",
|
|
20
|
+
version: str = "1.0",
|
|
21
|
+
authors: Iterable[str] = (),
|
|
22
|
+
) -> dict[str, Any]:
|
|
23
|
+
"""The shared leading object.json fields, in OpenRCT2's canonical key order.
|
|
24
|
+
|
|
25
|
+
``originalId`` is omitted when empty (OpenRCT2 treats it as absent); the
|
|
26
|
+
caller adds ``properties``/``strings``/``images`` to the returned dict.
|
|
27
|
+
"""
|
|
28
|
+
out: dict[str, Any] = {"id": obj_id}
|
|
29
|
+
if original_id:
|
|
30
|
+
out["originalId"] = original_id
|
|
31
|
+
out["version"] = version
|
|
32
|
+
out["authors"] = list(authors)
|
|
33
|
+
out["objectType"] = object_type
|
|
34
|
+
return out
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Write ``images.dat``, the object.json, and assemble the ``.parkobj`` ZIP.
|
|
3
|
+
|
|
4
|
+
Every object kind follows the same packaging path: render sprites into a single
|
|
5
|
+
``images.dat`` blob (or reuse a previous render), write the object.json that
|
|
6
|
+
references it via ``$LGX:``, and zip the two together. The per-kind work is just
|
|
7
|
+
*what* sprites to render and *what* metadata to emit; this module owns the rest.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import json
|
|
11
|
+
import logging
|
|
12
|
+
import zipfile
|
|
13
|
+
from collections.abc import Callable
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
from openrct2_x7_renderer.images_dat import write_images_dat
|
|
18
|
+
from openrct2_x7_renderer.types import IndexedImage
|
|
19
|
+
|
|
20
|
+
__all__ = ["RenderFn", "assemble_parkobj", "write_images_dat_lgx"]
|
|
21
|
+
|
|
22
|
+
log = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
# Render the object's sprites into ``work_dir`` (writing ``images.dat``) and
|
|
25
|
+
# return the object.json "images" list (the ``$LGX:`` references).
|
|
26
|
+
RenderFn = Callable[[Path], list[str]]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def write_images_dat_lgx(
|
|
30
|
+
images: list[IndexedImage], work_dir: Path, *, note: str = ""
|
|
31
|
+
) -> list[str]:
|
|
32
|
+
"""Write ``images`` to ``work_dir/images.dat`` and return the object.json
|
|
33
|
+
"images" value referencing it.
|
|
34
|
+
|
|
35
|
+
``note`` is appended to the log line (e.g. ``" for 4 tiles"``). Returns the
|
|
36
|
+
single-element ``["$LGX:images.dat[0..N-1]"]`` list OpenRCT2 expects.
|
|
37
|
+
"""
|
|
38
|
+
out_path = work_dir / "images.dat"
|
|
39
|
+
write_images_dat(images, out_path)
|
|
40
|
+
log.info(
|
|
41
|
+
"wrote %s (%d sprites%s, %.1f KB)",
|
|
42
|
+
out_path,
|
|
43
|
+
len(images),
|
|
44
|
+
note,
|
|
45
|
+
out_path.stat().st_size / 1024,
|
|
46
|
+
)
|
|
47
|
+
return [f"$LGX:images.dat[0..{len(images) - 1}]"]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def assemble_parkobj(
|
|
51
|
+
obj_json: dict[str, Any],
|
|
52
|
+
parkobj_path: Path,
|
|
53
|
+
work_dir: Path,
|
|
54
|
+
render: RenderFn,
|
|
55
|
+
*,
|
|
56
|
+
skip_render: bool = False,
|
|
57
|
+
) -> None:
|
|
58
|
+
"""Render (or reuse) sprites, write the object.json, and zip the ``.parkobj``.
|
|
59
|
+
|
|
60
|
+
Shared by every object kind; callers differ only in ``obj_json`` (the built
|
|
61
|
+
metadata) and ``render`` (which renders the sprites, writes ``images.dat``,
|
|
62
|
+
and returns the object.json "images" list -- typically via
|
|
63
|
+
:func:`write_images_dat_lgx`).
|
|
64
|
+
|
|
65
|
+
With ``skip_render`` the "images" list is read back from a previous run's
|
|
66
|
+
object.json in ``work_dir`` and ``render`` is not called; otherwise the
|
|
67
|
+
stale object.json / images.dat are removed first so a failed render can't
|
|
68
|
+
leave a half-written pair behind.
|
|
69
|
+
"""
|
|
70
|
+
work_dir.mkdir(parents=True, exist_ok=True)
|
|
71
|
+
|
|
72
|
+
if skip_render:
|
|
73
|
+
prev = json.loads((work_dir / "object.json").read_text())
|
|
74
|
+
images_json = prev.get("images")
|
|
75
|
+
if not isinstance(images_json, list):
|
|
76
|
+
raise RuntimeError('Property "images" is not an array')
|
|
77
|
+
else:
|
|
78
|
+
for p in (work_dir / "object.json", work_dir / "images.dat"):
|
|
79
|
+
p.unlink(missing_ok=True)
|
|
80
|
+
images_json = render(work_dir)
|
|
81
|
+
|
|
82
|
+
obj_json["images"] = images_json
|
|
83
|
+
(work_dir / "object.json").write_text(json.dumps(obj_json, indent=4))
|
|
84
|
+
|
|
85
|
+
parkobj_path.parent.mkdir(parents=True, exist_ok=True)
|
|
86
|
+
with zipfile.ZipFile(parkobj_path, "w", compression=zipfile.ZIP_DEFLATED) as zf:
|
|
87
|
+
zf.write(work_dir / "object.json", "object.json")
|
|
88
|
+
zf.write(work_dir / "images.dat", "images.dat")
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Place a Model's meshes into a render scene.
|
|
3
|
+
|
|
4
|
+
Both generators turn a ``Model`` (a list of placements, each carrying one
|
|
5
|
+
``MeshFrame`` per animation frame) into Embree scene geometry the same way:
|
|
6
|
+
convert the frame's degree orientation to a rotation matrix and add the
|
|
7
|
+
referenced mesh at its position. The only difference is how out-of-range frame
|
|
8
|
+
indices are handled (vehicles index exactly; scenery clamps to a placement's
|
|
9
|
+
last pose), which is the ``clamp_frame`` flag.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import math
|
|
13
|
+
|
|
14
|
+
import numpy as np
|
|
15
|
+
from openrct2_x7_renderer.geometry import rotate_x, rotate_y, rotate_z
|
|
16
|
+
from openrct2_x7_renderer.mesh import Mesh
|
|
17
|
+
from openrct2_x7_renderer.ray_trace import SceneBuilder
|
|
18
|
+
from openrct2_x7_renderer.types import Model
|
|
19
|
+
|
|
20
|
+
__all__ = ["add_model_to_scene", "orientation_to_matrix"]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def orientation_to_matrix(orientation_deg: np.ndarray) -> np.ndarray:
|
|
24
|
+
"""A MeshFrame orientation ``(angle_y, angle_z, angle_x)`` in degrees as a
|
|
25
|
+
``(3, 3)`` rotation matrix, applied as ``rotate_y @ rotate_z @ rotate_x``."""
|
|
26
|
+
rx, ry, rz = orientation_deg * (math.pi / 180.0)
|
|
27
|
+
return rotate_y(rx) @ rotate_z(ry) @ rotate_x(rz)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def add_model_to_scene(
|
|
31
|
+
builder: SceneBuilder,
|
|
32
|
+
meshes: list[Mesh],
|
|
33
|
+
model: Model,
|
|
34
|
+
*,
|
|
35
|
+
frame: int = 0,
|
|
36
|
+
mask: int = 0,
|
|
37
|
+
clamp_frame: bool = False,
|
|
38
|
+
) -> None:
|
|
39
|
+
"""Add ``model``'s placed meshes to an open ``SceneBuilder`` at pose ``frame``.
|
|
40
|
+
|
|
41
|
+
Placements whose ``mesh_index`` is ``-1`` (an empty slot) are skipped. With
|
|
42
|
+
``clamp_frame=True`` a placement with fewer frames falls back to its last
|
|
43
|
+
frame (scenery's animated poses); with ``False`` the frame is indexed exactly
|
|
44
|
+
(vehicle frames are uniform across placements). ``mask`` is the per-model
|
|
45
|
+
``MeshFlag`` bitmask (e.g. ghost / mask geometry).
|
|
46
|
+
"""
|
|
47
|
+
for mesh_frames in model.meshes:
|
|
48
|
+
idx = min(frame, len(mesh_frames) - 1) if clamp_frame else frame
|
|
49
|
+
mf = mesh_frames[idx]
|
|
50
|
+
if mf.mesh_index == -1:
|
|
51
|
+
continue
|
|
52
|
+
builder.add_model(
|
|
53
|
+
meshes[mf.mesh_index],
|
|
54
|
+
orientation_to_matrix(mf.orientation),
|
|
55
|
+
mf.position.astype(np.float64),
|
|
56
|
+
mask,
|
|
57
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: OpenRCT2-ObjectCommon
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Shared config, CLI, .parkobj, and object.json scaffolding for OpenRCT2 object generators.
|
|
5
|
+
Project-URL: Homepage, https://github.com/alex-parisi/OpenRCT2-ObjectCommon
|
|
6
|
+
Project-URL: Repository, https://github.com/alex-parisi/OpenRCT2-ObjectCommon
|
|
7
|
+
Author-email: Alex Parisi <alex@atparisi.com>
|
|
8
|
+
License-Expression: GPL-3.0-or-later
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Requires-Dist: numpy>=1.26
|
|
12
|
+
Requires-Dist: openrct2-x7-renderer>=0.3.0
|
|
13
|
+
Requires-Dist: pillow>=10.0
|
|
14
|
+
Requires-Dist: pyyaml>=6.0
|
|
15
|
+
Provides-Extra: blender
|
|
16
|
+
Requires-Dist: bpy>=4.0; extra == 'blender'
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# OpenRCT2 Object Common
|
|
20
|
+
|
|
21
|
+
Shared scaffolding for the OpenRCT2 object generators. This package sits between
|
|
22
|
+
the renderer and the generators, so the vehicle and scenery tools share one
|
|
23
|
+
config layer, one CLI flow, and one `.parkobj` packaging path instead of each
|
|
24
|
+
re-implementing them.
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
openrct2-x7-renderer the Embree-backed iso renderer (meshes -> sprites)
|
|
28
|
+
▲
|
|
29
|
+
OpenRCT2-ObjectCommon config, CLI, placement, object.json, .parkobj ← you are here
|
|
30
|
+
▲
|
|
31
|
+
┌────┴─────┐
|
|
32
|
+
Vehicle Scenery the generators (+ their Blender add-ons)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Rendering is handled by the external
|
|
36
|
+
[`openrct2-x7-renderer`](https://pypi.org/project/openrct2-x7-renderer/) package
|
|
37
|
+
(an Embree-backed ray tracer shipping prebuilt, vendored wheels), so this repo is
|
|
38
|
+
pure Python, with no compiler or Embree needed.
|
|
39
|
+
|
|
40
|
+
> Part of the **OpenRCT2-Tools** family — the
|
|
41
|
+
> [renderer](https://github.com/alex-parisi/OpenRCT2-X7-Renderer),
|
|
42
|
+
> [VehicleGenerator](https://github.com/alex-parisi/OpenRCT2-VehicleGenerator),
|
|
43
|
+
> and [SceneryGenerator](https://github.com/alex-parisi/OpenRCT2-SceneryGenerator)
|
|
44
|
+
> all build on this package.
|
|
45
|
+
|
|
46
|
+
## Requirements
|
|
47
|
+
|
|
48
|
+
- Python ≥ 3.11
|
|
49
|
+
- [uv](https://docs.astral.sh/uv/) (recommended); `uv sync` pulls everything,
|
|
50
|
+
including the renderer wheel from PyPI.
|
|
51
|
+
|
|
52
|
+
## Develop
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
uv sync
|
|
56
|
+
uv run pytest # coverage is enabled by default via pyproject.toml
|
|
57
|
+
uv run ruff check .
|
|
58
|
+
uv run mypy
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## What's here
|
|
62
|
+
|
|
63
|
+
| Module | What it provides |
|
|
64
|
+
|---|---|
|
|
65
|
+
| `config` | `parse_config` (JSON/YAML) and the `require_*` / `optional_*` validation helpers; `load_meshes` / `load_preview` |
|
|
66
|
+
| `cli` | `run_cli` (parse args → read config → resolve lights → render), `make_context`, `parse_cli_args`, `output_directory_of` |
|
|
67
|
+
| `objectjson` | `object_json_header` — the `id` / `originalId` / `version` / `authors` / `objectType` block every object shares |
|
|
68
|
+
| `placement` | `add_model_to_scene` and `orientation_to_matrix` — turn a `Model` into render-scene geometry |
|
|
69
|
+
| `parkobj` | `assemble_parkobj` (render-or-reuse → write object.json → zip) and `write_images_dat_lgx` |
|
|
70
|
+
| `blender.lights` | `lights_from_items` / `default_lights` — build the renderer's light rig from add-on UI items |
|
|
71
|
+
| `blender.modal` | `RenderModalBase` — the off-main-thread modal render operator the add-ons subclass |
|
|
72
|
+
|
|
73
|
+
## Usage
|
|
74
|
+
|
|
75
|
+
### CLI scaffolding
|
|
76
|
+
|
|
77
|
+
A generator's `__main__` wires its loader/exporter into the shared flow:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from openrct2_object_common.cli import make_context, output_directory_of, run_cli
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _render(args, root, lights):
|
|
84
|
+
obj = build_object(root) # generator-specific
|
|
85
|
+
context = make_context(lights, obj.units_per_tile, args.test)
|
|
86
|
+
export(obj, context, output_directory_of(root), skip_render=args.skip_render)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def main(argv=None):
|
|
90
|
+
return run_cli("openrct2-my-generator", argv, _render)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Packaging a `.parkobj`
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from openrct2_object_common.objectjson import object_json_header
|
|
97
|
+
from openrct2_object_common.parkobj import assemble_parkobj, write_images_dat_lgx
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def export_to(obj, context, parkobj_path, work_dir, skip_render=False):
|
|
101
|
+
obj_json = object_json_header(obj.id, object_type="scenery_small", authors=obj.authors)
|
|
102
|
+
obj_json["properties"] = build_properties(obj)
|
|
103
|
+
assemble_parkobj(
|
|
104
|
+
obj_json, parkobj_path, work_dir,
|
|
105
|
+
lambda wd: write_images_dat_lgx(render_sprites(obj, context), wd),
|
|
106
|
+
skip_render=skip_render,
|
|
107
|
+
)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Blender helpers
|
|
111
|
+
|
|
112
|
+
The `blender` subpackage imports `bpy` (only `blender.modal` — `blender.lights`
|
|
113
|
+
does not), so install the extra when working with it outside Blender:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
pip install "OpenRCT2-ObjectCommon[blender]"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
GPL-3.0-or-later.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
openrct2_object_common/__init__.py,sha256=adMVCDhNCiMIj-ROK9PV5QK0CihG5bTAWobjFVAq8NE,537
|
|
2
|
+
openrct2_object_common/cli.py,sha256=uIBd_P4Wg7jXgDjLsO3l4DpJKq8KkBdO--YES8sGGvU,3072
|
|
3
|
+
openrct2_object_common/config.py,sha256=P3Bqxz6apMmrMnpYuPxib3IM-sahEqkjJCO-HetHd2M,6445
|
|
4
|
+
openrct2_object_common/objectjson.py,sha256=SNqcBifrj3lFHLhy27Pn4g4ERqI9h1ISlrizxMoUHnA,1030
|
|
5
|
+
openrct2_object_common/parkobj.py,sha256=wEGNUugh3jDAPKmjO0AfnqjE9I3pBOOR9sRanksoWto,3214
|
|
6
|
+
openrct2_object_common/placement.py,sha256=syzOUd7lEjGngkx1QGcm-zwgvgmHy9s5BBxjgAC8XSE,2152
|
|
7
|
+
openrct2_object_common/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
openrct2_object_common/blender/__init__.py,sha256=jAlI1-klUzZN9r4jA5VTH6ywIWrlZXFMvYFFS-kiasY,416
|
|
9
|
+
openrct2_object_common/blender/lights.py,sha256=5pDbYeLjWChgx-_TmVg3v_yRQTWvhWsGQoYpq0_U4Cs,1885
|
|
10
|
+
openrct2_object_common/blender/modal.py,sha256=AY5D2eUE3UN_jtSJpHTi7IEWoo9k2ezhSwXy8jyMMlc,6382
|
|
11
|
+
openrct2_objectcommon-0.1.0.dist-info/METADATA,sha256=kBALGxpPvA5oLydMtmSJC390K-PvxvM05VwaGlvVoEY,4421
|
|
12
|
+
openrct2_objectcommon-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
13
|
+
openrct2_objectcommon-0.1.0.dist-info/licenses/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
|
|
14
|
+
openrct2_objectcommon-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 2, June 1991
|
|
3
|
+
|
|
4
|
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
|
5
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
6
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
7
|
+
of this license document, but changing it is not allowed.
|
|
8
|
+
|
|
9
|
+
Preamble
|
|
10
|
+
|
|
11
|
+
The licenses for most software are designed to take away your
|
|
12
|
+
freedom to share and change it. By contrast, the GNU General Public
|
|
13
|
+
License is intended to guarantee your freedom to share and change free
|
|
14
|
+
software--to make sure the software is free for all its users. This
|
|
15
|
+
General Public License applies to most of the Free Software
|
|
16
|
+
Foundation's software and to any other program whose authors commit to
|
|
17
|
+
using it. (Some other Free Software Foundation software is covered by
|
|
18
|
+
the GNU Lesser General Public License instead.) You can apply it to
|
|
19
|
+
your programs, too.
|
|
20
|
+
|
|
21
|
+
When we speak of free software, we are referring to freedom, not
|
|
22
|
+
price. Our General Public Licenses are designed to make sure that you
|
|
23
|
+
have the freedom to distribute copies of free software (and charge for
|
|
24
|
+
this service if you wish), that you receive source code or can get it
|
|
25
|
+
if you want it, that you can change the software or use pieces of it
|
|
26
|
+
in new free programs; and that you know you can do these things.
|
|
27
|
+
|
|
28
|
+
To protect your rights, we need to make restrictions that forbid
|
|
29
|
+
anyone to deny you these rights or to ask you to surrender the rights.
|
|
30
|
+
These restrictions translate to certain responsibilities for you if you
|
|
31
|
+
distribute copies of the software, or if you modify it.
|
|
32
|
+
|
|
33
|
+
For example, if you distribute copies of such a program, whether
|
|
34
|
+
gratis or for a fee, you must give the recipients all the rights that
|
|
35
|
+
you have. You must make sure that they, too, receive or can get the
|
|
36
|
+
source code. And you must show them these terms so they know their
|
|
37
|
+
rights.
|
|
38
|
+
|
|
39
|
+
We protect your rights with two steps: (1) copyright the software, and
|
|
40
|
+
(2) offer you this license which gives you legal permission to copy,
|
|
41
|
+
distribute and/or modify the software.
|
|
42
|
+
|
|
43
|
+
Also, for each author's protection and ours, we want to make certain
|
|
44
|
+
that everyone understands that there is no warranty for this free
|
|
45
|
+
software. If the software is modified by someone else and passed on, we
|
|
46
|
+
want its recipients to know that what they have is not the original, so
|
|
47
|
+
that any problems introduced by others will not reflect on the original
|
|
48
|
+
authors' reputations.
|
|
49
|
+
|
|
50
|
+
Finally, any free program is threatened constantly by software
|
|
51
|
+
patents. We wish to avoid the danger that redistributors of a free
|
|
52
|
+
program will individually obtain patent licenses, in effect making the
|
|
53
|
+
program proprietary. To prevent this, we have made it clear that any
|
|
54
|
+
patent must be licensed for everyone's free use or not licensed at all.
|
|
55
|
+
|
|
56
|
+
The precise terms and conditions for copying, distribution and
|
|
57
|
+
modification follow.
|
|
58
|
+
|
|
59
|
+
GNU GENERAL PUBLIC LICENSE
|
|
60
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
61
|
+
|
|
62
|
+
0. This License applies to any program or other work which contains
|
|
63
|
+
a notice placed by the copyright holder saying it may be distributed
|
|
64
|
+
under the terms of this General Public License. The "Program", below,
|
|
65
|
+
refers to any such program or work, and a "work based on the Program"
|
|
66
|
+
means either the Program or any derivative work under copyright law:
|
|
67
|
+
that is to say, a work containing the Program or a portion of it,
|
|
68
|
+
either verbatim or with modifications and/or translated into another
|
|
69
|
+
language. (Hereinafter, translation is included without limitation in
|
|
70
|
+
the term "modification".) Each licensee is addressed as "you".
|
|
71
|
+
|
|
72
|
+
Activities other than copying, distribution and modification are not
|
|
73
|
+
covered by this License; they are outside its scope. The act of
|
|
74
|
+
running the Program is not restricted, and the output from the Program
|
|
75
|
+
is covered only if its contents constitute a work based on the
|
|
76
|
+
Program (independent of having been made by running the Program).
|
|
77
|
+
Whether that is true depends on what the Program does.
|
|
78
|
+
|
|
79
|
+
1. You may copy and distribute verbatim copies of the Program's
|
|
80
|
+
source code as you receive it, in any medium, provided that you
|
|
81
|
+
conspicuously and appropriately publish on each copy an appropriate
|
|
82
|
+
copyright notice and disclaimer of warranty; keep intact all the
|
|
83
|
+
notices that refer to this License and to the absence of any warranty;
|
|
84
|
+
and give any other recipients of the Program a copy of this License
|
|
85
|
+
along with the Program.
|
|
86
|
+
|
|
87
|
+
You may charge a fee for the physical act of transferring a copy, and
|
|
88
|
+
you may at your option offer warranty protection in exchange for a fee.
|
|
89
|
+
|
|
90
|
+
2. You may modify your copy or copies of the Program or any portion
|
|
91
|
+
of it, thus forming a work based on the Program, and copy and
|
|
92
|
+
distribute such modifications or work under the terms of Section 1
|
|
93
|
+
above, provided that you also meet all of these conditions:
|
|
94
|
+
|
|
95
|
+
a) You must cause the modified files to carry prominent notices
|
|
96
|
+
stating that you changed the files and the date of any change.
|
|
97
|
+
|
|
98
|
+
b) You must cause any work that you distribute or publish, that in
|
|
99
|
+
whole or in part contains or is derived from the Program or any
|
|
100
|
+
part thereof, to be licensed as a whole at no charge to all third
|
|
101
|
+
parties under the terms of this License.
|
|
102
|
+
|
|
103
|
+
c) If the modified program normally reads commands interactively
|
|
104
|
+
when run, you must cause it, when started running for such
|
|
105
|
+
interactive use in the most ordinary way, to print or display an
|
|
106
|
+
announcement including an appropriate copyright notice and a
|
|
107
|
+
notice that there is no warranty (or else, saying that you provide
|
|
108
|
+
a warranty) and that users may redistribute the program under
|
|
109
|
+
these conditions, and telling the user how to view a copy of this
|
|
110
|
+
License. (Exception: if the Program itself is interactive but
|
|
111
|
+
does not normally print such an announcement, your work based on
|
|
112
|
+
the Program is not required to print an announcement.)
|
|
113
|
+
|
|
114
|
+
These requirements apply to the modified work as a whole. If
|
|
115
|
+
identifiable sections of that work are not derived from the Program,
|
|
116
|
+
and can be reasonably considered independent and separate works in
|
|
117
|
+
themselves, then this License, and its terms, do not apply to those
|
|
118
|
+
sections when you distribute them as separate works. But when you
|
|
119
|
+
distribute the same sections as part of a whole which is a work based
|
|
120
|
+
on the Program, the distribution of the whole must be on the terms of
|
|
121
|
+
this License, whose permissions for other licensees extend to the
|
|
122
|
+
entire whole, and thus to each and every part regardless of who wrote it.
|
|
123
|
+
|
|
124
|
+
Thus, it is not the intent of this section to claim rights or contest
|
|
125
|
+
your rights to work written entirely by you; rather, the intent is to
|
|
126
|
+
exercise the right to control the distribution of derivative or
|
|
127
|
+
collective works based on the Program.
|
|
128
|
+
|
|
129
|
+
In addition, mere aggregation of another work not based on the Program
|
|
130
|
+
with the Program (or with a work based on the Program) on a volume of
|
|
131
|
+
a storage or distribution medium does not bring the other work under
|
|
132
|
+
the scope of this License.
|
|
133
|
+
|
|
134
|
+
3. You may copy and distribute the Program (or a work based on it,
|
|
135
|
+
under Section 2) in object code or executable form under the terms of
|
|
136
|
+
Sections 1 and 2 above provided that you also do one of the following:
|
|
137
|
+
|
|
138
|
+
a) Accompany it with the complete corresponding machine-readable
|
|
139
|
+
source code, which must be distributed under the terms of Sections
|
|
140
|
+
1 and 2 above on a medium customarily used for software interchange; or,
|
|
141
|
+
|
|
142
|
+
b) Accompany it with a written offer, valid for at least three
|
|
143
|
+
years, to give any third party, for a charge no more than your
|
|
144
|
+
cost of physically performing source distribution, a complete
|
|
145
|
+
machine-readable copy of the corresponding source code, to be
|
|
146
|
+
distributed under the terms of Sections 1 and 2 above on a medium
|
|
147
|
+
customarily used for software interchange; or,
|
|
148
|
+
|
|
149
|
+
c) Accompany it with the information you received as to the offer
|
|
150
|
+
to distribute corresponding source code. (This alternative is
|
|
151
|
+
allowed only for noncommercial distribution and only if you
|
|
152
|
+
received the program in object code or executable form with such
|
|
153
|
+
an offer, in accord with Subsection b above.)
|
|
154
|
+
|
|
155
|
+
The source code for a work means the preferred form of the work for
|
|
156
|
+
making modifications to it. For an executable work, complete source
|
|
157
|
+
code means all the source code for all modules it contains, plus any
|
|
158
|
+
associated interface definition files, plus the scripts used to
|
|
159
|
+
control compilation and installation of the executable. However, as a
|
|
160
|
+
special exception, the source code distributed need not include
|
|
161
|
+
anything that is normally distributed (in either source or binary
|
|
162
|
+
form) with the major components (compiler, kernel, and so on) of the
|
|
163
|
+
operating system on which the executable runs, unless that component
|
|
164
|
+
itself accompanies the executable.
|
|
165
|
+
|
|
166
|
+
If distribution of executable or object code is made by offering
|
|
167
|
+
access to copy from a designated place, then offering equivalent
|
|
168
|
+
access to copy the source code from the same place counts as
|
|
169
|
+
distribution of the source code, even though third parties are not
|
|
170
|
+
compelled to copy the source along with the object code.
|
|
171
|
+
|
|
172
|
+
4. You may not copy, modify, sublicense, or distribute the Program
|
|
173
|
+
except as expressly provided under this License. Any attempt
|
|
174
|
+
otherwise to copy, modify, sublicense or distribute the Program is
|
|
175
|
+
void, and will automatically terminate your rights under this License.
|
|
176
|
+
However, parties who have received copies, or rights, from you under
|
|
177
|
+
this License will not have their licenses terminated so long as such
|
|
178
|
+
parties remain in full compliance.
|
|
179
|
+
|
|
180
|
+
5. You are not required to accept this License, since you have not
|
|
181
|
+
signed it. However, nothing else grants you permission to modify or
|
|
182
|
+
distribute the Program or its derivative works. These actions are
|
|
183
|
+
prohibited by law if you do not accept this License. Therefore, by
|
|
184
|
+
modifying or distributing the Program (or any work based on the
|
|
185
|
+
Program), you indicate your acceptance of this License to do so, and
|
|
186
|
+
all its terms and conditions for copying, distributing or modifying
|
|
187
|
+
the Program or works based on it.
|
|
188
|
+
|
|
189
|
+
6. Each time you redistribute the Program (or any work based on the
|
|
190
|
+
Program), the recipient automatically receives a license from the
|
|
191
|
+
original licensor to copy, distribute or modify the Program subject to
|
|
192
|
+
these terms and conditions. You may not impose any further
|
|
193
|
+
restrictions on the recipients' exercise of the rights granted herein.
|
|
194
|
+
You are not responsible for enforcing compliance by third parties to
|
|
195
|
+
this License.
|
|
196
|
+
|
|
197
|
+
7. If, as a consequence of a court judgment or allegation of patent
|
|
198
|
+
infringement or for any other reason (not limited to patent issues),
|
|
199
|
+
conditions are imposed on you (whether by court order, agreement or
|
|
200
|
+
otherwise) that contradict the conditions of this License, they do not
|
|
201
|
+
excuse you from the conditions of this License. If you cannot
|
|
202
|
+
distribute so as to satisfy simultaneously your obligations under this
|
|
203
|
+
License and any other pertinent obligations, then as a consequence you
|
|
204
|
+
may not distribute the Program at all. For example, if a patent
|
|
205
|
+
license would not permit royalty-free redistribution of the Program by
|
|
206
|
+
all those who receive copies directly or indirectly through you, then
|
|
207
|
+
the only way you could satisfy both it and this License would be to
|
|
208
|
+
refrain entirely from distribution of the Program.
|
|
209
|
+
|
|
210
|
+
If any portion of this section is held invalid or unenforceable under
|
|
211
|
+
any particular circumstance, the balance of the section is intended to
|
|
212
|
+
apply and the section as a whole is intended to apply in other
|
|
213
|
+
circumstances.
|
|
214
|
+
|
|
215
|
+
It is not the purpose of this section to induce you to infringe any
|
|
216
|
+
patents or other property right claims or to contest validity of any
|
|
217
|
+
such claims; this section has the sole purpose of protecting the
|
|
218
|
+
integrity of the free software distribution system, which is
|
|
219
|
+
implemented by public license practices. Many people have made
|
|
220
|
+
generous contributions to the wide range of software distributed
|
|
221
|
+
through that system in reliance on consistent application of that
|
|
222
|
+
system; it is up to the author/donor to decide if he or she is willing
|
|
223
|
+
to distribute software through any other system and a licensee cannot
|
|
224
|
+
impose that choice.
|
|
225
|
+
|
|
226
|
+
This section is intended to make thoroughly clear what is believed to
|
|
227
|
+
be a consequence of the rest of this License.
|
|
228
|
+
|
|
229
|
+
8. If the distribution and/or use of the Program is restricted in
|
|
230
|
+
certain countries either by patents or by copyrighted interfaces, the
|
|
231
|
+
original copyright holder who places the Program under this License
|
|
232
|
+
may add an explicit geographical distribution limitation excluding
|
|
233
|
+
those countries, so that distribution is permitted only in or among
|
|
234
|
+
countries not thus excluded. In such case, this License incorporates
|
|
235
|
+
the limitation as if written in the body of this License.
|
|
236
|
+
|
|
237
|
+
9. The Free Software Foundation may publish revised and/or new versions
|
|
238
|
+
of the General Public License from time to time. Such new versions will
|
|
239
|
+
be similar in spirit to the present version, but may differ in detail to
|
|
240
|
+
address new problems or concerns.
|
|
241
|
+
|
|
242
|
+
Each version is given a distinguishing version number. If the Program
|
|
243
|
+
specifies a version number of this License which applies to it and "any
|
|
244
|
+
later version", you have the option of following the terms and conditions
|
|
245
|
+
either of that version or of any later version published by the Free
|
|
246
|
+
Software Foundation. If the Program does not specify a version number of
|
|
247
|
+
this License, you may choose any version ever published by the Free Software
|
|
248
|
+
Foundation.
|
|
249
|
+
|
|
250
|
+
10. If you wish to incorporate parts of the Program into other free
|
|
251
|
+
programs whose distribution conditions are different, write to the author
|
|
252
|
+
to ask for permission. For software which is copyrighted by the Free
|
|
253
|
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
|
254
|
+
make exceptions for this. Our decision will be guided by the two goals
|
|
255
|
+
of preserving the free status of all derivatives of our free software and
|
|
256
|
+
of promoting the sharing and reuse of software generally.
|
|
257
|
+
|
|
258
|
+
NO WARRANTY
|
|
259
|
+
|
|
260
|
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
|
261
|
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
|
262
|
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
|
263
|
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
|
264
|
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
265
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
|
266
|
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
|
267
|
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
|
268
|
+
REPAIR OR CORRECTION.
|
|
269
|
+
|
|
270
|
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
271
|
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
|
272
|
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
|
273
|
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
|
274
|
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
|
275
|
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
|
276
|
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
|
277
|
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
|
278
|
+
POSSIBILITY OF SUCH DAMAGES.
|
|
279
|
+
|
|
280
|
+
END OF TERMS AND CONDITIONS
|
|
281
|
+
|
|
282
|
+
How to Apply These Terms to Your New Programs
|
|
283
|
+
|
|
284
|
+
If you develop a new program, and you want it to be of the greatest
|
|
285
|
+
possible use to the public, the best way to achieve this is to make it
|
|
286
|
+
free software which everyone can redistribute and change under these terms.
|
|
287
|
+
|
|
288
|
+
To do so, attach the following notices to the program. It is safest
|
|
289
|
+
to attach them to the start of each source file to most effectively
|
|
290
|
+
convey the exclusion of warranty; and each file should have at least
|
|
291
|
+
the "copyright" line and a pointer to where the full notice is found.
|
|
292
|
+
|
|
293
|
+
<one line to give the program's name and a brief idea of what it does.>
|
|
294
|
+
Copyright (C) <year> <name of author>
|
|
295
|
+
|
|
296
|
+
This program is free software; you can redistribute it and/or modify
|
|
297
|
+
it under the terms of the GNU General Public License as published by
|
|
298
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
299
|
+
(at your option) any later version.
|
|
300
|
+
|
|
301
|
+
This program is distributed in the hope that it will be useful,
|
|
302
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
303
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
304
|
+
GNU General Public License for more details.
|
|
305
|
+
|
|
306
|
+
You should have received a copy of the GNU General Public License along
|
|
307
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
308
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
309
|
+
|
|
310
|
+
Also add information on how to contact you by electronic and paper mail.
|
|
311
|
+
|
|
312
|
+
If the program is interactive, make it output a short notice like this
|
|
313
|
+
when it starts in an interactive mode:
|
|
314
|
+
|
|
315
|
+
Gnomovision version 69, Copyright (C) year name of author
|
|
316
|
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
317
|
+
This is free software, and you are welcome to redistribute it
|
|
318
|
+
under certain conditions; type `show c' for details.
|
|
319
|
+
|
|
320
|
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
321
|
+
parts of the General Public License. Of course, the commands you use may
|
|
322
|
+
be called something other than `show w' and `show c'; they could even be
|
|
323
|
+
mouse-clicks or menu items--whatever suits your program.
|
|
324
|
+
|
|
325
|
+
You should also get your employer (if you work as a programmer) or your
|
|
326
|
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
|
327
|
+
necessary. Here is a sample; alter the names:
|
|
328
|
+
|
|
329
|
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
|
330
|
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
|
331
|
+
|
|
332
|
+
<signature of Ty Coon>, 1 April 1989
|
|
333
|
+
Ty Coon, President of Vice
|
|
334
|
+
|
|
335
|
+
This General Public License does not permit incorporating your program into
|
|
336
|
+
proprietary programs. If your program is a subroutine library, you may
|
|
337
|
+
consider it more useful to permit linking proprietary applications with the
|
|
338
|
+
library. If this is what you want to do, use the GNU Lesser General
|
|
339
|
+
Public License instead of this License.
|