Пример #1
0
def phase_choice():
    # load start box
    choice_box = vizinfo.add('')
    choice_box.title('Phase Choice')
    choice_box.scale(2, 2)
    choice_box.translate(0.85, 0.65)
    choice_box.drag(viz.OFF)

    # add options for different mazes
    learning_phase = choice_box.add(viz.BUTTON, 'Learning')
    testing_phase = choice_box.add(viz.BUTTON, 'Testing')

    # add variables for user chocies
    learning_phase_pressed = viztask.waitButtonDown(learning_phase)
    testing_phase_pressed = viztask.waitButtonDown(testing_phase)

    # data variable to hold user choices
    data = viz.Data()

    global phase_selection
    yield viztask.waitAny([learning_phase_pressed, testing_phase_pressed],
                          data)
    if data.condition is learning_phase_pressed:
        phase_selection = 'Learning'
        choice_box.remove()
    elif data.condition is testing_phase_pressed:
        phase_selection = 'Testing'
        choice_box.remove()
Пример #2
0
def TrialTask(pos):
    """Task for individual trial. Returns whether pigeon was found."""

    #Reset tracker to origin
    tracker.setPosition([0,1.8,0])
    tracker.setEuler([0,0,0])

    # Flash screen
    FlashScreen()

    # Place pigeon at new location
    pigeon_root.setPosition(pos)
    pigeon_root.visible(True)
    hooting.play(loop=True)

    # Create proximity sensor for pigeon using main view as target
    manager = vizproximity.Manager()
    #manager.setDebug(True)
    manager.addTarget( vizproximity.Target(viz.MainView) )
    sensor = vizproximity.Sensor(vizproximity.Sphere(PROXIMITY_RADIUS),pigeon_root)
    manager.addSensor(sensor)

    # Wait until pigeon is found or time runs out
    wait_time = viztask.waitTask( TrialCountDownTask() )
    wait_find = vizproximity.waitEnter(sensor)
    data = yield viztask.waitAny([wait_time,wait_find])

    # Hide pigeon and remove proximity sensor
    pigeon_root.visible(False)
    hooting.pause()
    manager.remove()

    # Return whether pigeon was found
    viztask.returnValue(data.condition is wait_find)
Пример #3
0
def changeQ(sceneIndex, qList, delayTime, panelTitle, breakQ=True):
    indexQuestion = "delay"
    global indexQuestion
    if sceneIndex == "U_0_control.png" or sceneIndex == "2_med.png":
        condition = "demo"
        indexscene = sceneIndex
        shuffleQuestionList = list(IntroQ)
        shuffle(shuffleQuestionList)
    else:
        condition = "scene"
        indexScene = env_map_namelist[sceneIndex]
        shuffleQuestionList = list(qList)
        shuffle(shuffleQuestionList)

    global indexScene
    Panelvisible(Panel, 0)
    yield viztask.waitTime(delayTime)
    Panelvisible(Panel, 1)
    rowBottom.visible(viz.ON)
    maxNumber.visible(viz.ON)

    qIndex = 0
    while qIndex < len(qList):
        Panel.setTitle(panelTitle)
        viz.callback(dinput.HAT_EVENT, onHatChange)
        question = shuffleQuestionList[qIndex]
        changeMessage(shuffleQuestionList[qIndex], breakQ)

        if condition == "scene":
            index = mainQOrig.index(question)
        if condition == "demo":
            index = IntroQ.index(question)

        indexQuestion = str(index + 1)
        global indexQuestion
        #track.setEnabled(viz.OFF)
        yield viztask.waitAny([waitButton1], d)
        if d.condition is waitButton1:
            yield viztask.waitTime(.2)
            pos = Slider.get()
            if round(abs(pos / .1), 1) > 0:
                saveRate(qIndex, sceneIndex, index)
                Slider.set(0)
                Slider.message("")
                qIndex = qIndex + 1
            else:
                yield viztask.waitTime(.2)
                #Panel.setTitle("MINIMUM SELECTION IS (0)")
                yield viztask.waitTime(3)
    if qIndex == len(qList):
        #viztask.schedule(FadeToGrayTask())
        Panelvisible(Panel, 0)
        sky.visible(viz.OFF)
        yield viztask.waitTime(1)
Пример #4
0
	def __stride(self):
		leftDown = viztask.waitEvent(LEFT_ON_TREADMILL)
		leftUp = viztask.waitEvent(LEFT_OFF_TREADMILL)
		rightDown = viztask.waitEvent(RIGHT_ON_TREADMILL)
		rightUp = viztask.waitEvent(RIGHT_OFF_TREADMILL)
		while True:
			d = yield viztask.waitAny([leftDown, leftUp, rightDown, rightUp])
			if self.enable:
				if d.condition is leftDown:
					self.leftDownTime = viz.tick()
					self.leftDownPos[0] = self.forceplates.latestLeftCOP[0]
					self.leftDownPos[1] = self.forceplates.latestLeftCOP[1] + CORRECT_LEFT
					st = self.leftDownTime - self.leftUpTime
					if st > MIN_STRIDE_TIME and st < MAX_STRIDE_TIME:
						self.leftStrideTime[0] = st
						self.leftStrideTime = np.roll(self.leftStrideTime, 1)
					self.leftStrideLength = math.sqrt((self.leftDownPos[0] - self.leftUpPos[0])**2 +\
						(self.leftDownPos[1] - self.leftUpPos[1])**2)
					self.leftDistToDesired = self.leftDownPos[1] - DESIRED_POSITION
					if self.leftDistToDesired > MIN_DIST_TO_DESIRED:
						#set the left speed to be fast enough to get the foot back to the 'desired' while the right is up
						self.leftSpeed = FIXED_SPEED
						#self.leftSpeed = self.leftDistToDesired/np.mean(self.rightStrideTime + 1.e-6) #avoid 1/0
						self.tmill.moveLeftBelt(spd=min([self.leftSpeed, MAX_SPEED]), mpss=ACCELERATION)
						self.history.append("%10.9g %10.9g leftdown"%(viz.tick(), min([self.leftSpeed, MAX_SPEED])))
				elif d.condition is leftUp:
					self.tmill.moveLeftBelt(spd=0, mpss=DECELERATION)
					self.history.append("%10.9g %10.9g leftup"%(viz.tick(), 0))
					self.leftUpTime = viz.tick()
					self.leftUpPos[0] = self.forceplates.latestLeftCOP[0]
					self.leftUpPos[1] = self.forceplates.latestLeftCOP[1] + CORRECT_LEFT
				if d.condition is rightDown:
					self.rightDownTime = viz.tick()
					self.rightDownPos[0] = self.forceplates.latestRightCOP[0]
					self.rightDownPos[1] = self.forceplates.latestRightCOP[1]
					st = self.rightDownTime - self.rightUpTime
					if st > MIN_STRIDE_TIME and st < MAX_STRIDE_TIME:
						self.rightStrideTime[0] = st
						self.rightStrideTime = np.roll(self.rightStrideTime, 1)
					self.rightStrideLength = math.sqrt((self.rightDownPos[0] - self.rightUpPos[0])**2 +\
						(self.rightDownPos[1] - self.rightUpPos[1])**2)
					self.rightDistToDesired = self.rightDownPos[1] - DESIRED_POSITION
					if self.rightDistToDesired > MIN_DIST_TO_DESIRED:
						self.rightSpeed = FIXED_SPEED
						#self.rightSpeed = self.rightDistToDesired/np.mean(self.leftStrideTime + 1.e-6) #avoid 1/0
						self.tmill.moveRightBelt(spd=min([self.rightSpeed, MAX_SPEED]), mpss=ACCELERATION)
						self.history.append("%10.9g %10.9g rightdown"%(viz.tick(), min([self.rightSpeed, MAX_SPEED])))
				elif d.condition is rightUp:
					self.tmill.moveRightBelt(spd=0, mpss=DECELERATION)
					self.history.append("%10.9g %10.9g rightup"%(viz.tick(), 0))
					self.rightUpTime = viz.tick()
					self.rightUpPos[0] = self.forceplates.latestRightCOP[0]
					self.rightUpPos[1] = self.forceplates.latestRightCOP[1]
