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]
def fadeOutTask(self, fadeTime=1.5): """Yieldable task to fade out to silent""" initialVolume = self._mixer.getVolume() amount = - initialVolume * (self._timeStep / fadeTime) self.updateEvent = vizact.ontimer(self._timeStep, self._updateFadeOut, amount) yield viztask.waitEvent(FADE_COMPLETE) self.updateEvent.setEnabled(False) self._mixer.stop()
def doShutdownTreadmill(): yield viztask.waitKeyDown('q') viz.sendEvent(STOP_TREADMILL) yield viztask.waitEvent(TREADMILL_STOPPED) print "pause ...", yield viztask.waitTime(1) print "done" viz.quit()
def __stop(self): yield viztask.waitEvent(STOP_TREADMILL) if self.going: self.stopMotors() yield viztask.waitTime(1) print "Closing socket ...", self.T1.stop() print "done" viz.sendEvent(TREADMILL_STOPPED)
def updatePos(self): rad_to_deg = math.pi / 180.0 msg = viz.addText("", parent=viz.SCREEN, pos=(0.05, 0.9, 0), scale=(0.25, 0.25, 0)) msg.setBackdrop(viz.BACKDROP_OUTLINE) self.readTime = 0 t0 = viz.tick() while True: if self.going: #self.T1.ReadBothBeltsPosition() #self.T1.ReadBothBeltsSpeed() self.lbp = self.T1.plabTreadmill.leftBeltPosition.value self.rbp = self.T1.plabTreadmill.rightBeltPosition.value self.lbs = self.T1.plabTreadmill.leftBeltSpeed.value self.rbs = self.T1.plabTreadmill.rightBeltSpeed.value if self.verbose: self.message = "Left: %6.6f, %6.6f\nRight: %6.6f, %6.6f\nReadTime: %6.6f ms"%(\ self.lbp, self.lbs, self.rbp, self.rbs, 1000.0*self.readTime) else: self.message = "" msg.message(self.message) dt = viz.tick() - t0 dtheta_dt = (self.lbs - self.rbs) / self.separation dr_dt = 0.5 * (self.lbs + self.rbs) spinner = vizact.spin(0, 1, 0, dtheta_dt, dt) mover = vizact.move(0, 0, dr_dt, dt) spinmove = vizact.parallel(spinner, mover) #print "gh1",dr_dt, dt self.track.addAction(spinmove) yield viztask.waitActionEnd(self.track, spinmove) t0 = viz.tick() #for the recording if self.recording: #time, left pos, left speed, right pos, right speed, head pos (xyz, dir) pp = self.track.getPosition() self.history.append( (viz.tick(), self.lbp, self.lbs, self.rbp, self.rbs, pp[0], pp[1], pp[2], self.track.getEuler()[0])) #yield viztask.waitTime(1.0/19.0) yield viztask.waitEvent(TREADMILL_STATE_UPDATED)
def __ZeroSpacing(self, samples=60): while True: yield viztask.waitEvent(REQUEST_FEET_ALIGNMENT_TREADMILL) print "Starting zero ... ", yield None self.left = [] self.right = [] for i in range(samples): self.left.append(self.forceplates.latestLeftCOP[1]) self.right.append(self.forceplates.latestRightCOP[1]) yield None print "done" self.left = np.array(self.left) self.right = np.array(self.right) global CORRECT_LEFT CORRECT_LEFT = np.mean(self.right) - np.mean(self.left) print "Adjusting left ", CORRECT_LEFT, " meters to match right" print "Variability was ", np.std(self.left), " on the left" print "Variability was ", np.std(self.right), " on the right" viz.sendEvent(DONE_FEET_ALIGNMENT_TREADMILL)
hbar = viz.addTexture("images/hbar.png") vbar = viz.addTexture("images/vbar.png") cross = viz.add("images/cross.png") # Sounds correct_sound = viz.addAudio("images/beep-8.wav") incorrect_sound = viz.addAudio("images/beep-3.wav") # Text for feedback block_text = viz.addText("",parent=viz.SCREEN) block_text.setPosition(0.5,0.8) block_text.alignment(viz.ALIGN_CENTER_CENTER) block_text.font("times.ttf") MESSAGE_TIME = 1 # ---------- Configure so responses are mapped to cross components -- HBAR_RESPONSE = viztask.waitEvent(LEFT_BUTTON_EVENT,all=True) VBAR_RESPONSE = viztask.waitEvent(RIGHT_BUTTON_EVENT,all=True) # ------------------------------------------------------------------- #Add quad to screen quad = viz.addTexQuad( viz.SCREEN , pos=(0.5,0.5,0) , scale=(5,5,5) ) #quad.texture(cross) def training_display(rt,acc): print "acc",acc if acc: msg = "RIGHT" correct_sound.play() else: msg = "WRONG" incorrect_sound.play() block_text.message(msg + " %.2fs"%rt)
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)
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() )
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()
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)