Esempio n. 1
0
	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)
Esempio n. 2
0
def enableUnderWater():
    waterPlane.visible(viz.OFF)
    viz.fog(0.1)
    viz.fogcolor(0.7686, 0.8745, 0.8824)
    effect.setEnabled(viz.ON)
    timer.setEnabled(viz.OFF)
    waterSound.stop()
    move_and_scale()
Esempio n. 3
0
def init_settings(mainSceneWindow, cameraWindow, cameraWindowView, cam, pause_screen, nunchuck_disconnect_screen, message_screen, wiimote, nunchuck_wiimote, should_it_run):
	viz.MainWindow.visible(viz.OFF) #Hago invisible la main window
	viz.setMultiSample(8) # FSAA de 8
	viz.fogcolor = viz.BLACK # Color de sombra = negro
	viz.fog(0.15) # Agrega sombra de tipo exponencial
	viz.collision(viz.ON) # Habilita colisiones en el mundo
	viz.phys.enable() # Habilita la fisica

	#Desabilita mouse
	viz.mouse.setOverride(viz.ON)

	#Mouse invisible
	viz.mouse.setVisible(viz.OFF)

	#Subventana que renderea viz.MainWindow
	mainSceneWindow = viz.addWindow()
	mainSceneWindow.setSize(0.7,1)
	mainSceneWindow.setPosition(0,1)
	mainSceneWindow.fov(40, 1.3) # Coloca el FOV de la ventana principal en la actual con los valores de default (40 grados verticales, 1.3 aspect ratio)

	#Creando una ventana y un punto de vista para la camara
	cameraWindow = viz.addWindow(pos =[.7,1],size=(0.4,1)) #Creando la ventana
	cameraWindowView = viz.addView() #Creando un viewpoint
	cameraWindowView.setScene(2) #Poniendo la nueva ventana en la escena 2
	cameraWindow.setView(cameraWindowView) #Ligando el viewpoint con la nueva ventana

	#Vincular camara web a plugin de AR
	cam = ar.addWebCamera(window=cameraWindow) #Agregando una camara en la ventada nueva

	# Configuracion de mensajes de la pantalla
	message_screen = viz.addTexQuad(parent=viz.SCREEN, pos=[0.5,0.5,1], scale=[12.80,10.24,1]) 
	pause_screen = viz.add("PAUSA.png")
	nunchuck_disconnect_screen = viz.add("NUNCHUCK_DISCONNECTED.png")
	message_screen.texture(pause_screen)
	message_screen.visible(viz.OFF) #Cuando should_it_run sea False, viz.ON es el valor a usar.

	# Conecta al primer wiimote disponible
	wiimote = wii.addWiimote()
	# Prende el LED 1 del wiimote
	wiimote.led = wii.LED_1
	# Obten el nunchuck del wiimote
	nunchuck_wiimote = wiimote.nunchuk 

	#Determines wheter the program should run or not.
	#It will run if the Nunchuck is connected; otherwise, it won't.
	should_it_run = True

	#Ensures that the program won't run without the NUNCHUCK plug'd in.
	if(wiimote.getExtension() == wii.EXT_NUNCHUK):
		should_it_run = True
	else:
		print "Please plug-in the Wii NUNCHUCK."
		message_screen.texture(nunchuck_disconnect_screen)
		message_screen.visible(viz.ON)
		should_it_run = False
	
	return mainSceneWindow, cameraWindow, cameraWindowView, cam, pause_screen, nunchuck_disconnect_screen, message_screen, wiimote, nunchuck_wiimote, should_it_run
Esempio n. 4
0
	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)
Esempio n. 5
0
def setActive(value):
    global active
    if value == True:
        waterSound.play()
        waterSound.loop()
        choir_sound.play()
        waterPlane.setPosition([0, -2.0, 0])
        for obj in obj_vis:
            obj.visible(viz.ON)
        active = True
    else:
        for obj in obj_vis:
            obj.visible(viz.OFF)
        effect.setEnabled(viz.OFF)
        updateHandle.setEnabled(viz.OFF)
        timer.setEnabled(viz.OFF)
        viz.fog(0)
        waterSound.stop()
        choir_sound.stop()
        vizact.ontimer2(35, 0, resetBubbles)
        active = False
