def __init__(self, fig): self.canvasData = viz.Data(lock = threading.Lock(), havenewData=False ) self.fig = fig self.t = threading.Thread(target=self.computeFigureThread) self.t.start() #IMPORTANT: Wait for thread to finish before exiting vizact.onexit(self.t.join) #Create a blank texture to display canvas data self.tex = viz.addBlankTexture([1,1]) #Create onscreen quad to display texture self.quad = viz.addTexQuad(parent=viz.ORTHO,texture=self.tex) self.quad.alpha(0.5) self.link = viz.link(viz.MainWindow.CenterCenter,self.quad) # self.link.setOffset([400,200,0]) self.drawer = vizact.ontimer(0, self.drawPlot) self.rate_ctr = time.time() self.drawrate_txt = viz.addText('', viz.SCREEN) self.drawrate_txt.setPosition(0,0.01) self.drawrate_txt.scale(.7,.7) self.drawrate_txt.color(viz.WHITE) self.drawrate_txt.visible(0) self.rate = 0 #scale variables to change size of plot image self.scale_x = 1 self.scale_y = 1
def __init__(self, fig): self.canvasData = viz.Data(lock=threading.Lock(), havenewData=False) self.fig = fig self.t = threading.Thread(target=self.computeFigureThread) self.t.start() #IMPORTANT: Wait for thread to finish before exiting vizact.onexit(self.t.join) #Create a blank texture to display canvas data self.tex = viz.addBlankTexture([1, 1]) #Create onscreen quad to display texture self.quad = viz.addTexQuad(parent=viz.ORTHO, texture=self.tex) self.quad.alpha(0.5) self.link = viz.link(viz.MainWindow.CenterCenter, self.quad) # self.link.setOffset([400,200,0]) self.drawer = vizact.ontimer(0, self.drawPlot) self.rate_ctr = time.time() self.drawrate_txt = viz.addText('', viz.SCREEN) self.drawrate_txt.setPosition(0, 0.01) self.drawrate_txt.scale(.7, .7) self.drawrate_txt.color(viz.WHITE) self.drawrate_txt.visible(0) self.rate = 0 #scale variables to change size of plot image self.scale_x = 1 self.scale_y = 1
def main(): ### Configuration parameters # moved to config.py ### Game startup #overwrite escape key viz.setOption('viz.default_key.quit','0') # Physics viz.phys.enable() #viz.phys.setGravity(0,0,0) # Initialize pointer tool # Unused? glove = viz.addChild('.\\dataset\\Hand\\handPoint_Reduced.ply') glove.disable([viz.PHYSICS, viz.DYNAMICS]) glovePhys = glove.collideSphere() glove.setPosition([0,1,0]) glove.setScale([1,1,1]) # Initialize environment this will load the coliseum and sky sky = viz.addChild('sky_day.osgb') sky.collideMesh() sky.disable(viz.DYNAMICS) init.loadTemple() # Initialize pointer controls device = init.pointerInput(config.pointerMode, glove, sky) # Initialize display puzzle.model.display = init.DisplayInstance(config.dispMode,config.camMode,device,glove) #init.display(config.dispMode) # Initialize camera controls #init.cameraInput(config.camMode,config.dispMode, device, glove) # Launch menu system menu.init() puzzle.model.pointer = glove puzzle.model.pointer.setScale(0.015, 0.015, 0.015) puzzle.model.pointer.setEuler(0, -115, 0) # Override default escape key map to call main menu vizact.onkeydown(viz.KEY_ESCAPE, menu.toggle) # # Record moviefilms # viz.setOption('viz.AVIRecorder.maxWidth', '1280') # viz.setOption('viz.AVIRecorder.maxHeight', '720') # vizact.onkeydown(viz.KEY_F11, viz.window.startRecording, 'D:\\recording.avi') # vizact.onkeydown(viz.KEY_F12, viz.window.stopRecording) # Stuff to run on program termination vizact.onexit(puzzle.controller.end)
def main(): ### Configuration parameters # moved to config.py ### Game startup # overwrite escape key viz.setOption("viz.default_key.quit", "0") # Physics viz.phys.enable() # viz.phys.setGravity(0,0,0) # Initialize pointer tool # Unused? glove = viz.addChild(".\\dataset\\Hand\\handPoint_Reduced.ply") glove.disable([viz.PHYSICS, viz.DYNAMICS]) glovePhys = glove.collideSphere() glove.setPosition([0, 1, 0]) glove.setScale([1, 1, 1]) # Initialize environment this will load the coliseum and sky sky = viz.addChild("sky_day.osgb") sky.collideMesh() sky.disable(viz.DYNAMICS) init.loadTemple() # Initialize pointer controls device = init.pointerInput(config.pointerMode, glove, sky) # Initialize display puzzle.model.display = init.DisplayInstance(config.dispMode, config.camMode, device, glove) # init.display(config.dispMode) # Initialize camera controls # init.cameraInput(config.camMode,config.dispMode, device, glove) # Launch menu system menu.init() puzzle.model.pointer = glove puzzle.model.pointer.setScale(0.015, 0.015, 0.015) puzzle.model.pointer.setEuler(0, -115, 0) # Override default escape key map to call main menu vizact.onkeydown(viz.KEY_ESCAPE, menu.toggle) # # Record moviefilms # viz.setOption('viz.AVIRecorder.maxWidth', '1280') # viz.setOption('viz.AVIRecorder.maxHeight', '720') # vizact.onkeydown(viz.KEY_F11, viz.window.startRecording, 'D:\\recording.avi') # vizact.onkeydown(viz.KEY_F12, viz.window.stopRecording) # Stuff to run on program termination vizact.onexit(puzzle.controller.end)
def __init__(self): threading.Thread.__init__(self) self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP self.sock.bind((self.UDP_IP, self.UDP_PORT)) # event for stopping UDP listener self._stopEvent = threading.Event() # stop UDP listener on exit vizact.onexit(self.stop)
def __connectWiiMote(self): wii = viz.add('wiimote.dle')#Add wiimote extension # Replace old wiimote if( self.wiimote ): print 'Wiimote removed.' self.wiimote.remove() self.wiimote = wii.addWiimote()# Connect to first available wiimote vizact.onexit(self.wiimote.remove) # Make sure it is disconnected on quit self.wiimote.led = wii.LED_1 | wii.LED_4 #Turn on leds to show connection
def _connectWiiMote(self): wii = viz.add('wiimote.dle') #Add wiimote extension # Replace old wiimote if (self.wiimote): print 'Wiimote removed.' self.wiimote.remove() self.wiimote = wii.addWiimote() # Connect to first available wiimote vizact.onexit( self.wiimote.remove) # Make sure it is disconnected on quit self.wiimote.led = wii.LED_1 | wii.LED_4 #Turn on leds to show connection
def __init__(self, bldList): self.info = PointInfo() self.buildings = bldList self.trials = [] self.cTrial = None self.trialCtr = -1 self.trgAngle = None self.hideBuildings() self.trialData = {} # add vertex to measure true target angel viz.startLayer(viz.POINTS) viz.vertexColor(1,0,0) viz.pointSize(30) viz.vertex(0,0,0) self.refVert = viz.endLayer() self.refVert.disable(viz.RENDERING) # add grid to orient subject during # pointing viz.startLayer(viz.LINES) viz.lineWidth(6) viz.vertexColor(0,0.6,0) viz.vertex(-100, 0.01, 0) viz.vertex( 100, 0.01, 0) viz.vertex( 0, 0.01,-100) viz.vertex( 0, 0.01, 100) self.cross90 = viz.endLayer() self.cross90.visible(viz.OFF) self.grid = vizshape.addGrid(size=[200,200], step=10.0, boldStep=None) self.grid.color([0,.6,0]) self.grid.visible(viz.OFF) # add logger self.fields2log = {'trialNr' : 'i8', 'srcBuilding' : 'S10', 'trgBuilding' : 'S10', 'refAngle' : 'f4', 'measAngle' : 'f4', 'trueAngle' : 'f4', 'trialOnset' : 'f8', 'tChoiceMade' : 'f8', 'srcXZ' : [('x', 'f4'), ('z', 'f4')], 'trgXZ' : [('x', 'f4'), ('z', 'f4')], 'srcCtxt' : 'S1', 'trgCtxt' :'S1'} self.logHdl = lg.LogData(self.fields2log) # handle exit vizact.onexit( self.saveOnExit )
#Torch keydown functions vizact.onkeydown('v', torchy.changeBrightness, 1) vizact.onkeydown('c', torchy.changeBrightness, -1) #Screen recording keydown functions vizact.onkeydown('p', viz.window.toggleRecording, 'test.avi') vizact.onkeydown('o', viz.window.stopRecording) ################################ Wii ################################################# #Wiimote extension wii = viz.add('wiimote.dle') wiimote = wii.addWiimote() wiimote.led = wii.LED_1 | wii.LED_4 #when program closes/Wiimote disconnects vizact.onexit(wiimote.remove) ##mask Wiimote 1 & 2 to turn on or off the light vizact.onsensordown(wiimote, wii.BUTTON_1, torchy.mylight.enable) vizact.onsensordown(wiimote, wii.BUTTON_2, torchy.mylight.disable) #mask Wiimote + & - to dim or brighten the light to a limit vizact.onsensordown(wiimote, wii.BUTTON_MINUS, torchy.changeBrightness, -3) vizact.onsensordown(wiimote, wii.BUTTON_PLUS, torchy.changeBrightness, 3) ############################### Mocap ################################################# from mocapInterfaceNew import mocapInterface phaseSpaceIP = '192.168.1.230' owlParamMarkerCount = 20 # Dir where textures and rb files are located
def __init__(self): self.wiimote = wii.addWiimote()# Connect to first available wiimote vizact.onexit(self.wiimote.remove) # Make sure it is disconnected on quit self.wiimote.led = wii.LED_1 | wii.LED_4 #Turn on leds to show connection
for dn, f in zip(['D','N'],['day.png','night.png']): g = setStage(f) grounds[dn] = g backgrounds = {'D':viz.SKYBLUE, 'N':viz.BLACK} #load playback autofiles = {} for yr in yawrates: auto_fn = str(yr) playback = OpenTrial(auto_fn) autofiles[auto_fn] = playback wheel = LoadAutomationModules() wheel.FF_on(1) # set to zero to turn off force feedback vizact.onexit(CloseConnections, wheel) ## add participant interaction pp_id = viz.input('Participant code: ') #add participant code try: pp_id = int(pp_id) except: raiseandquit("invalid pp code") block = viz.input('Block: ') #add block number try: block = int(block) if block not in [1,2,3,4]: raiseandquit("invalid block number") except: raiseandquit("invalid block number")
def start(): """ Run everything necessary for game startup """ # Physics viz.phys.enable() ### Initialize pointer tool model.pointer = viz.addChild('.\\dataset\\Hand\\handPoint_reduced.ply') pointer = model.pointer pointer.setScale(0.012, 0.012, 0.012) pointer.setEuler(0, -115, 0) pointer.disable([viz.PHYSICS, viz.DYNAMICS]) # ### Alpha slice plane setup # viz.startLayer(viz.POINTS) # viz.vertex(0,0,0) # planeVert = viz.endLayer(parent = pointer) # planeVert.dynamic() # # # Setup normal vector for alpha slicing plane calculation # planeVert.setNormal(0,[0,1,0]) # model.planeVert = planeVert # slicePlane = vizshape.addPlane(size = [20, 20, 20], parent = pointer, cullFace = False) # slicePlane.alpha(0.20) # slicePlane.color(viz.ORANGE) ### Initialize environment this will load the coliseum and sky sky = viz.addChild('gallery.osgb') sky.setPosition([0, 0, -5]) sky.collideMesh() sky.disable(viz.DYNAMICS) # Lighting lights = [] [lights.append(viz.addLight()) for _ in range(2)] lights[0].setEuler(90, 40, 0) lights[0].intensity(0.5) lights[1].setEuler(270, 40, 0) lights[1].intensity(0.3) # Initialize pointer controls device = init.pointerInput(config.pointerMode, pointer, sky) ### Initialize display model.display = init.DisplayInstance(config.dispMode,config.camMode,device,pointer) ### Launch menu system model.menu = menu.MenuController() ### Override escape key to toggle menu viz.setOption('viz.default_key.quit','0') # # Record moviefilms # viz.setOption('viz.AVIRecorder.maxWidth', '1280') # viz.setOption('viz.AVIRecorder.maxHeight', '720') # vizact.onkeydown(viz.KEY_F11, viz.window.startRecording, 'D:\\recording.avi') # vizact.onkeydown(viz.KEY_F12, viz.window.stopRecording) # Stuff to run on program termination vizact.onexit(endGame)
def start(): """ Run everything necessary for game startup """ # Physics viz.phys.enable() ### Initialize pointer tool model.pointer = viz.addChild('.\\dataset\\Hand\\handPoint_reduced.ply') pointer = model.pointer pointer.setScale(0.012, 0.012, 0.012) pointer.setEuler(0, -115, 0) pointer.disable([viz.PHYSICS, viz.DYNAMICS]) # ### Alpha slice plane setup # viz.startLayer(viz.POINTS) # viz.vertex(0,0,0) # planeVert = viz.endLayer(parent = pointer) # planeVert.dynamic() # # # Setup normal vector for alpha slicing plane calculation # planeVert.setNormal(0,[0,1,0]) # model.planeVert = planeVert # slicePlane = vizshape.addPlane(size = [20, 20, 20], parent = pointer, cullFace = False) # slicePlane.alpha(0.20) # slicePlane.color(viz.ORANGE) ### Initialize environment this will load the coliseum and sky sky = viz.addChild('gallery.osgb') sky.setPosition([0, 0, -5]) sky.collideMesh() sky.disable(viz.DYNAMICS) # Lighting lights = [] [lights.append(viz.addLight()) for _ in range(2)] lights[0].setEuler(90, 40, 0) lights[0].intensity(0.5) lights[1].setEuler(270, 40, 0) lights[1].intensity(0.3) # Initialize pointer controls device = init.pointerInput(config.pointerMode, pointer, sky) ### Initialize display model.display = init.DisplayInstance(config.dispMode, config.camMode, device, pointer) ### Launch menu system model.menu = menu.MenuController() ### Override escape key to toggle menu viz.setOption('viz.default_key.quit', '0') # # Record moviefilms # viz.setOption('viz.AVIRecorder.maxWidth', '1280') # viz.setOption('viz.AVIRecorder.maxHeight', '720') # vizact.onkeydown(viz.KEY_F11, viz.window.startRecording, 'D:\\recording.avi') # vizact.onkeydown(viz.KEY_F12, viz.window.stopRecording) # Stuff to run on program termination vizact.onexit(endGame)