-
Notifications
You must be signed in to change notification settings - Fork 0
/
layout.py
33 lines (25 loc) · 900 Bytes
/
layout.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Load, render and simulate structured layouts of LED boards
import yaml
from OpenGL.GL import *
from board import Board
class Layout(object):
def __init__(self, name):
self.name = name
with file("layouts/%s.yaml" % name) as config_file:
self.config = yaml.load(config_file)
# Set up boards
self.boards = {}
for board in self.config['boards']:
self.boards[board['id']] = Board(board['type'], board['id'])
def update(self, time_offset):
for board in self.config['boards']:
self.boards[board['id']].update(time_offset)
def render(self):
for board in self.config['boards']:
glPushMatrix()
glTranslatef(board['translate']['x'], board['translate']['y'], board['translate']['z'])
glRotatef(board['rotate']['r'], 0, 0, 1)
glRotatef(board['rotate']['p'], 1, 0, 0)
glRotatef(board['rotate']['y'], 0, 1, 0)
self.boards[board['id']].render()
glPopMatrix()