def crystalBallScene():
 global globeScene, crystalBall
 globeScene.enable(viz.RENDERING)
 viz.fog(0.2)
 crystalBall = globeScene.getChild('preview.osgb')
 crystalBall.alpha(0.7)
 #insideCrystal = globeScene.getChild('preview2.osgb')
 crystalBall.disable(viz.RENDERING)
 #insideCrystal.disable(viz.RENDERING)
 yield fader.fadeInTask()
 #globeScene.playsound('background.wav')
 globe = globeScene.getChild('earthGlobe.OSGB')
 spinForever = vizact.spin(0,-1,0, 25, dur = viz.FOREVER)
 spinForever2 = vizact.spin(0,1,0, 20, dur = viz.FOREVER)
 spinSome = vizact.spin(0,-1,0, 30, dur=5)
 globe.addAction(spinSome)
 crystalBall.addAction(spinForever)
 #insideCrystal.addAction(spinForever2)
 yield viztask.waitTime(5)
 fadeOutGlobe = vizact.fadeTo(0, speed = .7)
 globe.addAction(fadeOutGlobe)
 crystalBall.enable(viz.RENDERING)
 #insideCrystal.enable(viz.RENDERING)
 yield viztask.waitTime(1)
 globe.remove()
 manager = vizproximity.Manager()
 manager.setDebug(False) #make true to see the outline of the proximity sensor
 rightHandTarget = vizproximity.Target(globals_oa.rightHand)
 leftHandTarget = vizproximity.Target(globals_oa.leftHand)
 ballSensor = vizproximity.Sensor(vizproximity.Sphere(1.5, center=[0,5.5,0]), source=crystalBall)
 manager.addTarget(rightHandTarget)
 manager.addTarget(leftHandTarget)
 manager.addSensor(ballSensor)
 #yield vizproximity.waitEnter(ballSensor)
 yield viztask.waitKeyDown('/')
 globals_oa.AUDIO_SUCCESS.play()
 yield fader.fadeOutTask()
 globeScene.remove()
 crystalBall.remove()
Esempio n. 7
0
def checkCityBounds():
	global flyingLink, cityModel
	
	view = viz.MainView
	viewPos = view.getPosition()
	viewCart = EulerToCartesian2D(view.getEuler())
	
	# Disable collision if the user is out of the inner bound
	# (so the user won't collide with the buildings on the outer ring)
	if cityModel.withinInnerBound(viewPos):
		if collisionEnabled:
			enableCollision()
	else:
		disableCollision()
	
	# Calculate the user's distance to the city boundaries
	# and set the fog according to the distance
	distance = cityModel.distanceToOuterBounds(viewPos)
	if distance < 0:
		viz.fog(0.02)
	else:
		viz.fog(0.2 /(distance + 10))
	
	# If the user is out of the city (out of bounds), teleport to the other side of the city
	if viewPos[0] <= CITY_BOUNDS[0] - BORDER_OFFSET and viewCart[0] < 0:
		flyingLink.postTrans([CITY_SIZE[0] + BORDER_OFFSET + REAPPEAR_OFFSET, 0, 0])
		
		print 'Out of bounds... TELEPORT!'
		
	elif viewPos[0] >= CITY_BOUNDS[1] + BORDER_OFFSET and viewCart[0] > 0:
		flyingLink.postTrans([- CITY_SIZE[0] - BORDER_OFFSET - REAPPEAR_OFFSET, 0, 0])
		print 'Out of bounds... TELEPORT!'

	if viewPos[2] <= CITY_BOUNDS[2] - BORDER_OFFSET and viewCart[2] < 0:
		flyingLink.postTrans([0, 0, CITY_SIZE[1] + BORDER_OFFSET + REAPPEAR_OFFSET])
		print 'Out of bounds... TELEPORT!'
		
	elif viewPos[2] >= CITY_BOUNDS[3] + BORDER_OFFSET and viewCart[2] > 0:
		flyingLink.postTrans([0, 0, - CITY_SIZE[1] - BORDER_OFFSET - REAPPEAR_OFFSET])
		print 'Out of bounds... TELEPORT!'
	
	viz.fog(1, 2)