Пример #5
0
def TrialTask():
    """Task for individual trial. Returns whether BOMB was found."""

    # Flash screen
    FlashScreen()

    # Wait until BOMB is found or time runs out
    wait_time = viztask.waitTask(TrialCountDownTask())
    wait_find = vizproximity.waitEnter(sensor)
    #print wait_find
    wait_find2 = vizproximity.waitEnter(sensor2)
    wait_find3 = vizproximity.waitEnter(sensor3)
    wait_find4 = vizproximity.waitEnter(sensor4)
    wait_find5 = vizproximity.waitEnter(sensor5)
    wait_find6 = vizproximity.waitEnter(sensor6)
    wait_find7 = vizproximity.waitEnter(sensor7)
    data = yield viztask.waitAny([
        wait_time, wait_find, wait_find2, wait_find3, wait_find4, wait_find5,
        wait_find6, wait_find7
    ])

    if data.condition == wait_find:
        manager.removeSensor(sensor)

    elif data.condition == wait_find2:
        manager.removeSensor(sensor2)

    elif data.condition == wait_find3:
        manager.removeSensor(sensor3)

    elif data.condition == wait_find4:
        manager.removeSensor(sensor4)

    elif data.condition == wait_find5:
        manager.removeSensor(sensor5)

    elif data.condition == wait_find6:
        manager.removeSensor(sensor6)

    elif data.condition == wait_find7:
        manager.removeSensor(sensor7)

    # Return whether bomb was found
    viztask.returnValue(
        data.condition is wait_find or data.condition is wait_find2
        or data.condition is wait_find3 or data.condition is wait_find4
        or data.condition is wait_find5 or data.condition is wait_find6
        or data.condition is wait_find7)
Пример #6
0
def runtrials():

    for i, trialtype in enumerate(TRIALSEQ):

        print("Trial: ", str(i))
        print("TrialType: ", str(i))

        trial_targetoccurence_prob = ConditionList_targetoccurence_prob[
            trialtype]  #set occurence parameter for the trial.
        trial_targetnumber = ConditionList_targetnumber[
            trialtype]  #set target number for the trial.

        print(str([trial_targetoccurence_prob, trial_targetnumber]))

        Distractor.StartTrial(trial_targetoccurence_prob,
                              trial_targetnumber,
                              trialn=i)  #starts trial

        print("Called Start Trial, now waiting")

        #yield viztask.waitTime(TotalTrialTime+.5) #this should always wait a little longer than the TrialTime, allowing the EndOfTrial function to get called in Count_Adjustable.

        def MonitorDistactor():
            """will return true if it is the end of trial"""
            EoTFlag = Distractor.getFlag()  # True if it's the end of the trial
            return (EoTFlag)

        yield viztask.waitTrue(MonitorDistactor)

        ###interface with End of Trial Screen
        pressed = 0
        while pressed < trial_targetnumber:

            #keep looking for gearpad presses until pressed reaches trial_targetnumber
            print("waiting for gear press")
            d = yield viztask.waitAny([waitButton1, waitButton2])
            pressed += 1
            print('pressed ' + str(pressed))
            Distractor.gearpaddown(d.condition)  #call gearpaddown.

            yield viztask.waitTime(.5)
            #Distractor.EoTScreen_Visibility(viz.OFF)
        Distractor.RecordCounts()
        #Finished = True
    else:

        viz.quit()  ##otherwise keeps writting data onto last file untill ESC
Пример #7
0
def videoScene():
 global player
# viz.MainScene.disable(viz.FOG, op=viz.OP_ROOT)
 
# Change parameters to False, True for PPT 1
# vhilGo(True, False, keyboardcontrol=False)
 player = spherical_player_Vive.Player(globals_oa.SPHERICAL_VIDEO, PPT1=False, radius=4, playPauseKey=' ')
# player.setVolume(0.25)

 screenPosition = player.screen.getPosition()
 player.screen.setPosition([screenPosition[0], 2, screenPosition[1]-1])  #change middle number to move sphere up or down on y axis
 player.toggleLooping()
 player.play()
 globals_oa.SPHERICAL_VIDEO_SCORE.play()
 globals_oa.SPHERICAL_VIDEO_NARRATION.play()
 yield globals_oa.fader.fadeInTask()

 
#	yield viztask.waitAny([viztask.waitTime(2), skipKey])
#	globals_oa.AUDIO_SPHERICAL_1.play()
#	result = yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.AUDIO_SPHERICAL_1), skipKey])
#	if result.condition is skipKey:
#		globals_oa.AUDIO_SPHERICAL_1.stop()
#
#	yield viztask.waitTime(1)
#	globals_oa.AUDIO_SPHERICAL_2.play()
#	result = yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.AUDIO_SPHERICAL_2), skipKey])
#	if result.condition is skipKey:
#		globals_oa.AUDIO_SPHERICAL_2.stop()

 # Waits until the video is done playing
#	result = yield viztask.waitAny([viztask.waitTime(player.getVideoDuration() - globals_oa.AUDIO_SPHERICAL_1.getDuration() - globals_oa.AUDIO_SPHERICAL_2.getDuration() - 3.5), skipKey])
#	if result.condition is skipKey:
#			player.pause()

 yield viztask.waitAny([viztask.waitTime(player.getVideoDuration()), skipKey])
# yield viztask.waitTime(player.getVideoDuration())
# yield globals_oa.fader.fadeOutTask()
 
# player2 = player.setMedia('D:/localAssets/OA/tribecaFinalAssets/TCR_transition_video.mp4')
 player.screen.visible(viz.OFF)
 
 viz.sendEvent(globals_oa.VIDEO_END_EVENT)
# globals_oa.AUDIO_ZONE3_AMBIENT.pause()
 player.pause()
    def changeQ(self, panelTitle, breakQ=True):
        #print self.survey
        indexQuestion = "warmup"
        shuffle(self.survey)
        self.Panel.visible(viz.OFF)
        yield viztask.waitTime(int(self.delay))
        self.Panel.visible(viz.ON)
        self.rowBottom.visible(viz.ON)
        #self.maxNumber.visible(viz.ON)

        for counter, items in enumerate(self.survey):

            self.Panel.setTitle(panelTitle)
            viz.callback(self.dinput.HAT_EVENT, self.onHatChange)
            question = items.split(":")[1]
            index = items.split(":")[0]
            scale = items.split(":")[2]

            self.changeMessage(question, scale, breakQ)

            #track.setEnabled(viz.OFF)
            yield viztask.waitAny([self.waitButton1], self.d)
            if self.d.condition is self.waitButton1:
                yield viztask.waitTime(.2)
                pos = self.Slider.get()
                if round(abs(pos / .1), 1) > 0:
                    #saveRate(qIndex,sceneIndex,index)
                    self.Slider.set(0)
                    self.Slider.message("")
                    yield viztask.waitTime(.2)
                else:
                    #Panel.setTitle("MINIMUM SELECTION IS (0)")
                    yield viztask.waitTime(3)
            if counter > len(self.survey):
                break
        self.Panel.visible(viz.OFF)
        yield viztask.waitTime(1)
Пример #9
0
def task_choice():

    # ensure that the mouse is turned on
    viz.mouse(viz.ON)
    viz.mouse.setVisible(viz.ON)

    # load condition_box
    condition_box = vizinfo.add('')
    condition_box.title('SNAP')
    condition_box.scale(2, 2)
    condition_box.translate(0.85, 0.65)
    condition_box.drag(viz.OFF)

    # add different options
    condition_one = condition_box.add(viz.BUTTON, 'Condition 1')
    condition_two = condition_box.add(viz.BUTTON, 'Condition 2')
    practice = condition_box.add(viz.BUTTON, 'Practice Program')
    expertise = condition_box.add(viz.BUTTON, 'Visuomotor Expertise Program')
    maze_quit = condition_box.add(viz.BUTTON, 'Quit Maze Program')

    # add variables for user chocies
    condition_one_pressed = viztask.waitButtonDown(condition_one)
    condition_two_pressed = viztask.waitButtonDown(condition_two)
    practice_pressed = viztask.waitButtonDown(practice)
    expertise_pressed = viztask.waitButtonDown(expertise)
    maze_quit_pressed = viztask.waitButtonDown(maze_quit)

    # data variable to hold user choices
    data = viz.Data()

    # setup globals
    global condition
    global maze_root
    global start_coords
    global start_ori
    global end_coords

    # While statment that will run a different maze based on user choice.
    # Will keep looping until the user selects quit and ends the program
    while True:
        yield viztask.waitAny([
            condition_one_pressed, condition_two_pressed, practice_pressed,
            expertise_pressed, maze_quit_pressed
        ], data)
        condition_box.remove()
        if data.condition is condition_one_pressed:
            condition = 1
            yield maze_choice()
            yield run_condition_one()
            yield task_choice()
        elif data.condition is condition_two_pressed:
            condition = 2
            yield maze_choice()
            yield run_condition_two()
            yield task_choice()
        elif data.condition is practice_pressed:
            viz.mouse(viz.OFF)
            viz.mouse.setVisible(viz.OFF)
            maze_root = 'C:\Experiments\Bike_Extend_Pilot\SNAP\PMS'
            start_coords = (0, 40, 0)
            start_ori = (3.5, 0, 0)
            yield practice_maze()
            yield task_choice()
        elif data.condition is expertise_pressed:
            viz.mouse(viz.OFF)
            viz.mouse.setVisible(viz.OFF)
            maze_root = 'C:\Experiments\Bike_Extend_Pilot\SNAP\VMS'
            start_coords = (0, 40, 0)
            start_ori = (0, 0, 0)
            end_coords = [1150, 1275, -190, -100]
            yield expertise_maze()
            yield task_choice()
        elif data.condition is maze_quit_pressed:
            viz.quit()

    viz.quit()
