def initDisplays(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawDisplay = vizconnect.getRawDisplayDict()

	#VC: initialize a new display
	_name = 'custom_window'
	if vizconnect.isPendingInit('display', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set the window for the display
			_window = viz.MainWindow
			
			#VC: set some parameters
			VFOV = 60
			aspect = viz.AUTO_COMPUTE
			stereo = viz.OFF
			
			#VC: create the raw object
			_window.fov(VFOV,aspect)
			_window.stereo(stereo)
			rawDisplay[_name] = _window
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addDisplay(rawDisplay[_name], _name, make='Generic', model='Custom Window')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getDisplay(_name).setParent(vizconnect.getAvatar('head_and_hand').getAttachmentPoint('head'))

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

	#VC: initialize a new display
	_name = 'rift'
	if vizconnect.isPendingInit('display', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set the window for the display
			_window = viz.MainWindow
			
			#VC: create the raw object
			import oculus
			_window.displayNode = oculus.Rift(window=_window, autoDetectMonitor=True)
			viz.window.setFullscreen(True)
			rawDisplay[_name] = _window
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addDisplay(rawDisplay[_name], _name, make='Oculus VR', model='Rift')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getDisplay(_name).setParent(vizconnect.getAvatar('female').getAttachmentPoint('head'))

	#VC: return values can be modified here
	return None
Beispiel #3
0
def fadeAvatar(showingAvatar):
	global avatars, currentAvatar
	for a in avatars:
		if a is showingAvatar:
			a.alpha(1)
			a.enable(viz.RENDERING)
			currentAvatar = a
			
			initAvatarMovement(avatarNames[avatars.index(currentAvatar)])
			#a.getBone('Bip01 Head').disable(viz.RENDERING) #makes it so the user can't see eyelashes, etc.
		else:
			a.alpha(0)
			a.disable(viz.RENDERING)
			if a != Male1:
				vizconnect.getAvatar(avatarNames[avatars.index(a)]).setAnimator(None, make='WorldViz', model='Inverse Kinematics')
	
	vizconnect.go('vizconnect_config_vive_proteus.py')
Beispiel #4
0
def initAvatarMovement(name):
	rawAvatar = vizconnect.getRawAvatar(name)
	from vizconnect.util.avatar import animator
	from vizconnect.util.avatar import skeleton

	# get the skeleton from the avatar
	_skeleton = skeleton.HumanAutoParse(rawAvatar)

	#VC: set which trackers animate which body part
	# format is: bone: (tracker, parent, degrees of freedom used)
	_trackerAssignmentDict = {
		vizconnect.AVATAR_HEAD:(vizconnect.getTracker('steamvr_hmd_tracker').getNode3d(), None, vizconnect.DOF_6DOF),
		vizconnect.AVATAR_L_HAND:(vizconnect.getTracker('steamvr_controller_tracker').getNode3d(), None, vizconnect.DOF_6DOF),
		vizconnect.AVATAR_R_HAND:(vizconnect.getTracker('steamvr_controller_tracker2').getNode3d(), None, vizconnect.DOF_6DOF),
	}

	#VC: create the raw object
	_rawAnimator = animator.InverseKinematics(rawAvatar, _skeleton, _trackerAssignmentDict)

	#VC: set animator in wrapper (DO NOT EDIT)
	vizconnect.getAvatar(name).setAnimator(_rawAnimator, make='WorldViz', model='Inverse Kinematics')
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
def initTools(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawTool = vizconnect.getRawToolDict()

	#VC: initialize a new tool
	_name = 'grabber'
	if vizconnect.isPendingInit('tool', _name, initFlag, initList):
		#VC: init which needs to happen before viz.go
		if initFlag&vizconnect.INIT_PREVIZGO:
			viz.setOption('viz.display.stencil',1)
	
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: initialization code needed by the parameters
			import tools
			from tools import grabber
			from tools import highlighter
			
			#VC: set some parameters
			usingPhysics = False
			highlightMode = tools.highlighter.MODE_OUTLINE
			placementMode = tools.placer.MODE_MID_AIR
			
			#VC: create the raw object
			rawTool[_name] = grabber.Grabber(usingPhysics=usingPhysics, usingSprings=usingPhysics, highlightMode=highlightMode, placementMode=placementMode, updatePriority=vizconnect.PRIORITY_ANIMATOR+3)
	
		#VC: init the mappings for the raw object
		if initFlag&vizconnect.INIT_MAPPINGS:
			#VC: per frame mappings
			if initFlag&vizconnect.INIT_MAPPINGS_PER_FRAME:
				#VC: get the raw input dict so we have access to signals
				import vizact
				rawInput = vizconnect.getConfiguration().getRawDict('input')
				#VC: set the update function which checks for input signals
				def update(tool):
					if rawInput['mouse_buttons'].getState()&viz.MOUSEBUTTON_LEFT:# make=Generic, model=Mouse Buttons, name=mouse_buttons, signal=Left Mouse Button
						tool.grabAndHold()
				rawTool[_name].setUpdateFunction(update)
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addTool(rawTool[_name], _name, make='Virtual', model='Grabber')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getTool(_name).setParent(vizconnect.getAvatar('head_and_hand').getAttachmentPoint('r_hand'))

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

	#VC: initialize a new display
	_name = 'main_display'
	if vizconnect.isPendingInit('display', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set the window for the display
			_window = viz.MainWindow
			
			#VC: make the window visible only for certain clients
			_clusterMask = viz.MASTER
			with viz.cluster.MaskedContext(viz.ALLCLIENTS&~_clusterMask):# hide
				_window.visible(False)
			with viz.cluster.MaskedContext(_clusterMask):# show
				_window.visible(True)
			
			#VC: set the fullscreen monitor
			with viz.cluster.MaskedContext(viz.MASTER):# only for clients with this display
				viz.window.setFullscreenMonitor(1)
				viz.window.setFullscreen(True)
			
			#VC: set some parameters
			autoDetectMonitor = True
			timeWarpEnabled = True
			
			#VC: create the raw object
			import oculus
			try:
				display = oculus.Rift(window=_window, autoDetectMonitor=autoDetectMonitor)
				display.setTimeWarp(timeWarpEnabled)
				_window.displayNode = display
				viz.window.setFullscreen(True)
			except AttributeError:
				_window.displayNode = None
			rawDisplay[_name] = _window
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addDisplay(rawDisplay[_name], _name, make='Oculus VR', model='Rift')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getDisplay(_name).setParent(vizconnect.getAvatar('main_avatar').getAttachmentPoint('head'))

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

	#VC: initialize a new tool
	_name = 'proxy'
	if vizconnect.isPendingInit('tool', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: create the raw object
			from tools import proxy
			rawTool[_name] = proxy.Proxy()
	
		#VC: init the mappings for the raw object
		if initFlag&vizconnect.INIT_MAPPINGS:
			#VC: per frame mappings
			if initFlag&vizconnect.INIT_MAPPINGS_PER_FRAME:
				#VC: get the raw input dict so we have access to signals
				import vizact
				rawInput = vizconnect.getConfiguration().getRawDict('input')
				#VC: set the update function which checks for input signals
				def update(tool):
					if rawInput['r_hand_input'].getState()&viz.MOUSEBUTTON_LEFT:# make=Generic, model=Mouse Buttons, name=r_hand_input, signal=Left Mouse Button
						tool.action1()
					if rawInput['r_hand_input'].getState()&viz.MOUSEBUTTON_RIGHT:# make=Generic, model=Mouse Buttons, name=r_hand_input, signal=Right Mouse Button
						tool.action2()
					if rawInput['r_hand_input'].getState()&viz.MOUSEBUTTON_MIDDLE:# make=Generic, model=Mouse Buttons, name=r_hand_input, signal=Middle Mouse Button
						tool.action3()
				rawTool[_name].setUpdateFunction(update)
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addTool(rawTool[_name], _name, make='Virtual', model='Proxy')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getTool(_name).setParent(vizconnect.getAvatar('main_avatar').getAttachmentPoint('r_hand'))

	#VC: set the name of the default
	vizconnect.setDefault('tool', 'proxy')

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

	#VC: initialize a new display
	_name = 'steamvr_hmd'
	if vizconnect.isPendingInit('display', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set the window for the display
			_window = viz.MainWindow
			
			#VC: set some parameters
			index = 0
			
			#VC: create the raw object
			import steamvr
			# Get sensor from extension if not specified
			hmd = None
			sensor = None
			hmdList = steamvr.getExtension().getHMDList()
			if hmdList:
				try:
					sensor = hmdList[index]
				except IndexError:
					viz.logError("** ERROR: Not enough HMD's")
			else:
				viz.logError('** ERROR: Failed to detect SteamVR HMD')
			if sensor:
				hmd = steamvr.HMD(sensor=sensor, window=_window)
			_window.displayNode = hmd
			rawDisplay[_name] = _window
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addDisplay(rawDisplay[_name], _name, make='Valve', model='SteamVR HMD')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getDisplay(_name).setParent(vizconnect.getAvatar('white_male').getAttachmentPoint('head'))

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

	#VC: initialize a new tool
	_name = 'proxy'
	if vizconnect.isPendingInit('tool', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: create the raw object
			from tools import proxy
			rawTool[_name] = proxy.Proxy()
	
		#VC: init the mappings for the raw object
		if initFlag&vizconnect.INIT_MAPPINGS:
			#VC: per frame mappings
			if initFlag&vizconnect.INIT_MAPPINGS_PER_FRAME:
				#VC: get the raw input dict so we have access to signals
				import vizact
				rawInput = vizconnect.getConfiguration().getRawDict('input')
				#VC: set the update function which checks for input signals
				def update(tool):
					if rawInput['flystick_buttons'].isButtonDown(0):# make=Generic, model=VRPN Buttons, name=flystick_buttons, signal=Button 0
						tool.action1()
				rawTool[_name].setUpdateFunction(update)
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addTool(rawTool[_name], _name, make='Virtual', model='Proxy')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getTool(_name).setParent(vizconnect.getAvatar('head_and_hand').getAttachmentPoint('r_hand'))

	#VC: return values can be modified here
	return None
Beispiel #11
0
def initDisplays(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawDisplay = vizconnect.getRawDisplayDict()

    #VC: initialize a new display
    _name = 'main_display'
    if vizconnect.isPendingInit('display', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set the window for the display
            _window = viz.MainWindow

            #VC: set some parameters
            VFOV = 60
            aspect = viz.AUTO_COMPUTE
            stereo = viz.STEREO_LEFT

            #VC: create the raw object
            _window.fov(VFOV, aspect)
            _window.stereo(stereo | viz.HMD)
            rawDisplay[_name] = _window

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

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getDisplay(_name).setParent(
                vizconnect.getAvatar('main_avatar').getAttachmentPoint('head'))

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

    #VC: initialize a new display
    _name = 'cave_data_file'
    if vizconnect.isPendingInit('display', _name, initFlag, initList):
        #VC: init which needs to happen before viz.go
        if initFlag & vizconnect.INIT_PREVIZGO:
            viz.setOption('viz.stereo', viz.QUAD_BUFFER)
            viz.setOption('viz.fullscreen', 1)

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set the window for the display
            _window = viz.MainWindow

            #VC: set some parameters
            stereo = viz.QUAD_BUFFER
            filename = 'C:/demos/Cave_settings.txt'

            #VC: create the raw object
            # Create a cave object
            import vizcave
            cave = vizcave.Cave(stereo=stereo)
            try:
                cave.load(filename)
            except IOError:
                viz.logError(
                    "** Error: unable to load cave configuration file {}.".
                    format(filename))

            # get an origin node
            originName = _name
            initGroups(vizconnect.INIT_INDEPENDENT,
                       [originName])  # ensure it's been created
            originNode = vizconnect.getGroup(originName).getNode3d()

            # We need to pass an object which will be used to update the projection
            # or the display to the view's position, typically this would be the
            # node attached to an avatar's head tracker.
            viewpoint = viz.addGroup()
            cave.setTracker(viewpoint)

            # Create a CaveView object for manipulating the entire cave environment.
            # The caveView is a node that can be adjusted to move the entire
            # cave around the virtual environment.
            caveView = vizcave.CaveView(viewpoint)

            _window.originLink = viz.link(originNode,
                                          caveView,
                                          dstFlag=viz.ABS_GLOBAL,
                                          srcFlag=viz.ABS_GLOBAL)
            _window.caveView = caveView
            _window.originNode = originNode
            _window.displayNode = cave
            _window.viewpointNode = viewpoint

            rawDisplay[_name] = _window

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addDisplay(rawDisplay[_name],
                                  _name,
                                  make='Generic',
                                  model='Cave Data File')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getDisplay(_name).setParent(
                vizconnect.getAvatar('head_and_hand').getAttachmentPoint(
                    'head'))

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

	#VC: initialize a new avatar
	_name = 'white_male'
	if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			filename = 'C:/Users/Jeremy Bailenson/Documents/GitHub/Demos/Proteus Demo Vive/assets/models/avatars/white_male.cfg'
			
			#VC: create the raw object
			avatar = viz.add(filename)
			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='Human', model='Auto Parse')
	
		#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.HumanAutoParse(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('steamvr_hmd_tracker').getNode3d(), None, vizconnect.DOF_6DOF),
				vizconnect.AVATAR_L_FOREARM:(vizconnect.getTracker('steamvr_controller_tracker').getNode3d(), None, vizconnect.DOF_6DOF),
				vizconnect.AVATAR_R_FOREARM:(vizconnect.getTracker('steamvr_controller_tracker2').getNode3d(), None, vizconnect.DOF_6DOF),
			}
			
			#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: initialize a new avatar
	_name = 'black_female'
	if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			filename = 'C:/Users/Jeremy Bailenson/Documents/GitHub/Demos/Proteus Demo Vive/assets/models/avatars/black_female.cfg'
			
			#VC: create the raw object
			avatar = viz.add(filename)
			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='Human', model='Auto Parse')
	
		#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.HumanAutoParse(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('steamvr_hmd_tracker').getNode3d(), None, vizconnect.DOF_6DOF),
				vizconnect.AVATAR_L_FOREARM:(vizconnect.getTracker('steamvr_controller_tracker').getNode3d(), None, vizconnect.DOF_6DOF),
				vizconnect.AVATAR_R_FOREARM:(vizconnect.getTracker('steamvr_controller_tracker2').getNode3d(), None, vizconnect.DOF_6DOF),
			}
			
			#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: initialize a new avatar
	_name = 'old_white_male'
	if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			filename = 'C:/Users/Jeremy Bailenson/Documents/GitHub/Demos/Proteus Demo Vive/assets/models/avatars/old_white_male.cfg'
			
			#VC: create the raw object
			avatar = viz.add(filename)
			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='Human', model='Auto Parse')
	
		#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.HumanAutoParse(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('steamvr_hmd_tracker').getNode3d(), None, vizconnect.DOF_6DOF),
				vizconnect.AVATAR_L_FOREARM:(vizconnect.getTracker('steamvr_controller_tracker').getNode3d(), None, vizconnect.DOF_6DOF),
				vizconnect.AVATAR_R_FOREARM:(vizconnect.getTracker('steamvr_controller_tracker2').getNode3d(), None, vizconnect.DOF_6DOF),
			}
			
			#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: initialize a new avatar
	_name = 'black_male'
	if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			filename = 'C:/Users/Jeremy Bailenson/Documents/GitHub/Demos/Proteus Demo Vive/assets/models/avatars/Male/CC2_m016_hipoly_A0.cfg'
			
			#VC: create the raw object
			avatar = viz.add(filename)
			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='Human', model='Auto Parse')
	
		#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.HumanAutoParse(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('steamvr_hmd_tracker').getNode3d(), None, vizconnect.DOF_6DOF),
				vizconnect.AVATAR_L_FOREARM:(vizconnect.getTracker('steamvr_controller_tracker').getNode3d(), None, vizconnect.DOF_6DOF),
				vizconnect.AVATAR_R_FOREARM:(vizconnect.getTracker('steamvr_controller_tracker2').getNode3d(), None, vizconnect.DOF_6DOF),
			}
			
			#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: initialize a new avatar
	_name = 'blonde_female'
	if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			filename = 'C:/Users/Jeremy Bailenson/Documents/GitHub/Demos/Proteus Demo Vive/assets/models/avatars/female/CC2_f010_hipoly_A0.cfg'
			
			#VC: create the raw object
			avatar = viz.add(filename)
			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='Human', model='Auto Parse')
	
		#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.HumanAutoParse(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('steamvr_hmd_tracker').getNode3d(), None, vizconnect.DOF_6DOF),
				vizconnect.AVATAR_L_FOREARM:(vizconnect.getTracker('steamvr_controller_tracker').getNode3d(), None, vizconnect.DOF_6DOF),
				vizconnect.AVATAR_R_FOREARM:(vizconnect.getTracker('steamvr_controller_tracker2').getNode3d(), None, vizconnect.DOF_6DOF),
			}
			
			#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: return values can be modified here
	return None