Esempio n. 8
0
def goBoat():
	global skipKey, bigCO2, bigH2O, boatProximityManager, h2co3molecule, footprints, rightHandTarget, leftHandTarget, h2co3FormationTriggered
#####	** participant is standing on the back platform of the boat**
	#load the environment if not already loaded
	
#	print "waiting for city scene to end"
#	yield viztask.waitEvent(globals_oa.CITY_SCENE_END_EVENT)
#	print "received city end event"

	loadStuffAtStartAndHideThemALL()
	print "starting molecule scene"
#	globals_oa.user.setPosition(globals_oa.boatSceneUserStartPos)

	#turning the user around
	globals_oa.user.setAxisAngle([0.0, 1.0, 0.0, 180.0])
	
	#adding a manager for handling boat proximity events
	boatProximityManager = vizproximity.Manager()
#	boatProximityManager.setDebug(viz.ON)
	boatProximityManager.setDebugColor(viz.PURPLE)
	boatProximityManager.setDebugActiveColor(viz.GREEN)

	leftHandTarget = None
	rightHandTarget = None

	if globals_oa.lhModel != None: leftHandTarget = vizproximity.Target(globals_oa.leftHand)
	else: print "lhModel not set up"
	
	if globals_oa.rhModel != None: rightHandTarget = vizproximity.Target(globals_oa.rightHand)
	else: print "rhModel not set up"

	if globals_oa.fader is None: globals_oa.fader = View_Fader.addFader(fadeTime=5)
	
	globals_oa.BOAT_SCENE_AMBIENT.play()
	viz.fog(0)
	globals_oa.fader.fadeIn()
	globals_oa.fadingSphere.alpha(0)

	#unhide boat and stuff
	showStuff()
#	globals_oa.boat.enable(viz.RENDERING)

#####	You’re now on a boat in the middle of the ocean. Look around and observe the CO2 molecules surrounding you.
#	globals_oa.BOAT_SCENE1.play()
#	print "playing BOAT_SCENE1 now"
#	yield viztask.waitAny([viztask.waitTime(29), skipKey])
	
	
#####	Look down at the floor and move so that you’re standing on top of the footprints.

#####*wait until the participant is in the correct position to start*
#	TODO: add a position sensor for the viewpoint of the user to step in
#	boatProximityManager.clearTargets()
#	boatProximityManager.addTarget(vizproximity.Target(viz.MainView))
#	boatProximityManager.clearSensors()
#	footprintsSensor = vizproximity.Sensor(vizproximity.RectangleArea([0.6, 0.6], center = globals_oa.footprintPos), None)
#	boatProximityManager.addSensor(footprintsSensor)
#	
#	boatProximityManager.onEnter(footprintsSensor, footprintSteppedOnEvent)
#
#	print "waiting for the footprint event ..."
#	yield viztask.waitAny([viztask.waitEvent(globals_oa.FOOTPRINT_EVENT), skipKey])

#####Look at water behind the boat. The molecule you see floating on the ocean’s surface is a water molecule, also known as H2O. 
#####Now, remember that CO2 molecule from the car? It’s floating towards you right now.
	
	yield viztask.waitTime(12)   #adds a little time before narration starts, not sure why the number has to be so large...
	globals_oa.BOAT_SCENE2.play()
	print "playing BOAT_SCENE2 now, which is atually the first boat scene"
	yield viztask.waitAny([viztask.waitTime(16), skipKey])
#	yield viztask.waitAny([viztask.waitTime(globals_oa.BOAT_SCENE2.getDuration()), skipKey])

#####**molecule drops down at the back of the boat**
	print "showing the falling molecule and setting its animation time to 0.0"
	yield flyingCO2()
	
#####To view the chemical reaction that occurs when CO2 is absorbed into the ocean, push the molecule over the side of the boat.
	globals_oa.BOAT_SCENE3.play()
	print "playing BOAT_SCENE3 now"
	yield viztask.waitAny([viztask.waitTime(15), skipKey])

