def initInputs(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawInput = vizconnect.getRawInputDict()

	#VC: initialize a new input
	_name = 'r_hand_input'
	if vizconnect.isPendingInit('input', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: create the raw object
			rawInput[_name] = viz.mouse
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addInput(rawInput[_name], _name, make='Generic', model='Mouse Buttons')
	
		#VC: init the mappings for the wrapper
		if initFlag&vizconnect.INIT_WRAPPER_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(input):
					if rawInput['r_hand_input'].getState()&viz.MOUSEBUTTON_LEFT:# make=Generic, model=Mouse Buttons, name=r_hand_input, signal=Left Mouse Button
						input.setQuasimode('alt1')
				vizconnect.getInput(_name).setUpdateFunction(update)

	#VC: initialize a new input
	_name = 'keyboard'
	if vizconnect.isPendingInit('input', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			index = 0
			
			#VC: create the raw object
			d = viz.add('directinput.dle')
			device = d.getKeyboardDevices()[index]
			rawInput[_name] = d.addKeyboard(device)
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addInput(rawInput[_name], _name, make='Generic', model='Keyboard')

	#VC: return values can be modified here
	return None
Exemple #2
0
def initInputs(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawInput = vizconnect.getRawInputDict()

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

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

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

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

    #VC: return values can be modified here
    return None
Exemple #3
0
vizconnect.go('vizconnect_config2.py')

#Init Game
room = viz.add('room.osgb')
scientist = viz.add('./avatars/male/avatar 003.cfg')
scientist.setPosition([-7.64, 0, 7.91])
scientist.setEuler(120,0,0)
scientist.state(1)

#Emotions for Scientist
affectManager=AffectManager(24)
scientist_expression=affectManager.createBasicEkmanWithExpression(scientist)

head = vizconnect.getTracker('rift_orientation_tracker').getNode3d()

joystick = vizconnect.getInput('joystick')
transport = vizconnect.getTransport('wandmagiccarpet')

avatarNova = viz.add('./avatars/female/avatar 001.cfg')
avatarNova.state(1)
avatarNova.setParent(transport.getNode3d())


##Joystick##
# Load DirectInput plug-in 
dinput = viz.add('DirectInput.dle')
# Add first available joystick
joy = dinput.addJoystick()

#Left Bumper = Button 4
#Right Bumper = Button 5
def initInputs(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawInput = vizconnect.getRawInputDict()

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

            #VC: create the raw object
            d = viz.add('directinput.dle')
            device = d.getKeyboardDevices()[index]
            rawInput[_name] = d.addKeyboard(device)

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

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

            #VC: create the raw object
            import steamvr
            try:
                input = steamvr.getControllerList()[index]
                input._isValid = True
            except IndexError:
                viz.logWarn(
                    "** WARNING: Not able to connect to a controller at index {0}. It's likely that not enough controllers are connected."
                    .format(index))
                input = viz.VizExtensionSensor(-1)
                input.isButtonDown = lambda e: False
                input.getTrackpad = lambda: [0, 0]
                input._isValid = False
            rawInput[_name] = input

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

        #VC: init the mappings for the wrapper
        if initFlag & vizconnect.INIT_WRAPPER_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(input):
                    if rawInput['r_hand_input'].isButtonDown(
                            2
                    ):  # make=HTC, model=Vive Controller, name=r_hand_input, signal=Button Trigger
                        input.setQuasimode()

                vizconnect.getInput(_name).setUpdateFunction(update)

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

            #VC: create the raw object
            import steamvr
            try:
                input = steamvr.getControllerList()[index]
                input._isValid = True
            except IndexError:
                viz.logWarn(
                    "** WARNING: Not able to connect to a controller at index {0}. It's likely that not enough controllers are connected."
                    .format(index))
                input = viz.VizExtensionSensor(-1)
                input.isButtonDown = lambda e: False
                input.getTrackpad = lambda: [0, 0]
                input._isValid = False
            rawInput[_name] = input

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

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

    #VC: return values can be modified here
    return None