Ejemplo n.º 1
0
	def registerWiimoteActions(self):
				
		wii = viz.add('wiimote.dle')#Add wiimote extension
		
		#vizact.onsensordown(self.config.wiimote,wii.BUTTON_B,self.launchKeyDown) 
		#vizact.onsensorup(self.config.wiimote,wii.BUTTON_B,self.launchKeyUp) 
		
		if( self.config.use_phasespace == True ):
			
			mocapSys = self.config.mocap;
		
			vizact.onsensorup(self.config.wiimote,wii.BUTTON_DOWN,mocapSys.resetRigid,'hmd') 
			vizact.onsensorup(self.config.wiimote,wii.BUTTON_UP,mocapSys.saveRigid,'hmd') 
Ejemplo n.º 2
0
def setupBimanualAsymmetricControl():
	#Create proximity proximityManager
	global proximityManager
	proximityManager = vizproximity.Manager()
	#proximityManager.setDebug(viz.ON)

	#Add third appendage as proximity target
	global thirdAppendage
	targetThirdAppendage = vizproximity.Target(thirdAppendage)
	proximityManager.addTarget(targetThirdAppendage)
	
	#lhPPTLink = viz.link(pptextensionDK2.rhPPT, viz.NullLinkable)
	sensorNonDominantHand = None
	if pptextensionDK2.lhPPT is not None:
		lhPPTLink = viz.link(pptextensionDK2.lhPPT, viz.NullLinkable)
		sensorNonDominantHand = vizproximity.Sensor(vizproximity.Sphere(
			0.4, center = pptextensionDK2.lhPPT.getPosition()), lhPPTLink)
		proximityManager.addSensor(sensorNonDominantHand)
	
	global thirdAppendageReadyForGrab, thirdAppendageGrabbed, grabLink
	thirdAppendageReadyForGrab = False
	thirdAppendageGrabbed = False
	grabLink = None
	
	#adding a wiimote to trigger grab action
	#Add wiimote extension 
	wii = viz.add('wiimote.dle')

	#Connect to first available wiimote 
	wiimote = wii.addWiimote()
	
	vizact.onsensordown(wiimote,wii.BUTTON_A,grabActionOnThirdAppendage,True)
	vizact.onsensorup(wiimote,wii.BUTTON_A,grabActionOnThirdAppendage,False)

	#things to highlight the third appendage when ready for selection for grab action
#	from tools import highlighter
#	global highlightingTool
#	highlightingTool = highlighter.Highlighter()
#	highlightingTool.setItems([thirdAppendage])
#	highlightingTool.setHighlightMode(highlighter.MODE_BOX)
#	highlightingTool.highlight()
#	thirdAppendage.set

	#methods to trigger selection of the third appendage with the non-dominant hand
	if sensorNonDominantHand is not None:
		proximityManager.onEnter(sensorNonDominantHand, EnterProximity)
		proximityManager.onExit(sensorNonDominantHand, ExitProximity)