Пример #10
0
def run(CL, tracks, grounds, backgrounds, cave, driver, autofiles, wheel, save_prefix):
	
	DEBUG = False
	
	trialtime = tracks[list(tracks.keys())[0]].trialtime	
	if DEBUG: trialtime = 6
		
	wait_texture = setStage('dusk.png')	
	wait_col = list(np.mean(np.array([viz.BLACK,viz.SKYBLUE]).T, axis = 1))	
	
		
	#add audio files
	manual_audio = 'C:\\VENLAB data\\shared_modules\\textures\\490_200ms.wav'
	viz.playSound(manual_audio, viz.SOUND_PRELOAD)	
	def SingleBeep():
		"""play single beep"""
		viz.playSound(manual_audio)
	"""
	datacolumns = ('autofile_i','bend','maxyr',
	'onsettime','ppid','trialn','block','timestamp_exp','timestamp_trial',
	'world_x','world_z','world_yaw','swa', 
	'yawrate_seconds','turnangle_frames',
	'distance_frames','dt','wheelcorrection', 
	'steeringbias', 'autoflag', 'autofile')
	"""
	"""
			UpdateValues = []
		UpdateValues.append(yawrate)
		UpdateValues.append(turnangle)
		UpdateValues.append(distance)
		UpdateValues.append(dt)
		UpdateValues.append(SteeringWheelValue)
		UpdateValues.append(self.__Wheel_yawrate_adjustment)
	"""
	
	expid, ppid, block = save_prefix.split('_')
	columns = ('ppid','block','world_x','world_z','world_yaw','timestamp_exp','timestamp_trial','maxyr', 'onsettime', 'bend','dn','autoflag','yr_sec','yr_frames','distance_frames','dt','sw_value','wheelcorrection','sw_angle')	
	
	def update(num):		
		
		
		if UPDATE:
			
			trialtimer = viz.tick() - trialstart	
			if DEBUG: txtmode.message(str(onset) +'\n' + str(yr) + '\n' + str(round(trialtimer,2)))
			
			if AUTOFLAG:
				
				#read the corresponding entry on the playback_data
				if trialtimer <= onset:
					i, auto_row = next(playback_iter)
					#print(i, auto_row)
					dir = auto_row.bend							
					new_swa = auto_row.swa * dir * bend #these columns are named slightly differently to the final experiment data
					new_yr = auto_row.yr * dir * bend
					
					#move the wheel.									
					wheel.set_position(new_swa)	#set steering wheel to 							
				else:
					#driver.setAutomation(False)
					new_yr = 0 #off-tangent failure
			
			else:
				new_yr = None					
			
			#update position
			updatevals = driver.UpdateView(new_yr) 
			#return the values used in position update			
				
				
				#retrieve position and orientation
			pos = cave.getPosition()							
			yaw = vizmat.NormAngle(cave.getEuler()[0])			
						
			#record data	
			#columns = ('ppid', 'block','world_x','world_z','world_yaw','timestamp_exp','timestamp_trial','maxyr', 'onsettime', 'bend','dn','autoflag','yr_sec','yr_frames','distance_frames','dt','sw_value','wheelcorrection','sw_angle')	
			output = (ppid, block, pos[0], pos[2], yaw, viz.tick(), trialtimer, yr, onset, bend, dn, int(AUTOFLAG), updatevals[0], updatevals[1],updatevals[2], updatevals[3],updatevals[4],updatevals[5], updatevals[4]*90) #output array			
				
			#print(output)
		
			#self.OutputWriter.loc[self.Current_RowIndex,:] = output #this dataframe is actually just one line. 		
			OutputWriter.writerow(output)  #output to csv. any quicker?
			
	
	#call update every frame
	UPDATE = False
	
	viz.callback(viz.TIMER_EVENT, update)
	viz.starttimer(0,1.0/60.0,viz.FOREVER)
	
		
	txtmode = viz.addText("Mode",parent=viz.SCREEN)	
	#set above skyline so I can easily filter glances to the letter out of the data
	txtmode.setPosition(.05,.52)
	txtmode.fontSize(36)
	txtmode.color(viz.WHITE)	

	if not DEBUG: txtmode.message('A')
		
	print(CL)	
		
	for trial_i, (idx, trial) in enumerate(CL.iterrows()):
		
		#reset key trial variables 
		trialstart = viz.tick()
		AUTOFLAG = True
		driver.setAutomation(AUTOFLAG)
		
		#set up dataframe and csv writer
		OutputFile = io.BytesIO()
		OutputWriter = csv.writer(OutputFile)
		OutputWriter.writerow(columns) #write headers.
		
		bend = int(trial['Bend'])
		yr = trial['maxYR']
		dn = trial['Day/Night']
		onset = trial['OnsetTime']		
		key = str(bend)+'_'+str(yr)+'_' + dn
		#retrieve playback
		playback = autofiles[str(yr)]
		playback_iter = playback.iterrows()
		
		
		
		#only switch on update loop after retrieving parameters
		
		
		#pick track and make visible
		track = tracks[key]
		track.ToggleVisibility(1)
		
		ground = grounds[dn]
		ground.visible(viz.ON)
		
		viz.clearcolor(backgrounds[dn])
		if trial_i == 0:
			yield viztask.waitTime(2)
		else:
			yield viztask.waitTime(.5)
		
		
		#start the trial proper
		UPDATE = True
		
		#run trial
		def PlaybackReached():
			"""checks for playback limit or whether automation has been disengaged"""
			end = False
			#print(viz.tick() - trialstart)
			if (viz.tick() - trialstart) > trialtime: end = True
			return(end)
		
		def CheckDisengage():
			"""checks automation status of driver class """
			end = False
			auto = driver.getAutomation()
			if auto == False:end = True				
			return (end)

		#create viztask functions.
		waitPlayback = viztask.waitTrue( PlaybackReached )
		waitDisengage = viztask.waitTrue( CheckDisengage )
		
		d = yield viztask.waitAny( [ waitPlayback, waitDisengage ] )		

		if d.condition is waitPlayback:
			print ('end of trial reached')
			
		elif d.condition is waitDisengage:
			print ('Automation Disengaged')
			if not DEBUG: txtmode.message('M')
			
			AUTOFLAG = False				
			wheel.FF_on(.2)				
			SingleBeep()
			yield viztask.waitTime(trialtime - (viz.tick()-trialstart))
			
		#END OF STEERING TASK
		
		#reset trial
		track.ToggleVisibility(0)
		ground.visible(viz.OFF)
		driver.reset()
		wait_texture.visible(1)
		viz.clearcolor(wait_col)
		UPDATE = False
		if not DEBUG: txtmode.message('A')
		
		yield viztask.waitTime(.5)
		wait_texture.visible(0)
		UPDATE = True
		
		savename = save_prefix +'_'+str(trial_i)
		SaveData(OutputFile, savename)
	
	
	CloseConnections(wheel)
Пример #11
0
def findObject():
	global speciesIndex, numFound, scavengerHuntEndSound, displayObjects, time_text, quad, score_text, rhtool, lhtool, objectsToSelect
	yield viztask.waitTime(TIME_BETWEEN_TASKS)
	
	print speciesIndex
	if speciesIndex == len(species):
		endScavengerHunt()
#		print "SCAVENGER HUNT OVER"
#		#if scavengerHuntEndSound is None:
#			#scavengerHuntEndSound = loadAudioFile(AUDIO_DIRECTORY + 'bell.wav')
#		#scavengerHuntEndSound.play()
#		time_text.message('Scavenger hunt over')
#		if globals_oa.currentZoneNumber == 0: 
#			globals_oa.scavengerHuntCompleteInTestZone = True
#			#making the slate and stuff on it invisible after the practice scvenger hunt
#			time_text.visible(False)
#			globals_oa.slate.visible(False)
#			quad.visible(False)
#			score_text.visible(False)
#			time_text.message('')
#			score_text.message('')
#		elif globals_oa.currentZoneNumber == 1: 
#			globals_oa.scavengerHuntCompleteInZone1 = True
#			globals_oa.MOVEMENT_DATA_RECORDING_TAG = globals_oa.TAG_SCAVENGER_HUNT_END_ZONE_1
#			viz.sendEvent(ZONE1_OVER_EVENT)
#		#elif globals_oa.currentZoneNumber == 2: globals_oa.scavengerHuntCompleteInZone2 = True
#		elif globals_oa.currentZoneNumber == 3: 
#			globals_oa.scavengerHuntCompleteInZone3 = True
#			globals_oa.slate.visible(False)
#			globals_oa.MOVEMENT_DATA_RECORDING_TAG = globals_oa.TAG_SCAVENGER_HUNT_END_ZONE_3
#			viz.sendEvent(ZONE3_OVER_EVENT)
#		if (not globals_oa.isDemo): toggleTempPromptScreen()
		return
	
	objectsToSelect.extend(nodesToHuntForEachSpecies[species[speciesIndex]])
