def trialCountDownTask():
	"""Task that count downs to time limit for trial"""	
	# Action for text fading out
	text_fade = vizact.parallel(
		vizact.fadeTo(0,time=0.8,interpolate=vizact.easeOut)
		,vizact.sizeTo([.1,.1,.1],time=0.8,interpolate=vizact.easeOut)
	)
	
	# Reset time text
	time_text.clearActions()
	time_text.alpha(1.0)
	time_text.color(viz.BLACK)
	time_text.setScale([.05,.05,.05])
	time_text.message('REMAINING: ' + str(int(globals_oa.TIME_TO_FIND_IN_SCAVENGER_HUNT)/60)+ ':' + str(int(globals_oa.TIME_TO_FIND_IN_SCAVENGER_HUNT)%60).zfill(2))
	
	# Countdown from time limit
	start_time = viz.getFrameTime()
	last_remain = int(globals_oa.TIME_TO_FIND_IN_SCAVENGER_HUNT)
	while (viz.getFrameTime() - start_time) < globals_oa.TIME_TO_FIND_IN_SCAVENGER_HUNT:
		# Compute remaining whole seconds
		remain = int(math.ceil(globals_oa.TIME_TO_FIND_IN_SCAVENGER_HUNT - (viz.getFrameTime() - start_time)))

		# Update text if time remaining changed
		if remain != last_remain:
			if remain <= 5:
				time_text.alpha(1.0)
				time_text.color(viz.RED)
				time_text.setScale([.05]*3)
				time_text.runAction(text_fade)
			time_text.message(str(remain/60)+ ':'+str(remain%60).zfill(2))
			last_remain = remain
			
		# Wait tenth of second	
		yield viztask.waitTime(0.1)
	print 'OUT OF TIME'
示例#2
0
def TrialCountDownTask():
    """Task that count downs to time limit for trial"""
    # Action for text fading out
    text_fade = vizact.parallel(
        vizact.fadeTo(0, time=0.8, interpolate=vizact.easeOut),
        vizact.sizeTo([1.5, 1.5, 1.0], time=0.8, interpolate=vizact.easeOut))

    # Reset time text
    time_text.clearActions()
    time_text.alpha(1.0)
    time_text.color(viz.WHITE)
    time_text.setScale([1, 1, 1])
    time_text.message(str(int(TRIAL_DURATION)))

    # Countdown from time limit
    start_time = viz.getFrameTime()
    last_remain = int(TRIAL_DURATION)
    while (viz.getFrameTime() - start_time) < TRIAL_DURATION:
        # Compute remaining whole seconds
        remain = int(
            math.ceil(TRIAL_DURATION - (viz.getFrameTime() - start_time)))
        # Update text if time remaining changed
        if remain != last_remain:
            if remain <= 5:
                time_text.alpha(1.0)
                time_text.color(viz.RED)
                time_text.setScale([1] * 3)
                time_text.runAction(text_fade)
                viz.playSound('sounds/beep.wav')
            time_text.message(str(remain))
            last_remain = remain

        # Wait tenth of second
        yield viztask.waitTime(0.1)
示例#3
0
	def SackAnim (self, sid):	#sid is the sack id: {1R, 2R, 1L, or 2L}
		self._usedSackCounter += 1
		sack = self.components['sack'+sid]
		self.sack_path = self.sackItem.getChild('path'+sid).copy()
		self.sack_path.setParent(self.factory)	#prevent from appearing in MainWindow
		sack.setParent(self.sack_path, node='path'+sid)
		self.sack_path.setAnimationSpeed(1)
		sack.addAction(vizact.waittime(3))	#wait for sack animation
		endAnimSignal = vizact.signal()
		trig = endAnimSignal.trigger
		hide = vizact.method.visible(0)
		sack.addAction(vizact.parallel(hide, trig))
		self.sackPour.addAction(endAnimSignal.wait)	# wait for animation before pouring starts
		self.sackPour.addAction(vizact.method.alpha(1, node='sack_bent'))
		self.sackPour.addAction(vizact.spinTo(euler=[0,-45,0], time=.75, interpolate=vizact.easeInStrong))
		self.sackPour.addAction(vizact.fadeTo(1, begin=0, time=.5, node='olive_flow'))
		loadSignal = vizact.signal()
		self.sackPour.addAction(loadSignal.trigger)
		self.sackPour.addAction(vizact.waittime(5))
		self.sackPour.addAction(vizact.fadeTo(0, time=.5))
		self.sackPour.addAction(vizact.method.setEuler([0,0,0]))	# put it back standing
		self.mixedPulp.addAction(loadSignal.wait)	# wait for olive pouring before pulp appears
		self.mixedPulp.addAction(vizact.method.visible(1))
		#self.mixedPulp.addAction(vizact.fadeTo(1, begin=0, time=1, node='olives'))
		move = vizact.moveTo([0, 0, 0], time=5)
		resize = vizact.sizeTo([1, 1, 1], time=5, interpolate=vizact.easeIn)
		self.mixedPulp.addAction(vizact.parallel(move, resize))
		self.sack_path.addAction(loadSignal.wait)
		self.sack_path.addAction(vizact.method.setAnimationSpeed(-100))	#put sack back