Ejemplo n.º 3
0
def wiimoteInitializer(wiimote, nunchuck_wiimote, should_it_run, message_screen):
	vizact.onsensordown(wiimote, wii.BUTTON_HOME, wiiButtonManager, wiimote, nunchuck_wiimote, should_it_run, message_screen)
	vizact.onsensordown(wiimote, wii.BUTTON_UP, wiiButtonManager, wiimote, nunchuck_wiimote, should_it_run, message_screen)
	vizact.onsensordown(wiimote, wii.BUTTON_DOWN, wiiButtonManager, wiimote, nunchuck_wiimote, should_it_run, message_screen)
	vizact.onsensordown(wiimote, wii.BUTTON_LEFT, wiiButtonManager, wiimote, nunchuck_wiimote, should_it_run, message_screen)
	vizact.onsensordown(wiimote, wii.BUTTON_RIGHT, wiiButtonManager, wiimote, nunchuck_wiimote, should_it_run, message_screen)
	vizact.onsensordown(wiimote, wii.BUTTON_A, wiiButtonManager, wiimote, nunchuck_wiimote, should_it_run, message_screen)
	vizact.onsensordown(wiimote, wii.BUTTON_B, wiiButtonManager, wiimote, nunchuck_wiimote, should_it_run, message_screen)
	vizact.onsensordown(wiimote, wii.BUTTON_PLUS, wiiButtonManager, wiimote, nunchuck_wiimote, should_it_run, message_screen)
	vizact.onsensordown(wiimote, wii.BUTTON_MINUS, wiiButtonManager, wiimote, nunchuck_wiimote, should_it_run, message_screen)
	vizact.onsensordown(wiimote, wii.BUTTON_1, wiiButtonManager, wiimote, nunchuck_wiimote, should_it_run, message_screen)
	vizact.onsensordown(wiimote, wii.BUTTON_2, wiiButtonManager, wiimote, nunchuck_wiimote, should_it_run, message_screen)
	vizact.onsensordown(wiimote, wii.NUNCHUK_C, wiiButtonManager, wiimote, nunchuck_wiimote, should_it_run, message_screen)
	vizact.onsensordown(wiimote, wii.NUNCHUK_Z, wiiButtonManager, wiimote, nunchuck_wiimote, should_it_run, message_screen)
	
	#Rumble the wiimote while the B button is down
	vizact.onsensordown(wiimote,wii.BUTTON_B,wiimote.setRumble,True)
	vizact.onsensorup(wiimote,wii.BUTTON_B,wiimote.setRumble,False)
Ejemplo n.º 4
0
	def setAsMain(self):
#		self.VIEW_LINK.setOffset([0,self.EYE_HEIGHT,0])
		self.VIEW_LINK.preTrans([0,-self.EYE_HEIGHT,0])
		
		viz.mouse.setOverride(viz.ON) 
		viz.fov(self.FOV)
		
		val = mathlite.getNewRange(self.joy.getSlider(),1,-1,self.MIN_SPEED,self.MAX_SPEED)
		self.MOVE_SPEED = val
		
		vizact.ontimer(0, self.updateView)
		vizact.onsensorup(self.joy, self.KEYS['reset'], self.reset)
		viz.callback(getExtension().SLIDER_EVENT,self.onSliderChange)
		
		def onMouseMove(e):
			euler = self.VIEW.getEuler()
			euler[0] += e.dx*0.05
			euler[1] += -e.dy*0.05
			euler[1] = viz.clamp(euler[1],-85.0,85.0)
			self.VIEW.setEuler(euler)
		viz.callback(viz.MOUSE_MOVE_EVENT, onMouseMove)	
Ejemplo n.º 5
0
    markerNum = 0

    vizact.onkeydown('1', env.setNewCornerPosition, 0, markerNum)
    vizact.onkeydown('2', env.setNewCornerPosition, 1, markerNum)
    vizact.onkeydown('3', env.setNewCornerPosition, 2, markerNum)
    vizact.onkeydown('4', env.setNewCornerPosition, 3, markerNum)

    vizact.onkeydown('0', env.updatePowerwall)

    vizact.onkeydown('s', config.mocap.resetRigid, 'shutterGlass')
    vizact.onkeydown('S', config.mocap.saveRigid, 'shutterGlass')

    wii = viz.add('wiimote.dle')  #Add wiimote extension

    vizact.onsensorup(config.wiimote, wii.BUTTON_LEFT,
                      env.setNewCornerPosition, 0, markerNum)
    vizact.onsensorup(config.wiimote, wii.BUTTON_UP, env.setNewCornerPosition,
                      1, markerNum)
    vizact.onsensorup(config.wiimote, wii.BUTTON_RIGHT,
                      env.setNewCornerPosition, 2, markerNum)
    vizact.onsensorup(config.wiimote, wii.BUTTON_DOWN,
                      env.setNewCornerPosition, 3, markerNum)
    vizact.onsensorup(config.wiimote, wii.BUTTON_PLUS, env.updatePowerwall)

    vizact.onsensorup(config.wiimote, wii.BUTTON_MINUS,
                      viz.MainWindow.setStereoSwap, viz.TOGGLE)

    duckBeginPos = env.getCenterPos()
    duck = viz.addAvatar('duck.cfg', pos=duckBeginPos)
    duck.scale([0.3, 0.3, 0.3])
    eyeSphere.setMocapRigidBody(config.mocap, 'shutter')
