Пример #1
0
 def moveView(self):
     # move view
     xT,_,zT  = self.cTrial.getPos('src', 'near')
     moveTo = vizact.moveTo([xT,ct.EYE_HEIGHT,zT], speed=5)
     viz.MainView.addAction(moveTo)
  
     yield viztask.waitActionEnd(viz.MainView, moveTo)
  
     # make source building semi transparent
     self.cTrial.showBuilding('src', 'transparent')
     
     # align reference vertex to mainview
     self.refVert.setMatrix( viz.MainView.getMatrix() )
             
     # enable user mouse look
     WalkNavigate(forward='w', backward='s', left='a', right='d', moveScale=0, turnScale=1.0)
     
     vx, _, vz = viz.MainView.getPosition()
     # draw grid            
     self.cross90.setPosition(vx, 0.01, vz)
     self.cross90.visible(viz.ON)
             
     self.grid.setPosition(vx, 0.1, vz)
     self.grid.visible(viz.ON)
     
     viztask.schedule( self.getTargetAngle() )
Пример #2
0
def strippedTrialTask(avatar, turningAngle, vLinear, tLegs, idxTrial, output = {}):
	"""
	master task that invokes all other tasks as subtasks to ensure right order
	"""
	# add text for instructions
	screenText = viz.addText('trial no. '+str(idxTrial),viz.SCREEN)
	screenText.setBackdrop(viz.BACKDROP_RIGHT_BOTTOM)
	screenText.setBackdropColor(viz.GRAY)
	screenText.setPosition(0.05, 0.5)
	
	# wait for key press and execute trial
	yield viztask.waitKeyDown(' ')
	screenText.message('')
	passage = passageAction(turningAngle, vLinear, tLegs)
	avatar.addAction(passage)
	yield viztask.waitActionEnd(avatar, passage)
	
	# get homing vectors
	yield helperFunctions.saveHomingVectors(avatar, output)
	print output
	
	# post trial instructions & position reset
	yield viztask.waitTime(0.2)
	screenText.message('please select your\nanswer for trial '+str(idxTrial))
	yield viztask.waitKeyDown(' ')
	screenText.remove()
	yield helperFunctions.resetTask(avatar)
Пример #3
0
def showVRText(msg, color=[1.0, 1.0, 1.0], distance=2.0, scale=0.05, duration=2.0):
    """ Display head-locked message in VR, e.g. for instructions.
    
    Args:
        msg (str): Message text
        color: RBG 3-tuple of color values
        distance (float): Z rendering distance from MainView
        scale (float): Text node scaling factor
        duration (float): Message display duration (seconds)
    """
    # Create 3D text object
    text = viz.addText3D(msg, scale=[scale, scale, scale], color=color)
    text.resolution(1.0)
    text.setThickness(0.1)
    text.alignment(viz.ALIGN_CENTER)
    
    # Lock text to user viewpoint at fixed distance
    text_link = viz.link(viz.MainView, text, enabled=True)
    text_link.preTrans([0.0, 0.0, distance])
    
    # Fade text away after <duration> seconds
    fadeout = vizact.fadeTo(0, time=0.7)
    yield viztask.waitTime(duration)
    text.addAction(fadeout)
    yield viztask.waitActionEnd(text, fadeout)
    text.remove()
Пример #4
0
def loadEndofExperienceSnap():
 globals_oa.EOE_TEXTURE = viz.addTexture(globals_oa.EOE_HIGH_SHOCK_TEXTURE_PATH)
 globals_oa.CANVAS_QUAD.texture(globals_oa.EOE_TEXTURE)
 globals_oa.CANVAS_QUAD.visible(True)
 yield viztask.waitTime(globals_oa.EOE_SNAP_TIME)
 removeZoneSnapShots = globals_oa.EOE_TEXTURE.remove()
 globals_oa.CANVAS_QUAD.visible(False)
 yield viztask.waitActionEnd(globals_oa.EOE_TEXTURE, removeZoneSnapShots)
Пример #5
0
def loadAcknowledgment():
 globals_oa.ACKNOWLEDGMENT_QUAD_TEXTURE = viz.addTexture(globals_oa.ACKNOWLEDGMENT_TEXTURE_PATH)
 globals_oa.CANVAS_QUAD.texture(globals_oa.ACKNOWLEDGMENT_QUAD_TEXTURE)
 globals_oa.CANVAS_QUAD.visible(True)

 yield viztask.waitTime(globals_oa.TOTAL_FADING_DRAMA_TIME)
 removeAcknowledgment = globals_oa.ACKNOWLEDGMENT_QUAD_TEXTURE.remove()
 yield viztask.waitActionEnd(globals_oa.ACKNOWLEDGMENT_QUAD_TEXTURE, removeAcknowledgment)
def moveBackwards( node, seat ):
	global seatQueue
	spin = vizact.turn(145)
	moveHead = vizact.headto(25,0,0, bone='Bip01 Head')
	move = vizact.moveTo(pos=seat,speed=0.75,interpolate=vizact.easeInOut)
	slide = vizact.animation(66)
	shuffle = vizact.parallel(spin,moveHead,move,slide)
	shuffleBack = vizact.sequence(shuffle)
	node.add(shuffleBack)
	yield viztask.waitActionEnd(node,shuffleBack)
	node.setPosition(seat)