#TODO: add a CO2 to the list of sensors in the molecule scene proximity manager
	boatProximityManager.clearTargets()
	if leftHandTarget is not None: 	boatProximityManager.addTarget(leftHandTarget)
	if rightHandTarget is not None: boatProximityManager.addTarget(rightHandTarget)

	boatProximityManager.clearSensors()
	co2Sensor = vizproximity.addBoundingBoxSensor(bigCO2)
	boatProximityManager.addSensor(co2Sensor)
	
	boatProximityManager.onEnter(co2Sensor, h2co3FormationTriggerEvent)
	
	print "waiting for the H2CO3 reaction-animation completion event ..."

	moleculePushFailAudio = globals_oa.BOAT_SCENE_TOUCH
	failTimer = vizact.ontimer(5 + moleculePushFailAudio.getDuration(), moleculePushFailAudio.play)
	
	yield viztask.waitAny([viztask.waitEvent(globals_oa.H2CO3_COMPLETION_EVENT), skipKey])
#	yield skipKey
#	yield viztask.waitAny([viztask.waitTime(4), skipKey])
	failTimer.remove()
	if not h2co3FormationTriggered: viztask.schedule(H2CO3formation())

#####Observe the chemical reaction. When carbon dioxide, or CO2, is absorbed into the ocean it reacts with seawater to form carbonic acid, or H2CO3. 
#####This process is called ocean acidification. If enough carbonic acid is created, the seawater becomes corrosive.  

#####The ocean covers over 70% of the Earth’s surface. Since the Industrial Revolution the ocean has absorbed 
#####roughly ¼ of the carbon dioxide produced by burning fossil fuels. 

#####We may not be able to see these reactions in our daily lives, but we can take a look at how these reactions affect marine life.
#####You will now travel to a special site where scientists have made a breakthrough discovery about carbon dioxide emissions.
	globals_oa.BOAT_SCENE4.play()
	print "playing BOAT_SCENE4 now"
	yield viztask.waitAny([viztask.waitTime(22), skipKey])
	#hide H2CO3
	h2co3molecule.visible(viz.OFF)
	
	yield showHiddenMolecules()
	yield viztask.waitAny([viztask.waitTime(21), skipKey])
#	print "waiting for a final skip key to fade out now - NOT PART OF THE NARRATION"
#	yield skipKey

	globals_oa.BOAT_SCENE_AMBIENT.stop()

	globals_oa.fader.fadeOut()

	#Cleanup
	hideStuff()

	#turning the user around
	globals_oa.user.setAxisAngle([0.0, 1.0, 0.0, 0.0])

	viz.sendEvent(globals_oa.BOAT_SCENE_END_EVENT)
Esempio n. 9
0
def cityScene():
 global city, skyDome2, CRYSTAL_EVENT, moleculeList, rightHandTarget, leftHandTarget
 global mole1, mole2, mole3
 global mole4, mole5, mole6, mole7, mole8, mole9, mole10, mole11
 print "city scene starting"
 globals_oa.CITY_SCENE_AMBIENT.play()
 city.enable(viz.RENDERING)
 viz.fog(0)
 arrow = city.getChild('greenArrow.OSGB')
 arrow.disable(viz.RENDERING)
 tube = city.getChild('yellowTube.OSGB')
 tube.disable(viz.RENDERING)

 yield globals_oa.fader.fadeInTask()
# yield viztask.waitTime(3)
 yield viztask.waitAny([viztask.waitTime(3), skipKey])
# carAudio1 = globals_oa.CAR_SCENE1
# carAudio1.play()
## yield viztask.waitMediaEnd(carAudio1)
# yield viztask.waitAny([viztask.waitTime(10), skipKey])
 carAudio2 = globals_oa.CAR_SCENE2
 carAudio2.play()
 arrow.enable(viz.RENDERING)
 fadeIn = vizact.fadeTo(1, time=1)
 fadeOut = vizact.fadeTo(0, time=1)
 sequence = vizact.sequence(fadeIn, fadeOut, viz.FOREVER)
 arrow.add(sequence)