Ejemplo n.º 6
0


import vizact
import PyWiiUse as wiiuse

#<wii>.addWiimote(device=-1)



#class wiimote():
#	def __init__(self):
#		wiimote = wii.addWiimote()
#		vizact.onsensordown(wiimote,wii.BUTTON_A,wiimote.setRumble,True) 
#		vizact.onsensorup(wiimote,wii.BUTTON_A,wiimote.setRumble,False)


wiimotes = wiiuse.init(1, 1, handle_event, handle_ctrl_status, handle_disconnect)

wii = viz.add('wiimote.dle') 
wiimote = wii.addWiimote()
vizact.onsensordown(wiimote,wii.BUTTON_A,wiimote.setRumble,True) 
vizact.onsensorup(wiimote,wii.BUTTON_A,wiimote.setRumble,False)

viz.go()
Ejemplo n.º 7
0
import vizact
import PyWiiUse as wiiuse

#<wii>.addWiimote(device=-1)

# class wiimote():
#	def __init__(self):
#		wiimote = wii.addWiimote()
#		vizact.onsensordown(wiimote,wii.BUTTON_A,wiimote.setRumble,True)
#		vizact.onsensorup(wiimote,wii.BUTTON_A,wiimote.setRumble,False)

wiimotes = wiiuse.init(1, 1, handle_event, handle_ctrl_status,
                       handle_disconnect)

wii = viz.add('wiimote.dle')
wiimote = wii.addWiimote()
vizact.onsensordown(wiimote, wii.BUTTON_A, wiimote.setRumble, True)
vizact.onsensorup(wiimote, wii.BUTTON_A, wiimote.setRumble, False)

viz.go()
Ejemplo n.º 8
0
def goCG():
	bgcolor = [0.15*1.2, 0.67*1.2, 0.95*1.2]
	viz.clearcolor(bgcolor)
	global skipKey, egg
	flagPile = globals_oa.terrainZone1.getChild('flagPile.OSGB', viz.CHILD_REPLACE_TRANSFORM)
	fishZone1 = schooling.initialize(1)
#	yield viztask.waitEvent(globals_oa.VIDEO_END_EVENT)
	
#	loadStuffAtStartAndHideThemALL()
	
	vizact.onsensorup(globals_oa.rhViveTracker, steamvr.BUTTON_TRIGGER, printRightHandPosition)
	vizact.onsensorup(globals_oa.lhViveTracker, steamvr.BUTTON_TRIGGER, printLeftHandPosition)
	
	globals_oa.terrainZone1.visible(viz.ON)
	globals_oa.ocean.visible(viz.ON)
#	schooling.hidePercentage(0)
#	schooling.chromis_chromis.hidePercentage(0)
#	schooling.diplodus_annularis.hidePercentage(0)
#	schooling.labrus_viridis.hidePercentage(0)
#	schooling.sarpa_salpa.hidePercentage(0)
	
#	schooling.show(fishZone1)
	
#	fog = vizfx.addFogEffect(colorRamp=viz.addTexture(globals_oa.MODEL_DIRECTORY + 'FogRamp.tif'), height=1, density=(.09))
#	fog = vizfx.addFogEffect(colorRamp=viz.addTexture(globals_oa.MODEL_DIRECTORY + 'FogRamp.tif'), height=1, density=(10))
#	vizfx.getComposer().addEffect(fog)
#	viz.MainScene.enable(viz.FOG, op=viz.OP_ROOT)
	
	viz.fogcolor(viz.AZURE)
	viz.fog(0.025)
	
