示例#1
1
	def bindKeys(self):
		self._keyBindings.append(vizact.onkeydown('o', model.proxManager.setDebug, viz.TOGGLE)) #debug shapes
		self._keyBindings.append(vizact.onkeydown(' ', self.grab)) #space select
		self._keyBindings.append(vizact.onkeydown('65421', self.grab)) #numpad enter select
		self._keyBindings.append(vizact.onkeydown(viz.KEY_ALT_R, self.snapCheck))
		self._keyBindings.append(vizact.onkeydown(viz.KEY_ALT_L, self.snapCheck))
		self._keyBindings.append(vizact.onkeyup(' ', self.release))
		self._keyBindings.append(vizact.onkeyup('65421', self.release))
		self._keyBindings.append(vizact.onkeydown('65460', self.viewcube.toggleModes)) # Numpad '4' key
		self._keyBindings.append(vizact.onkeydown(viz.KEY_CONTROL_R, self.solve))
	def setAsMain(self):
		viz.logStatus("""Setting KeyboardMouse as main""")
		
#		self.VIEW_LINK.preTrans([0,-self.EYE_HEIGHT,0])
		
		viz.mouse.setOverride(viz.ON) 
		viz.fov(self.FOV)

#		self.MOVE_SPEED = 2
		
		vizact.ontimer(0,self.updateView)
		vizact.onkeyup(self.KEYS['reset'],self.reset)
		
		def onMouseMove(e):
			euler = self.VIEW.getEuler(viz.HEAD_ORI)
			euler[0] += e.dx*0.05
			euler[1] += -e.dy*0.05
			euler[1] = viz.clamp(euler[1],-85.0,85.0)
			self.VIEW.setEuler(euler,viz.HEAD_ORI)
		viz.callback(viz.MOUSE_MOVE_EVENT, onMouseMove)	
示例#3
0
t3.start()
t4.start()

print("\n")
print("press 'q' to stop")


def TargetUpdate(arg):
    global target
    target = target + .05


def KepPressDetector(arg):
    global PSYCHO
    PSYCHO = arg
    prompt4TwoChoice.visible(0)


vizact.onkeydown(
    'q', raisestop, 'biggle'
)  #biggle is meaningless, just need to pass something into the raisestop callback
###################### CJS 12/17/2016 ######################
''' This will take the ibnput from the Logitech to indicate if the first or the second trial was longer'''
vizact.onkeydown('65366', KepPressDetector, 1)  # Second trial was longer
vizact.onkeyup('65366', KepPressDetector, 0)  #No longer indicating anything
vizact.onkeydown('65365', KepPressDetector, -1)  # First trial was longer
vizact.onkeyup('65365', KepPressDetector, 0)  #No longer indicating anything
print('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^')
print('^^^^^^^^^^^^^^^^^^Key Press^^^^^^^^^^^^^^')
print('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^')
############################################################
	def setAsMain(self):
		self.MOVE_SPEED = 2.0	

		vizact.ontimer(0,self.updateView)
		vizact.onkeyup(self.KEYS['reset'], self.reset)
t4.daemon = True
#start the threads
t1.start()
t2.start()
t3.start()
t4.start()
	
print("\n")
print("press 'q' to stop")

def TargetUpdate(arg):
	global target
	target=target+.05
	
def KepPressDetector(arg):
	global PSYCHO
	PSYCHO=arg
	prompt4TwoChoice.visible(0)


vizact.onkeydown('q',raisestop,'biggle')#biggle is meaningless, just need to pass something into the raisestop callback
###################### CJS 12/17/2016 ###################### 
''' This will take the ibnput from the Logitech to indicate if the first or the second trial was longer'''
vizact.onkeydown('65366',KepPressDetector, 1) # Second trial was longer
vizact.onkeyup('65366',KepPressDetector, 0) #No longer indicating anything
vizact.onkeydown('65365',KepPressDetector, -1) # First trial was longer
vizact.onkeyup('65365',KepPressDetector, 0) #No longer indicating anything
print('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^')
print('^^^^^^^^^^^^^^^^^^Key Press^^^^^^^^^^^^^^')
print('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^')
############################################################ 
root = ''#empty string
savestring = ''
speedlist = array.array('i')
q = Queue.Queue()#initialize the queue
qq = Queue.Queue()#another queue for treadmill commands
q3 = Queue.Queue()#intialize another queue for saving data
#create threads for client
t1 = threading.Thread(target=runclient,args=(root,q))
t2 = threading.Thread(target=UpdateViz,args=(root,q,speedlist,qq,savestring,q3))
t3 = threading.Thread(target=sendtreadmillcommand,args=(speedlist,qq))
t4 = threading.Thread(target=savedata,args=(savestring,q3))
t1.daemon = True
t2.daemon = True
t3.daemon = True
t4.daemon = True
#start the threads
t1.start()
t2.start()
t3.start()
t4.start()
	
print("\n")
print("press 'q' to stop")

def TargetUpdate(arg):
	global target
	target=target+.05