# yield viztask.waitMediaEnd(carAudio2) 
 yield viztask.waitAny([viztask.waitTime(7), skipKey])
 carAudio3 = globals_oa.CAR_SCENE3
 carAudio3.play()
 arrow.disable(viz.RENDERING)
 manager = vizproximity.Manager()
 manager.setDebug(False)
 rightHandTarget = vizproximity.Target(globals_oa.rightHand)
 leftHandTarget = vizproximity.Target(globals_oa.leftHand)
 car1 = city.getChild('BlueCar.OSGB')
 exhaust = city.getChild('p_silencer-OFFSET')
 car1Sensor = vizproximity.Sensor(vizproximity.Box([0.5,0.7,0.4], center=[1.4,4.2,0]), source=exhaust)
 manager.addTarget(rightHandTarget)
 manager.addTarget(leftHandTarget)
 manager.addSensor(car1Sensor)
 tube.enable(viz.RENDERING)
 tube.add(sequence)
# car1Sensor = vizproximity.Sensor(vizproximity.Box([3.3,1.6,1.8], center=[5,0.4,-10.5]), source=car1)
 
 if carAudio3.audioObj.getState() == viz.MEDIA_RUNNING:
#  yield viztask.waitMediaEnd(carAudio3)
  yield viztask.waitAny([viztask.waitTime(4), skipKey])