#	print "OBJECTS TO SELECT:"
#	print objectsToSelect

	if rhtool is not None: rhtool.setItems(objectsToSelect)
	if lhtool is not None: lhtool.setItems(objectsToSelect)
	
	time_text.message('')
	
	
	#Wait for instructions to end.
	#yield viztask.waitTime(instructions.getDuration())
	
	
	#quad.texture(pics[speciesIndex])
	#quad.visible(viz.ON)
	
	#Wait to display object
	if displayObjects <> []: yield displaySpecies(displayObjects[speciesIndex], species[speciesIndex])

	#updateScore()
	
	#if not globals_oa.isDemo:
	#	fileOutputAtScavengerHuntStart()
	
#	if globals_oa.currentZoneNumber == 0:
#		wait_time = viztask.waitTime(globals_oa.TIME_TO_FIND_IN_PRACTICE_HUNT)#viztask.waitTask( trialCountDownTask() )
#	else:
#		wait_time = viztask.waitTime(globals_oa.TIME_TO_FIND_IN_SCAVENGER_HUNT)#viztask.waitTask( trialCountDownTask() )

	wait_time = viztask.waitTask( trialCountDownTask() )
	wait_find = viztask.waitEvent(ALL_FOUND_EVENT)
	first_complete = yield viztask.waitAny([wait_time,wait_find])
	
	if first_complete.condition is wait_find:
		time_text.message('Good Job! you found: {} / {}'.format(numFound,numObjectsToFind[speciesIndex]))
	elif first_complete.condition is wait_time:
		disableGrabber()
		print 'OUT OF TIME'
		time_text.clearActions()
		time_text.alpha(1.0)
		time_text.color(viz.BLACK)
		time_text.setScale([.05,.05,.05])
		time_text.message('Out of time')
#	if not globals_oa.isDemo:
#		fileOutputAtScavengerHuntEnd()

	speciesIndex += 1
	numFound = 0
	viztask.schedule( findObject() )
Пример #12
0
def swimFromZoneToZone():
 global SWIM_ZONE_TO_ZONE_COMPLETE_EVENT, LOOKED_OPENING_EVENT, lookingOpeningTimer, skipKey
 yield viztask.waitEvent(scavengerhunt.ZONE1_OVER_EVENT)
 scavengerhunt.disableGrabber()
 globals_oa.ZONE1_AUDIO_1.stop()
 globals_oa.basket.disable(viz.RENDERING)
 
 # Uncomment next block for immediately fading to zone 3 from zone 1; comment out lines 783 to 881 to skip swimming through the trench
# yield fader.fadeOutTask()
# for school in schooling.all_fish_schools:
#  school.hidePercentage(50)
# globals_oa.currentZoneNumber = 2
# transport_vhil.cycleZones()
# yield fader.fadeInTask()

 #get the child of the zone1 to hide
 stuffToHide1 = globals_oa.terrainZone1.getChild('RemoveThisWall')
 stuffToHide1.visible(False)

 playAudioAndSaveGlobalPointer(globals_oa.ZONE3_TRANSITION)
 result = yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.ZONE3_TRANSITION), skipKey])
 markAudioPlayAsEnded()
 if result.condition is skipKey:
  globals_oa.ZONE3_TRANSITION.stop()
 #playAudioAndSaveGlobalPointer(globals_oa.ZONE3_TRANSITION2)
 #yield viztask.waitMediaEnd(globals_oa.ZONE3_TRANSITION2)
 #markAudioPlayAsEnded()
 
 vizact.onkeydown('q', shootForward)
# viz.phys.disable()
 
 # Waits until the user has looked at the opening for 2 seconds before it starts swimming instructions
 viz.setCollectRenderStats(True)
 lookingOpeningTimer = vizact.ontimer(0.1, lookingAtOpening)
 yield viztask.waitAny([viztask.waitEvent(LOOKED_OPENING_EVENT), skipKey])

 
 #create proximity sensor for the swimming between zones
 swimBetweenZonesProximityManager = vizproximity.Manager()
# swimBetweenZonesProximityManager.setDebug(viz.ON)
 
 swimBetweenZonesProximityTarget = vizproximity.Target(viz.MainView)
 swimBetweenZonesProximityManager.addTarget(swimBetweenZonesProximityTarget)
 
 #create a box to act as the end of tunnel sensor, for zone-to-zone swimming
 endOfTunnelBox = vizshape.addBox(size = [3.0, 3.0, 3.0])
 endOfTunnelBox.setPosition(globals_oa.CURRENT_ABS_POS_OF_END_OF_ZONE_TO_ZONE_TUNNEL)
 endOfTunnelBox.visible(False)
 zone3Sensor = vizproximity.addBoundingBoxSensor(endOfTunnelBox)
 swimBetweenZonesProximityManager.addSensor(zone3Sensor)
 
 swimBetweenZonesProximityManager.onEnter(zone3Sensor, EnterZone3Proximity)
 
 #create a sensor around the tube through the tunnel
 tunnelBox1 = globals_oa.terrainZone1.getChild('Box001')
 tunnelBox2 = globals_oa.terrainZone1.getChild('Box002')
 tunnelBox3 = globals_oa.terrainZone1.getChild('Box003')
 tunnelBox4 = globals_oa.terrainZone1.getChild('Box004')
 
 tunnelBox1.visible(False)
 tunnelBox2.visible(False)
 tunnelBox3.visible(False)
 tunnelBox4.visible(False)

 tunnelBoxSensor1 = vizproximity.addBoundingBoxSensor(tunnelBox1)
 tunnelBoxSensor2 = vizproximity.addBoundingBoxSensor(tunnelBox2)
 tunnelBoxSensor3 = vizproximity.addBoundingBoxSensor(tunnelBox3)
 tunnelBoxSensor4 = vizproximity.addBoundingBoxSensor(tunnelBox4)
 
 boundingBox = stuffToHide1.getBoundingBox()
 trackerLink = viz.link(stuffToHide1, viz.NullLinkable)
 tunnelOpeningSensor = vizproximity.Sensor(vizproximity.Box([boundingBox.width * 0.6, boundingBox.height * 0.3, boundingBox.depth * 1.2], 
 [boundingBox.center[0] + 2.2, boundingBox.center[1], boundingBox.center[2] + 2]), trackerLink)
 
 swimBetweenZonesProximityManager.addSensor(tunnelBoxSensor1)
 swimBetweenZonesProximityManager.addSensor(tunnelBoxSensor2)
 swimBetweenZonesProximityManager.addSensor(tunnelBoxSensor3)
 swimBetweenZonesProximityManager.addSensor(tunnelBoxSensor4)
 swimBetweenZonesProximityManager.addSensor(tunnelOpeningSensor)
 swimBetweenZonesProximityManager.onEnter(tunnelBoxSensor1, EnterTunnelTube)
 swimBetweenZonesProximityManager.onEnter(tunnelBoxSensor2, EnterTunnelTube)
 swimBetweenZonesProximityManager.onEnter(tunnelBoxSensor3, EnterTunnelTube)
 swimBetweenZonesProximityManager.onEnter(tunnelBoxSensor4, EnterTunnelTube)
 swimBetweenZonesProximityManager.onEnter(tunnelOpeningSensor, EnterTunnelOpening)
 swimBetweenZonesProximityManager.onExit(tunnelBoxSensor1, ExitTunnelTube)
 swimBetweenZonesProximityManager.onExit(tunnelBoxSensor2, ExitTunnelTube)
 swimBetweenZonesProximityManager.onExit(tunnelBoxSensor3, ExitTunnelTube)
 swimBetweenZonesProximityManager.onExit(tunnelBoxSensor4, ExitTunnelTube)
 swimBetweenZonesProximityManager.onExit(tunnelOpeningSensor, ExitTunnelOpening)
 
 #turning on swimming
 transport_vhil.onKeyDown('g')
 
 playAudioAndSaveGlobalPointer(globals_oa.SWIMMING_INSTRUCTIONS)
 viztask.schedule(swimTutorial)
 viztask.schedule(removeGhostHands)
 result = yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.SWIMMING_INSTRUCTIONS), skipKey])
 markAudioPlayAsEnded()
 if result.condition is skipKey:
  globals_oa.SWIMMING_INSTRUCTIONS.stop()
 
# print "waiting for swimming to end"
 yield viztask.waitAny([viztask.waitEvent(SWIM_ZONE_TO_ZONE_COMPLETE_EVENT), skipKey])
 viztask.schedule(startZone3Hunt())