示例#4
0
	def PulpInTank (self, inOut):	# >0 -> add, <0 -> subtract
		self.PulpLevel += inOut
		amount = self.PulpLevel * .05
		pulp = self.components['pulp']
		move = vizact.moveTo([0,amount,0], time=3)
		resize = vizact.sizeTo([1+amount/4,1,1+amount/2], time=3)
		pulp.addAction(vizact.parallel(move, resize))
示例#5
0
def TrialCountDownTask():
    """Task that count downs to time limit for trial"""
    global revealSelf
    global manChase

    # Action for text fading out
    text_fade = vizact.parallel(
        vizact.fadeTo(0,time=0.8,interpolate=vizact.easeOut)
        ,vizact.sizeTo([1.5,1.5,1.0],time=0.8,interpolate=vizact.easeOut)
    )

    # Reset time text
    time_text.clearActions()
    time_text.alpha(1.0)
    time_text.color(viz.WHITE)
    time_text.setScale([1,1,1])
    time_text.message(str(int(TRIAL_DURATION)))

    # Countdown from time limit
    start_time = viz.getFrameTime()
    last_remain = int(TRIAL_DURATION)
    male2.clearActions()
    male2.setPosition(2.5,0,7.5)

    while (viz.getFrameTime() - start_time) < TRIAL_DURATION:

        if revealSelf:
            pigeon.clearActions()
            pos = viz.MainView.getPosition()
            pigeon.addAction( vizact.walkTo([pos[0], 0, pos[2]]) )

        if manChase:
            male.clearActions()
            male2.state(2)
            pos = pigeon.getPosition()
            male2.addAction( vizact.walkTo([pos[0] - .5, 0, pos[2] - .5]))

        if male2.getPosition()[2] == (pigeon.getPosition()[2] - .5):
            #allow for other actions to take place (chase takes precedence)
            manChase = False
            male2.state(9)

        # Compute remaining whole seconds
        remain = int(math.ceil(TRIAL_DURATION - (viz.getFrameTime() - start_time)))

        # Update text if time remaining changed
        if remain != last_remain:
            if remain <= 5:
                time_text.alpha(1.0)
                time_text.color(viz.RED)
                time_text.setScale([1]*3)
                time_text.runAction(text_fade)
                viz.playSound('sounds/beep.wav')
            time_text.message(str(remain))
            last_remain = remain

        # Wait tenth of second
        yield viztask.waitTime(0.1)
示例#6
0
def move_and_scale():
    for m_b in range(bubble_num):
        groups_bubble[m_b].visible(viz.ON)
        bubble_pos = groups_bubble[m_b].getPosition(viz.ABS_GLOBAL)
        bubble_pos[1] = bubble_pos[1] + 30.0
        action_bubble = vizact.moveTo(bubble_pos, speed=1)
        action_scale_bubble = vizact.sizeTo([10, 10, 10], time=30)
        groups_bubble[m_b].addAction(action_bubble, pool=11)
        groups_bubble[m_b].addAction(action_scale_bubble, pool=12)