# manager.addTarget(rightHandTarget)
# manager.addTarget(leftHandTarget)
# manager.addSensor(car1Sensor)
# CAR_TOUCHED = False
 failAudio = globals_oa.CAR_FAIL_AUDIO
 failAudio.stop()
 failTimer = vizact.ontimer(5 + failAudio.getDuration(), playWrapper, failAudio)
 #yield vizproximity.waitEnter(car1Sensor)

 
 def vibrateRightHand():
  globals_oa.rhViveTracker.setVibration(0.004)
 def vibrateLeftHand():
  globals_oa.lhViveTracker.setVibration(0.004)
 def onEnter(e): 
  global rightHandTarget, leftHandTarget
  print 'working'
  if e.target == rightHandTarget:
    vizact.ontimer2(.004, 100, vibrateRightHand)
  if e.target == leftHandTarget:
    vizact.ontimer2(.004, 100, vibrateLeftHand)
 manager.onEnter(car1Sensor, onEnter)
 
 def startCar1():
  global mole1, mole2, mole3, moleculeList
  mole1 = vizfx.addChild(globals_oa.FILE_PATH_TO_MOLECULE1)
  moleculeList.append(mole1)
  mole1.setPosition([-1.2, 0.35, -0.08])
  mole1.setScale([3,3,3])
  mole1.setAnimationSpeed(3)
  mole1.setEuler(-90,0,0)
  mole2 = vizfx.addChild(globals_oa.FILE_PATH_TO_MOLECULE2)
  moleculeList.append(mole2)
  mole2.setPosition([-1.1,0.3,0])
  mole2.setScale([3,3,3])
  mole2.setAnimationSpeed(2.1)
  mole2.setEuler(-90,0,0)
  mole3 = vizfx.addChild(globals_oa.FILE_PATH_TO_MOLECULE2)
  moleculeList.append(mole3)
  mole3.setPosition([-1.05,0.29,-0.05])
  mole3.setScale([3,3,3])
  mole3.setAnimationSpeed(5)
  mole3.setEuler(-90,0,0)
 def floatersGo():
  global mole4, mole5, mole6, mole7, mole8, mole9, mole10, mole11, moleculeList
  mole4 = vizfx.addChild(globals_oa.FILE_PATH_TO_MOLECULE1)
  moleculeList.append(mole4)
  mole4.setPosition([-.2,2.9,0])
  mole4.setEuler([0,-90,0])
  mole4.setScale([3,3,3])
  mole4.setAnimationSpeed(2)
  mole5 = vizfx.addChild(globals_oa.FILE_PATH_TO_MOLECULE2)
  moleculeList.append(mole5)
  mole5.setPosition([-.2,2.9,0])
  mole5.setEuler([90,-90,0])
  mole5.setScale([3,3,3])
  mole5.setAnimationSpeed(2)
  mole6 = vizfx.addChild(globals_oa.FILE_PATH_TO_MOLECULE1)
  moleculeList.append(mole6)
  mole6.setPosition([-.2,2.9,0])
  mole6.setEuler([180,-90,0])
  mole6.setScale([3,3,3])
  mole6.setAnimationSpeed(2)
  mole7 = vizfx.addChild(globals_oa.FILE_PATH_TO_MOLECULE2)
  moleculeList.append(mole7)
  mole7.setPosition([-.2,2.9,0])
  mole7.setEuler([-90,-90,0])
  mole7.setScale([3,3,3])
  mole7.setAnimationSpeed(2)
  mole8 = vizfx.addChild(globals_oa.FILE_PATH_TO_MOLECULE2)
  moleculeList.append(mole8)
  mole8.setPosition([-.2,2.9,0])
  mole8.setEuler([-45,-90,0])
  mole8.setScale([3,3,3])
  mole8.setAnimationSpeed(2)
  mole9 = vizfx.addChild(globals_oa.FILE_PATH_TO_MOLECULE2)
  moleculeList.append(mole9)
  mole9.setPosition([-.2,2.9,0])
  mole9.setEuler([45,-90,0])
  mole9.setScale([3,3,3])
  mole9.setAnimationSpeed(2)
  mole10 = vizfx.addChild(globals_oa.FILE_PATH_TO_MOLECULE2)
  moleculeList.append(mole10)
  mole10.setPosition([-.2,2.9,0])
  mole10.setEuler([-135,-90,0])
  mole10.setScale([3,3,3])
  mole10.setAnimationSpeed(2)
  mole11 = vizfx.addChild(globals_oa.FILE_PATH_TO_MOLECULE2)
  moleculeList.append(mole11)
  mole11.setPosition([-.2,2.9,0])
  mole11.setEuler([135,-90,0])
  mole11.setScale([3,3,3])
  mole11.setAnimationSpeed(2)
 def goSpecialMole():
  global specialMole
  yield viztask.waitTime(1)
  specialMole = vizfx.addChild(globals_oa.FILE_PATH_TO_MOLECULE3)
  specialMole.setPosition([-1.33023,0.35456,-0.04151])
  specialMole.setScale([4,4,4])
  lowPolyMole = specialMole.getChild('singleCO2_noAnimation.OSGB')
  lowPolyMole.disable(viz.RENDERING)
  path = viz.addAnimationPath()
  path.addControlPoint(0, pos=[-1.33023,0.35456,-0.04151], euler=(90,0,0), scale= ([4,4,4]))
  path.addControlPoint(1, pos=[-1,0.4, 0], euler=(45,0,0), scale = ([4,4,4]))
  path.addControlPoint(2, pos=[-0.8,0.9,0.1], euler=(0,0,0), scale = ([4,4,4]))
  path.addControlPoint(3, pos=[-0.4,1.3,0.2], euler=(90,0,0), scale = ([4,4,4]))
  pathLink = viz.link(path, specialMole)
  path.play()
 def flyOut():
  global specialMole, skipKey
  yield viztask.waitTime(1)
  path = viz.addAnimationPath()
  path.addControlPoint(0, pos=[-0.4,1.3,0.2], euler=(90,0,0), scale= ([4,4,4]))
  path.addControlPoint(1, pos=[-0.4,1.5,0.6], euler=(55,0,0), scale= ([4,4,4]))
  path.addControlPoint(2, pos=[-0.4,3.3,0.1], euler=(100,0,0), scale= ([4,4,4]))
  path.addControlPoint(3, pos=[-0.4,4.8,0.8], euler=(75,0,0), scale= ([4,4,4]))
  path.addControlPoint(50, pos=[-0.4,70,0.4], euler=(90,0,0), scale = ([4,4,4]))
  pathLink = viz.link(path, specialMole)
  path.play()
# yield viztask.waitKeyDown('/')
 yield vizproximity.waitEnter(car1Sensor)
 failTimer.remove()
 tube.disable(viz.RENDERING)
 globals_oa.CAR_START.play()
 things = vizact.ontimer2(1,10, startCar1)
 yield things
 yield vizact.waittime(1.5)
 things2 = vizact.ontimer2(1,10, floatersGo)
 globals_oa.CAR_SCENE4.play()
 yield things2
 yield vizact.waittime(1.5)