Пример #13
0
def startBoatOutro():
 global skipKey
 #yield viztask.waitEvent(scavengerhunt.ZONE3_OVER_EVENT)
 yield viztask.waitAny([viztask.waitTime(52), skipKey])
 globals_oa.ZONE3_AUDIO_1.stop()
 yield fader.fadeOutTask()
 globals_oa.user.setPosition([0,0,0])
 killOceanScene()
 
 yield fader.fadeOutTask()
 globals_oa.AUDIO_SPHERICAL_TRANSITION.play()
 result = yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.AUDIO_SPHERICAL_TRANSITION), skipKey])
 if result.condition is skipKey:
  globals_oa.AUDIO_SPHERICAL_TRANSITION.stop()
 
 # Gets rid of all the fish
 for school in schooling.all_fish_schools:
  school.hidePercentage(100)
 
 # Stops swimming
 # transport_vhil.onKeyDown('g')
# viz.MainScene.disable(viz.FOG, op=viz.OP_ROOT)

 # Change parameters to False, True for PPT 1
 vhilGo(True, False, keyboardcontrol=False)
 player = spherical_player_Vive.Player(globals_oa.SPHERICAL_VIDEO, PPT1=False, radius=2.7, playPauseKey=' ')
 
 screenPosition = player.screen.getPosition()
 viz.MainView.setPosition([screenPosition[0], 1.82, screenPosition[1]])
 
 player.toggleLooping()
 player.play()
 yield fader.fadeInTask()

 yield viztask.waitAny([viztask.waitTime(2), skipKey])
 globals_oa.AUDIO_SPHERICAL_1.play()
 result = yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.AUDIO_SPHERICAL_1), skipKey])
 if result.condition is skipKey:
  globals_oa.AUDIO_SPHERICAL_1.stop()
 
 yield viztask.waitTime(1)
 globals_oa.AUDIO_SPHERICAL_2.play()
 result = yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.AUDIO_SPHERICAL_2), skipKey])
 if result.condition is skipKey:
  globals_oa.AUDIO_SPHERICAL_2.stop()
 
 # Waits until the video is done playing
 result = yield viztask.waitAny([viztask.waitTime(player.getVideoDuration() - globals_oa.AUDIO_SPHERICAL_1.getDuration() - globals_oa.AUDIO_SPHERICAL_2.getDuration() - 3.5), skipKey])
 if result.condition is skipKey:
  player.pause()

 yield fader.fadeOutTask()
 
 player.screen.visible(viz.OFF)
 globals_oa.AUDIO_ZONE3_AMBIENT.pause()
 
# killOceanScene()
 boatscene.revealScene()
 boatscene.unhideBoatAndIschia()
 yield viztask.waitAny([viztask.waitTime(3), skipKey])
 globals_oa.AUDIO_BOAT_AMBIENT_OUTRO.play()
 yield fader.fadeInTask()
 yield viztask.waitAny([viztask.waitTime(3), skipKey])
 
 playAudioAndSaveGlobalPointer(globals_oa.BOAT_AUDIO_OUTRO_2)
 result = yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.BOAT_AUDIO_OUTRO_2), skipKey])
 markAudioPlayAsEnded()
 if result.condition is skipKey:
  globals_oa.BOAT_AUDIO_OUTRO_2.stop()

 viz.clearcolor(0, 0, 0)
 
 yield fader.fadeOutTask()
 boatscene.killScene()
 
 
 yield viztask.waitTime(3)
 
 viztask.schedule(loadAcknowledgment)
 yield fader.fadeInTask() #1.5
 yield viztask.waitTime(globals_oa.BETWEEN_FADING_TIME) #4
 yield fader.fadeOutTask() #1.5
Пример #14
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()
Пример #15
0
def maze_choice():

    # load start box
    choice_box = vizinfo.add('')
    choice_box.title('Maze Choice')
    choice_box.scale(2, 2)
    choice_box.translate(0.85, 0.65)
    choice_box.drag(viz.OFF)

    # add options for different mazes
    maze_a = choice_box.add(viz.BUTTON, 'Maze Layout A')
    maze_b = choice_box.add(viz.BUTTON, 'Maze Layout B')
    maze_c = choice_box.add(viz.BUTTON, 'Maze Layout C')
    maze_d = choice_box.add(viz.BUTTON, 'Maze Layout D')

    # add variables for user chocies
    maze_a_pressed = viztask.waitButtonDown(maze_a)
    maze_b_pressed = viztask.waitButtonDown(maze_b)
    maze_c_pressed = viztask.waitButtonDown(maze_c)
    maze_d_pressed = viztask.waitButtonDown(maze_d)

    # data variable to hold user choices
    data = viz.Data()

    # get the maze name root, and start/end coordinates from user choice
    global maze_root
    global start_coords
    global start_ori
    global end_coords
    yield viztask.waitAny(
        [maze_a_pressed, maze_b_pressed, maze_c_pressed, maze_d_pressed], data)
    if data.condition is maze_a_pressed:
        choice_box.remove()
        yield phase_choice()
        maze_root = 'C:\Experiments\Bike_Extend_Pilot\SNAP\SNAPMazeA'
        start_coords = (0, 40, 0)
        start_ori = (0, 0, 0)
        end_coords = (-745, -700, 2125, 2180)
    elif data.condition is maze_b_pressed:
        choice_box.remove()
        yield phase_choice()
        maze_root = 'C:\Experiments\Bike_Extend_Pilot\SNAP\SNAPMazeB'
        start_coords = (-1114, 40, 2151)
        start_ori = (-180, 0, 0)
        end_coords = (-1876, -1795, 115, 156)
    elif data.condition is maze_c_pressed:
        choice_box.remove()
        yield phase_choice()
        maze_root = 'C:\Experiments\Bike_Extend_Pilot\SNAP\SNAPMazeC'
        start_coords = (100, 0, -47)
        start_ori = (90, 0, 0)
        end_coords = (640, 750, 2080, 2120)
    elif data.condition is maze_d_pressed:
        choice_box.remove()
        yield phase_choice()
        maze_root = 'C:\Experiments\Bike_Extend_Pilot\SNAP\SNAPMazeD'
        start_coords = (414, 0, 285)
        start_ori = (0, 0, 0)
        end_coords = (550, 575, 1100, 1200)
    choice_box.remove()

    # turn the mouse off so it doesn't interfere with the environment
    viz.mouse(viz.OFF)
    viz.mouse.setVisible(viz.OFF)
Пример #16
0
def startBoatIntro():
 global boatScene, ALL_GRABBED_EVENT, wheel, radius, wheelTimer, skipKey
# hideOceanScene()
# FADE_IN_TIME = 4
 globals_oa.user.setPosition([0,0,0])
# yield fader.fadeOutTask()
 yield fader.fadeInTask() #1.5
 yield viztask.waitTime(4) #4
 yield fader.fadeOutTask() #1.5
 yield crystalBallScene()
 yield cityScene()
 yield globals_oa.AUDIO_BOAT_AMBIENT_INTRO.play()
 yield fader.fadeInTask() #1.5
 yield viztask.waitTime(globals_oa.BETWEEN_FADING_TIME - 1) #4
 yield fader.fadeOutTask() #1.5
 yield viztask.waitTime(1)
 boatscene.unhideBoatAndIschia()
 yield fader.fadeInTask()
 
 # Next few blocks of code for making the steering wheel on the boat spin
 wheel = globals_oa.boat.getChild('steeringWheel')
 box = wheel.getBoundingBox()
 wheel.setCenter(box.center)
 radius = box.height / 2
 wheelTimer = vizact.ontimer(0.01, rotateWheel, radius)
 wheelManager = vizproximity.Manager()
 
 global rhandtar, lhandtar
 rhsphere = vizshape.addSphere(radius = 0.05) 
 rhsphere.setParent(globals_oa.rhModel)
 rhsphere.setPosition([0,0,.55])
 rhsphere.disable(viz.RENDERING)
 lhsphere = vizshape.addSphere(radius = 0.05) 
 lhsphere.setParent(globals_oa.lhModel)
 lhsphere.setPosition([0,0,.55])
 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)
 wheelManager.addTarget(rhandtar)
 wheelManager.addTarget(lhandtar)
 
 wheelSource = vizshape.addBox([box.width - 2, box.height, box.depth - 2])
 wheelSource.setPosition([box.center[0] - 3.65, box.center[1], box.center[2] + 0.83])
 wheelSource.visible(False)
 wheelSensor = vizproximity.addBoundingBoxSensor(wheelSource)
 wheelManager.addSensor(wheelSensor)
# wheelManager.setDebug(viz.ON)
 
 wheelManager.onEnter(wheelSensor, enterWheel)
 wheelManager.onExit(wheelSensor, exitWheel)
 