def initDisplays(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawDisplay = vizconnect.getRawDisplayDict()
	

	#VC: initialize a new display
	_name = 'cave_manual_configuration'
	if vizconnect.isPendingInit('display', _name, initFlag, initList):
		#VC: init which needs to happen before viz.go
		if initFlag&vizconnect.INIT_PREVIZGO:
			#viz.setOption('viz.stereo', viz.QUAD_BUFFER)
			viz.setOption('viz.fullscreen', 1)
			viz.setOption('viz.antialias', 8)
	
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set the window for the display
			_window = viz.MainWindow
			
			#VC: set some parameters
			frontWall = [1,2]
			rightWall = [3,4]
			backWall = -1
			leftWall = [5,6]
			floor = -1
			ceiling = -1
			frontImageWidth = 3.6
			imageHeight = 2.5
			imageRise = 0.02
			originLeft = 1.725
			originRight = 2.205
			sideImageWidth = 4
			shiftRight = 0
			shiftUp = 0
			shiftForward = 0
			stereo = viz.QUAD_BUFFER
			frontWallSwapStereo = False
			rightWallSwapStereo = False
			backWallSwapStereo = False
			leftWallSwapStereo = False
			floorSwapStereo = False
			ceilingSwapStereo = False
			
			#VC: create the raw object
			# Create a cave object
			import vizcave
			cave = vizcave.Cave(stereo=stereo)
			
			# get an origin node
			originName = _name
			initGroups(vizconnect.INIT_INDEPENDENT, [originName])# ensure it's been created
			originNode = vizconnect.getGroup(originName).getNode3d()
			
			if sideImageWidth == 0:
				sideImageWidth = frontImageWidth
			
			# extra configuration options to more explicitly control which wall goes where.
			frontWallClientIndex=-1
			rightWallClientIndex=-1
			backWallClientIndex=-1
			leftWallClientIndex=-1
			floorClientIndex=-1
			ceilingClientIndex=-1
			
			# get the originLeft angle from the origin measurements
			import math
			aOR = math.pi/4.0
			aAOR = (originRight**2 - originLeft**2 - frontImageWidth**2)/(-2*originLeft*frontImageWidth)
			if abs(aAOR) <= 1:
				aOR = math.acos(aAOR)
			
			# convert the angle to front and right shifts
			Sr =-(math.cos(aOR)*originLeft-frontImageWidth/2.0)
			Sf = (math.sin(aOR)*originLeft-sideImageWidth/2.0)
			
			# find left/right, up/down, front/back (x,y,z) extent of caves
			R = frontImageWidth/2.0+Sr+shiftRight# right
			L =-frontImageWidth/2.0+Sr+shiftRight# left
			U = imageRise+imageHeight+shiftUp# up/top
			D = imageRise+shiftUp# bottom/down
			F = sideImageWidth/2.0+Sf+shiftForward# front
			B =-sideImageWidth/2.0+Sf+shiftForward# back
			
			# find corners
			# e.g.
			# Front Wall: C1,C2,C5,C6
			# Left  Wall: C0,C1,C4,C5
			# Right Wall: C2,C3,C6,C7
			C0 = L, U, B
			C1 = L, U, F
			C2 = R, U, F
			C3 = R, U, B
			C4 = L, D, B
			C5 = L, D, F
			C6 = R, D, F
			C7 = R, D, B
			
			clients = 0
			
			#Create front wall
			if frontWall >= 0:
				wall = vizcave.Wall(	upperLeft=C1,
										upperRight=C2,
										lowerLeft=C5,
										lowerRight=C6,
										name='Front Wall' )
				
				if frontWallClientIndex == -1:
					frontWallClientIndex = clients
				cave.addWall(wall, mask=2**frontWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**frontWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(frontWall)
					_window.setStereoSwap(frontWallSwapStereo)
					viz.window.setFullscreenRectangle([2563, 15, 2260, 1585])
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create right wall
			if rightWall >= 0:
				wall = vizcave.Wall(	upperLeft=C2,
										upperRight=C3,
										lowerLeft=C6,
										lowerRight=C7,
										name='Right Wall' )
				
				if rightWallClientIndex == -1:
					rightWallClientIndex = clients
				cave.addWall(wall, mask=2**rightWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**rightWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(rightWall)
					_window.setStereoSwap(rightWallSwapStereo)
					viz.window.setFullscreenRectangle([5120, 12, 2526, 1587])
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create back wall
			if backWall >= 0:
				wall = vizcave.Wall(	upperLeft=C3,
										upperRight=C0,
										lowerLeft=C7,
										lowerRight=C4,
										name='Back Wall' )
				
				if backWallClientIndex == -1:
					backWallClientIndex = clients
				cave.addWall(wall, mask=2**backWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**backWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(backWall)
					_window.setStereoSwap(backWallSwapStereo)
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create left wall
			if leftWall >= 0:
				wall = vizcave.Wall(	upperLeft=C0,
										upperRight=C1,
										lowerLeft=C4,
										lowerRight=C5,
										name='Left Wall' )
				
				leftWallClientIndex = clients
				cave.addWall(wall, mask=2**leftWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**leftWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(leftWall)
					_window.setStereoSwap(leftWallSwapStereo)
					viz.window.setFullscreenRectangle([32, 20, 2525, 1580])
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create floor
			if floor >= 0:
				wall = vizcave.Wall(	upperLeft=C5,
										upperRight=C6,
										lowerLeft=C4,
										lowerRight=C7,
										name='Floor' )
				
				floorClientIndex = clients
				cave.addWall(wall, mask=2**floorClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**floorClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(floor)
					_window.setStereoSwap(floorSwapStereo)
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create ceiling
			if ceiling >= 0:
				wall = vizcave.Wall(	upperLeft=C0,
										upperRight=C3,
										lowerLeft=C1,
										lowerRight=C2,
										name='Ceiling' )
				
				ceilingClientIndex = clients
				cave.addWall(wall, mask=2**ceilingClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**ceilingClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(ceiling)
					_window.setStereoSwap(ceilingSwapStereo)
					viz.window.setFullscreen(True)
				clients += 1
			
			# We need to pass an object which will be used to update the projection
			# or the display to the view's position, typically this would be the
			# node attached to an avatar's head tracker. 
			viewpoint = viz.addGroup()
			cave.setTracker(viewpoint)
			
			# Create a CaveView object for manipulating the entire cave environment.
			# The caveView is a node that can be adjusted to move the entire 
			# cave around the virtual environment.
			caveView = vizcave.CaveView(viewpoint)
			
			_window.originLink = viz.link(originNode, caveView, dstFlag=viz.ABS_GLOBAL, srcFlag=viz.ABS_GLOBAL)
			_window.caveView = caveView
			_window.originNode = originNode
			_window.displayNode = cave
			_window.viewpointNode = viewpoint
			
			
			rawDisplay[_name] = _window
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addDisplay(rawDisplay[_name], _name, make='Generic', model='Cave Manual Configuration')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getDisplay(_name).setParent(vizconnect.getAvatar('head_and_hand').getAttachmentPoint('head'))

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

	#VC: initialize a new avatar
	_name = 'head_and_hand'
	if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			rightHandFilename = 'glove.cfg'
			leftHandFilename = ''
			
			#VC: create the raw object
			# base avatar
			avatar = viz.addGroup()
			avatar._bodyPartDict = {}
			avatar._handModelDict = {}
			# head
			head = viz.addGroup()
			head.setParent(avatar)
			avatar._bodyPartDict[vizconnect.AVATAR_HEAD] = head
			# left hand
			if leftHandFilename:
				leftHand = avatar.add(leftHandFilename)
				avatar.leftHandFilename = leftHandFilename
			else:
				leftHand = viz.addGroup()
				avatar.leftHandFilename = None
			leftHand.setParent(avatar)
			avatar._bodyPartDict[vizconnect.AVATAR_L_HAND] = leftHand
			# right hand
			if rightHandFilename:
				rightHand = avatar.add(rightHandFilename)
				avatar.rightHandFilename = rightHandFilename
			else:
				rightHand = viz.addGroup()
				avatar.rightHandFilename = None
			rightHand.setParent(avatar)
			avatar._bodyPartDict[vizconnect.AVATAR_R_HAND] = rightHand
			# done
			rawAvatar[_name] = avatar
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addAvatar(rawAvatar[_name], _name, make='Generic', model='Head and Hand')
	
		#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.Disembodied(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('headtracker').getNode3d(), None, vizconnect.DOF_6DOF),
				vizconnect.AVATAR_R_HAND:(vizconnect.getTracker('wandtracker').getNode3d(), None, vizconnect.DOF_6DOF),
			}
			
			#VC: create the raw object
			_rawAnimator = animator.Disembodied(rawAvatar[_name], _skeleton, _trackerAssignmentDict)
			
			#VC: set animator in wrapper (DO NOT EDIT)
			vizconnect.getAvatar(_name).setAnimator(_rawAnimator, make='Virtual', model='Disembodied')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getAvatar(_name).setParent(vizconnect.getGroup('cave_manual_configuration'))

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

	#VC: initialize a new transport
	_name = 'wandmagiccarpet'
	if vizconnect.isPendingInit('transport', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			orientationTracker = None
			debug = False
			acceleration = 2
			maxSpeed = 2
			rotationAcceleration = 60
			maxRotationSpeed = 65
			autoBreakingDragCoef = 0.1
			dragCoef = 0.0001
			rotationAutoBreakingDragCoef = 0.2
			rotationDragCoef = 0.0001
			usingPhysics = False
			parentedTracker = False
			transportationGroup = None
			
			#VC: create the raw object
			from transportation import wand_magic_carpet
			rawTransport[_name] = wand_magic_carpet.WandMagicCarpet(	orientationTracker=orientationTracker,
																					debug=debug,
																					acceleration=acceleration,
																					maxSpeed=maxSpeed,
																					rotationAcceleration=rotationAcceleration,
																					maxRotationSpeed=maxRotationSpeed,
																					autoBreakingDragCoef=autoBreakingDragCoef,
																					dragCoef=dragCoef,
																					rotationAutoBreakingDragCoef=rotationAutoBreakingDragCoef,
																					rotationDragCoef=rotationDragCoef,
																					usingPhysics=usingPhysics,
																					parentedTracker=parentedTracker,
																					node=transportationGroup)
	
		#VC: init the mappings for the raw object
		if initFlag&vizconnect.INIT_MAPPINGS:
			#VC: per frame mappings
			if initFlag&vizconnect.INIT_MAPPINGS_PER_FRAME:
				#VC: get the raw input dict so we have access to signals
				import vizact
				rawInput = vizconnect.getConfiguration().getRawDict('input')
				#VC: set the update function which checks for input signals
				def update(transport):
					if rawInput['flystick_analog'].getData()[1] > 0.05:# make=Generic, model=VRPN Analog, name=flystick_analog, signal=Analog 1 Positive
						transport.moveForward(mag=abs(rawInput['flystick_analog'].getData()[1]))
					if rawInput['flystick_analog'].getData()[1] < -0.05:# make=Generic, model=VRPN Analog, name=flystick_analog, signal=Analog 1 Negative
						transport.moveBackward(mag=abs(rawInput['flystick_analog'].getData()[1]))
					if rawInput['flystick_analog'].getData()[0] < -0.05:# make=Generic, model=VRPN Analog, name=flystick_analog, signal=Analog 0 Negative
						transport.moveLeft(mag=abs(rawInput['flystick_analog'].getData()[0]))
					if rawInput['flystick_analog'].getData()[0] > 0.05:# make=Generic, model=VRPN Analog, name=flystick_analog, signal=Analog 0 Positive
						transport.moveRight(mag=abs(rawInput['flystick_analog'].getData()[0]))
					if rawInput['flystick_buttons'].isButtonDown(3):# make=Generic, model=VRPN Buttons, name=flystick_buttons, signal=Button 3
						transport.moveUp(mag=1)
					if rawInput['flystick_buttons'].isButtonDown(2):# make=Generic, model=VRPN Buttons, name=flystick_buttons, signal=Button 2
						transport.moveDown(mag=1)
					if rawInput['flystick_buttons'].isButtonDown(4):# make=Generic, model=VRPN Buttons, name=flystick_buttons, signal=Button 4
						transport.turnLeft(mag=1)
					if rawInput['flystick_buttons'].isButtonDown(1):# make=Generic, model=VRPN Buttons, name=flystick_buttons, signal=Button 1
						transport.turnRight(mag=1)
				rawTransport[_name].setUpdateFunction(update)
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addTransport(rawTransport[_name], _name, make='Virtual', model='WandMagicCarpet')
			
		#VC: set the pivot of the node
		if initFlag&vizconnect.INIT_PIVOTS:
			vizconnect.getTransport(_name).setPivot(vizconnect.getAvatar('head_and_hand').getAttachmentPoint('head').getNode3d())

	#VC: return values can be modified here
	return None
Beispiel #17
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 = 'vrpn'
    if vizconnect.isPendingInit('tracker', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            trackerId = 'Tracker0'
            ip = 'localhost'
            sensorIndex = 38

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

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

        #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 swap
            _link.swapPos([-1, 2, 3])

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getTracker(_name).setParent(
                vizconnect.getAvatar('male').getAttachmentPoint('head'))

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

            #VC: create the raw object
            isense = viz.add('intersense.dle')
            isenseTracker = isense.addTracker(port=port)
            if not isenseTracker.valid():
                viz.logWarn(
                    "** WARNING: can't connect to InterSense InertiaCube at {0}."
                    .format(port))
            rawTracker[_name] = isenseTracker

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

    #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, ['vrpn'])
            initTrackers(vizconnect.INIT_INDEPENDENT, ['inertiacube'])

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            posTracker = vizconnect.getTracker('vrpn').getNode3d()
            oriTracker = vizconnect.getTracker('inertiacube').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: initialize a new tracker
    _name = 'vrpn3'
    if vizconnect.isPendingInit('tracker', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            trackerId = 'Tracker0'
            ip = 'localhost'
            sensorIndex = 40

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

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

        #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 swap
            _link.swapPos([-1, 2, 3])
            _link.swapQuat([-1, 2, 3, -4])

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

    #VC: initialize a new tracker
    _name = 'vrpn2'
    if vizconnect.isPendingInit('tracker', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            trackerId = 'Tracker0'
            ip = 'localhost'
            sensorIndex = 39

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

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

        #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 swap
            _link.swapPos([-1, 2, 3])
            _link.swapQuat([-1, 2, 3, -4])

    #VC: return values can be modified here
    return None
Beispiel #18
0
#	def playXylo2(self):
#		self.play('xylo31.wav')
#	def playXylo2(self):
#		self.play('xylo32.wav')
#	def playXylo2(self):
#		self.play('xylo33.wav')
#	def playXylo2(self):
#		self.play('xylo34.wav')
#	def playXylo2(self):
#		self.play('xylo35.wav')

sp = SoundPlayer()

enteredDir = None

rHand = vizconnect.getAvatar().getAttachmentPoint('r_hand').getNode3d()
lHand = vizconnect.getAvatar().getAttachmentPoint('l_hand').getNode3d()
rHandTar = vizproximity.Target(rHand)
lHandTar = vizproximity.Target(lHand)


class DirectionUpdater:
    def __init__(self):
        self.rHandPre = rHand.getPosition()
        self.rHandPost = rHand.getPosition()
        self.lHandPre = lHand.getPosition()
        self.lHandPost = lHand.getPosition()
        self.fist = True

    def upadate(self):
        #if self.fist:
def initAvatars(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawAvatar = vizconnect.getRawAvatarDict()

    #VC: initialize a new avatar
    _name = 'head_and_hand'
    if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            # rightHandFilename = 'glove.cfg'
            rightHandFilename = ''
            leftHandFilename = ''

            #VC: create the raw object
            # base avatar
            avatar = viz.addGroup()
            avatar._bodyPartDict = {}
            avatar._handModelDict = {}
            # head
            head = viz.addGroup()
            head.setParent(avatar)
            avatar._bodyPartDict[vizconnect.AVATAR_HEAD] = head
            # left hand
            if leftHandFilename:
                leftHand = avatar.add(leftHandFilename)
                avatar.leftHandFilename = leftHandFilename
            else:
                leftHand = viz.addGroup()
                avatar.leftHandFilename = None
            leftHand.setParent(avatar)
            avatar._bodyPartDict[vizconnect.AVATAR_L_HAND] = leftHand
            # right hand
            if rightHandFilename:
                rightHand = avatar.add(rightHandFilename)
                avatar.rightHandFilename = rightHandFilename
            else:
                rightHand = viz.addGroup()
                avatar.rightHandFilename = None
            rightHand.setParent(avatar)
            avatar._bodyPartDict[vizconnect.AVATAR_R_HAND] = rightHand
            # done
            rawAvatar[_name] = avatar

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addAvatar(rawAvatar[_name],
                                 _name,
                                 make='Generic',
                                 model='Head and Hand')

        #VC: init the gestures
        if initFlag & vizconnect.INIT_GESTURES:
            #VC: need to get the raw input dict so we have access to signals
            import vizact
            rawInput = vizconnect.getConfiguration().getRawDict('input')

            #VC: gestures for the avatar's r_hand
            import hand
            # remove the old hand
            rightHand = rawAvatar[_name]._bodyPartDict[
                vizconnect.AVATAR_R_HAND]
            if rightHand:
                rightHand.remove()
            # add a new hand
            def initHand():
                sensor = hand.InputSensor()
                rawAvatar[_name].handSensor = sensor
                sensor.createHandRenderer = lambda *args, **kw: hand._InputDeviceRenderer(
                    *args, **kw)

                def appliedGetData():
                    #VC: set the mappings for the gestures
                    if rawInput['flystick'].isButtonDown(
                            0
                    ):  # make=ART, model=Flystick, name=flystick, signal=Button 0
                        return (hand.GESTURE_FIST, False, False
                                )  # GESTURE_FIST
                    #VC: end gesture mappings
                    return (hand.GESTURE_FLAT_HAND, False, False)

                sensor.getData = appliedGetData
                file = None
                if hasattr(rawAvatar[_name], "rightHandFilename"):
                    file = rawAvatar[_name].rightHandFilename
                return hand.HandModel(left=False,
                                      type=hand.GLOVE_5DT,
                                      file=file,
                                      sensor=sensor)

            rightHand = initHand()
            rightHand.setParent(rawAvatar[_name])
            rawAvatar[_name]._bodyPartDict[
                vizconnect.AVATAR_R_HAND] = rightHand
            rawAvatar[_name]._handModelDict[
                vizconnect.AVATAR_R_HAND] = rightHand

            #VC: gestures may change the raw avatar, so refresh the raw in the wrapper
            vizconnect.getAvatar(_name).setRaw(rawAvatar[_name])

        #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.Disembodied(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('dtrack_head').getNode3d(), None,
                 vizconnect.DOF_6DOF),
                vizconnect.AVATAR_R_HAND:
                (vizconnect.getTracker('dtrack_flystick').getNode3d(), None,
                 vizconnect.DOF_6DOF),
            }

            #VC: create the raw object
            _rawAnimator = animator.Disembodied(rawAvatar[_name], _skeleton,
                                                _trackerAssignmentDict)

            #VC: set animator in wrapper (DO NOT EDIT)
            vizconnect.getAvatar(_name).setAnimator(_rawAnimator,
                                                    make='Virtual',
                                                    model='Disembodied')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getAvatar(_name).setParent(
                vizconnect.getGroup('cave_manual_configuration'))

    #VC: set the name of the default
    vizconnect.setDefault('avatar', 'head_and_hand')

    #VC: return values can be modified here
    return None
Beispiel #20
0
def initTransports(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawTransport = vizconnect.getRawTransportDict()

	#VC: initialize a new transport
	_name = 'main_transport'
	if vizconnect.isPendingInit('transport', _name, initFlag, initList):
		#VC: request that any dependencies be created
		if initFlag&vizconnect.INIT_INDEPENDENT:
			initTrackers(vizconnect.INIT_INDEPENDENT, ['head_tracker'])
	
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			orientationTracker = vizconnect.getTracker('head_tracker').getNode3d()
			debug = False
			acceleration = 4.0
			maxSpeed = 10.44
			rotationAcceleration = 90.0
			maxRotationSpeed = 120.0
			autoBreakingDragCoef = 0.1
			dragCoef = 0.0001
			rotationAutoBreakingDragCoef = 0.2
			rotationDragCoef = 0.0001
			usingPhysics = False
			parentedTracker = False
			transportationGroup = None
			
			#VC: create the raw object
			from transportation import wand_magic_carpet
			rawTransport[_name] = wand_magic_carpet.WandMagicCarpet(	orientationTracker=orientationTracker,
																					debug=debug,
																					acceleration=acceleration,
																					maxSpeed=maxSpeed,
																					rotationAcceleration=rotationAcceleration,
																					maxRotationSpeed=maxRotationSpeed,
																					autoBreakingDragCoef=autoBreakingDragCoef,
																					dragCoef=dragCoef,
																					rotationAutoBreakingDragCoef=rotationAutoBreakingDragCoef,
																					rotationDragCoef=rotationDragCoef,
																					usingPhysics=usingPhysics,
																					parentedTracker=parentedTracker,
																					node=transportationGroup)
	
		#VC: init the mappings for the raw object
		if initFlag&vizconnect.INIT_MAPPINGS:
			#VC: per frame mappings
			if initFlag&vizconnect.INIT_MAPPINGS_PER_FRAME:
				#VC: get the raw input dict so we have access to signals
				import vizact
				rawInput = vizconnect.getConfiguration().getRawDict('input')
				#VC: set the update function which checks for input signals
				def update(transport):
					if rawInput['keyboard'].isButtonDown(17):# make=Generic, model=Keyboard, name=keyboard, signal=Key W
						transport.moveForward(mag=1)
					if rawInput['keyboard'].isButtonDown(31):# make=Generic, model=Keyboard, name=keyboard, signal=Key S
						transport.moveBackward(mag=1)
					if rawInput['keyboard'].isButtonDown(30):# make=Generic, model=Keyboard, name=keyboard, signal=Key A
						transport.moveLeft(mag=1)
					if rawInput['keyboard'].isButtonDown(32):# make=Generic, model=Keyboard, name=keyboard, signal=Key D
						transport.moveRight(mag=1)
					if rawInput['keyboard'].isButtonDown(45):# make=Generic, model=Keyboard, name=keyboard, signal=Key X
						transport.moveUp(mag=1)
					if rawInput['keyboard'].isButtonDown(44):# make=Generic, model=Keyboard, name=keyboard, signal=Key Z
						transport.moveDown(mag=1)
					if rawInput['keyboard'].isButtonDown(16):# make=Generic, model=Keyboard, name=keyboard, signal=Key Q
						transport.turnLeft(mag=1)
					if rawInput['keyboard'].isButtonDown(18):# make=Generic, model=Keyboard, name=keyboard, signal=Key E
						transport.turnRight(mag=1)
				rawTransport[_name].setUpdateFunction(update)
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addTransport(rawTransport[_name], _name, make='Virtual', model='WandMagicCarpet')
	
		#VC: set the pivot of the node
		if initFlag&vizconnect.INIT_PIVOTS:
			vizconnect.getTransport(_name).setPivot(vizconnect.getAvatar('main_avatar').getAttachmentPoint('head').getNode3d())

	#VC: set the name of the default
	vizconnect.setDefault('transport', 'main_transport')

	#VC: return values can be modified here
	return None
Beispiel #21
0
avatars = []
avatars.append(Male1)
avatars.append(Female1)
avatars.append(Male2)
avatars.append(Male3)
avatars.append(Female2)
avatars.append(Female3)
avatars.append(Male4)
avatars.append(Female4)
avatars.append(Male5)
avatars.append(Female5)

initAvatarMovement('white_male')
initAvatarMovement(avatarNames[avatars.index(currentAvatar)])
#bones = white_male.getBoneList()
#for b in bones:
#	print b.getName()
	
for a in avatars:
	a.emissive([1,1,1])
	if a is not currentAvatar:
		a.alpha(0)
		a.disable(viz.RENDERING)
		if a != Male1:
			vizconnect.getAvatar(avatarNames[avatars.index(a)]).setAnimator(None, make='WorldViz', model='Inverse Kinematics')
	#a.getBone('Bip01 Head').disable(viz.RENDERING)
	a.enable(viz.SAMPLE_ALPHA_TO_COVERAGE)
	a.disable(viz.BLEND)


addMustacheMan()
Beispiel #22
0
def initTransports(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawTransport = vizconnect.getRawTransportDict()

    #VC: initialize a new transport
    _name = 'main_transport'
    if vizconnect.isPendingInit('transport', _name, initFlag, initList):
        #VC: request that any dependencies be created
        if initFlag & vizconnect.INIT_INDEPENDENT:
            initTrackers(vizconnect.INIT_INDEPENDENT, ['head_tracker'])

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            orientationTracker = vizconnect.getTracker(
                'head_tracker').getNode3d()
            debug = False
            acceleration = 2
            maxSpeed = 2
            rotationAcceleration = 60
            maxRotationSpeed = 65
            autoBreakingDragCoef = 0.1
            dragCoef = 0.0001
            rotationAutoBreakingDragCoef = 0.2
            rotationDragCoef = 0.0001
            usingPhysics = False
            parentedTracker = False
            transportationGroup = None

            #VC: create the raw object
            from transportation import wand_magic_carpet
            rawTransport[_name] = wand_magic_carpet.WandMagicCarpet(
                orientationTracker=orientationTracker,
                debug=debug,
                acceleration=acceleration,
                maxSpeed=maxSpeed,
                rotationAcceleration=rotationAcceleration,
                maxRotationSpeed=maxRotationSpeed,
                autoBreakingDragCoef=autoBreakingDragCoef,
                dragCoef=dragCoef,
                rotationAutoBreakingDragCoef=rotationAutoBreakingDragCoef,
                rotationDragCoef=rotationDragCoef,
                usingPhysics=usingPhysics,
                parentedTracker=parentedTracker,
                node=transportationGroup)

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addTransport(rawTransport[_name],
                                    _name,
                                    make='Virtual',
                                    model='WandMagicCarpet')

        #VC: set the pivot of the node
        if initFlag & vizconnect.INIT_PIVOTS:
            vizconnect.getTransport(_name).setPivot(
                vizconnect.getAvatar('main_avatar').getAttachmentPoint(
                    'head').getNode3d())

    #VC: set the name of the default
    vizconnect.setDefault('transport', 'main_transport')

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

    #VC: initialize a new tool
    _name = 'proxy'
    if vizconnect.isPendingInit('tool', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: create the raw object
            from tools import proxy
            rawTool[_name] = proxy.Proxy()

        #VC: init the mappings for the raw object
        if initFlag & vizconnect.INIT_MAPPINGS:
            #VC: per frame mappings
            if initFlag & vizconnect.INIT_MAPPINGS_PER_FRAME:
                #VC: get the raw input dict so we have access to signals
                import vizact
                rawInput = vizconnect.getConfiguration().getRawDict('input')

                #VC: set the update function which checks for input signals
                def update(tool):
                    if rawInput['flystick'].isButtonDown(
                            0
                    ):  # make=ART, model=Flystick, name=flystick, signal=Button 0
                        tool.action1()
                    if rawInput['flystick'].isButtonDown(
                            1
                    ):  # make=ART, model=Flystick, name=flystick, signal=Button 1
                        tool.action2()
                    if rawInput['flystick'].isButtonDown(
                            2
                    ):  # make=ART, model=Flystick, name=flystick, signal=Button 2
                        tool.action3()
                    if rawInput['flystick'].isButtonDown(
                            3
                    ):  # make=ART, model=Flystick, name=flystick, signal=Button 3
                        tool.action4()
                    if rawInput['flystick'].isButtonDown(
                            4
                    ):  # make=ART, model=Flystick, name=flystick, signal=Button 4
                        tool.action5()
                    if rawInput['flystick'].isButtonDown(
                            5
                    ):  # make=ART, model=Flystick, name=flystick, signal=Button 5
                        tool.action()

                rawTool[_name].setUpdateFunction(update)

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addTool(rawTool[_name],
                               _name,
                               make='Virtual',
                               model='Proxy')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getTool(_name).setParent(
                vizconnect.getAvatar('head_and_hand').getAttachmentPoint(
                    'r_hand'))

    #VC: initialize a new tool
    _name = 'laser_pointer'
    if vizconnect.isPendingInit('tool', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: initialization code needed by the parameters
            import tools.laser_pointer

            #VC: set some parameters
            displayDistance = True
            showEndNode = True
            distanceMetric = tools.laser_pointer.DISTANCE_METERS

            #VC: create the raw object
            endNode = None if showEndNode else viz.addGroup()
            rawTool[_name] = tools.laser_pointer.LaserPointer(
                displayDistance=displayDistance,
                updatePriority=vizconnect.PRIORITY_ANIMATOR + 3,
                endNode=endNode,
                distanceMetric=distanceMetric)

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addTool(rawTool[_name],
                               _name,
                               make='Virtual',
                               model='Laser Pointer')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getTool(_name).setParent(
                vizconnect.getAvatar('head_and_hand').getAttachmentPoint(
                    'l_hand'))

    #VC: set the name of the default
    vizconnect.setDefault('tool', 'proxy')

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

    #VC: initialize a new display
    _name = 'main_display'
    if vizconnect.isPendingInit('display', _name, initFlag, initList):
        #VC: init which needs to happen before viz.go
        if initFlag & vizconnect.INIT_PREVIZGO:
            viz.setOption('viz.stereo', viz.QUAD_BUFFER)
            viz.setOption('viz.fullscreen', 1)

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set the window for the display
            _window = viz.MainWindow

            #VC: set some parameters
            imageWidth = 3
            imageHeight = 2.25
            imageRise = 0.045
            originLeft = 2.897
            originRight = 2.934
            shiftRight = 0
            shiftUp = 0
            shiftForward = 0
            stereo = viz.QUAD_BUFFER
            swapStereo = False

            #VC: create the raw object
            # Create a cave object
            import vizcave
            cave = vizcave.Cave(stereo=stereo)

            # get an origin node
            originName = _name
            initGroups(vizconnect.INIT_INDEPENDENT,
                       [originName])  # ensure it's been created
            originNode = vizconnect.getGroup(originName).getNode3d()

            # get the originLeft angle from the origin measurements
            import math
            aOR = math.pi / 4.0
            aAOR = (originRight**2 - originLeft**2 -
                    imageWidth**2) / (-2 * originLeft * imageWidth)
            if abs(aAOR) <= 1:
                aOR = math.acos(aAOR)

            # convert the angle to front and right shifts
            Sr = -(math.cos(aOR) * originLeft - imageWidth / 2.0)
            distanceToFront = math.sin(aOR) * originLeft

            # find left/right, up/down, front/back (x,y,z) extent of caves
            R = imageWidth / 2.0 + Sr + shiftRight  # right
            L = -imageWidth / 2.0 + Sr + shiftRight  # left
            U = imageRise + imageHeight + shiftUp  # up/top
            D = imageRise + shiftUp  # bottom/down
            F = distanceToFront + shiftForward  # front

            C0 = L, U, F
            C1 = R, U, F
            C2 = L, D, F
            C3 = R, D, F

            #Create front wall
            wall = vizcave.Wall(upperLeft=C0,
                                upperRight=C1,
                                lowerLeft=C2,
                                lowerRight=C3,
                                name='Front Wall')

            cave.addWall(wall, window=_window)

            _window.setStereoSwap(swapStereo)

            #_window.setSize([1, 1])

            # We need to pass an object which will be used to update the projection
            # or the display to the view's position, typically this would be the
            # node attached to an avatar's head tracker.
            viewpoint = viz.addGroup()
            cave.setTracker(viewpoint)

            # Create a CaveView object for manipulating the entire cave environment.
            # The caveView is a node that can be adjusted to move the entire
            # cave around the virtual environment.
            caveView = vizcave.CaveView(viewpoint, view=_window.getView())
            _window.originLink = viz.link(originNode,
                                          caveView,
                                          dstFlag=viz.ABS_GLOBAL,
                                          srcFlag=viz.ABS_GLOBAL)
            _window.caveView = caveView
            _window.originNode = originNode
            _window.displayNode = cave
            _window.viewpointNode = viewpoint

            rawDisplay[_name] = _window

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

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getDisplay(_name).setParent(
                vizconnect.getAvatar('main_avatar').getAttachmentPoint('head'))

    #VC: set the name of the default
    vizconnect.setDefault('display', 'main_display')

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

    #VC: initialize a new avatar
    _name = 'main_avatar'
    if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            head = False
            rightHand = False
            leftHand = False
            torso = False
            lowerBody = False
            rightArm = False
            leftArm = False

            #VC: create the raw object
            # base avatar
            import vizfx
            avatar = vizfx.addChild('mark.cfg')
            avatar._bodyPartDict = {}
            avatar._handModelDict = {}
            avatar.visible(head, r'mark_head.cmf')
            avatar.visible(rightHand, r'mark_hand_r.cmf')
            avatar.visible(leftHand, r'mark_hand_l.cmf')
            avatar.visible(torso, r'mark_torso.cmf')
            avatar.visible(lowerBody, r'mark_legs.cmf')
            avatar.visible(rightArm, r'mark_arm_r.cmf')
            avatar.visible(leftArm, r'mark_arm_l.cmf')
            rawAvatar[_name] = avatar

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addAvatar(rawAvatar[_name],
                                 _name,
                                 make='WorldViz',
                                 model='Mark')

        #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.CompleteCharactersHD(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('head_tracker').getNode3d(), None,
                 vizconnect.DOF_POS),
                vizconnect.AVATAR_R_HAND:
                (vizconnect.getTracker('r_hand_tracker').getNode3d(), None,
                 vizconnect.DOF_POS),
            }

            #VC: create the raw object
            _rawAnimator = animator.Direct(rawAvatar[_name], _skeleton,
                                           _trackerAssignmentDict)

            #VC: set animator in wrapper (DO NOT EDIT)
            vizconnect.getAvatar(_name).setAnimator(_rawAnimator,
                                                    make='Virtual',
                                                    model='Direct')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getAvatar(_name).setParent(
                vizconnect.getGroup('main_display'))

    #VC: set the name of the default
    vizconnect.setDefault('avatar', 'main_avatar')

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

	#VC: initialize a new avatar
	_name = 'head_and_hand'
	if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			rightHandFilename = 'glove.cfg'
			leftHandFilename = ''
			
			#VC: create the raw object
			# base avatar
			avatar = viz.addGroup()
			avatar._bodyPartDict = {}
			avatar._handModelDict = {}
			# head
			head = viz.addGroup()
			head.setParent(avatar)
			avatar._bodyPartDict[vizconnect.AVATAR_HEAD] = head
			# left hand
			if leftHandFilename:
				leftHand = avatar.add(leftHandFilename)
				avatar.leftHandFilename = leftHandFilename
			else:
				leftHand = viz.addGroup()
				avatar.leftHandFilename = None
			leftHand.setParent(avatar)
			avatar._bodyPartDict[vizconnect.AVATAR_L_HAND] = leftHand
			# right hand
			if rightHandFilename:
				rightHand = avatar.add(rightHandFilename)
				avatar.rightHandFilename = rightHandFilename
			else:
				rightHand = viz.addGroup()
				avatar.rightHandFilename = None
			rightHand.setParent(avatar)
			avatar._bodyPartDict[vizconnect.AVATAR_R_HAND] = rightHand
			# done
			rawAvatar[_name] = avatar
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addAvatar(rawAvatar[_name], _name, make='Generic', model='Head and Hand')
	
		#VC: init the gestures
		if initFlag&vizconnect.INIT_GESTURES:
			#VC: need to get the raw input dict so we have access to signals
			import vizact
			rawInput = vizconnect.getConfiguration().getRawDict('input')
			
			#VC: gestures for the avatar's r_hand
			import hand
			# remove the old hand
			rightHand = rawAvatar[_name]._bodyPartDict[vizconnect.AVATAR_R_HAND]
			if rightHand:
				rightHand.remove()
			# add a new hand
			def initHand():
				sensor = hand.InputSensor()
				rawAvatar[_name].handSensor = sensor
				sensor.createHandRenderer = lambda *args,**kw: hand._InputDeviceRenderer(*args,**kw)
				def appliedGetData():
					#VC: set the mappings for the gestures
					if rawInput['mouse_buttons'].getState()&viz.MOUSEBUTTON_LEFT:# make=Generic, model=Mouse Buttons, name=mouse_buttons, signal=Left Mouse Button
						return (hand.GESTURE_FIST, False, False)# GESTURE_FIST
					#VC: end gesture mappings
					return (hand.GESTURE_FLAT_HAND,False,False)
				sensor.getData = appliedGetData
				file=None
				if hasattr(rawAvatar[_name], "rightHandFilename"):
					file = rawAvatar[_name].rightHandFilename
				return hand.HandModel(left=False, type=hand.GLOVE_5DT, file=file, sensor=sensor)
			rightHand = initHand()
			rightHand.setParent(rawAvatar[_name])
			rawAvatar[_name]._bodyPartDict[vizconnect.AVATAR_R_HAND] = rightHand
			rawAvatar[_name]._handModelDict[vizconnect.AVATAR_R_HAND] = rightHand
			
			#VC: gestures may change the raw avatar, so refresh the raw in the wrapper
			vizconnect.getAvatar(_name).setRaw(rawAvatar[_name])
	
		#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.Disembodied(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('mouse_and_keyboard_walking').getNode3d(), None, vizconnect.DOF_6DOF),
				vizconnect.AVATAR_R_HAND:(vizconnect.getTracker('mouse_scrollwheel').getNode3d(), vizconnect.AVATAR_HEAD, vizconnect.DOF_POS),
			}
			
			#VC: create the raw object
			_rawAnimator = animator.Disembodied(rawAvatar[_name], _skeleton, _trackerAssignmentDict)
			
			#VC: set animator in wrapper (DO NOT EDIT)
			vizconnect.getAvatar(_name).setAnimator(_rawAnimator, make='Virtual', model='Disembodied')

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

	#VC: initialize a new transport
	_name = 'main_transport'
	if vizconnect.isPendingInit('transport', _name, initFlag, initList):
		#VC: request that any dependencies be created
		if initFlag&vizconnect.INIT_INDEPENDENT:
			initTrackers(vizconnect.INIT_INDEPENDENT, ['head_tracker'])
	
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			orientationTracker = vizconnect.getTracker('head_tracker').getNode3d()
			debug = False
			acceleration = 2.0
			maxSpeed = 2.0
			rotationAcceleration = 60.0
			maxRotationSpeed = 65.0
			autoBreakingDragCoef = 0.1
			dragCoef = 0.0001
			rotationAutoBreakingDragCoef = 0.2
			rotationDragCoef = 0.0001
			usingPhysics = False
			parentedTracker = False
			transportationGroup = None
			
			#VC: create the raw object
			from transportation import wand_magic_carpet
			rawTransport[_name] = wand_magic_carpet.WandMagicCarpet(	orientationTracker=orientationTracker,
																					debug=debug,
																					acceleration=acceleration,
																					maxSpeed=maxSpeed,
																					rotationAcceleration=rotationAcceleration,
																					maxRotationSpeed=maxRotationSpeed,
																					autoBreakingDragCoef=autoBreakingDragCoef,
																					dragCoef=dragCoef,
																					rotationAutoBreakingDragCoef=rotationAutoBreakingDragCoef,
																					rotationDragCoef=rotationDragCoef,
																					usingPhysics=usingPhysics,
																					parentedTracker=parentedTracker,
																					node=transportationGroup)
	
		#VC: init the mappings for the raw object
		if initFlag&vizconnect.INIT_MAPPINGS:
			#VC: per frame mappings
			if initFlag&vizconnect.INIT_MAPPINGS_PER_FRAME:
				#VC: get the raw input dict so we have access to signals
				import vizact
				rawInput = vizconnect.getConfiguration().getRawDict('input')
				#VC: set the update function which checks for input signals
				def update(transport):
					if rawInput['keyboard'].isButtonDown(17):# make=Generic, model=Keyboard, name=keyboard, signal=Key W
						transport.moveForward(mag=1)
					if rawInput['keyboard'].isButtonDown(31):# make=Generic, model=Keyboard, name=keyboard, signal=Key S
						transport.moveBackward(mag=1)
					if rawInput['keyboard'].isButtonDown(30):# make=Generic, model=Keyboard, name=keyboard, signal=Key A
						transport.moveLeft(mag=1)
					if rawInput['keyboard'].isButtonDown(32):# make=Generic, model=Keyboard, name=keyboard, signal=Key D
						transport.moveRight(mag=1)
					if rawInput['keyboard'].isButtonDown(57):# make=Generic, model=Keyboard, name=keyboard, signal=Key SPACE
						transport.moveUp(mag=1)
					if rawInput['keyboard'].isButtonDown(29):# make=Generic, model=Keyboard, name=keyboard, signal=Key CONTROL_L
						transport.moveDown(mag=1)
					if rawInput['keyboard'].isButtonDown(16):# make=Generic, model=Keyboard, name=keyboard, signal=Key Q
						transport.turnLeft(mag=1)
					if rawInput['keyboard'].isButtonDown(18):# make=Generic, model=Keyboard, name=keyboard, signal=Key E
						transport.turnRight(mag=1)
				rawTransport[_name].setUpdateFunction(update)
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addTransport(rawTransport[_name], _name, make='Virtual', model='WandMagicCarpet')
	
		#VC: set the pivot of the node
		if initFlag&vizconnect.INIT_PIVOTS:
			vizconnect.getTransport(_name).setPivot(vizconnect.getAvatar('main_avatar').getAttachmentPoint('head').getNode3d())

	#VC: set the name of the default
	vizconnect.setDefault('transport', 'main_transport')

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

    #VC: initialize a new tool
    _name = 'grabber'
    if vizconnect.isPendingInit('tool', _name, initFlag, initList):
        #VC: init which needs to happen before viz.go
        if initFlag & vizconnect.INIT_PREVIZGO:
            viz.setOption('viz.display.stencil', 1)

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: initialization code needed by the parameters
            import tools
            from tools import grabber
            from tools import highlighter

            #VC: set some parameters
            usingPhysics = True
            highlightMode = tools.highlighter.MODE_OUTLINE
            placementMode = tools.placer.MODE_MID_AIR

            #VC: create the raw object
            rawTool[_name] = grabber.Grabber(
                usingPhysics=usingPhysics,
                usingSprings=usingPhysics,
                highlightMode=highlightMode,
                placementMode=placementMode,
                updatePriority=vizconnect.PRIORITY_ANIMATOR + 3)

        #VC: init the mappings for the raw object
        if initFlag & vizconnect.INIT_MAPPINGS:
            #VC: per frame mappings
            if initFlag & vizconnect.INIT_MAPPINGS_PER_FRAME:
                #VC: get the raw input dict so we have access to signals
                import vizact
                rawInput = vizconnect.getConfiguration().getRawDict('input')

                #VC: set the update function which checks for input signals
                def update(tool):
                    if rawInput['flystick'].isButtonDown(
                            0
                    ):  # make=ART, model=Flystick, name=flystick, signal=Button 0
                        tool.grabAndHold()

                rawTool[_name].setUpdateFunction(update)

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addTool(rawTool[_name],
                               _name,
                               make='Virtual',
                               model='Grabber')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getTool(_name).setParent(
                vizconnect.getAvatar('head_and_hand').getAttachmentPoint(
                    'r_hand'))

    #VC: initialize a new tool
    _name = 'laser_pointer'
    if vizconnect.isPendingInit('tool', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            displayDistance = True

            #VC: create the raw object
            from tools import laser_pointer
            rawTool[_name] = laser_pointer.LaserPointer(
                displayDistance=displayDistance,
                updatePriority=vizconnect.PRIORITY_ANIMATOR + 3)

        #VC: init the mappings for the raw object
        if initFlag & vizconnect.INIT_MAPPINGS:
            #VC: per frame mappings
            if initFlag & vizconnect.INIT_MAPPINGS_PER_FRAME:
                #VC: get the raw input dict so we have access to signals
                import vizact
                rawInput = vizconnect.getConfiguration().getRawDict('input')

                #VC: set the update function which checks for input signals
                def update(tool):
                    if rawInput['flystick'].isButtonDown(
                            5
                    ):  # make=ART, model=Flystick, name=flystick, signal=Button 5
                        tool.shoot()

                rawTool[_name].setUpdateFunction(update)

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addTool(rawTool[_name],
                               _name,
                               make='Virtual',
                               model='Laser Pointer')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getTool(_name).setParent(
                vizconnect.getAvatar('head_and_hand').getAttachmentPoint(
                    'r_hand'))

    #VC: set the name of the default
    vizconnect.setDefault('tool', 'grabber')

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

	#VC: initialize a new avatar
	_name = 'main_avatar'
	if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			rightHandFilename = 'glove.cfg'
			leftHandFilename = ''
			
			#VC: create the raw object
			# base avatar
			avatar = viz.addGroup()
			avatar._bodyPartDict = {}
			avatar._handModelDict = {}
			# head
			head = viz.addGroup()
			head.setParent(avatar)
			avatar._bodyPartDict[vizconnect.AVATAR_HEAD] = head
			# left hand
			if leftHandFilename:
				leftHand = avatar.add(leftHandFilename)
				avatar.leftHandFilename = leftHandFilename
			else:
				leftHand = viz.addGroup()
				avatar.leftHandFilename = None
			leftHand.setParent(avatar)
			avatar._bodyPartDict[vizconnect.AVATAR_L_HAND] = leftHand
			# right hand
			if rightHandFilename:
				rightHand = avatar.add(rightHandFilename)
				avatar.rightHandFilename = rightHandFilename
			else:
				rightHand = viz.addGroup()
				avatar.rightHandFilename = None
			rightHand.setParent(avatar)
			avatar._bodyPartDict[vizconnect.AVATAR_R_HAND] = rightHand
			# done
			rawAvatar[_name] = avatar
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addAvatar(rawAvatar[_name], _name, make='Generic', model='Head and Hand')
	
		#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.Disembodied(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('head_tracker').getNode3d(), None, vizconnect.DOF_6DOF),
			}
			
			#VC: create the raw object
			_rawAnimator = animator.Disembodied(rawAvatar[_name], _skeleton, _trackerAssignmentDict)
			
			#VC: set animator in wrapper (DO NOT EDIT)
			vizconnect.getAvatar(_name).setAnimator(_rawAnimator, make='Virtual', model='Disembodied')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getAvatar(_name).setParent(vizconnect.getTransport('main_transport'))

	#VC: set the name of the default
	vizconnect.setDefault('avatar', 'main_avatar')

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

    #VC: initialize a new display
    CAVE_CONFIG_NAME = 'cave_manual_configuration'

    if vizconnect.isPendingInit('display', CAVE_CONFIG_NAME, initFlag,
                                initList):
        #VC: init which needs to happen before viz.go
        if initFlag & vizconnect.INIT_PREVIZGO:
            viz.setOption('viz.stereo', viz.QUAD_BUFFER)

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set the window for the display
            _window = viz.MainWindow

            #APG: constants, 5 total instances running...
            FRONT_WALL_CLUSTER_CLIENT = viz.CLIENT1
            LEFT_WALL_CLUSTER_CLIENT = viz.CLIENT2
            RIGHT_WALL_CLUSTER_CLIENT = viz.CLIENT3
            FLOOR_LEFT_CLUSTER_CLIENT = viz.CLIENT4
            FLOOR_RIGHT_CLUSTER_CLIENT = viz.CLIENT5

            #These are determined by testing the monitors
            FRONT_WALL_MONITOR_ID = 1
            LEFT_WALL_MONITOR_ID = 4
            RIGHT_WALL_MONITOR_ID = 5
            FLOOR_LEFT_MONITOR_ID = 3
            FLOOR_RIGHT_MONITOR_ID = 2

            #==============================================
            #Cave calculations

            #VC: create the raw object
            # Create a cave object
            import vizcave
            cave = vizcave.Cave(stereo=viz.QUAD_BUFFER)

            # get an origin node
            originName = CAVE_CONFIG_NAME
            initGroups(vizconnect.INIT_INDEPENDENT,
                       [originName])  # ensure it's been created
            originNode = vizconnect.getGroup(originName).getNode3d()

            frontImageWidth = 5.5372
            imageHeight = 2.2225
            imageRise = 0.0
            originLeft = 3.5503
            originRight = 3.5503
            sideImageWidth = 2.9591
            shiftRight = 0
            shiftUp = 0
            shiftForward = 0

            # get the originLeft angle from the origin measurements
            import math
            aOR = math.pi / 4.0
            aAOR = (originRight**2 - originLeft**2 -
                    frontImageWidth**2) / (-2 * originLeft * frontImageWidth)
            if abs(aAOR) <= 1:
                aOR = math.acos(aAOR)

            # convert the angle to front and right shifts
            Sr = -(math.cos(aOR) * originLeft - frontImageWidth / 2.0)
            Sf = (math.sin(aOR) * originLeft - sideImageWidth / 2.0)

            # find left/right, up/down, front/back (x,y,z) extent of caves
            R = frontImageWidth / 2.0 + Sr + shiftRight  # right
            L = -frontImageWidth / 2.0 + Sr + shiftRight  # left
            U = imageRise + imageHeight + shiftUp  # up/top
            D = imageRise + shiftUp  # bottom/down
            F = sideImageWidth / 2.0 + Sf + shiftForward  # front
            B = -sideImageWidth / 2.0 + Sf + shiftForward  # back

            # find corners
            # e.g.
            # Front Wall: C1,C2,C5,C6
            # Left  Wall: C0,C1,C4,C5
            # Right Wall: C2,C3,C6,C7
            C0 = L, U, B
            C1 = L, U, F
            C2 = R, U, F
            C3 = R, U, B
            C4 = L, D, B
            C5 = L, D, F
            C6 = R, D, F
            C7 = R, D, B
            C8 = L, D, 0
            C9 = R, D, 0
            C10 = -0.19939, D, F
            C11 = 0.19939, D, F
            C12 = -0.19939, D, 0
            C13 = 0.19939, D, 0

            #			wall_list = [C0, C1, C2, C3, C4,
            #						C5, C6, C7, C8,
            #						C9, C10, C11, C12, C13]
            #
            #			for item in wall_list:
            #				print(item)

            #==============================================

            WALL_CORNERS = "corners"
            WALL_NAME = "name"
            WALL_CLUSTER_ID = "cluster_id"
            WALL_MONITOR_ID = "monitor_id"

            #Creates wall, then adds it to the vizcave obj
            def config_wall(wall_config, window):
                points = wall_config[WALL_CORNERS]
                cluster_client_id = wall_config[WALL_CLUSTER_ID]
                monitor_id = wall_config[WALL_MONITOR_ID]

                new_wall = vizcave.Wall(upperLeft=points[0],
                                        upperRight=points[1],
                                        lowerLeft=points[2],
                                        lowerRight=points[3],
                                        name=wall_config[WALL_NAME])

                cave.addWall(new_wall, mask=cluster_client_id, window=window)

                with viz.cluster.MaskedContext(cluster_client_id):
                    viz.window.setFullscreenMonitor(monitor_id)
                    _window.setStereoSwap(False)
                    viz.window.setFullscreen(True)

            #Create front wall
            #==================================
            wall_config = {}
            wall_config[WALL_CORNERS] = [C1, C2, C5, C6]
            wall_config[WALL_NAME] = "Front Wall"
            wall_config[WALL_CLUSTER_ID] = FRONT_WALL_CLUSTER_CLIENT
            wall_config[WALL_MONITOR_ID] = FRONT_WALL_MONITOR_ID

            config_wall(wall_config, _window)

            #Create right wall
            #==================================
            wall_config = {}
            wall_config[WALL_CORNERS] = [C2, C3, C6, C7]
            wall_config[WALL_NAME] = "Right Wall"
            wall_config[WALL_CLUSTER_ID] = RIGHT_WALL_CLUSTER_CLIENT
            wall_config[WALL_MONITOR_ID] = RIGHT_WALL_MONITOR_ID

            config_wall(wall_config, _window)

            # #Create left wall
            # #=================================
            wall_config = {}
            wall_config[WALL_CORNERS] = [C0, C1, C4, C5]
            wall_config[WALL_NAME] = "Left Wall"
            wall_config[WALL_CLUSTER_ID] = LEFT_WALL_CLUSTER_CLIENT
            wall_config[WALL_MONITOR_ID] = LEFT_WALL_MONITOR_ID

            config_wall(wall_config, _window)

            #Create floor_left
            #==================================
            wall_config = {}
            wall_config[WALL_CORNERS] = [C5, C11, C8, C13]
            wall_config[WALL_NAME] = "Floor Left"
            wall_config[WALL_CLUSTER_ID] = FLOOR_LEFT_CLUSTER_CLIENT
            wall_config[WALL_MONITOR_ID] = FLOOR_LEFT_MONITOR_ID

            config_wall(wall_config, _window)

            #Create floor_right
            #==================================
            wall_config = {}
            wall_config[WALL_CORNERS] = [C10, C6, C12, C9]
            wall_config[WALL_NAME] = "Floor Right"
            wall_config[WALL_CLUSTER_ID] = FLOOR_RIGHT_CLUSTER_CLIENT
            wall_config[WALL_MONITOR_ID] = FLOOR_RIGHT_MONITOR_ID

            config_wall(wall_config, _window)

            #==================================

            # We need to pass an object which will be used to update the projection
            # or the display to the view's position, typically this would be the
            # node attached to an avatar's head tracker.
            viewpoint = viz.addGroup()
            cave.setTracker(viewpoint)

            # Create a CaveView object for manipulating the entire cave environment.
            # The caveView is a node that can be adjusted to move the entire
            # cave around the virtual environment.
            caveView = vizcave.CaveView(viewpoint)

            _window.originLink = viz.link(originNode,
                                          caveView,
                                          dstFlag=viz.ABS_GLOBAL,
                                          srcFlag=viz.ABS_GLOBAL)
            _window.caveView = caveView
            _window.originNode = originNode
            _window.displayNode = cave
            _window.viewpointNode = viewpoint

            rawDisplay[CAVE_CONFIG_NAME] = _window

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addDisplay(rawDisplay[CAVE_CONFIG_NAME],
                                  CAVE_CONFIG_NAME,
                                  make='Generic',
                                  model='Cave Manual Configuration')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getDisplay(CAVE_CONFIG_NAME).setParent(
                vizconnect.getAvatar('head_and_hand').getAttachmentPoint(
                    'head'))

    #VC: set the name of the default
    vizconnect.setDefault('display', 'cave_manual_configuration')

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

    #VC: initialize a new transport
    _name = 'main_transport'
    if vizconnect.isPendingInit('transport', _name, initFlag, initList):
        #VC: request that any dependencies be created
        if initFlag & vizconnect.INIT_INDEPENDENT:
            initTrackers(vizconnect.INIT_INDEPENDENT, ['head_tracker'])

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            orientationTracker = vizconnect.getTracker(
                'head_tracker').getNode3d()
            debug = False
            acceleration = 2
            maxSpeed = 2
            rotationAcceleration = 60
            maxRotationSpeed = 65
            autoBreakingDragCoef = 0.1
            dragCoef = 0.0001
            rotationAutoBreakingDragCoef = 0.2
            rotationDragCoef = 0.0001
            usingPhysics = False
            parentedTracker = False
            transportationGroup = None

            #VC: create the raw object
            from transportation import wand_magic_carpet
            rawTransport[_name] = wand_magic_carpet.WandMagicCarpet(
                orientationTracker=orientationTracker,
                debug=debug,
                acceleration=acceleration,
                maxSpeed=maxSpeed,
                rotationAcceleration=rotationAcceleration,
                maxRotationSpeed=maxRotationSpeed,
                autoBreakingDragCoef=autoBreakingDragCoef,
                dragCoef=dragCoef,
                rotationAutoBreakingDragCoef=rotationAutoBreakingDragCoef,
                rotationDragCoef=rotationDragCoef,
                usingPhysics=usingPhysics,
                parentedTracker=parentedTracker,
                node=transportationGroup)

        #VC: init the mappings for the raw object
        if initFlag & vizconnect.INIT_MAPPINGS:
            #VC: per frame mappings
            if initFlag & vizconnect.INIT_MAPPINGS_PER_FRAME:
                #VC: get the raw input dict so we have access to signals
                import vizact
                rawInput = vizconnect.getConfiguration().getRawDict('input')

                #VC: set the update function which checks for input signals
                def update(transport):
                    if rawInput['r_hand_input'].getTrackpad(
                    )[1] > 0.01:  # make=HTC, model=Vive Controller, name=r_hand_input, signal=Trackpad Top
                        transport.moveForward(
                            mag=abs(rawInput['r_hand_input'].getTrackpad()[1]))
                    if rawInput['r_hand_input'].getTrackpad(
                    )[1] < -0.01:  # make=HTC, model=Vive Controller, name=r_hand_input, signal=Trackpad Bottom
                        transport.moveBackward(
                            mag=abs(rawInput['r_hand_input'].getTrackpad()[1]))
                    if rawInput['r_hand_input'].getTrackpad(
                    )[0] < -0.01:  # make=HTC, model=Vive Controller, name=r_hand_input, signal=Trackpad Left
                        transport.moveLeft(
                            mag=abs(rawInput['r_hand_input'].getTrackpad()[0]))
                    if rawInput['r_hand_input'].getTrackpad(
                    )[0] > 0.01:  # make=HTC, model=Vive Controller, name=r_hand_input, signal=Trackpad Right
                        transport.moveRight(
                            mag=abs(rawInput['r_hand_input'].getTrackpad()[0]))

                rawTransport[_name].setUpdateFunction(update)

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addTransport(rawTransport[_name],
                                    _name,
                                    make='Virtual',
                                    model='WandMagicCarpet')

        #VC: set the pivot of the node
        if initFlag & vizconnect.INIT_PIVOTS:
            vizconnect.getTransport(_name).setPivot(
                vizconnect.getAvatar('main_avatar').getAttachmentPoint(
                    'head').getNode3d())

    #VC: set the name of the default
    vizconnect.setDefault('transport', 'main_transport')

    #VC: return values can be modified here
    return None
Beispiel #32
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 = 'main_avatar'
	if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			head = False
			rightHand = True
			leftHand = False
			torso = False
			lowerBody = False
			rightArm = False
			leftArm = False
			
			#VC: create the raw object
			# base avatar
			import vizfx
			avatar = vizfx.addChild('mark.cfg')
			avatar.disable(viz.LIGHTING)
			avatar._bodyPartDict = {}
			avatar._handModelDict = {}
			avatar.visible(head, r'mark_head.cmf')
			avatar.visible(rightHand, r'mark_hand_r.cmf')
			avatar.visible(leftHand, r'mark_hand_l.cmf')
			avatar.visible(torso, r'mark_torso.cmf')
			avatar.visible(lowerBody, r'mark_legs.cmf')
			avatar.visible(rightArm, r'mark_arm_r.cmf')
			avatar.visible(leftArm, r'mark_arm_l.cmf')
			rawAvatar[_name] = avatar
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addAvatar(rawAvatar[_name], _name, make='WorldViz', model='Mark')
	
		#VC: init the gestures
		if initFlag&vizconnect.INIT_GESTURES:
			#VC: need to get the raw input dict so we have access to signals
			import vizact
			rawInput = vizconnect.getConfiguration().getRawDict('input')
			
			#VC: gestures for the avatar's r_hand
			import hand
			def initHand():
				sensor = hand.InputSensor()
				rawAvatar[_name].handSensor = sensor
				sensor.createHandRenderer = lambda *args,**kw: hand._InputDeviceRenderer(*args,**kw)
				def appliedGetData():
					#VC: set the mappings for the gestures
					if rawInput['r_hand_input'].getState()&viz.MOUSEBUTTON_LEFT:# make=Generic, model=Mouse Buttons, name=r_hand_input, signal=Left Mouse Button
						return (hand.GESTURE_FIST, False, False)# GESTURE_FIST
					#VC: end gesture mappings
					return (hand.GESTURE_FLAT_HAND,False,False)
				sensor.getData = appliedGetData
				return hand.AvatarHandModel(rawAvatar[_name], left=False, type=hand.GLOVE_5DT, sensor=sensor)
			rightHand = initHand()
			rawAvatar[_name]._bodyPartDict[vizconnect.AVATAR_R_HAND] = rightHand
			rawAvatar[_name]._handModelDict[vizconnect.AVATAR_R_HAND] = rightHand
			
			#VC: gestures may change the raw avatar, so refresh the raw in the wrapper
			vizconnect.getAvatar(_name).setRaw(rawAvatar[_name])
	
		#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.CompleteCharactersHD(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('head_tracker').getNode3d(), None, vizconnect.DOF_6DOF),
				vizconnect.AVATAR_R_HAND:(vizconnect.getTracker('r_hand_tracker').getNode3d(), vizconnect.AVATAR_HEAD, vizconnect.DOF_POS),
			}
			
			#VC: create the raw object
			_rawAnimator = animator.Direct(rawAvatar[_name], _skeleton, _trackerAssignmentDict)
			
			#VC: set animator in wrapper (DO NOT EDIT)
			vizconnect.getAvatar(_name).setAnimator(_rawAnimator, make='Virtual', model='Direct')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getAvatar(_name).setParent(vizconnect.getTransport('main_transport'))

	#VC: set the name of the default
	vizconnect.setDefault('avatar', 'main_avatar')

	#VC: return values can be modified here
	return None
Beispiel #33
0
def initTools(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawTool = vizconnect.getRawToolDict()

    #VC: initialize a new tool
    _name = 'grabber'
    if vizconnect.isPendingInit('tool', _name, initFlag, initList):
        #VC: init which needs to happen before viz.go
        if initFlag & vizconnect.INIT_PREVIZGO:
            viz.setOption('viz.display.stencil', 1)

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: initialization code needed by the parameters
            import tools
            from tools import grabber
            from tools import highlighter

            #VC: set some parameters
            usingPhysics = False
            highlightMode = tools.highlighter.MODE_OUTLINE
            placementMode = tools.placer.MODE_MID_AIR

            #VC: create the raw object
            rawTool[_name] = grabber.Grabber(
                usingPhysics=usingPhysics,
                usingSprings=usingPhysics,
                highlightMode=highlightMode,
                placementMode=placementMode,
                updatePriority=vizconnect.PRIORITY_ANIMATOR + 3)

        #VC: init the mappings for the raw object
        if initFlag & vizconnect.INIT_MAPPINGS:
            #VC: per frame mappings
            if initFlag & vizconnect.INIT_MAPPINGS_PER_FRAME:
                #VC: get the raw input dict so we have access to signals
                import vizact
                rawInput = vizconnect.getConfiguration().getRawDict('input')

                #VC: set the update function which checks for input signals
                def update(tool):
                    if rawInput['mouse_buttons'].getState(
                    ) & viz.MOUSEBUTTON_LEFT:  # make=Generic, model=Mouse Buttons, name=mouse_buttons, signal=Left Mouse Button
                        tool.grabAndHold()
                    if rawInput['mouse_buttons'].getState(
                    ) & viz.MOUSEBUTTON_RIGHT:  # make=Generic, model=Mouse Buttons, name=mouse_buttons, signal=Right Mouse Button
                        tool.release()

                rawTool[_name].setUpdateFunction(update)

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addTool(rawTool[_name],
                               _name,
                               make='Virtual',
                               model='Grabber')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getTool(_name).setParent(
                vizconnect.getAvatar('male_2').getAttachmentPoint('r_hand'))

    #VC: return values can be modified here
    return None