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 init(avatar, pack_objs, intro, **kwargs):
	global isBusScene, moveSeats, seatQueue
	isBusScene = False
	DetectWhetherInView.init(**kwargs)
	seats = [Seats.getseatplacement(id)[0] for id in avatar.teleSeatIDs] # TODO: Abstract to handle arbitrary orientation too (for front right seats)
	seatQueue = deque([[seat[0],seat[1],seat[2]-0.5] for seat in seats]) # Node is in bus aisle

	
	global introAudio1, introAudio2
	introAudio1 = intro
	introAudio2 = viz.addAudio('Audio/CreepyTaskIntroduction.wav')
	
	FadeObject.init(pack_objs, 25, 0.01, **kwargs)
	
	viztask.schedule( creepilyMoveCloser(avatar) )
예제 #3
0
import viz
import vizact
import FadeObject
import keyboardcontrol

keyboardcontrol.control(viz.MainView)  

VFOV_DEFAULT = 40 # Vertical field of view in degrees
VFOV_RIFT = 106.09 # source: https://vrwiki.wikispaces.com/Oculus+Rift+Development+Kit+2
HFOV_RIFT = 95.06 # source: https://vrwiki.wikispaces.com/Oculus+Rift+Development+Kit+2


viz.setMultiSample(4)
viz.fov(60)
viz.go()

viz.MainView.setPosition([2, 1, 2])
viz.MainView.setEuler([227,10,0])

#setting scene
ground = viz.addChild('ground.osgb')
day = viz.add('sky_day.osgb')
day.renderToBackground()

#wheelbarrow object and node detector
wb = viz.addChild('wheelbarrow.ive')

FadeObject.init(wb, 10, 0.01)
FadeObject.beginFading()