示例#7
0
	def UpdateScore(self, points):
		curScore = int(self._score.getMessage())
		if self._newScore == None:	#this ensures correct update of the score
			self._newScore = curScore + points
		else:
			self._newScore += points
		self.SOUNDS['score'+str(int(points>0))].play()
		resize = vizact.sizeTo([1.5-(points<0),1.5-(points<0),0], time=.25)	#resizes to .5 if deducting points
		color = [viz.RED, viz.GREEN][points>0]
		fade = vizact.fadeTo(color, time=.25)
		self._scoreIcon.addAction(vizact.parallel(resize, fade))
		waitAnim = vizact.signal()
		self._scoreIcon.addAction(waitAnim.trigger)
		self._score.addAction(waitAnim.wait)
		self._score.addAction(vizact.method.message(str(self._newScore)))
		self._score.addAction(vizact.call(self.resetNewScore))
		resize = vizact.sizeTo([1,1,0], time=.25)
		fade = vizact.fadeTo(viz.YELLOW, time=.25)
		self._scoreIcon.addAction(vizact.parallel(resize, fade))
示例#8
0
	def PasteInTank (self):
		hatch = self.components['hatch'+self.LR]
		hatch.addAction(vizact.moveTo([.3-.275, .976-.879, -0.956+.907], time=1, interpolate=vizact.easeInOut))
		hatch.addAction(vizact.waittime(1))
		openSignal = vizact.signal()
		hatch.addAction(openSignal.trigger)
		# code for pouring animation
		self.pourPulp.addAction(openSignal.wait)
		self.pourPulp.addAction(vizact.fadeTo(1, time=.5))
		self.pourPulp.addAction(vizact.waittime(5))
		self.pourPulp.addAction(vizact.fadeTo(0, time=.5))
		self.tankPulp.addAction(openSignal.wait)
		self.tankPulp.addAction(vizact.waittime(.5))
		self.tankPulp.addAction(vizact.moveTo([0,.4,0], time=5, interpolate=vizact.easeOut))
		self.mixedPulp.addAction(openSignal.wait)
#		self.mixedPulp.addAction(vizact.fadeTo(0, time=5))
		move = vizact.moveTo([0, -.28, 0], time=5, interpolate=vizact.easeOut)
		resize = vizact.sizeTo([.85,1,.85], time=5, interpolate=vizact.easeOut)
		self.mixedPulp.addAction(vizact.parallel(move, resize))
示例#9
0
文件: D2C3.py 项目: vhilab/VRITS-2015
def TrialCountDownTask():
    """Task that count downs to time limit for trial"""

    # Action for text fading out
    text_fade = vizact.parallel(
        vizact.fadeTo(0,time=0.8,interpolate=vizact.easeOut)
        ,vizact.sizeTo([1.5,1.5,1.0],time=0.8,interpolate=vizact.easeOut)
    )

    # Reset time text
    time_text.clearActions()
    time_text.alpha(1.0)
    time_text.color(viz.WHITE)
    time_text.setScale([1,1,1])
    time_text.message(str(int(TRIAL_DURATION)))

    # Countdown from time limit
    start_time = viz.getFrameTime()
    last_remain = int(TRIAL_DURATION)
    while (viz.getFrameTime() - start_time) < TRIAL_DURATION:

        # Compute remaining whole seconds
        remain = int(math.ceil(TRIAL_DURATION - (viz.getFrameTime() - start_time)))

        # Update text if time remaining changed
        if remain != last_remain:
            if remain <= 5:
                time_text.alpha(1.0)
                time_text.color(viz.RED)
                time_text.setScale([1]*3)
                time_text.runAction(text_fade)
                viz.playSound('sounds/beep.wav')
            time_text.message(str(remain))
            last_remain = remain

        # Wait tenth of second
        yield viztask.waitTime(0.1)
示例#10
0
	def Pressing (self):
		# start moving the piston upwards (not sure why it's working with Z value)
		self.piston.addAction(vizact.moveTo([0,1.2,0], time=60, interpolate=vizact.easeOutCubic))
		stopStrain=vizact.signal()	# signal when the straining finished (60 secs)
