Example #1
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)
import spherical_player_Vive
from vhil_devkit_Vive import *

import vizfx.postprocess

#DK2 demo
import viz
import oculus_08 as oculus
import steamvr
import vizfx
import vector3
from vector3 import *

viz.go()

fader = View_Fader.addFader()


skipKey = viztask.waitKeyDown('-')

headLight = viz.MainView.getHeadLight() 
headLight.disable()

def loadStuffAtStart():
	global city
	#loading the Crystal Ball Scene
	globals_oa.globeScene = vizfx.addChild(globals_oa.FILE_PATH_TO_GLOBE)
	globals_oa.globeScene.setScale([0.2,0.2,0.2])
	globals_oa.globeScene.setPosition([0,0,1])
	globals_oa.globeScene.disable(viz.RENDERING)
Example #3
0
import vizfx.postprocess

#DK2 demo
import viz
#import oculus_08 as oculus
import steamvr
import vizfx
import vector3
from vector3 import *
from random import *

viz.setOption('viz.model.hint', viz.PRELOAD_HINT)
viz.setOption('viz.preload', 1)
viz.go()

if globals_oa.fader is None: globals_oa.fader = View_Fader.addFader()



#def setup():
#	# Setup Oculus Rift HMD
#	headTracker = None
#	hmd = oculus.Rift()
#	headTracker = hmd.getSensor()
#
#	if not headTracker:
#		hmd = steamvr.HMD()
#		headTracker = hmd.getSensor()
#	else:
#		globals_oa.hmdType = "RIFT"
#
Example #4
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()