Пример #1
0
def initAvatars(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawAvatar = vizconnect.getRawAvatarDict()

	#VC: initialize a new avatar
	_name = 'female'
	if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: create the raw object
			avatar = viz.add('vcc_female.cfg')
			avatar._bodyPartDict = {}
			avatar._handModelDict = {}
			rawAvatar[_name] = avatar
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addAvatar(rawAvatar[_name], _name, make='Complete Characters', model='Female')
	
		#VC: init the animator
		if initFlag&vizconnect.INIT_ANIMATOR:
			# need to get the raw tracker dict for animating the avatars
			from vizconnect.util.avatar import animator
			from vizconnect.util.avatar import skeleton
			
			# get the skeleton from the avatar
			_skeleton = skeleton.CompleteCharacters(rawAvatar[_name])
			
			#VC: set which trackers animate which body part
			# format is: bone: (tracker, parent, degrees of freedom used)
			_trackerAssignmentDict = {
				vizconnect.AVATAR_HEAD:(vizconnect.getTracker('rift_orientation_tracker').getNode3d(), None, vizconnect.DOF_ORI),
			}
			
			#VC: create the raw object
			_rawAnimator = animator.InverseKinematics(rawAvatar[_name], _skeleton, _trackerAssignmentDict)
			
			#VC: set animator in wrapper (DO NOT EDIT)
			vizconnect.getAvatar(_name).setAnimator(_rawAnimator, make='WorldViz', model='Inverse Kinematics')
	
		#VC: init the mappings for the wrapper
		if initFlag&vizconnect.INIT_WRAPPER_MAPPINGS:
			#VC: on-state mappings
			if initFlag&vizconnect.INIT_MAPPINGS_ON_STATE:
				vizconnect.getAvatar(_name).setOnStateEventList([
						vizconnect.onstate(lambda rawInput: rawInput['joystick'].isButtonDown(3), vizconnect.getAvatar(_name).setVisible),# make=Generic, model=Joystick, name=joystick, signal=Button 3
				])
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getAvatar(_name).setParent(vizconnect.getTransport('walking'))

	#VC: return values can be modified here
	return None
Пример #2
0
def initTrackers(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawTracker = vizconnect.getRawTrackerDict()

    #VC: initialize a new tracker
    _name = 'dk2'
    if vizconnect.isPendingInit('tracker', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            index = 0

            #VC: create the raw object
            import oculus
            sensorList = oculus.getSensors()
            if index < len(sensorList):
                orientationTracker = sensorList[index]
            else:
                viz.logWarn(
                    "** WARNING: Oculus VR Rift Orientation Tracker not present."
                )
                orientationTracker = viz.addGroup()
                orientationTracker.invalidTracker = True
            rawTracker[_name] = orientationTracker

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addTracker(rawTracker[_name],
                                  _name,
                                  make='Oculus VR',
                                  model='DK2')

        #VC: init the offsets
        if initFlag & vizconnect.INIT_OFFSETS:
            _link = vizconnect.getTracker(_name).getLink()
            #VC: clear link offsets
            _link.reset(viz.RESET_OPERATORS)

            #VC: apply offsets
            _link.postTrans([0, 1.405, 0])

        #VC: init the mappings for the wrapper
        if initFlag & vizconnect.INIT_WRAPPER_MAPPINGS:
            #VC: on-state mappings
            if initFlag & vizconnect.INIT_MAPPINGS_ON_STATE:
                vizconnect.getTracker(_name).setOnStateEventList([
                    vizconnect.onstate(
                        lambda rawInput: rawInput['keyboard'].isButtonDown(19),
                        vizconnect.getTracker(_name).resetHeading
                    ),  # make=Generic, model=Keyboard, name=keyboard, signal=Key R
                ])

    #VC: return values can be modified here
    return None
def initTrackers(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawTracker = vizconnect.getRawTrackerDict()

	#VC: initialize a new tracker
	_name = 'head_tracker'
	if vizconnect.isPendingInit('tracker', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			addMouseOrientation = True
			positionSensitivity = 2.5
			heightOffset = 1.82
			sensorIndex = 0
			
			#VC: create the raw object
			import oculus
			sensorList = oculus.getSensors()
			if sensorIndex < len(sensorList):
				dk2Tracker = sensorList[sensorIndex]
				from vizconnect.util import virtual_trackers
				tracker = virtual_trackers.TrackerAndKeyboardWalking(dk2Tracker, addMouseOrientation=addMouseOrientation, positionSensitivity=positionSensitivity, heightOffset=heightOffset)
			else:
				viz.logWarn("** WARNING: Oculus Tracker not present.")
				tracker = viz.addGroup()
				tracker.invalidTracker = True
			rawTracker[_name] = tracker
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addTracker(rawTracker[_name], _name, make='Oculus VR', model='Rift With Mouse And Keyboard')
	
		#VC: init the offsets
		if initFlag&vizconnect.INIT_OFFSETS:
			_link = vizconnect.getTracker(_name).getLink()
			#VC: clear link offsets
			_link.reset(viz.RESET_OPERATORS)
			
			#VC: reset orientation
			_link.preEuler([0, 0, 0], target=viz.LINK_ORI_OP, priority=-20)
	
		#VC: init the mappings for the wrapper
		if initFlag&vizconnect.INIT_WRAPPER_MAPPINGS:
			#VC: on-state mappings
			if initFlag&vizconnect.INIT_MAPPINGS_ON_STATE:
				vizconnect.getTracker(_name).setOnStateEventList([
						vizconnect.onstate(lambda rawInput: rawInput['keyboard'].isButtonDown(19), vizconnect.getTracker(_name).resetHeading),# make=Generic, model=Keyboard, name=keyboard, signal=Key R
				])

	#VC: return values can be modified here
	return None
Пример #4
0
def initTrackers(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawTracker = vizconnect.getRawTrackerDict()

	#VC: initialize a new tracker
	_name = 'rift_orientation_tracker'
	if vizconnect.isPendingInit('tracker', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: create the raw object
			import oculus
			index=0
			sensorList = oculus.getSensors()
			if index < len(sensorList):
				orientationTracker = sensorList[index]
			else:
				viz.logWarn("** WARNING: Oculus VR Rift Orientation Tracker not present.")
				orientationTracker = viz.addGroup()
				orientationTracker.invalidTracker = True
			rawTracker[_name] = orientationTracker
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addTracker(rawTracker[_name], _name, make='Oculus VR', model='Rift Orientation Tracker')
	
		#VC: init the offsets
		if initFlag&vizconnect.INIT_OFFSETS:
			_link = vizconnect.getTracker(_name).getLink()
			#VC: clear link offsets
			_link.reset(viz.RESET_OPERATORS)
			
			#VC: reset orientation
			_link.preEuler([0, 0, 0], target=viz.LINK_ORI_OP, priority=-20)
			
			#VC: apply offsets
			_link.postTrans([0, 1.68, 0])			
	
		#VC: init the mappings for the wrapper
		if initFlag&vizconnect.INIT_WRAPPER_MAPPINGS:
			#VC: on-state mappings
			if initFlag&vizconnect.INIT_MAPPINGS_ON_STATE:
				vizconnect.getTracker(_name).setOnStateEventList([
						vizconnect.onstate(lambda rawInput: rawInput['joystick'].isButtonDown(2), vizconnect.getTracker(_name).resetHeading),# make=Generic, model=Joystick, name=joystick, signal=Button 2
				])

	#VC: return values can be modified here
	return None
Пример #5
0
def initInputs(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawInput = vizconnect.getRawInputDict()

    #VC: initialize a new input
    _name = 'joystick'
    if vizconnect.isPendingInit('input', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: create the raw object
            import vizjoy
            rawInput[_name] = vizjoy.add()

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addInput(rawInput[_name],
                                _name,
                                make='Generic',
                                model='Joystick')

        #VC: init the mappings for the wrapper
        if initFlag & vizconnect.INIT_WRAPPER_MAPPINGS:
            #VC: on-state mappings
            if initFlag & vizconnect.INIT_MAPPINGS_ON_STATE:
                vizconnect.getInput(_name).setOnStateEventList([
                    vizconnect.onstate(
                        lambda rawInput: rawInput['joystick'].isButtonDown(1),
                        vizconnect.getInput(_name).setMode
                    ),  # make=Generic, model=Joystick, name=joystick, signal=Button 1
                ])

    #VC: set the name of the default
    vizconnect.setDefault('input', 'joystick')

    #VC: return values can be modified here
    return None
def initTrackers(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawTracker = vizconnect.getRawTrackerDict()

    #VC: initialize a new tracker
    _name = 'dtrack_head'
    if vizconnect.isPendingInit('tracker', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            vrpnName = 'DTrack'
            ip = '192.168.5.160'
            index = 1

            #VC: create the raw object
            vrpn7 = viz.add('vrpn7.dle')
            rawTracker[_name] = vrpn7.addTracker(vrpnName + '@' + ip, index)

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addTracker(rawTracker[_name],
                                  _name,
                                  make='A.R.T.',
                                  model='DTrack')

        #VC: init the offsets
        if initFlag & vizconnect.INIT_OFFSETS:
            _link = vizconnect.getTracker(_name).getLink()
            #VC: clear link offsets
            _link.reset(viz.RESET_OPERATORS)

            #VC: reset orientation
            _link.preEuler([0, 0, 0], target=viz.LINK_ORI_OP, priority=-20)

            #VC: apply offsets
            _link.postTrans([0, 0, -0.02])

    #VC: initialize a new tracker
    _name = 'dtrack_flystick'
    if vizconnect.isPendingInit('tracker', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            vrpnName = 'DTrack'
            ip = '192.168.5.160'
            index = 3

            #VC: create the raw object
            vrpn7 = viz.add('vrpn7.dle')
            rawTracker[_name] = vrpn7.addTracker(vrpnName + '@' + ip, index)

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addTracker(rawTracker[_name],
                                  _name,
                                  make='A.R.T.',
                                  model='DTrack')

        #VC: init the mappings for the wrapper
        if initFlag & vizconnect.INIT_WRAPPER_MAPPINGS:
            #VC: on-state mappings
            if initFlag & vizconnect.INIT_MAPPINGS_ON_STATE:
                vizconnect.getTracker(_name).setOnStateEventList([
                    vizconnect.onstate(
                        lambda rawInput: rawInput['flystick'].isButtonDown(2),
                        vizconnect.getTracker(_name).resetHeading
                    ),  # make=ART, model=Flystick, name=flystick, signal=Button 2
                ])

    #VC: set the name of the default
    vizconnect.setDefault('tracker', 'dtrack_head')

    #VC: return values can be modified here
    return None
def initTrackers(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawTracker = vizconnect.getRawTrackerDict()

	#VC: initialize a new tracker
	_name = 'ppt_left_eye'
	if vizconnect.isPendingInit('tracker', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			pptHostname = '171.64.33.43'
			markerId = 1
			
			#VC: create the raw object
			vrpn7 = viz.add('vrpn7.dle')
			rawTracker[_name] = vrpn7.addTracker('PPT0@'+pptHostname, markerId-1)
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addTracker(rawTracker[_name], _name, make='WorldViz', model='PPT')

	#VC: initialize a new tracker
	_name = 'rift_orientation_tracker'
	if vizconnect.isPendingInit('tracker', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			index = 0
			
			#VC: create the raw object
			import oculus
			sensorList = oculus.getSensors()
			if index < len(sensorList):
				orientationTracker = sensorList[index]
			else:
				viz.logWarn("** WARNING: Oculus VR Rift Orientation Tracker not present.")
				orientationTracker = viz.addGroup()
				orientationTracker.invalidTracker = True
			rawTracker[_name] = orientationTracker
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addTracker(rawTracker[_name], _name, make='Oculus VR', model='Rift Orientation Tracker')
	
		#VC: init the mappings for the wrapper
		if initFlag&vizconnect.INIT_WRAPPER_MAPPINGS:
			#VC: on-state mappings
			if initFlag&vizconnect.INIT_MAPPINGS_ON_STATE:
				vizconnect.getTracker(_name).setOnStateEventList([
						vizconnect.onstate(lambda rawInput: rawInput['keyboard'].isButtonDown(19), vizconnect.getTracker(_name).resetHeading),# make=Generic, model=Keyboard, name=keyboard, signal=Key R
				])

	#VC: initialize a new tracker
	_name = 'merged'
	if vizconnect.isPendingInit('tracker', _name, initFlag, initList):
		#VC: request that any dependencies be created
		if initFlag&vizconnect.INIT_INDEPENDENT:
			initTrackers(vizconnect.INIT_INDEPENDENT, ['ppt_left_eye'])
			initTrackers(vizconnect.INIT_INDEPENDENT, ['rift_orientation_tracker'])
	
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			posTracker = vizconnect.getTracker('ppt_left_eye').getNode3d()
			oriTracker = vizconnect.getTracker('rift_orientation_tracker').getNode3d()
			
			#VC: create the raw object
			try:
				raw = viz.mergeLinkable(posTracker, oriTracker)
			except:
				viz.logError('Error **: unable to create merged tracker, providing empty tracker object.')
				raw = viz.addGroup()
				raw.invalidTracker = True
			rawTracker[_name] = raw
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addTracker(rawTracker[_name], _name, make='Virtual', model='Merged')
	
		#VC: init the offsets
		if initFlag&vizconnect.INIT_OFFSETS:
			_link = vizconnect.getTracker(_name).getLink()
			#VC: clear link offsets
			_link.reset(viz.RESET_OPERATORS)
			
			#VC: reset orientation
			_link.preEuler([0, 0, 0], target=viz.LINK_ORI_OP, priority=-20)

				#VC: apply offsets
			_link.preTrans([0.0975, -0.08, -0.07])

		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getTracker(_name).setParent(vizconnect.getTransport('wandmagiccarpet'))

	#VC: initialize a new tracker
	_name = 'rift_with_mouse_and_keyboard'
	if vizconnect.isPendingInit('tracker', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			addMouseOrientation = True
			positionSensitivity = 2.5
			heightOffset = 1.82
			sensorIndex = 0
			
			#VC: create the raw object
			import oculus
			sensorList = oculus.getSensors()
			if sensorIndex < len(sensorList):
				dk2Tracker = sensorList[sensorIndex]
				from vizconnect.util import virtual_trackers
				tracker = virtual_trackers.TrackerAndKeyboardWalking(dk2Tracker, addMouseOrientation=addMouseOrientation, positionSensitivity=positionSensitivity, heightOffset=heightOffset)
			else:
				viz.logWarn("** WARNING: Oculus Tracker not present.")
				tracker = viz.addGroup()
				tracker.invalidTracker = True
			rawTracker[_name] = tracker
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addTracker(rawTracker[_name], _name, make='Oculus VR', model='Rift With Mouse And Keyboard')

	#VC: return values can be modified here
	return None