Пример #7
0
def displaySpecies(node, name):
	global speciesText, display
	if speciesText is not None:
		speciesText.message(name)
		speciesText.visible(True)
		node.alpha(0)
		node.visible(True)
		node.addAction(display)
		yield viztask.waitActionEnd(node,display)
		node.visible(False)
		speciesText.visible(False)
Пример #8
0
def moveToDash(node):
	if (node == cup1):#cup1
		move = vizact.sequence(vizact.moveTo([-.70,1.4,-2.4],speed=.5),vizact.moveTo([.69,1.4,-2.4],speed=.5), vizact.moveTo([.69,1.23,-2.76],speed=.5))
		node.addAction(move)
		yield viztask.waitActionEnd(node,move)
		viz.sendEvent(FINDING_TASK_OVER_EVENT, SCENE)
	elif (node == toothBrush or node == bristles): #toothbrush
		move = vizact.sequence(vizact.moveTo([7,10,-3],speed=5), vizact.moveTo([10,13.5,-15],speed=5))
		toothBrush.addAction(move)
		bristles.addAction(move)
		yield viztask.waitActionEnd(bristles,move)
	elif (node == toothPaste or node == cap): #toothpaste
		move = vizact.sequence(vizact.moveTo([0,1,10],speed=7),vizact.moveTo([18,1,-3],speed=7))
		toothPaste.addAction(move)
		cap.addAction(move)
		yield viztask.waitActionEnd(cap,move)
	elif (node == bottle1 or node == bottleCap1):#bottle 1
		move = vizact.moveTo([0,-17.5, -8], time=1)
		spin = vizact.spinTo(euler=[0,25,0], time = 1)
		spinMove = vizact.parallel(spin, move)
		move = vizact.sequence(spinMove, vizact.moveTo([15,-13,-6],speed=8), vizact.moveTo([15,-3,-6],speed=8), vizact.moveTo([18,-5,-17],speed=8))
		bottle1.addAction(move)
		bottleCap1.addAction(move)
		yield viztask.waitActionEnd(bottle1,move)
	elif (node == bottle2 or node == bottleCap2): #bottle 2
		move = vizact.sequence(vizact.moveTo([7,12,-3],speed=5), vizact.moveTo([8,12,-14],speed=5))
		bottle2.addAction(move)
		bottleCap2.addAction(move)
		yield viztask.waitActionEnd(bottle2,move)
	elif (node == cup2): #cup 2
		move = vizact.sequence(vizact.moveTo([0,2.5,0],speed=5),vizact.moveTo([15,2.5,0],speed=5), vizact.moveTo([15,0,0],speed=5))
		node.addAction(move)
		yield viztask.waitActionEnd(node,move)
		viz.sendEvent(FINDING_TASK_OVER_EVENT, SCENE)
def moveBackToFirstSeat( node, seatQueue ):
	yield viztask.waitTime(1)
	spin = vizact.turn(145)
	moveHead = vizact.headto(25,0,0, bone='Bip01 Head')
	moveFirst = vizact.moveTo(pos=seatQueue[2],speed=0.75,interpolate=vizact.easeInOut)
	moveSecond = vizact.moveTo(pos=seatQueue[1],speed=0.75,interpolate=vizact.easeInOut)
	moveThird = vizact.moveTo(pos=seatQueue[0],speed=0.75,interpolate=vizact.easeInOut)
	slide = vizact.animation(66)
	slideBackOnce = vizact.parallel(spin,moveHead,moveFirst,slide)
	slideBackTwice = vizact.parallel(spin,moveHead,moveSecond,slide)
	slideBackThrice = vizact.parallel(spin,moveHead,moveThird,slide)
	shuffleToFirst = vizact.sequence(slideBackOnce,slideBackTwice,slideBackThrice)
	node.add(shuffleToFirst)
	yield viztask.waitActionEnd(node,shuffleToFirst)
	node.setPosition(seatQueue[0])
Пример #10
0
	def fadingFadeThing():
		yield viztask.waitTime(1)
		globals_oa.fadingSphere.addAction(fadeOutSphere)
		yield viztask.waitActionEnd(globals_oa.fadingSphere, fadeOutSphere)
		globals_oa.terrainZone3.visible(viz.OFF)
		globals_oa.ocean.visible(viz.OFF)
#		globals_oa.terrainZone1.visible(viz.ON)
		globals_oa.globeScene.enable(viz.RENDERING)
		globals_oa.user.setPosition(0.0,-0.05,0.0)
		viz.fogcolor(viz.BLACK)
		viz.fog(0.2)
		viz.clearcolor(viz.BLACK)
		globals_oa.fader.fadeOutTask()
		globals_oa.fader.fadeInTask()
#		yield viztask.waitTime(2)
		yield globals_oa.fadingSphere.addAction(fadeInSphere)
Пример #11
0
    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)
Пример #12
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)