#	worldvizcode.initVFXforDC(globals_oa.terrainZone1) # should moved into loadAndHide?
	worldvizcode.startEffects(globals_oa.terrainZone1) #not needed?
	
	#positioning the user on the terrain
#	offsetting the user on the terrain
	y_offset = -1.5
	userPos = globals_oa.user.getPosition(viz.ABS_GLOBAL)
	globals_oa.user.setPosition([userPos[0], y_offset, userPos[2]])
	
#####** Healthy CG zone fades in**
#	terrain1Child = globals_oa.terrainZone1.getChild('Terrain_Zone009')
#	posToMoveUserTo = terrain1Child.getBoundingBox().center
#	print "posToMoveUserTo = " + str(posToMoveUserTo)
	
	if globals_oa.fader is None: globals_oa.fader = View_Fader.addFader(fadeTime=5)
	globals_oa.fader.fadeIn()

#####	#This is a healthy reef, where carbon dioxide has not yet altered seawater chemistry. 
	#
#####	#When scientists measure the health and biodiversity of a reef, they perform something called a species count. 
#####	#Today, you will be counting the number of sea snails on this part of the reef. Look at your right hand
	#
	globals_oa.TRANSITION_TO_CG.play()
	yield viztask.waitAny([viztask.waitTime(10), skipKey])
	globals_oa.CG_SCENE1_1.play()
#	getAllChildrenZone1 = viz.MainScene.getChildren(all=True)
	def fadeAllZone1():
		globals_oa.terrainZone1.alpha(0)
		globals_oa.terrainZone1.visible(viz.ON)
		worldvizcode.stopEffects()
		viz.fog(0)
		fadeInZone1 = vizact.fadeTo(1, time=2)
		yield globals_oa.terrainZone1.addAction(fadeInZone1)
#		for child in getAllChildrenZone1: 
#			child.addAction(fadeInZone1)
			
	yield viztask.waitAny([viztask.waitTime(17), skipKey])	
#	globals_oa.CG_SCENE1_1.stop()
	
	#*participant sees 3D model of sea snail rotating like a hologram*
#	if globals_oa.rhViveTracker is not None:
#	vizact.ontimer2(0.004, 25, scavengerhunt.vibrateHandController, 2)
#	leftHandVibrateTimer.setEnabled(True)
#	rightHandVibrateTimer.setEnabled(True)
	
	
	rotatingSnail.visible(viz.ON)
	snailLink = None
	vizact.ontimer2(.004, 50, vibrateRightHand)
	if globals_oa.rhViveTracker is not None:
		snailLink = viz.link(globals_oa.rhViveTracker, rotatingSnail)
		snailLink.setOffset([0.0, y_offset, 0.0])
		snailLink.preTrans([0.01,-0.03,-0.13])
		snailLink.preEuler([0,0,180])

	
	yield viztask.waitTime(11)
	

#####	#*hologram disappears, species count begins*
	if snailLink is not None: snailLink.remove()
	rotatingSnail.visible(viz.OFF)
	rotatingSnail.remove()

##### flashing the flag pile ######
	egg.visible(viz.ON)
	flashOn = vizact.fadeTo(1, time=1, interpolate=vizact.easeInOut)
	flashOff = vizact.fadeTo(0, time=1, interpolate=vizact.easeInOut)
	flashSequence = vizact.sequence(flashOn, flashOff, 5)
	egg.add(flashSequence)
	
	
	yield viztask.waitTime(11)

	globals_oa.CG_SCENE1_2.play()
	print "playing CG_SCENE1_2 now"
#	yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.CG_SCENE1_2), skipKey])
	yield viztask.waitAny([viztask.waitTime(17), skipKey])
#	scavengerhunt.initialize(globals_oa.terrainZone1, globals_oa.filePathToSpeciesForScavengerHuntInZone1)
#	scavengerhunt.hideBasketAndStuffAttachedToIt()
	print "waiting for the species hunt end event, or for a timer to run out"
