File: multiview.py

package info (click to toggle)
glitch 0.6-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 488 kB
  • ctags: 649
  • sloc: python: 3,432; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 1,133 bytes parent folder | download | duplicates (2)
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
34
35
36
37
38
39
40
41
42
43

import gobject
import gtk

import glitch, glitch.gtk
from glitch.limbo.lights import LightSwitch, AmbientLight
from glitch.limbo.material import Material
from glitch.limbo.objects import Cube

def tick():
    global theta
    theta = (theta + 5) % 360
    rotate.angle = theta
    view1.refresh()
    view2.refresh()
    view3.refresh()
    return True

if __name__ == '__main__':
    theta = 0
    rotate = glitch.Rotate(y=1, children=[Cube()])
    scene = LightSwitch(children=[
        AmbientLight(2, 2, 2, children=[
            Material(1.0, 0.5, 0.5, children=[rotate])])])

    w = gtk.Window()
    box = gtk.HBox()
    box.props.spacing = 1
    # XXX: views don't share textures
    view1 = glitch.gtk.GtkCamera(eye=[0, 0, 2], children=[scene])
    view2 = glitch.gtk.GtkCamera(eye=[0, 2, 0.01], children=[scene])
    view3 = glitch.gtk.GtkCamera(eye=[1.5, 1.5, 1.5], children=[scene])

    w.add(box)
    box.pack_start(view1, True)
    box.pack_start(view2, True)
    box.pack_start(view3, True)
    w.show_all()

    gobject.timeout_add(1000/30, tick)
    w.connect('destroy', lambda w: gtk.main_quit())
    gtk.main()