示例#1
0
 def GetInput(self):
     input = None
     if self.joystick:
         delta_x, delta_y, buttons = sid.get()
         if abs(delta_x) > self.epsilon or abs(delta_y) > self.epsilon:
             input = 'JS'
             speed = self.NormalizeJoystickPosition(self.JOYSTICK_CENTER_Y -
                                                    delta_y)
             rotspeed = self.NormalizeJoystickPosition(
                 self.JOYSTICK_CENTER_X - delta_x)
     if not input and self.mouse and viz.buttonstate(
     ) & viz.MOUSEBUTTON_LEFT:
         delta_y, delta_x = viz.mousepos()
         if delta_x or delta_y:
             input = 'MS'
             speed = 2 * (delta_x - 0.5)
             rotspeed = -1 * (delta_y - 0.5)
     if not input and self.keyboard:
         delta_x = delta_y = 0
         if viz.iskeydown(viz.KEY_LEFT): delta_y = 1
         if viz.iskeydown(viz.KEY_RIGHT): delta_y = -1
         if viz.iskeydown(viz.KEY_DOWN): delta_x = -1
         if viz.iskeydown(viz.KEY_UP): delta_x = 1
         if delta_x or delta_y:
             input = 'KB'
             speed = delta_x * 2.0
             rotspeed = delta_y * 0.75
     if not input: return 0, 0
     #print 'JoyStick.GetInput::', input, speed, rotspeed,
     #print self.fwdDistance,self.bwdDistance,self.rtDistance,self.ltDistance
     speed *= self.CONVERT_SPEED
     rotspeed *= -self.CONVERT_ROTSPEED
     return speed, rotspeed
示例#2
0
 def _camUpdate( self, e ):
     #Check keyboard movement
     if viz.iskeydown ('w' ):
         #move forward the amout of time in seconds sence the last call to _camUpdate
         e.view.move( [0, 0, e.elapsed * 10] )
     elif viz.iskeydown ('s' ):
         #move backward the amout of time in seconds sence the last call to _camUpdate
         e.view.move( [0, 0, -e.elapsed * 10] )
     elif viz.iskeydown ('a') and viz.iskeydown("w"):
         #move backward the amout of time in seconds sence the last call to _camUpdate
         e.view.move( [ -e.elapsed * 10, 0,-e.elapsed * 10] )
	def	downPressed(self):
		"""Virtual function to use keyboard if indicated.
		
		This function can be omitted.
		If this function is omitted, the wiimote will always be used.
		"""
		if self.use_keyboard:
			return viz.iskeydown(viz.KEY_DOWN)#keyboard input
		
		return caveapp.CaveApplication.downPressed(self) #wiimote input
	def	joystick(self):
		"""Virtual function to use keyboard if indicated.
		
		This function can be omitted.
		If this function is omitted, the wiimote will always be used.
		"""
		if self.use_keyboard:
			
			#keyboard input
			
			result = [0.0,0.0]
			
			if viz.iskeydown('['): 
				result[0] -= 1.0
				
			if viz.iskeydown(']'): 
				result[0] += 1.0
				
			return result
		
		return caveapp.CaveApplication.joystick(self) #wiimote input
示例#5
0
	def	joystick(self):
		"""Virtual function to use keyboard if indicated.
		
		This function can be omitted.
		If this function is omitted, the wiimote will always be used.
		"""
		
		# Warning: this function is called using polling!
		
		if self.use_keyboard:
			result = [0.0,0.0,0.0]
			
			if viz.iskeydown('a'): 
				result[0] -= 1.0
				
			if viz.iskeydown('d'): 
				result[0] += 1.0
				
			#if viz.iskeydown('q'): 
				#result[1] -= 1.0
				
			#if viz.iskeydown('e'): 
				#result[1] += 1.0
				
			if viz.iskeydown('s'): 
				result[2] -= 1.0
				
			if viz.iskeydown('w'): 
				result[2] += 1.0
				
			if viz.iskeydown('p'): 
				print self.cavelib.getOriginTracker().getPosition()
				
			if viz.iskeydown('r'):
				self.speed = self.speed * 1.01
				
			if viz.iskeydown('f'):
				self.speed = self.speed * 0.99
				
			return result
		
		return caveapp.CaveApplication.joystick(self) #wiimote input
示例#6
0
	def userView(self):
		"""Do we need to show user view.
		
		You can override this function if you want to use a different key/input device for this.
		"""
		return viz.iskeydown('U')
示例#7
0
	def keyPPressed(self):
		return viz.iskeydown('p')
示例#8
0
	def spacePressed(self):
		return viz.iskeydown(' ')