#	yield viztask.waitAny([viztask.waitEvent(scavengerhunt.ZONE1_OVER_EVENT), viztask.waitTime(60), skipKey])
	yield viztask.waitAny([viztask.waitTime(35), skipKey])
	print "species hunt is over"
#	leftHandVibrateTimer.setEnabled(False)
#	rightHandVibrateTimer.setEnabled(False)
#	scavengerhunt.endScavengerHunt()
#	yield viztask.waitEvent(scavengerhunt.ZONE1_OVER_EVENT)
#	scavengerhunt.disableGrabber()

	#waiting for the audio to end
	print "waiting for the narration to end"
	yield viztask.waitAny([viztask.waitTime(5), skipKey])

	#healthy zone fading out
#	print "fading out from zone-1 begin"
#	globals_oa.fader.fadeOutTask()
	globals_oa.fader.fadeOut()
#	print "fading out from zone-1 complete"
	
	yield viztask.waitAny([viztask.waitTime(5), skipKey])
	
#####	#**Unhealthy CG zone fades in**
#	globals_oa.terrainZone1.disable(viz.RENDERING)
	globals_oa.terrainZone1.visible(viz.OFF)
	if globals_oa.lhModelFlag is not None: globals_oa.lhModelFlag.visible(viz.OFF)
	if globals_oa.rhModelFlag is not None: globals_oa.rhModelFlag.visible(viz.OFF)
	schooling.hide(fishZone1)
	
#	userPos = globals_oa.user.getPosition()
#	globals_oa.user.setPosition(userPos[0] + globals_oa.zone3_X_offset, userPos[1], userPos[2])
#	globals_oa.user.setPosition(userPos[0], userPos[1], userPos[2])
#	globals_oa.basket.setPosition(globals_oa.basketPosInCGscene3)
#	globals_oa.terrainZone3.setPosition(-60.73, 0.0, 0.0)
#	scavengerhunt.hideBasketAndStuffAttachedToIt()
	
	globals_oa.terrainZone3.visible(viz.ON)
#	worldvizcode.stopEffects()
	worldvizcode.startEffects(globals_oa.terrainZone3)

#	schooling.show(fishZone2)	

#	print "fading into zone-3 begin"
#	globals_oa.fader.fadeInTask()
	globals_oa.fader.fadeIn()
#	print "fading into zone-3 complete"

#####	Observe the changes that have occurred as acidity has increased. Reach out and touch one of the streams of bubbles rising from the sea floor
	globals_oa.CG_SCENE2_1.play()
	print "playing CG_SCENE2_1 now"
#	yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.CG_SCENE2_1), skipKey])

#adding proximity handling for touching the bubbles
	global bubbleVibratorManager
	bubbleVibratorManager = vizproximity.Manager()
	
#	bubbleVibratorManager.setDebug(viz.ON)
	vizact.onkeydown('b', bubbleVibratorManager.setDebug, viz.TOGGLE)

	#adding bounding box sensors around the bubbles
	updateVibrationSensors()
#	vizact.onkeydown('u',updateVibrationSensors)

	#adding boxes around the hands as targets
	global rhandtar, lhandtar
#	rhsphere = vizshape.addSphere(radius = 0.07) 
	rhsphere = vizshape.addBox(size=(0.1,0.1,0.3))
	rhsphere.setParent(globals_oa.rightHand)
	rhsphere.setPosition([0,0,-0.15])
	rhsphere.disable(viz.RENDERING)
#	lhsphere = vizshape.addSphere(radius = 0.07) 
	lhsphere = vizshape.addBox(size=(0.1,0.1,0.3))
	lhsphere.setParent(globals_oa.leftHand)
	lhsphere.setPosition([0,0,-0.15])
	lhsphere.disable(viz.RENDERING)
#	if globals_oa.rhModel is not None:
	rhandtar = vizproximity.Target(rhsphere)#globals_oa.rhModel)