####new audio additions 
 yield viztask.waitAny([viztask.waitTime(globals_oa.INITIAL_WAIT_TIME), skipKey])
# yield globals_oa.BOAT_AUDIO_INTRO_1.play()
 playAudioAndSaveGlobalPointer(globals_oa.BOAT_AUDIO_INTRO_1)
 result = yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.BOAT_AUDIO_INTRO_1), skipKey])
 markAudioPlayAsEnded()
 if result.condition is skipKey:
  globals_oa.BOAT_AUDIO_INTRO_1.stop()
 else:
  yield viztask.waitAny([viztask.waitTime(2), skipKey])
### 
 loadDisabledZonesAndInitWorldvizCode()
 
 boatscene.Quad1()
# yield globals_oa.BOAT_AUDIO_INTRO_2.play()
 playAudioAndSaveGlobalPointer(globals_oa.BOAT_AUDIO_INTRO_2)
 result = yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.BOAT_AUDIO_INTRO_2), skipKey])
 markAudioPlayAsEnded()
 if result.condition is skipKey:
  globals_oa.BOAT_AUDIO_INTRO_2.stop()
 else:
  yield viztask.waitAny([viztask.waitTime(3), skipKey])
 boatscene.Quad2()
# yield globals_oa.BOAT_AUDIO_INTRO_3.play()
 playAudioAndSaveGlobalPointer(globals_oa.BOAT_AUDIO_INTRO_3)
 result = yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.BOAT_AUDIO_INTRO_3), skipKey])
 if result.condition is skipKey:
  globals_oa.BOAT_AUDIO_INTRO_3.stop()
 else:
  yield viztask.waitAny([viztask.waitTime(3), skipKey])
 boatscene.Quad3()
# yield globals_oa.BOAT_AUDIO_INTRO_4.play()
 playAudioAndSaveGlobalPointer(globals_oa.BOAT_AUDIO_INTRO_4)
 result = yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.BOAT_AUDIO_INTRO_4), skipKey])
 markAudioPlayAsEnded()
 if result.condition is skipKey:
  globals_oa.BOAT_AUDIO_INTRO_4.stop()
 else:
  yield viztask.waitAny([viztask.waitTime(3), skipKey])
 yield globals_oa.CANVAS_QUAD.visible(False)
 globals_oa.CANVAS_QUAD_3_TEXTURE.remove()
 
 #grab on boat: start
 #init grab on boat
 initializeBoatGrabberAndPhysics()

# yield globals_oa.BOAT_AUDIO_INTRO_5.play() 
 playAudioAndSaveGlobalPointer(globals_oa.BOAT_AUDIO_INTRO_5)
 result = yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.BOAT_AUDIO_INTRO_5), skipKey])
 markAudioPlayAsEnded()
 if result.condition is skipKey:
  globals_oa.BOAT_AUDIO_INTRO_5.stop()
 
 #adding a 1 min slot for grab testing on boat
 yield viztask.waitAny( [viztask.waitTime(1 * 60), viztask.waitEvent(ALL_GRABBED_EVENT), skipKey])

 #stop grabbing, now that you are going underwater!
 disableBoatGrabberAndPhysics()
 wheelTimer.setEnabled(0)
 #grab on boat: end
 
 yield fader.fadeOutTask()
 
 boatscene.hideScene()
 enableOceanScene()
 
 #hiding the tunnel boxes before diving underwater
 tunnelBox1 = globals_oa.terrainZone1.getChild('Box001')
 tunnelBox2 = globals_oa.terrainZone1.getChild('Box002')
 tunnelBox3 = globals_oa.terrainZone1.getChild('Box003')
 tunnelBox4 = globals_oa.terrainZone1.getChild('Box004')
 
 tunnelBox1.visible(False)
 tunnelBox2.visible(False)
 tunnelBox3.visible(False)
 tunnelBox4.visible(False)
 globals_oa.AUDIO_BOAT_AMBIENT_INTRO.stop()
# globals_oa.ZONE1_TRANSITION.play()
 playAudioAndSaveGlobalPointer(globals_oa.ZONE1_TRANSITION)
 globals_oa.AUDIO_BOAT_AMBIENT_SPLASH.play() 
 
# yield viztask.waitMediaEnd(globals_oa.AUDIO_BOAT_AMBIENT_SPLASH)
 result = yield viztask.waitAny([viztask.waitMediaEnd(globals_oa.ZONE1_TRANSITION), skipKey])
 markAudioPlayAsEnded()
 if result.condition is skipKey:
  globals_oa.ZONE1_TRANSITION.stop()
 #viz.res.addPublishFile('data/speciesToFindZone1.txt')

 scavengerhunt.initialize(globals_oa.terrainZone1, globals_oa.filePathToSpeciesForScavengerHuntInZone1)
# transport_vhil.onKeyDown('g')
 viztask.schedule(swimFromZoneToZone())
 #the scheduling below is moved to swimFromZoneToZone
# viztask.schedule(startZone3Hunt())
 yield fader.fadeInTask()
# removeSphere()
# showOceanScene()
 globals_oa.AUDIO_ZONE1_AMBIENT.play()
 globals_oa.ZONE1_AUDIO_1.play()
Пример #17
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)
Пример #18
0
    def runtrials(self):
        """Loops through the trial sequence"""

        viz.MainScene.visible(viz.ON, viz.WORLD)
        viz.mouse.setVisible(viz.OFF)  #switch mouse off
        viz.clearcolor(
            viz.SKYBLUE)  #HACK, since eyetracker background is white.
        if self.EYETRACKING:
            #pass it the filename, and also the timestamp.
            et_file = str(self.EXP_ID) + '_' + str(
                self.PP_id)  #one file for the whole task.
            self.comms.start_trial(fname=et_file, timestamp=viz.tick())

        if self.EYETRACKING:
            #viz.MainScene.visible(viz.OFF,viz.WORLD)

            #remove straight
            self.Straight.ToggleVisibility(0)
            filename = str(self.EXP_ID) + "_Calibration_" + str(
                self.PP_id
            )  #+ str(demographics[0]) + "_" + str(demographics[2]) #add experimental block to filename
            print(filename)

            # Start logging the pupil data
            pupilfile = gzip.open(
                os.path.join("Data", filename + ".pupil.jsons.gz"), 'a')

            closer = pupil_logger.start_logging(pupilfile,
                                                timestamper=viz.tick)

            def stop_pupil_logging():
                closer()
                pupilfile.close()

            EXIT_CALLBACKS.insert(0, stop_pupil_logging)

            yield run_calibration(self.comms, filename)
            yield run_accuracy(self.comms, filename)

            #put straight visible
            self.Straight.ToggleVisibility(1)
            #add message after calibration to give the experimenter and participant time to prepare for the simulation.

            self.markers = Markers()

            #set up distractor task
        if self.DISTRACTOR_TYPE is not None:
            distractorfilename = str(self.EXP_ID) + '_' + str(
                self.PP_id) + '_distractor_'
            Distractor = Count_Adjustable.Distractor(
                distractorfilename,
                self.targetnumber,
                ppid=1,
                startscreentime=self.StartScreenTime,
                triallength=np.inf,
                ntrials=len(self.TRIALSEQ_df.index))
        else:
            Distractor = None

        #set up scene before eyetracking
        self.driver = vizdriver.Driver(self.caveview, Distractor)

        viz.message(
            '\t\tYou will now begin the experiment \n\n The automated vehicle will attempt to navigate a series of bends. \nYour task as the supervisory driver is to make sure the vehicle stays within the road edges. \nDuring automation please keep your hands loosely on the wheel. \nYou may take control by pressing the gear pads. \nOnce pressed, you will immediately be in control of the vehicle \n\n Please fixate the centre of the calibration point in between trials'
        )
        self.ToggleTextVisibility(viz.ON)

        for i, trial in self.TRIALSEQ_df.iterrows():

            #if half-way through do accuracy test.
            #Trial loop has finished.
            if i == int(np.round(self.total_trials / 2, 0)):
                if self.EYETRACKING:
                    self.markers.markers_visibility(
                        0)  #remove markers for calibration
                    self.Straight.ToggleVisibility(0)

                    accuracy_filename = filename + '_middle'
                    yield run_accuracy(self.comms, accuracy_filename)
                    yield viztask.waitTime(
                        1)  #a second pause before going into

                    self.markers.markers_visibility(
                        1)  #remove markersthe next trial
                    self.Straight.ToggleVisibility(1)

            #import vizjoy

            print("Trialn: ", str(i))

            print("current trial:", trial)

            #trial is now a row from a dataframe
            print("current trial radius:", trial["radius"])
            trial_radii = trial['radius']
            trial_yawrate_offset = trial['sab']
            trial_dir = trial['bend']

            print(str([trial_radii, trial_yawrate_offset]))

            txtDir = ""

            #print ("Length of bend array:", len(self.rightbends))

            self.driver.setAutomation(True)
            self.AUTOMATION = True
            self.txtMode.message('A')
            if self.AUTOWHEEL:
                self.Wheel.control_on()

            if self.DISTRACTOR_TYPE is not None:
                if i == 0:  #the first trial.

                    #annotate eyetracking
                    if self.EYETRACKING:
                        self.comms.annotate("DistractorScreen")

                    #switch texts off for the first trial.

                    self.ToggleTextVisibility(viz.OFF)

                    Distractor.StartTrial(self.targetoccurence_prob,
                                          self.targetnumber,
                                          trialn=i,
                                          displayscreen=True)  #starts trial
                    yield viztask.waitTrue(Distractor.getPlaySoundFlag)

                    self.ToggleTextVisibility(viz.ON)

                else:
                    Distractor.StartTrial(self.targetoccurence_prob,
                                          self.targetnumber,
                                          trialn=i,
                                          displayscreen=False)  #starts trial

            radius_index = self.FACTOR_radiiPool.index(trial_radii)

            #choose correct road object.

            if trial_dir > 0:  #right bend
                trialbend = self.rightbends[radius_index]
                txtDir = "R"
            else:
                trialbend = self.leftbends[radius_index]
                txtDir = "L"
                #trialbend = self.rightbends[radius_index]
                #txtDir = "R"

            trialbend.ToggleVisibility(viz.ON)

            if trial_radii > 0:  #if trial_radii is above zero it is a bend, not a straight
                msg = "Radius: " + str(trial_radii) + txtDir + '_' + str(
                    trial_yawrate_offset)
            else:
                msg = "Radius: Straight" + txtDir + '_' + str(
                    trial_yawrate_offset)