#		self.mats.addAction(startSqueeze.trigger)
		self.mats.addAction(vizact.sizeTo([1,.5,1], time=60, interpolate=vizact.easeOutCubic))
		self.mats.addAction(stopStrain.trigger)
		# oil straining starts 2'' after squeezing starts and stops 3'' after squeezing stops
		self.oilStrain.addAction(vizact.waittime(2))	# start straining after 2 secs
		startSqueeze = vizact.signal()	# signal when straining starts
		self.oilStrain.addAction(startSqueeze.trigger)
		self.oilStrain.addAction(vizact.method.visible(1))
		self.oilStrain.addAction(vizact.fadeTo(1, begin=0, time=1))
		self.oilStrain.addAction(stopStrain.wait)
		self.oilStrain.addAction(vizact.fadeTo(0, time=3))
		# oil gathering starts when mats reach the top and finishes 5'' after strain is over
		self.oilGathered.addAction(startSqueeze.wait)
		self.oilGathered.addAction(vizact.method.visible(1))
		self.oilGathered.addAction(vizact.fadeTo(1, begin=0, time=5))
		startDrop = vizact.signal()	# signal when the drop should start (5'' after oil gathered)
		self.oilGathered.addAction(startDrop.trigger)
		self.oilGathered.addAction(stopStrain.wait)
		self.oilGathered.addAction(vizact.waittime(5))	# wait 5 more secs for gathered oil to drop
		self.oilGathered.addAction(vizact.fadeTo(0, time=1))
		self.oilGathered.addAction(vizact.method.visible(0))
		# oil drop stars 5'' after oil is gathered and finishes 5'' after strain is over
		self.oilDrop.addAction(startDrop.wait)	# start drop and tank filling after 5 secs
		self.oilDrop.addAction(vizact.method.visible(1))
		self.oilDrop.addAction(vizact.fadeTo(1, begin=0, time=1))
		self.oilDrop.addAction(stopStrain.wait)
		self.oilDrop.addAction(vizact.waittime(5))
		self.oilDrop.addAction(vizact.fadeTo(0, time=1))
		self.oilDrop.addAction(vizact.method.visible(0))
		# oil in can starts filling up when oil drop starts (45'')
		self.oilSurface.addAction(startDrop.wait)
		self.oilSurface.addAction(vizact.moveTo([0,0,0], time=45))
示例#11
0
def _plaqueAni():
	global nextRoundPlaque
	yield nextRoundPlaque.addAction(vizact.sizeTo(nextRoundPlaque.getBoundingBox().getSize(), begin=[0.01] * 3, time=0.5))
	nextRoundPlaque.visible(viz.ON)
	yield viztask.waitTime(2.0)
	nextRoundPlaque.visible(viz.OFF)
示例#12
0
 def update(self, elapsed, object):
     pos = tracker.getPosition()
     comeToUser = vizact.moveTo(pos, begin=None, speed=1, time=1, mode=viz.ABS_PARENT, interpolate=None)
     getBigger = vizact.sizeTo(1.5, 1.5, 1.5)
     moveForward = vizact.move(1, 0, 0, elapsed)
     pigeon.addAction(moveForward)
示例#13
0
	def Releasing (self, dur):
		self.piston.addAction(vizact.moveTo([0,0,0], time=dur, interpolate=vizact.easeOut))
		self.mats.addAction(vizact.sizeTo([1,.75,1], time=dur, interpolate=vizact.easeOutCubic))
示例#14
0

viztask.schedule(scenesTask())

# Proximity code
manager = vizproximity.Manager()

# Add main viewpoint as proximity target
target = vizproximity.Target(viz.MainView)
manager.addTarget(target)

# Add scene1 proximity sensor
manager.addSensor(scene1.stoneSensor)

scaleAction = vizact.sequence([
    vizact.sizeTo(size=[1.3, 1.3, 1.3], time=1),
    vizact.sizeTo(size=[1, 1, 1], time=1)
], viz.FOREVER)
fadeAction = vizact.sequence([
    vizact.fadeTo([0.63, 0.32, 0.18], time=2),
    vizact.fadeTo(viz.WHITE, time=2)
], viz.FOREVER)


def onGrab(e):
    e.grabbed.runAction(fadeAction, pool=1)
    e.grabbed.runAction(scaleAction, pool=2)
    if scene2.getActive():
        scene2.music.play()
        viz.window.setPolyMode(viz.POLY_POINT)