def creepilyMoveCloser(node): global introAudio1, introAudio2 global comeForward, firstSeatPosition, seatQueue global PID dout = DataOutputHelper(PID) comeForward = seatQueue[-2] firstSeatPosition = seatQueue[0] node.setPosition(firstSeatPosition) yield viztask.waitMediaEnd(introAudio1) introAudio2.play() # We want the participant to have a minute after the audio ends viz.callback(viz.MEDIA_EVENT,onAudioEnd) dout.timestamp(dout.busFile, 'Initial audio ended') yield viztask.waitMediaEnd(introAudio2) yield viztask.waitTime(.1) # Pause necessary for NodeViewDetection to get necessary info about node nvd = DetectWhetherInView.NodeViewDetection(node) FadeObject.beginFading() moveAsUsual = False getCloserBeforeBackAway = True while getCloserBeforeBackAway: node.setPosition(firstSeatPosition) yield waitTilNodeAndDestOutsideView(nvd, firstSeatPosition) yield waitTilNodeInsideView(nvd) node.setPosition(comeForward) yield creepilyMakeEyeContact(node, comeForward, dout) yield moveBackToFirstSeat(node, seatQueue) if abs(node.getPosition()[0] - firstSeatPosition[0]) < 0.1: getCloserBeforeBackAway = False moveAsUsual = True print 'waiting til node inside view...' yield waitTilNodeInsideView(nvd) while moveAsUsual: print 'waiting until node and dest outside view...' nextPosition = seatQueue[1] # Peek at nextPosition yield waitTilNodeAndDestOutsideView(nvd, nextPosition) # Pauses til node and that position are outside of view # Move to nextPosition print 'node and dest are outside view! Moving to next position...' node.setPosition(nextPosition) seatQueue.rotate(-1) # update seatQueue print 'waiting til node inside view...' yield waitTilNodeInsideView(nvd) print 'creepily dodging eye contact...' yield creepilyMakeEyeContact(node, seatQueue[0], dout) #if seatQueue[0] is not finalSeatPosition: print 'waiting 5 seconds then moving him back if hes in view at the end of the 5 seconds.' # TODO: This is not exactly what we want. yield moveBackwardsIfStaredAt(node, nvd) # If the node is not in the last seat position,
def playStory(): global selectedAvatar, playing, avs if selectedAvatar.name == 'exit': viztask.schedule(playBusCloseAudio) else: selectedAvatar.story.play() playing = True toOutput = 'Started listening to ' + selectedAvatar.name dc.collect(toOutput) yield viztask.waitMediaEnd(selectedAvatar.story) playing = False selectedAvatar.done = True if selectedAvatar.name == 'son/father': for avatar in avs: if avatar.name == 'father/son': avatar.done = True break if selectedAvatar.name == 'father/son': for avatar in avs: if avatar.name == 'son/father': avatar.done = True break toOutput = 'Finished listening to ' + selectedAvatar.name dc.collect(toOutput) yield viztask.waitTime(0.1) selectedAvatar = None
def playBusCloseAudio(): global selector selector.removeOnDeselectCallback(avs) selector.removeOnSelectCallback(avs) selector.removeOnDeselectCallback(exit) selector.removeOnSelectCallback(exit) selector.disable() global busCloseAudio1, busCloseAudio2, ambientBusAudio busCloseAudio1.play() yield viztask.waitMediaEnd(busCloseAudio1) ambientBusAudio.stop() StreetlightBusEffect.disableStreetLights() # TODO: stop streetlightbuseffect busCloseAudio2.volume(.3) busCloseAudio2.play() yield viztask.waitMediaEnd(busCloseAudio2) global remove for node in remove: node.remove()
def begin(): global introAudio introAudio.play() yield viztask.waitMediaEnd(introAudio) global selectedAvatar selectedAvatar = None global playing playing = False global avs, SCENE global selector selector.onSelect(avs, allowSelection) selector.onDeselect(avs, endSelection) selector.enable() vizact.onmousedown(viz.MOUSEBUTTON_LEFT, startStory)
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
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())
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()