Commit d0ffb5c1 authored by Taddeus Kroes's avatar Taddeus Kroes

Sterted integration of MultitouchServer with VTK.

parent 0a8bc7fc
import vtk
from threading import Thread
from objreader import read_obj
from touch import MultitouchServer
class MultitouchInteractor():
def __init__(self):
self.iren = vtk.vtkRenderWindowInteractor()
self.touch_server = MultitouchServer(verbose=1, tuio_verbose=1)
self.touch_server.bind('rotate', self.on_rotate)
self.touch_server.bind('pinch', self.on_pinch)
self.touch_server.bind('tap', self.on_tap)
def SetRenderWindow(self, window):
self.iren.SetRenderWindow(window)
self.window = window
def Initialize(self):
self.iren.Initialize()
def Start(self):
#self.iren.Start()
#t = Thread(target=self.iren.Start)
#t.daemon = True
#t.start()
self.touch_server.start(threaded=True, daemon=True)
try:
import time
while True:
self.window.Render()
time.sleep(1. / 60)
except KeyboardInterrupt:
return
def SetCamera(self, camera):
self.camera = camera
def on_rotate(self, event):
self.camera.Roll(event.angle)
def on_pinch(self, event):
pass
def on_tap(self, event):
print 'tap:', event
if __name__ == '__main__':
# Create render window and interactor
ren = vtk.vtkRenderer()
win = vtk.vtkRenderWindow()
win.AddRenderer(ren)
mt = MultitouchInteractor()
mt.SetRenderWindow(win)
# Read OBJ file
cubemapper = read_obj('cube.obj')
# Create actor
cubeactor = vtk.vtkActor()
cubeactor.SetMapper(cubemapper)
ren.AddActor(cubeactor)
mt.Initialize()
mt.SetCamera(ren.GetActiveCamera())
win.Render()
mt.Start()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment