View:
id: rendering
canvas.before:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
scene: 'skateboard.obj'
obj_scale: 3
display_all: True
#ambiant: 0.5
#diffuse: 0.5
#specular: 0.5
mode: 'triangles'
#light_radius: 10
#nb_lights: 7
#move_light: True
cam_mode: 'quaternions'
cam_rotation: quat_to_matrix(root.sensor.quaternions.get())
cam_translation: 0, 0, -8
light_sources:
{
x: ([float(y) * 10 - 5 for y in bin(x)[2:].rjust(3, '0')] + [1.0])
for x in range(8)
}
quaternions = ObjectProperty()
And then in init of the sensor class:
self.quaternions = Queue()
self.quaternions.put([1,0,0,0])
So won't this do the binding automatically? Thanks for your help, I'll try setting up a trigger first, that puts the new data in rendering.cam_rotation whenever new data is there.
def on_cam_rotation(self, *args):
...some alternative modes...
elif self.cam_mode == 'quaternions':
m = Matrix()
m.set(self.cam_rotation)
self.cam_rot.matrix = m
def update_ui(self, *args):
"""Scheduled with Clock
"""
# another thread calculates quaternions and puts them in the queue, so I get always the latest here, right?
new_quat = self.sensor.quaternions.get()
self.rendering.cam_rotation = quat_to_matrix(new_quat)