#			txtCondt.message(msg)

#pick radius
            self.Trial_radius = trial_radii

            #pick file. Put this in dedicated function. TODO: Should open all of these at the start of the file to save on processing.

            self.Trial_autofile_i = int(trial['autofile_i'])

            self.Trial_YR_readout = self.YR_readouts_80[self.Trial_autofile_i]
            self.Trial_SWA_readout = self.SWA_readouts_80[
                self.Trial_autofile_i]
            self.Trial_playbackfilename = self.PlaybackPool80[
                self.Trial_autofile_i]
            """
			if self.Trial_radius == 40:
				i = random.choice(range(len(self.YR_readouts_40)))
				self.Trial_YR_readout = self.YR_readouts_40[i]
				self.Trial_SWA_readout = self.SWA_readouts_40[i]
				self.Trial_playbackfilename = self.PlaybackPool40[i]
				

			elif self.Trial_radius == 80:
				i = random.choice(range(len(self.YR_readouts_80)))
				self.Trial_YR_readout = self.YR_readouts_80[i]
				self.Trial_SWA_readout = self.SWA_readouts_80[i]
				self.Trial_playbackfilename = self.PlaybackPool80[i]

			else:
				raise Exception("Something bad happened")

			"""

            #update class#
            self.Trial_simulatedttlc = trial['simulated_ttlc']
            self.Trial_design = trial['design']
            self.Trial_dir = trial_dir
            self.Trial_N = i
            self.Trial_YawRate_Offset = trial_yawrate_offset
            self.Trial_BendObject = trialbend
            self.Trial_trialtype_signed = trial_dir
            self.Trial_playbacklength = len(self.Trial_YR_readout)
            self.Trial_midline = np.vstack(
                (self.Straight.midline, self.Trial_BendObject.midline))
            self.Trial_OnsetTime = trial['onsettime']
            #self.Trial_OnsetTime = np.random.choice(self.OnsetTimePool, size=1)[0]
            self.Trial_SaveName = str(self.EXP_ID) + '_' + str(
                self.PP_id) + '_' + str(self.Trial_N)

            #renew data frame.
            #self.OutputWriter = pd.DataFrame(index = range(self.TrialLength*60), columns=self.datacolumns) #make new empty EndofTrial data

            #renew csv writer
            self.OutputFile = io.BytesIO()
            self.OutputWriter = csv.writer(self.OutputFile)
            self.OutputWriter.writerow(self.datacolumns)  #write headers.

            #annotate eyetracking
            if self.EYETRACKING:
                self.comms.annotate('Start_' + self.Trial_SaveName)

            yield viztask.waitTime(.5)  #pause at beginning of trial

            #annotate eyetracking
            if self.EYETRACKING:
                #remove calib_pt and wait a further .5 s
                #TODO: add 1 s calibration dot.
                self.calib_pt.visible(1)
                yield viztask.waitTime(1.5)  #pause at beginning of trial
                self.calib_pt.visible(0)
                yield viztask.waitTime(.5)  #pause at beginning of trial

            if self.DEBUG:
                conditionmessage = 'SAB: ' + str(self.Trial_YawRate_Offset) + \
                '\nRadius: ' +str(self.Trial_radius) + \
                '\nOnsetTime: ' + str(self.Trial_OnsetTime) + \
                '\nAutoFile: ' + str(self.Trial_autofile_i) + \
                '\nsim TTLC: ' + str(self.Trial_simulatedttlc) + \
                '\nDesign: ' + str(self.Trial_design) + \
                '\nTask: ' + str(self.DISTRACTOR_TYPE)
                self.txtTrial.message(conditionmessage)

                if self.DEBUG_PLOT:
                    #realtime plot.
                    self.line_midline.set_data(self.Trial_midline[:, 0],
                                               self.Trial_midline[:, 1])
                    self.dot_origin.set_data(
                        self.Trial_BendObject.CurveOrigin[0],
                        self.Trial_BendObject.CurveOrigin[1])
                    self.plot_ax.axis([
                        min(self.Trial_midline[:, 0]) - 10,
                        max(self.Trial_midline[:, 0]) + 10,
                        min(self.Trial_midline[:, 1]) - 10,
                        max(self.Trial_midline[:, 1]) + 10
                    ])  #set axis limits

                    self.plot_positionarray_x, self.plot_positionarray_z, self.plot_closestpt_x,  self.plot_closestpt_z = [], [], [], [] #arrays to store plot data in

            self.UPDATELOOP = True  #

            def PlaybackReached():
                """checks for playback limit or whether automation has been disengaged"""

                end = False

                #check whether automation has been switched off.
                if self.Current_playbackindex >= self.Trial_playbacklength:
                    end = True

                return (end)

            def CheckDisengage():
                """checks automation status of driver class """

                end = False
                auto = self.driver.getAutomation()
                if auto == False:

                    self.AUTOMATION = auto
                    self.txtMode.message('M')
                    #switch wheel control off, because user has disengaged
                    #begin = timer()
                    if self.AUTOWHEEL:
                        self.Wheel.control_off()

                    if self.EYETRACKING:
                        self.comms.annotate('Disengage_' + self.Trial_SaveName)
                        #pass
                    #print ("WheelControlOff", timer() - begin)
                    end = True

                return (end)

            #create viztask functions.
            waitPlayback = viztask.waitTrue(PlaybackReached)
            waitDisengage = viztask.waitTrue(CheckDisengage)

            d = yield viztask.waitAny([waitPlayback, waitDisengage])

            if d.condition is waitPlayback:
                print('Playback Limit Reached')
            elif d.condition is waitDisengage:
                print('Automation Disengaged')

                self.SingleBeep()

                def RoadRunout():
                    """temporary HACK function to check whether the participant has ran out of road"""

                    end = False
                    if self.Trial_Timer > self.TrialLength:
                        end = True

                    return (end)

                #waitRoad = viztask.waitTrue (RoadRunout)
                #waitManual = viztask.waitTime(5)

                #d = yield viztask.waitAny( [ waitRoad, waitManual ] )

                yield viztask.waitTrue(RoadRunout)
                print("Run out of Road")
                #if d.condition is waitRoad:
                #	print ('Run out of Road')
                #elif d.condition is waitManual:
                #	print ('Manual Time Elapsed')

            ##### END STEERING TASK ######

            self.UPDATELOOP = False

            self.Trial_BendObject.ToggleVisibility(viz.OFF)

            ##reset trial. Also need to annotate each eyetracking trial.
            viz.director(self.SaveData, self.OutputFile, self.Trial_SaveName)

            self.ResetTrialAndDriver(
            )  #reset parameters for beginning of trial

            ##### INITIALISE END OF TRIAL SCREEN FOR DISTRACTOR TASK #######
            if self.DISTRACTOR_TYPE is not None:

                #annotate eyetracking
                if self.EYETRACKING:
                    self.comms.annotate('Distractor_' + self.Trial_SaveName)

                if self.AUTOWHEEL:
                    self.Wheel.control_off()

                #switch text off
                self.ToggleTextVisibility(viz.OFF)

                Distractor.EndofTrial()  #throw up the screen to record counts.

                # Pause before the query screen to avoid
                # spurious presses carrying over from the
                # task.
                # Hack the screen to be blank
                Distractor.EoTScreen.visible(viz.ON)
                Distractor.Question.visible(viz.OFF)
                Distractor.lblscore.visible(viz.OFF)
                yield viztask.waitTime(1.0)
                Distractor.EoTScreen_Visibility(viz.ON)

                ###interface with End of Trial Screen
                pressed = 0
                while pressed < self.targetnumber:

                    #keep looking for gearpad presses until pressed reaches trial_targetnumber
                    print("waiting for gear press")
                    yield viztask.waitTrue(self.driver.getGearPressed)
                    pressed += 1
                    print('pressed ' + str(pressed))

                    Distractor.gearpaddown()

                    self.driver.setGearPressed(False)

                    yield viztask.waitTime(.5)
                    #Distractor.EoTScreen_Visibility(viz.OFF)
                Distractor.RecordCounts()

                self.ToggleTextVisibility(viz.ON)

            #annotate eyetracking
            if self.EYETRACKING:
                self.comms.annotate('End_' + self.Trial_SaveName)

        #Trial loop has finished.
        if self.EYETRACKING:
            self.markers.remove_markers()  #remove markers
            self.Straight.ToggleVisibility(0)
            accuracy_filename = filename + '_end'
            yield run_accuracy(self.comms, accuracy_filename)
        self.CloseConnections()