#	if globals_oa.lhModel is not None:
	lhandtar = vizproximity.Target(lhsphere)#globals_oa.lhModel)
	
	bubbleVibratorManager.addTarget(rhandtar)
	bubbleVibratorManager.addTarget(lhandtar)

	bubbleVibratorManager.onEnter(None, vibrateHandInBubbles)
	bubbleVibratorManager.onExit(None, stopVibrationOfHandInBubbles)
	
	print "*********************************** SENSORS ADDED FOR VIBRATING BUBBLES ***********************************"

	yield viztask.waitAny([viztask.waitTime(globals_oa.CG_SCENE2_1.getDuration()), skipKey])
	
#####	**wait until participant touches a stream of bubbles**
#####	** repeat last sentence until they do so**


#####The vents here in Ischia are releasing carbon dioxide, which is making the water more acidic. 
#####You study this part of the reef to predict how human carbon dioxide emissions will affect 
#####our world’s oceans and the species that live within them. 
#####Look at your right hand.
	globals_oa.CG_SCENE2_2.play()
	print "playing CG_SCENE2_2 now"
	
	yield viztask.waitAny([viztask.waitTime(16), skipKey])
	
	if globals_oa.rhViveTracker is not None:
		corrodedRotatingSnail.visible(viz.ON)
		vizact.ontimer2(.004, 50, vibrateRightHand)
		print '***********linking cooroded snail'
		snailLink = viz.link(globals_oa.rhViveTracker, corrodedRotatingSnail)
		snailLink.setOffset([0.0, y_offset, 0.0])
		snailLink.preTrans([0.01, -0.03, -0.13])
		snailLink.preEuler([0, 0, 180])
		snailLink.setMask(viz.LINK_POS)
		spinForever = vizact.spin(0,1,0, 90, dur = viz.FOREVER)
		corrodedRotatingSnail.runAction(spinForever)
	yield viztask.waitTime(10)
	corrodedRotatingSnail.visible(viz.OFF)
	
	yield viztask.waitAny([viztask.waitTime(40), skipKey])
	if bubbleVibratorManager is not None:
		bubbleVibratorManager.clearSensors()
		bubbleVibratorManager.clearTargets()

	if rightHandVibrateTimer is not None: rightHandVibrateTimer.setEnabled(False)
	if leftHandVibrateTimer is not None: leftHandVibrateTimer.setEnabled(False)
	globals_oa.finalTransitionSound.play()
#	yield viztask.waitTime(1)
	bubbleStreams = globals_oa.terrainZone3.getChild('zone2_smaller.OSGB')
	bubbleStreams.setAnimationSpeed(0.1)
	globals_oa.UNDERWATER_AMBIENT.stop()
	yield viztask.waitTime(3)
	globals_oa.FINAL_SCENE.play()
	yield viztask.waitAny([viztask.waitTime(10), skipKey])
	fadeInSphere = vizact.fadeTo(0, time=2)
	fadeOutSphere = vizact.fadeTo(1, time=2)
	def fadingFadeThing():
		yield viztask.waitTime(1)
		globals_oa.fadingSphere.addAction(fadeOutSphere)
		yield viztask.waitActionEnd(globals_oa.fadingSphere, fadeOutSphere)
		globals_oa.terrainZone3.visible(viz.OFF)
		globals_oa.ocean.visible(viz.OFF)
#		globals_oa.terrainZone1.visible(viz.ON)
		globals_oa.globeScene.enable(viz.RENDERING)
		globals_oa.user.setPosition(0.0,-0.05,0.0)
		viz.fogcolor(viz.BLACK)
		viz.fog(0.2)
		viz.clearcolor(viz.BLACK)
		globals_oa.fader.fadeOutTask()
		globals_oa.fader.fadeInTask()
#		yield viztask.waitTime(2)
		yield globals_oa.fadingSphere.addAction(fadeInSphere)
	viztask.schedule(fadingFadeThing)
	globals_oa.fader.fadeOutTask()