Пример #1
0
def createCustomComposite(id=0):
    viz.logNotice('MotionNode Head Tracking')

    # Use general VRPN tracker.
    vrpn = viz.add('vrpn7.dle')
    PPT_VRPN = 'Tracker0@localhost'
    head = vrpn.addTracker(PPT_VRPN)
    # Need to change rotation axes from MotionNode
    # to Vizard conventions.
    head.swapQuat([-3, -2, -1, 4])

    # Or, use the built in MotionNode tracker
    # support.
    #MotionNode = viz.add('MotionNode.dle')
    #head = MotionNode.addSensor()

    headfinal = viz.addGroup()
    headlink = viz.link(head, headfinal, enabled=False)
    import vizact
    vizact.onupdate(viz.PRIORITY_PLUGINS + 1, headlink.update)
    headlink.postTrans([0, 0.1, 0])  # Apply 10 cm translate in Y axis

    import vizuniverse as VU
    comp = VU.VUCompositeTrackers()
    comp.storeTracker(comp.HEAD, headfinal)

    comp.createAvatarNone()
    comp.defineViewpoint()
    comp.finishTrackers()
    return comp
Пример #2
0
def losGehts():

    while(True):

        viz.waitFrame(200)
        viz.logNotice("Bin in Schleife")
        pre = viz.Event(blub="ME")
        viz.postEvent(INC_JASON_EVENT,pre)
Пример #3
0
def fileTask():
    
    yield viztask.waitKeyDown(' ')
    viz.logNotice('Started file operation')
    
    #Execute the getLast function in a separate thread
    #and wait for it to complete and return some data
    data = yield viztask.waitDirector(getLast)
    
    viz.logNotice('Finished file operation, last line is: ',data.returnValue)
Пример #4
0
	def __init__(self):		
		super(self.__class__,self).__init__()
		
		# Link navigation node to main view
#		self.NODE = viz.addGroup()
#		self.VIEW_LINK = viz.link(self.NODE, self.VIEW)
		
		# --add oculus as HMD
		self.hmd = oculus.Rift()
		
		if not self.hmd.getSensor():
			viz.logError('** ERROR: Failed to detect Oculus Rift')
		else:
			# Reset HMD orientation
			self.hmd.getSensor().reset()

			# Setup navigation node and link to main view
#			self.NODE = viz.addGroup()
#			self.VIEW_LINK = viz.link(self.NODE, viz.VIEW)
			self.VIEW_LINK.preMultLinkable(self.hmd.getSensor())

			# --Apply user profile eye height to view
			profile = self.hmd.getProfile()
			if profile:
				self.VIEW_LINK.setOffset([0,profile.eyeHeight,0])
				viz.logNotice('Oculus profile name:', profile.name)
				viz.logNotice('Oculus IPD:', profile.ipd)
				viz.logNotice('Oculus player height:', profile.playerHeight)
				viz.logNotice('Oculus eye height:', profile.eyeHeight)
			else: 
				self.VIEW_LINK.setOffset([0,self.EYE_HEIGHT,0])
				
			# Check if HMD supports position tracking
			supportPositionTracking = self.hmd.getSensor().getSrcMask() & viz.LINK_POS
			if supportPositionTracking:
				
				# Add camera bounds model
				self.camera_bounds = self.hmd.addCameraBounds()
				self.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:
						self.camera_bounds.color(viz.GREEN)
					else:
						self.camera_bounds.color(viz.RED)
				vizact.onupdate(0, checkPositionTracked)

				# Setup camera bounds toggle key
				def toggleBounds():
					self.camera_bounds.visible(viz.TOGGLE)
				vizact.onkeydown(self.KEYS['camera'], toggleBounds)
Пример #5
0
	def __init__(self):		
		super(self.__class__,self).__init__()
	
		# --Override Key commands
		self.KEYS = { 'forward'	: 'w'
					,'back' 	: 's'
					,'left' 	: 'a'
					,'right'	: 'd'
					,'camera'	: 'c'
					,'restart'	: viz.KEY_END
					,'home'		: viz.KEY_HOME
					,'utility'	: ' '
					,'reset'	: 0
					,'showMenu' : 1
					,'down'		: 2
					,'orient'	: 3
					,'up'		: 4
					,'mode'		: 5
					,'builder'	: 6
					,'walk'		: 7
					,'angles'	: 8
					,'road'		: 10
					,'esc'		: 999
					,'slideFar'	: 0
					,'slideNear': 180
					,'env'		: '-'
					,'grid'		: '-'
					,'snapMenu'	: viz.KEY_CONTROL_L
					,'interact' : viz.MOUSEBUTTON_LEFT
					,'rotate'	: viz.MOUSEBUTTON_RIGHT
					,'proxi'	: 'p'
					,'viewer'	: 'o'
					,'collide'	: 'c'
					,'stereo' 	: 'm'
					,'hand'		: 'h'
					,'capslock'	: viz.KEY_CAPS_LOCK
		}
		
		self.TURN_SPEED = 45
		
		# Get device from extension if not specified
		self.device = None
		if self.device is None:
			allDevices = getDevices()
			if allDevices:
				self.device = allDevices[0]	
			else:
				viz.logError('** ERROR: Failed to detect Joystick')

		# Connect to selected device
		self.joy = getExtension().addJoystick(self.device)
		if not self.joy:
			viz.logError('** ERROR: Failed to connect to Joystick')

		# Set dead zone threshold so small movements of joystick are ignored
		self.joy.setDeadZone(0.2)

		# Display joystick information in config window
#		vizconfig.register(self.joy)
#		vizconfig.getConfigWindow().setWindowVisible(True)
		
		# --add oculus as HMD
		self.hmd = oculus.Rift()
		
		if not self.hmd.getSensor():
			viz.logError('** ERROR: Failed to detect Oculus')
		else:
			# Reset HMD orientation
			self.hmd.getSensor().reset()

			# Setup navigation node and link to main view
			self.VIEW_LINK.preMultLinkable(self.hmd.getSensor())

			# --Apply user profile eye height to view
			profile = self.hmd.getProfile()
			if profile:
				self.VIEW_LINK.setOffset([0,profile.eyeHeight,0])
				viz.logNotice('Oculus profile name:', profile.name)
				viz.logNotice('Oculus IPD:', profile.ipd)
				viz.logNotice('Oculus player height:', profile.playerHeight)
				viz.logNotice('Oculus eye height:', profile.eyeHeight)
			else: 
				self.VIEW_LINK.setOffset([0,self.EYE_HEIGHT,0])
				
			# Check if HMD supports position tracking
			supportPositionTracking = self.hmd.getSensor().getSrcMask() & viz.LINK_POS
			if supportPositionTracking:
				
				# Add camera bounds model
				self.camera_bounds = self.hmd.addCameraBounds()
				self.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:
						self.camera_bounds.color(viz.GREEN)
					else:
						self.camera_bounds.color(viz.RED)
				vizact.onupdate(0, checkPositionTracked)

				# Setup camera bounds toggle key
				def toggleBounds():
					self.camera_bounds.visible(viz.TOGGLE)
				vizact.onkeydown(self.KEYS['camera'], toggleBounds)