Пример #19
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)
Пример #20
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)
Пример #21
0
def cross_trial(start_time, wait_time, rt_deadline, remove, 
					message="",training=False):
	""" Implements a single trial
	Parameters
	==========
	start_time:float
	  IF start_time == 0, wait for the next trigger pulse. Else,
	  wait until start_time to begin the trial.
	wait_time:float
	  time to wait until the cross should remove one of its lines
	rt_deadline:float
	  if the subject did not respond more quickly than the deadline,
	  tell them they blew it
	remove:str
	  The portion of the cross to remove. Either "hbar" or "vbar".
	"""
	descr = {"onset":start_time,
			 "duration":wait_time,
			 "crossbar":remove}
	new_texture = hbar if remove == "vbar" else vbar
	if start_time == 0:
		yield vizact.waitsignal(TRIGGER_EVENT)
	else:
		while viz.tick() < start_time:
			yield viz.waitTime(0.01)
			
	# ---- If there's a message, display it for MESSAGE_TIME
	#block_text.message(message)
	#vizact.ontimer2(rate=MESSAGE_TIME, repeats=0,func=clear_text)
	
	# ---- Flash the cue
	quad.texture(cue)
	yield viztask.waitTime(0.5)
	quad.texture(cross)
	
	# ---- Wait the required time
	yield viztask.waitTime(wait_time)
	
	# ---- Set the new texture
	quad.texture(new_texture)
	#Wait for next frame to be drawn to screen
	d = yield viztask.waitDraw()

	#Save display time
	displayTime = d.time

	#Wait for a reaction
	reaction = yield viztask.waitAny( 
		[HBAR_RESPONSE,
		 VBAR_RESPONSE] )
	time_at_response, = reaction.data.data[0]

	# How did they do??
	# -> Hbar remains
	if reaction.condition is HBAR_RESPONSE:
		descr["acc_success"] = remove == "vbar"
		response = "hbar"
	# -> vbar remains
	if reaction.condition is VBAR_RESPONSE:
		descr["acc_success"] = remove == "hbar"
		response = "vbar"
		
	# print "removed:", remove,"responded:",response
	# Calculate reaction time
	reactionTime = time_at_response - displayTime
	descr["speed_success"] = reactionTime < rt_deadline
	success = descr["speed_success"] and descr["acc_success"]
	# What sort of feedback to give?
	#if training:
		# In training blocks, show the rt
		#yield training_display(reactionTime,descr["acc_success"])
	#else:
	if success:
		yield success_display(reactionTime)
	else:
		failtype = "WRONG" if descr["speed_success"] else "TIMEOUT"
		yield fail_display(failtype, reactionTime)
	
	quad.texture(cross)
	descr["response"]   = response
	descr["success"]    = success
	descr["rt"]         = reactionTime
	descr["rt_deadline"]= rt_deadline
	descr["changetime"] = d.time
	viztask.returnValue(descr)
Пример #22
0
def scenesTask():

    while True:

        # Scene 1 events
        vp1[0].add(display)
        vizconnect.resetViewpoints()
        yield viztask.waitTime(waitJumpTime)
        jumpSignal()
        yield viztask.waitEvent(CHANGE_SCENES_EVENT)
        jump_signal.visible(0)
        jumpFlash()
        vp1[0].remove(display)
        vp1[1].add(display)
        vizconnect.resetViewpoints()
        scene1.waterSound.volume(0.05)
        scene1.choir_sound.minmax(0, 3)
        yield viztask.waitTime(waitJumpTime)
        jumpSignal()
        yield viztask.waitEvent(CHANGE_SCENES_EVENT)
        jump_signal.visible(0)
        scene1.waterSound.volume(0.2)
        scene1.choir_sound.minmax(5, 15)
        jumpFlash()
        vp1[1].remove(display)
        vp1[2].add(display)
        vizconnect.resetViewpoints()
        yield viztask.waitTime(waitJumpTime)
        jumpSignal()
        yield viztask.waitEvent(CHANGE_SCENES_EVENT)
        jump_signal.visible(0)
        jumpFlash()
        vp1[2].remove(display)
        vp1[3].add(display)
        vizconnect.resetViewpoints()
        scene1.timer.setEnabled(viz.ON)
        yield viztask.waitEvent(scene1.WATER_RISE_EVENT)
        yield scene1.BlurTask()
        scene1.enableUnderWater()
        yield viztask.waitTime(waitJumpTime)
        jumpSignal()
        yield viztask.waitEvent(CHANGE_SCENES_EVENT)
        jump_signal.visible(0)
        manager.removeSensor(scene1.stoneSensor)
        jumpFlash()
        vp1[3].remove(display)

        # Scene 2 events
        scene1.setActive(False)
        scene2.setActive(True)
        grabTool.setItems(scene2.getGrabObjects())
        vp2[0].add(display)
        vizconnect.resetViewpoints()
        yield viztask.waitTime(waitJumpTime)
        jumpSignal()
        yield viztask.waitEvent(CHANGE_SCENES_EVENT)
        jump_signal.visible(0)
        jumpFlash()
        vp2[0].remove(display)
        vp2[1].add(display)
        vizconnect.resetViewpoints()
        yield viztask.waitTime(waitJumpTime)
        jumpSignal()
        yield viztask.waitEvent(CHANGE_SCENES_EVENT)
        jump_signal.visible(0)
        jumpFlash()
        vp2[1].remove(display)
        vp2[2].add(display)
        vizconnect.resetViewpoints()
        yield viztask.waitTime(waitJumpTime)
        jumpSignal()
        yield viztask.waitEvent(CHANGE_SCENES_EVENT)
        jump_signal.visible(0)
        jumpFlash()
        vp2[2].remove(display)
        vp2[3].add(display)
        vizconnect.resetViewpoints()
        yield viztask.waitTime(waitJumpTime)
        jumpSignal()
        yield viztask.waitEvent(CHANGE_SCENES_EVENT)
        jump_signal.visible(0)
        vp2[3].remove(display)

        # Scene 3 events
        scene2.setActive(False)
        scene3.setActive(True)
        vp3[0].add(display)
        vizconnect.resetViewpoints()
        yield viztask.waitAny([waitKey1, wait10])
        scene3.lowerBox()
        yield viztask.waitAny([waitKey2, wait10])
        scene3.raiseWalls()
        yield viztask.waitTime(waitJumpTime)
        jumpSignal()
        yield viztask.waitEvent(CHANGE_SCENES_EVENT)
        jump_signal.visible(0)
        jumpFlash()
        vp3[0].remove(display)
        vp3[1].add(display)
        vizconnect.resetViewpoints()
        yield viztask.waitTime(waitJumpTime)
        jumpSignal()
        yield viztask.waitEvent(CHANGE_SCENES_EVENT)
        jump_signal.visible(0)
        jumpFlash()
        vp3[1].remove(display)
        vp3[2].add(display)
        vizconnect.resetViewpoints()
        yield viztask.waitTime(waitJumpTime)
        jumpSignal()
        yield viztask.waitEvent(CHANGE_SCENES_EVENT)
        jump_signal.visible(0)
        jumpFlash()
        vp3[2].remove(display)
        vp3[3].add(display)
        vizconnect.resetViewpoints()
        yield viztask.waitTime(waitJumpTime)
        jumpSignal()
        yield viztask.waitEvent(CHANGE_SCENES_EVENT)
        jump_signal.visible(0)
        vp3[3].remove(display)
        scene3.setActive(False)
        scene3.raiseBox()
        scene1.setActive(True)