# yield viztask.waitMediaEnd(globals_oa.CAR_SCENE4)
 yield viztask.waitAny([viztask.waitTime(15), skipKey])
 yield goSpecialMole()
 viztask.waitTime(3)
 globals_oa.CAR_SCENE5.play()
# yield viztask.waitMediaEnd(globals_oa.CAR_SCENE5)
 yield viztask.waitAny([viztask.waitTime(6), skipKey]) 
 yield flyOut()
 yield viztask.waitTime(6)
# childList = range(1,160)
# for child in childList:
#  object = viz.VizChild(child)
#  object.remove()
 for mole in moleculeList:
  mole.remove()

 yield globals_oa.fader.fadeOutTask()
 globals_oa.CITY_SCENE_AMBIENT.stop()
 city.remove()

 
 print "sending city end event"
 viz.sendEvent(globals_oa.CITY_SCENE_END_EVENT)
Esempio n. 10
0
def crystalBallSceneGo():
# try:
 global crystalBall, skipKey
 viz.clip(.1,100000)
 globals_oa.globeScene.enable(viz.RENDERING)
 viz.fogcolor(viz.BLACK)
 viz.fog(0.2)
 #add globe and crystal ball, spinning
 crystalBall = globals_oa.globeScene.getChild('crystalBall.OSGB')
 crystalBall.alpha(.7)
 floor = globals_oa.globeScene.getChild('sceneFloor.osgb')
 #GenerateStarDome(150000,2,0,2000, 1, 0)

 spinForever = vizact.spin(0,-1,0, 25, dur = viz.FOREVER)
 crystalBall.addAction(spinForever,0)
 globe = globals_oa.globeScene.getChild('earthGlobe.OSGB')
 spinSome = vizact.spin(0,-1,0, 30, dur=viz.FOREVER)
 globe.addAction(spinSome,2)
 yield globals_oa.fader.fadeInTask()

 #play audio file
 globeAudio1 = globals_oa.GLOBE_SCENE_AUDIO1
 globeAudio2 = globals_oa.GLOBE_SCENE_AUDIO2
 globeAudio1.play()
 globeAudio2.play()
 
 if globals_oa.skippingActivated: raise MyException()
 
# spinForever2 = vizact.spin(0,1,0, 20, dur = viz.FOREVER)
# yield viztask.waitTime(20)
 yield viztask.waitAny([viztask.waitTime(20), skipKey])
 crystalBall.visible(viz.OFF)
 fadeOutGlobe = vizact.fadeTo(0,time = 3)
 globe.addAction(fadeOutGlobe, 3)
 yield viztask.waitActionEnd(globe, fadeOutGlobe)
 globe.remove()
 crystalBall.visible(viz.ON)
# yield viztask.waitTime(8)
 yield viztask.waitAny([viztask.waitTime(6), skipKey])
 manager = vizproximity.Manager()
 manager.setDebug(False) #make true to see the outline of the proximity sensor
 rightHandTarget = vizproximity.Target(globals_oa.rightHand)
 leftHandTarget = vizproximity.Target(globals_oa.leftHand)
 ballSensor = vizproximity.Sensor(vizproximity.Sphere(3, center=[0,5.5,0]), source=crystalBall)
 manager.addTarget(rightHandTarget)
 manager.addTarget(leftHandTarget)
 manager.addSensor(ballSensor) 
 yield viztask.waitTime(globeAudio2.getDuration()-33)
 failAudio = globals_oa.GLOBE_FAIL_AUDIO
 failTimer = vizact.ontimer(5 + failAudio.getDuration(), failAudio.play) 

 yield vizproximity.waitEnter(ballSensor)
# failTimer = vizact.ontimer(5 + failAudio.getDuration(),playWrapper, failAudio)
 failTimer.remove()
# yield viztask.waitKeyDown('/')
 
 globals_oa.AUDIO_SUCCESS.play()
 yield globals_oa.fader.fadeOutTask()
 globals_oa.globeScene.disable(viz.RENDERING)
 globals_oa.GLOBE_SCENE_AUDIO1.stop()
 viz.fog(0)
Esempio n. 11
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()