vizact.onkeydown('q',raisestop,'biggle')#biggle is meaningless, just need to pass something into the raisestop callback
vizact.onkeyup('65366',TargetUpdate, 'biggle')
示例#7
0
#	trackerLink.preEuler([0,0,0])
#	trackerLink.postTrans([.5,-.2,0])
	
#	trackerLink.setPosition([0,5,1])
#	vizact.ontimer(0,updateClampedPos)
#	vizact.ontimer(0,updateHand,tracker)
#	arrowLink = viz.link(tracker,highlighter)
#	arrowLink.postMultLinkable(navigator.VIEW)
#	arrowLink = viz.link(tracker,arrow)
#	arrowLink = viz.link(arrow,highlighter)
#	arrowLink.preMultLinkable(viz.MainView)
#	arrowLink.preMultLinkable(navigator.VIEW)
#	arrowLink.postMultLinkable(navigator.VIEW)
#	vizact.ontimer(0,updateHand,arrow)
#	vizact.ontimer(0,updateArrow,trackerLink,arrow)
	
	canvas = viz.addGUICanvas(align=viz.ALIGN_CENTER)
	viz.MainWindow.setDefaultGUICanvas(canvas)
	canvas.setRenderWorld([600,400],[2,viz.AUTO_COMPUTE])
	canvas.setMouseStyle(viz.CANVAS_MOUSE_BUTTON | viz.CANVAS_MOUSE_VISIBLE)
	panel = vizdlg.TabPanel(parent=canvas,align=viz.ALIGN_CENTER)
	panel_A = vizdlg.Panel()
	panel_B = vizdlg.Panel()
	tab_A = panel.addPanel('Tab A',panel_A)
	tab_B = panel.addPanel('Tab B',panel_B)
	canvas.setPosition(0,2,3)
	
	vizact.ontimer(0,updateMousePosition,canvas,highlighter.getRayCaster())
	vizact.onkeyup(' ',toggleMenu,node=navigator.NODE,menu=canvas)
	
	viz.addChild('maze.osgb')
示例#8
0
def collisionTempDeactivate():
	keys = [viz.KEY_KP_1, viz.KEY_KP_2, viz.KEY_KP_1]
	for p in gPlayers.keys():
		vizact.onkeydown(keys[p-1], gPlayers[p]['player']._view.collision, 0)
		vizact.onkeyup(keys[p-1], gPlayers[p]['player']._view.collision, 1)
	def __init__(self):		
		# --Key commands
		KEYS = { 'forward'	: 'w'
				,'back' 	: 's'
				,'left' 	: 'a'
				,'right'	: 'd'
				,'reset'	: 'r'
				,'camera'	: 'c'
		}
	
		# --add oculus as HMD
		self.hmd = oculus.Rift()
		
		if not self.hmd.getSensor():
		#	sys.exit('Oculus Rift not detected')
			print('Oculus Rift not detected')
			return None
		else:
			# Reset HMD orientation
			self.hmd.getSensor().reset()
			
			# Setup heading reset key
			vizact.onkeyup(KEYS['reset'], self.hmd.getSensor().reset)

			# Check if HMD supports position tracking
			self.supportPositionTracking = self.hmd.getSensor().getSrcMask() & viz.LINK_POS
			if self.supportPositionTracking:

				# Add camera bounds model
				camera_bounds = self.hmd.addCameraBounds()
				camera_bounds.visible(False)

				# Change color of bounds to reflect whether position was tracked
				def CheckPositionTracked():
					if self.hmd.getSensor().getStatus() & oculus.STATUS_POSITION_TRACKED:
						camera_bounds.color(viz.GREEN)
					else:
						camera_bounds.color(viz.RED)
				vizact.onupdate(0, CheckPositionTracked)

				# Setup camera bounds toggle key
				def toggleBounds():
					camera_bounds.visible(viz.TOGGLE)
					camera_toggle.set(camera_bounds.getVisible())
				vizact.onkeydown(KEYS['camera'], toggleBounds)
				
			# Setup navigation node and link to main view
			self.navigationNode = viz.addGroup()
			self.viewLink = viz.link(self.navigationNode, viz.MainView)
			self.viewLink.preMultLinkable(self.hmd.getSensor())

			# --Apply user profile eye height to view
			profile = self.hmd.getProfile()
			if profile:
				self.viewLink.setOffset([0,profile.eyeHeight,0])
			else:
				self.viewLink.setOffset([0,1.8,0])
			# --Setup arrow key navigation
			MOVE_SPEED = 2.0
			def UpdateView():
				yaw,pitch,roll = self.viewLink.getEuler()
				m = viz.Matrix.euler(yaw,0,0)
				dm = viz.getFrameElapsed() * MOVE_SPEED
				if viz.key.isDown(KEYS['forward']):
					m.preTrans([0,0,dm])
				if viz.key.isDown(KEYS['back']):
					m.preTrans([0,0,-dm])
				if viz.key.isDown(KEYS['left']):
					m.preTrans([-dm,0,0])
				if viz.key.isDown(KEYS['right']):
					m.preTrans([dm,0,0])
				self.navigationNode.setPosition(m.getPosition(), viz.REL_PARENT)
			vizact.ontimer(0,UpdateView)