ya2 · news · projects · code · about

better arrangement of the side panel
[pmachines.git] / pmachines / items / background.py
... / ...
CommitLineData
1from itertools import product
2from panda3d.core import NodePath
3
4
5class Background:
6
7 def __init__(self):
8 root = NodePath('background_root')
9 root.reparent_to(render)
10 ncols, nrows = 16, 8
11 start_size, end_size = 5, 2.5
12 offset = 5
13 for col, row in product(range(ncols), range(nrows)):
14 model = loader.load_model('assets/gltf/background/background.gltf')
15 model.set_scale(end_size / start_size)
16 model.reparent_to(root)
17 total_width, total_height = end_size * ncols, end_size * nrows
18 left, bottom = -total_width/2, -total_height/2
19 model.set_pos(left + end_size * col, offset, bottom + end_size * row)
20 root.clear_model_nodes()
21 root.flatten_strong()