def __init__(self,textColor=viz.WHITE,shadowColor=viz.BLACK):
		super(self.__class__, self).__init__()
		
		#--Create info text
		self._info_text = viz.addText3D('Info',pos=[0,15,-5],scale=(1,1,1),parent=self._root,align=viz.ALIGN_CENTER)
		self._info_text.color(textColor)
		self._info_text_shadow = viz.addText3D('Info',parent=self._info_text,align=viz.ALIGN_CENTER)
		self._info_text_shadow.setPosition([0,0,0.2])
		self._info_text_shadow.color(shadowColor)
		self._info_text_shadow.alpha(0.75)
Exemple #2
0
def calibrate ():
	calibration = viz.addText3D('Please take a moment to calibrate the headset',pos = [-10,(float(height)+3),25])
	calibration.color(0,0,0)
	fixation = viz.addText3D('+',pos = [0,(float(height)),10])
	fixation.color(0,0,0)
	calibration.color(0,0,0)
	adjust = viz.addText3D('Adjust the position of the headset on your face and slide',pos = [-12.5,(float(height)-2.45),25])
	adjust.color(0,0,0)
	lever = viz.addText3D('the lever under your right eye until the plus sign is in focus',pos = [-12.5,(float(height)-4),25])
	lever.color(0,0,0)
	yield viztask.waitKeyDown(viz.KEY_KP_ENTER)
	fixation.remove()
	calibration.remove()
	adjust.remove()
	lever.remove()
Exemple #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()
Exemple #4
0
def task ():
	yield calibrate ()
	yield trial_up()
	print 'end trial 1'
	yield trial_down()
	print 'end trial 2'
	yield trial_up()
	print 'end trial 3'
	yield trial_down()
	print 'end trial 4'
	yield trial_up()
	print 'end trial 5'
	yield trial_down()
	print 'end trial 6'
	yield trial_up()
	print 'end trial 7'
	yield trial_down()
	print 'end trial 8'
	yield trial_up()
	print 'end trial 9'
	yield trial_down()
	print 'end trial 10'
	average = mean(times)
	print 'Final Threshold:', average
	end_text = viz.addText3D('Please wait for instructions',pos = [-6,1.7,20])
	end_text.color(0,0,0)
Exemple #5
0
		def writeText():
			text = textBox.get()
			userPosition = viz.MainView.getPosition()
			text3D = viz.addText3D(text, pos = [userPosition[0]-0.2, userPosition[1], userPosition[2] + 0.2])
			text3D.setScale(0.2, 0.2, 0.2)
			text3D.color(viz.RED)
			infoBox.remove()
			noteList.append(text3D)
			globalVariables.windowOpen = False
def addAimer(imageFile='crosshair.png', size=.3, scene=viz.MainScene, incomingColor = viz.WHITE):
#	print 'ADD AIMER CALLED'
	global crosshair
	global crosshairLink
	
#	scene=viz.MainScene

	if vhil_devkit.hmd is not None:
		hud = vhil_devkit.hmd.getHUD()
		
		crosshairPos = [0.0, 0.0, 1.0]
		crosshairScale = 0.05
		crosshair = viz.addText3D("O", pos=crosshairPos, parent=hud)
		crosshairScale = 0.025
		crosshair.setScale(crosshairScale, crosshairScale, crosshairScale)
		crosshair.drawOrder(1000000)
		if incomingColor is viz.GREEN:
			crosshairScale = 0.05
			crosshair.setScale(crosshairScale, crosshairScale, crosshairScale)
			shift = -0.01
			crosshairPos = [shift, shift, 1.0]
			crosshair.setPosition(crosshairPos)
			crosshair.color(incomingColor)
		crosshair.disable(viz.INTERSECTION)
		crosshair.disable(viz.LIGHTING)
		crosshair.disable(viz.DEPTH_TEST)

#		crosshair = viz.addTexQuad(texture=viz.add(imageFile), size=size, scene=scene, parent=hud)
		crosshairLink = viz.link(viz.MainView, crosshair)
		crosshairLink.disable()
#		crosshairLink.preTrans([0,0,4])
#		crosshairLink.preTrans([0,0,1.0])
#		crosshair.disable(viz.INTERSECTION)
#		crosshair.disable(viz.LIGHTING)
#
#		# Appear above other nodes
#		crosshair.drawOrder(100)
#		crosshair.disable(viz.DEPTH_TEST)
		print "HERE"
	else:
		crosshair = viz.addTexQuad(texture=viz.add(imageFile), size=size, scene=scene)
		crosshairLink = viz.link(viz.MainView, crosshair)
		crosshairLink.preTrans([0,0,4])
		crosshair.disable(viz.INTERSECTION)
		crosshair.disable(viz.LIGHTING)

		# Appear above other nodes
		crosshair.drawOrder(100)
		crosshair.disable(viz.DEPTH_TEST)

	return crosshair, crosshairLink
def loadStuff():
	globals_oa.loadScavengerHuntAssetsCalled = True
#	
	globals_oa.basket = vizfx.addChild(EQUIPMENT_DIRECTORY + 'diveBasketslate.osgb')
	#globals_oa.basket = vizfx.addChild(EQUIPMENT_DIRECTORY + 'diveBasket.osgb')
	#globals_oa.basket.setScale([0.75, 0.85, 0.75]) old basket scale, no shelf
	globals_oa.basket.setScale([0.65, 0.75, 0.65])
	globals_oa.basket.billboard(viz.BILLBOARD_YAXIS)
	globals_oa.slate = globals_oa.basket.getChild('Slate_New.OSGB')
#	globals_oa.slate = vizfx.addChild(EQUIPMENT_DIRECTORY + 'Slate_New.osgb')
#	globals_oa.slate.visible(False)
	
	global pics
	pics = []
	pics.append( viz.addTexture('resources/Ocinebrina Edwardsii_Zone' + str(globals_oa.currentZoneNumber) + '.png') )
	pics.append( viz.addTexture('resources/Octopus_2D.png') )
	pics.append( viz.addTexture('resources/Eel_2D.png') )
	pics.append( viz.addTexture('resources/seagrass.jpg') ) # Get picture of seagrass
	
	global time_text
	time_text = viz.addText3D('', pos = [0, 0, 0])
	time_text.visible(False)
	
	global count_text1
	global count_text2
	global count_text3
	global quad1
	global quad2
	global quad3
	
	quad1 = viz.addTexQuad(size = 0.15)
	quad2 = viz.addTexQuad(size = 0.15)
	quad3 = viz.addTexQuad(size = 0.15)
	count_text1 = viz.addText('found: 0')
	count_text2 = viz.addText('found: 0')
	count_text3 = viz.addText('found: 0')
	
#	quad1.disable(viz.LIGHTING)
#	quad2.disable(viz.LIGHTING)
#	quad3.disable(viz.LIGHTING)
	quad1.disable(viz.FOG)
	quad2.disable(viz.FOG)
	quad3.disable(viz.FOG)
	
	hideBasketAndStuffAttachedToIt()
Exemple #8
0
    def titleScreen(self):
        #Commands to setup the title screen
        self.description = viz.addText3D(
            'Make a last stand against an endless alien attack \n\n' +
            'Use the A and D keys or left and right keys to move ship\n\n' +
            'Press the spacebar to fire \n\n' +
            'There are 5 different types of aliens\n\n' +
            'Red: Shoots back at player\n\n' +
            'Blue: Tank takes 3 hits to kill \n\n' +
            'Purple: Has both the Blue and Red alien abilities\n\n' +
            'Orange: Gives players an extra hitpoint when hit\n\n' +
            'Green: Boss alien which will be a challenge to defeat\n\n' +
            'Press enter when you are ready to begin!')

        self.description.font('Comic Sans MS')  #Best font
        self.description.alignment(viz.ALIGN_CENTER)
        mat = viz.Matrix()
        mat.postScale(.05, .05, .05)
        mat.postAxisAngle(1, 0, 0, self.theta)
        mat.postTrans(0, .3, -.1)
        self.description.setMatrix(mat)
Exemple #9
0
    def _setup_stressindicator(self):
        """
		Setup all objects for the stessindicator.
		"""
        # Create a 3D text to display the measured stress
        self._stressindicator_text = viz.addText3D('3D Text', pos=[0, -1, 0])
        self._stressindicator_text.alignment(viz.ALIGN_LEFT_BOTTOM)
        self._stressindicator_text.color(viz.GREEN)
        self._stressindicator_text.setScale([.05, .05, .05])
        # Create a green sphere where the measurement takes place
        self._stressindicator = vizshape.addSphere(radius=0.01,
                                                   color=viz.GREEN)
        self._stressindicator_text.setParent(self._stressindicator)
        self._stressindicator_text.setPosition([0, .1, 0], viz.ABS_PARENT)
        # Create a group to add an offset to the measurement sphere
        tmp = viz.addGroup()
        self._stressindicator.setParent(tmp)
        self._stressindicator.setPosition([0, -.01, .05], viz.ABS_PARENT)
        self._stressindicator.setEuler([0, 90, 0], viz.ABS_PARENT)
        # Connect the stressindicator to the right controller
        viz.link(vizconnect.getRawTracker('r_hand_tracker'), tmp)
        # Hide the objects until the stressindicator gets used
        self._stressindicator.visible(False)
Exemple #10
0
    def gameOver(self, gameWon):
        self.killtimer(0)
        self.killtimer(1)
        self.killtimer(2)

        self.map.remove()
        self.gun.remove()
        self.sky.remove()
        self.skybox.remove()
        viz.mouse(viz.OFF)

        for enemy in self.enemyList:
            enemy.remove()

        for bullet in self.bullets:
            bullet.remove()

        if not gameWon:
            text = viz.addText3D('Game Over \nScore: ' + str(self.score))
            text.color(viz.BLACK)
            text.font('COURIER NEW')
        else:
            text = viz.addText('You Win \nScore: ' + str(self.score))
            text.color(viz.BLACK)
            text.font('COURIER NEW')

        self.gameOverText = text

        mat = viz.Matrix()
        mat.postTrans(0, 0, 0)
        self.camera.setMatrix(mat)
        mat.postTrans(-4, 2, 15)
        self.gameOverText.setMatrix(mat)

        self.killtimer(0)
        self.killtimer(1)
        self.killtimer(2)
def initializeMovementCalculation(participantID):
	global lastUserPosition, lastLeftHandPos, lastRightHandPos, limbDataOutputFilePointer
	lastUserPosition = globals_oa.user.getPosition()
	vizact.ontimer(globals_oa.TIME_INTERVAL_OF_DISTANCE_MEASURED, calculateDistanceTravelledAndHandsMoved)

	hud = globals_oa.rift.getHUD()
	textPos = [0.0, -0.2, 1]
	textScale = 0.05
	globals_oa.hudDistanceTravelled = viz.addText3D("distanceTravelled", pos=textPos, parent=hud)
	globals_oa.hudDistanceTravelled.setScale(textScale, textScale, textScale)
	globals_oa.hudDistanceTravelled.visible(False)
	
	if globals_oa.leftHand is not None:
		lastLeftHandPos = globals_oa.leftHand.getPosition()
		
	if globals_oa.rightHand is not None:
		lastRightHandPos = globals_oa.rightHand.getPosition()

	#open a file for recording distance covered and time taken in each scavenger hunt
#	filename = globals_oa.DATA_DIRECTORY + participantID + '.dat'
	filename = globals_oa.PATH_TO_DATA_DIRECTORY + str(participantID) + '.dat'
	globals_oa.mainOutputFilePointer = None
	#testing if the file already exists
	if os.path.isfile(filename):
		sys.exit('****data file ' + filename + ' already exists, use a different participant ID!****')
#	globals_oa.mainOutputFilePointer = open(filename, 'r')
#	if globals_oa.mainOutputFilePointer is not None: sys.exit('****data file ' + filename + ' already exists, use a different participant ID!****')
	try: globals_oa.mainOutputFilePointer = open(filename, 'w')
	except: sys.exit('****CANNOT OPEN FILE TO RECORD DATA AT ' + filename + ' !****')
	print 'Opened a file to record main data at ' + filename

	filename = globals_oa.PATH_TO_DATA_DIRECTORY + str(participantID) + '_limbData.dat'
	limbDataOutputFilePointer = None
	try: limbDataOutputFilePointer = open(filename, 'w')
	except: sys.exit('****CANNOT OPEN FILE TO RECORD DATA AT ' + filename + ' !****')
	print 'Opened a file to record limb data at ' + filename
def experiment():
    yield participantInfo()
    yield calibrate()
    yield Data()
    yield practice()
    wait_text = viz.addText3D('Please wait for instructions.',
                              pos=[-6, 1.7, 30])
    wait_text.color(0, 0, 0)
    yield viztask.waitKeyDown(viz.KEY_KP_ENTER)
    wait_text.remove()
    exp_text = viz.addText3D('Get ready to start the experiment!',
                             pos=[-6, 1.7, 30])
    exp_text.color(0, 0, 0)
    yield viztask.waitTime(2)
    exp_text.remove()
    yield Block1()
    end_block1 = viz.addText3D(
        'End of the first block of trials. Please wait for instructions.',
        pos=[-12, 1.7, 35])
    end_block1.color(0, 0, 0)
    yield viztask.waitKeyDown(viz.KEY_KP_ENTER)
    end_block1.remove()
    yield viztask.waitTime(1)
    yield view()
    start_block2 = viz.addText3D(
        'Beginning second block of trials. Please wait for instructions.',
        pos=[-12, 1.7, 35])
    start_block2.color(0, 0, 0)
    yield viztask.waitKeyDown(viz.KEY_KP_ENTER)
    start_block2.remove()
    yield viztask.waitTime(1)
    yield Block2()
    end_block2 = viz.addText3D(
        'End of the second block of trials. Please wait for instructions.',
        pos=[-12, 1.7, 35])
    end_block2.color(0, 0, 0)
    yield viztask.waitKeyDown(viz.KEY_KP_ENTER)
    end_block2.remove()
    yield viztask.waitTime(1)
    yield Block3()
    datafile.close()
    end_text = viz.addText3D('Please wait for instructions', pos=[-6, 1.7, 30])
    end_text.color(0, 0, 0)
Exemple #13
0
This script demonstrates how to use keyboard callbacks. 
When a key is pressed, its value will be printed out. 
Also the screen will toggle between black and white. 
"""
import viz
import vizfx
import vizshape
import vizact
import viztask
import time
# viz.go()

# 文字の表示
text3D_G = viz.addText3D('G',
                         pos=[-0.2, 1.76, 2],
                         align=viz.ALIGN_CENTER_BOTTOM,
                         color=viz.WHITE,
                         scale=[0.8, 0.9, 1],
                         font='Times New Roman')
text3D_L = viz.addText3D('L',
                         pos=[0.24, 1.76, 2],
                         align=viz.ALIGN_CENTER_BOTTOM,
                         color=viz.WHITE,
                         scale=[0.8, 0.9, 1],
                         font='Times New Roman')
text3D_GL = viz.addText3D('GEEKLAB',
                          pos=[0.0, 1.48, 2],
                          align=viz.ALIGN_CENTER_BOTTOM,
                          color=viz.WHITE,
                          scale=[0.18, 0.2, 1],
                          font='Times New Roman')
text3D_nagnao = viz.addText3D('NAGANO',
Exemple #14
0
    tracker.setPosition([0, 1.8, 0])
    viz.link(tracker, viz.MainView)
    viz.mouse.setVisible(True)

# grid 表示
grid = vizshape.addGrid()
grid.color(viz.GREEN)
viz.clearcolor(viz.BLACK)

viz.mouse.setTrap(True)  #アプリ内でしか動けなくなる
viz.mouse.setVisible(False)
viz.mouse.setOverride(viz.ON)

text3D = viz.addText3D(u'Press Enter Key',
                       pos=[0, 2.2, 2],
                       align=viz.ALIGN_CENTER_BOTTOM,
                       color=viz.WHITE,
                       scale=[0.1, 0.05, 0.1],
                       font='Times New Roman')
text3D.setEncoding(viz.ENCODING_UTF8)
text3D.add(
    vizact.sequence(vizact.moveTo((0, 2.1, 2), speed=0.03),
                    vizact.moveTo((0, 2.2, 2), speed=0.03), viz.FOREVER))
text3D.setThickness(0.001)


def myTask():
    sound = viz.addAudio('sound/samplerButton.wav')
    sound.play()

    fadeout = vizact.fadeTo(0, time=2)
    yield text3D.addAction(fadeout)
Exemple #15
0
    def __init__(self, config):
        viz.EventClass.__init__(self)
        viz.mouse(viz.ON)
        self.config = config

        # set first person movement controls and hide mouse
        viz.cam.setHandler(vizcam.WalkNavigate(moveScale=2.0, turnScale=2.0))
        viz.mouse.setVisible(viz.OFF)

        # initialize camera and map
        self.camera = viz.MainView
        self.map = viz.add(self.config[0])
        self.camX = self.config[1]
        self.camY = self.config[2]
        self.camZ = self.config[3]
        self.camAngle = self.camera.getAxisAngle()
        self.camVector = [0, 0, 0]
        self.bulletVector = [0, 0, 0]

        # initialize gun
        self.gun = viz.add('gun.dae')

        # track active bullets
        self.bullets = []

        # reload indicator
        self.reload = viz.addText3D('   R\n   to Reload')
        self.reload.color(viz.WHITE)
        self.reload.font('COURIER NEW')
        self.reload.visible(viz.OFF)

        self.gunX = self.config[1]
        self.gunY = self.config[2]
        self.gunZ = self.config[3] + 2
        mat = viz.Matrix()
        mat.postTrans(self.gunX, self.gunY, self.gunZ)
        self.gun.setMatrix(mat)

        # position the camera
        self.setCameraTransforms()

        # add enemies
        enemyCoords = self.config[4]
        self.enemyList = []
        counter = 0
        for x, y, z, radius in enemyCoords:
            self.enemyList.append(viz.add('model.dae'))
            mat = viz.Matrix()
            mat.postScale(0.125, 0.125, 0.125)
            mat.postTrans(x, y, z)
            self.enemyList[counter].setMatrix(mat)
            counter += 1

        # scoring variables
        self.enemyCount = 0
        for enemy in self.enemyList:
            self.enemyCount += 1
        self.score = 0

        # game over variables
        self.gameIsOver = False
        self.gameOverText = None

        # add a sky
        self.sky = viz.add(viz.ENVIRONMENT_MAP, 'sky.jpg')
        self.skybox = viz.add('skydome.dlc')
        self.skybox.texture(self.sky)

        # enable physics
        self.setPhysics()

        self.callback(viz.TIMER_EVENT, self.onTimer)
        self.callback(viz.MOUSEDOWN_EVENT, self.onMouseDown)
        self.callback(viz.COLLIDE_BEGIN_EVENT, self.onCollide)
        self.callback(viz.COLLISION_EVENT, self.camCollide)
        self.callback(viz.KEYDOWN_EVENT, self.onKeyDown)
        self.starttimer(0, 1 / 2, viz.FOREVER)
Exemple #16
0
    def __init__(self):
        viz.mouse(viz.OFF)
        viz.EventClass.__init__(self)

        #Title Screen - disappears after user pushes RETURN
        self.title = viz.addText3D(
            'Michael Ippolito and Christopher McCoy \n' +
            '        Graphics Final Project \n' +
            '        Press Enter to Start')
        self.title.color(viz.BLACK)
        self.title.font('COURIER NEW')

        #Boolean set true after the title disappears
        self.mapSelect = False

        #Map 1: Shipment
        self.shipment = viz.addText3D('Shipment')
        self.shipment.color(viz.BLACK)
        self.shipment.font('COURIER NEW')

        mat = viz.Matrix()
        mat.postTrans(-11, 3, 25)
        self.title.setMatrix(mat)

        self.shipment.setMatrix(mat)
        self.shipment.visible(viz.OFF)

        #Map 2:
        self.factory = viz.addText3D('Factory')
        self.factory.color(viz.BLACK)
        self.factory.font('COURIER NEW')

        mat = viz.Matrix()
        mat.postTrans(0, 3, 25)

        self.factory.setMatrix(mat)
        self.factory.visible(viz.OFF)

        #Instructions
        self.mapText = viz.addText3D(
            'Press Left and Right to select.\nPress enter to start.')
        self.mapText.color(viz.BLACK)
        self.mapText.font('COURIER NEW')

        mat = viz.Matrix()
        mat.postTrans(-11, 5, 25)

        self.mapText.setMatrix(mat)
        self.mapText.visible(viz.OFF)

        self.maps = [self.shipment, self.factory]
        self.curMap = 0

        #Configuration for each map
        #[filename, startX, startY, startZ, [[enemy1x,enemy1y,enemy1z, enemy1radius][...]]]

        self.config = [[
            'shipment.dae', 50, 2.5, 50,
            [[50, 0, 88, 3.5], [39, 0, 71, 2], [72, 0, 110, 1.5],
             [102, 0, 96, 2], [69, 0, 80, 2], [110, 0, 33, 3]]
        ], ['factory.dae', 15, 2.0, 5, [[15, 0, 9, 1]]]]

        self.callback(viz.KEYDOWN_EVENT, self.onKeyDown)
Exemple #17
0
def trial_down ():
	global k
	k = 0
	global x
	x = 0
	for i in range (100):
		yield viztask.waitTime(.5)
		ready_text = viz.addText3D('Get ready!',pos = [-2,1.7,20])	
		ready_text.color(0,0,0)
		yield viztask.waitTime(1)
		ready_text.remove ()
		yield viztask.waitTime(2)	
		yield room ()
		doors = []
		D1 = random.choice([-4.25,-3.25,-2.25,-1.25])
		D2 = random.choice([4.75,5.75,6.75,7.75])
		D3 = random.choice([13.75,14.75,15.75,16.75])
		D4 = random.choice([22.75,23.75,24.75,25.75])
		D5 = random.choice([31.75,32.75,33.75,34.75])
		L_doors = []
		L_doors.append(D1)
		L_doors.append(D2)
		L_doors.append(D3)
		L_doors.append(D4)
		L_doors.append(D5)
		D7 = random.choice([-4.25,-3.25,-2.25,-1.25])
		D8 = random.choice([4.75,5.75,6.75,7.75])
		D9 = random.choice([13.75,14.75,15.75,16.75])
		D10 = random.choice([22.75,23.75,24.75,25.75])
		D11 = random.choice([31.75,32.75,33.75,34.75])
		R_doors = []
		R_doors.append(D7)
		R_doors.append(D8)
		R_doors.append(D9)
		R_doors.append(D10)
		R_doors.append(D11)
		people = []
		P1 = random.choice([9.25,10.25,11.25,12.25,18.25,19.25,20.25,21.25])
		P2 = random.choice([27.25,28.25,29.25,30.25,36.25,37.25,38.25,39.25])
		L_people = []
		L_people.append(P1)
		L_people.append(P2)
		P3 = random.choice([9.25,10.25,11.25,12.25,18.25,19.25,20.25,21.25])
		P4 = random.choice([27.25,28.25,29.25,30.25,36.25,37.25,38.25,39.25])
		R_people = []
		R_people.append(P3)
		R_people.append(P4)
		targ = random.choice(targets)
		if targ == 2.5:
			size = .051006
		if targ == 3.5:
			size = .071409	
		if targ == 4.8:
			size = .097932
		if targ == 6.2:
			size = .126495
		if targ == 7.6:
			size = .155059
		if targ == 9:
			size = .183622
		if targ == 10.4:
			size = .212186
		if targ == 11.8:
			size = .240749
		if targ == 13.2:
			size = .269313
		if targ == 14.6:
			size = .297876
		if targ == 17.4:
			size = .355003
		if targ == 20.2:
			size = .41213
		if targ == 23:
			size = .469257
		if targ == 25.8:
			size = .526384
		if targ == 30:
			size = .612075
		if targ == 38:
			size = .775295
		print targ
		sphere = vizshape.addSphere((size),20,20)
		sphere.color(1.02,.444,0)
		sphere.setPosition([0,(size),(targ)])
		shadow = vizshape.addCircle((size),20)
		shadow.color([.05,.05,.05]) #proportion of 1 for amount of each color (red, green, blue). 0,0,0 = black, 1,1,1 = white.
		shadow.setEuler([0,90,0])
		shadow.setPosition([0,.001,(targ)])
		for z in np.asarray(L_doors):
			door = vizshape.addBox(size=[.04445,2.13,.91])  
			door.texture(wood)
			door.setPosition([-4.9733,1.065,float(z)])
			doors.append(door)
			doorknob = vizshape.addSphere(radius=.045,axis=vizshape.AXIS_X)
			doorknob.color(viz.YELLOW)
			doorknob.setPosition(-4.9396,1,(float(z)-.3364))
			doors.append(doorknob)
		for z in np.asarray(R_doors):
			door = vizshape.addBox(size=[.04445,2.13,.91])  
			door.texture(wood)
			door.setPosition([4.9683,1.065,float(z)])
			doors.append(door)
			doorknob = vizshape.addSphere(radius=.045,axis=vizshape.AXIS_X)
			doorknob.color(viz.YELLOW)
			doorknob.setPosition(4.9396,1,(float(z)-.3364))
			doors.append(doorknob)	
		for z in np.asarray(L_people):
			o = random.choice([0,90,180])
			person = viz.addAvatar('vcc_female.cfg',euler=(float(o),0,0))
			person.setPosition([-4.25,0,float(z)])
			person.state(1)
			people.append(person)
		for z in np.asarray(R_people):
			o = random.choice([0,180,270])
			person = viz.addAvatar('vcc_female.cfg',euler=(float(o),0,0))
			person.setPosition([4.5,0,float(z)])
			person.state(1)
			people.append(person)	
		en_env()
		tic = time.time()
		yield viztask.waitTime(.01) 
		time.sleep(.09+x)
		toc = time.time ()
		mask.enable(viz.RENDERING)
		dis_env()
		sphere.remove ()
		shadow.remove ()
		for door in np.asarray(doors):
			door.remove()
		for person in np.asarray(people):
			person.remove()
		yield viztask.waitTime(1)
		mask.disable(viz.RENDERING)
		print toc - tic
		viz.callback(viz.KEYDOWN_EVENT,KeyEvents)
		yield viztask.waitKeyDown(viz.KEY_KP_ENTER) 
		if k == 1:
			break
	times.append((toc - tic)+.01)		
	print times
Exemple #18
0
    def __init__(self):

        viz.EventClass.__init__(self)

        self.callback(viz.TIMER_EVENT, self.onTimer)
        self.callback(viz.KEYDOWN_EVENT, self.onKeyDown)
        self.callback(viz.MOUSEDOWN_EVENT, self.onClick)
        self.callback(viz.COLLIDE_BEGIN_EVENT, self.onCollide)

        self.x = 0
        self.y = 0
        self.z = 0

        self.scaleValue = 2

        self.roll = 0
        self.pitch = 0
        self.yaw = 0

        self.rotateValue = 3

        self.numLives = 5

        self.t = viz.addText("Lives: " + str(self.numLives),
                             viz.SCREEN,
                             pos=[0, 0.9, 0])
        self.t.font('Times New Roman')
        self.t.fontSize(20)

        self.winText = viz.addText3D(
            "You survived the trench!\n   Press any key to quit",
            viz.SCREEN,
            pos=[0.1, 0.9, 0],
            scene=viz.Scene2)
        self.winText.font('Times New Roman')
        self.winText.color(viz.YELLOW)

        self.loseText = viz.addText3D(
            "   You died horribly!\n Press any key to quit",
            viz.SCREEN,
            pos=[0.15, 0.9, 0],
            scene=viz.Scene3)
        self.loseText.font('Times New Roman')
        self.loseText.color(viz.YELLOW)

        self.sounds = [
            'audio/XWING/XWing-Fly1.wav', 'audio/XWING/XWing-Fly2.wav',
            'audio/XWING/XWing-Fly3.wav', 'audio/XWING/YWing-Fly1.wav',
            'audio/XWING/YWing-Fly2.wav', 'audio/TIE/TIE-Fly1.wav',
            'audio/TIE/TIE-Fly2.wav', 'audio/TIE/TIE-Fly3.wav',
            'audio/TIE/TIE-Fly4.wav', 'audio/TIE/TIE-Fly5.wav',
            'audio/TIE/TIE-Fly6.wav', 'audio/TIE/TIE-Fly7.wav'
        ]

        self.rotmatrix = viz.Matrix()

        self.trench = viz.addGroup()

        space = viz.add(viz.ENVIRONMENT_MAP, 'Skybox/stars.jpg')
        skybox = viz.add('skydome.dlc')
        skybox.texture(space)
        m = viz.Matrix()
        m.postScale(100, 100, 100)
        skybox.setMatrix(m)

        self.model = None

        self.xWing = viz.add('x-wing/x-wing.dae')
        self.tie = viz.add('tie/tie.dae')

        self.destroyer = viz.add('StarDestroyer.dae')
        self.destroyer.setAxisAngle(0, 1, 0, -45)
        self.destroyer.setPosition(-1000, 250, 15000)

        self.destroyer2 = viz.add('StarDestroyer.dae')
        self.destroyer2.setAxisAngle(0, 1, 0, -45)
        self.destroyer2.setPosition(-1000, 500, 17500)

        self.deathStar = viz.add('DeathStar.dae')

        m = viz.Matrix()
        m.postScale(10, 10, 10)
        m.postAxisAngle(0, 1, 0, 100)
        m.postTrans(1000, 3000, 20000)
        self.deathStar.setMatrix(m)
        self.deathStar.collideMesh()
        #self.deathStar.enable(viz.COLLIDE_NOTIFY)

        self.monCal = viz.add('MC80a.dae')
        self.monCal.setAxisAngle(0, 1, 0, 45)
        self.monCal.setPosition(300, 500, 15000)

        self.picking = True
        self.win = False
        self.lose = False

        self.winSong = ''
        self.loseSong = ''
        self.ambient = ''

        self.pickShip()
def Block3():
    datafile.write('\n')
    datafile.write('Block3')
    global dum3
    if dum == 2.5 and dum2 == 3.5:
        dum3 = 38
    if dum == 2.5 and dum2 == 38:
        dum3 = 3.5
    if dum == 3.5 and dum2 == 2.5:
        dum3 = 38
    if dum == 3.5 and dum2 == 38:
        dum3 = 2.5
    if dum == 38 and dum2 == 2.5:
        dum3 = 3.5
    if dum == 38 and dum2 == 3.5:
        dum3 = 2.5
    targets = [
        4.8, 6.2, 7.6, 9, 10.4, 11.8, 13.2, 14.6, 17.4, 20.2, 23, 25.8, 30,
        float(dum3),
        float(dum3)
    ]
    while len(targets) > 0:
        global k
        k = 0
        yield viztask.waitTime(.5)
        ready_text = viz.addText3D('Get ready!', pos=[-2, 1.7, 20])
        ready_text.color(0, 0, 0)
        yield viztask.waitTime(1)
        ready_text.remove()
        yield viztask.waitTime(2)
        yield room()
        doors = []
        D1 = random.choice([-4.25, -3.25, -2.25, -1.25])
        D2 = random.choice([4.75, 5.75, 6.75, 7.75])
        D3 = random.choice([13.75, 14.75, 15.75, 16.75])
        D4 = random.choice([22.75, 23.75, 24.75, 25.75])
        D5 = random.choice([31.75, 32.75, 33.75, 34.75])
        L_doors = []
        L_doors.append(D1)
        L_doors.append(D2)
        L_doors.append(D3)
        L_doors.append(D4)
        L_doors.append(D5)
        D7 = random.choice([-4.25, -3.25, -2.25, -1.25])
        D8 = random.choice([4.75, 5.75, 6.75, 7.75])
        D9 = random.choice([13.75, 14.75, 15.75, 16.75])
        D10 = random.choice([22.75, 23.75, 24.75, 25.75])
        D11 = random.choice([31.75, 32.75, 33.75, 34.75])
        R_doors = []
        R_doors.append(D7)
        R_doors.append(D8)
        R_doors.append(D9)
        R_doors.append(D10)
        R_doors.append(D11)
        people = []
        P1 = random.choice([-3.75, -2.75, -1.75, .75, 1.75, 2.75, 3.75, 5.25])
        P2 = random.choice(
            [9.25, 10.25, 11.25, 12.25, 18.25, 19.25, 20.25, 21.25])
        P3 = random.choice(
            [27.25, 28.25, 29.25, 30.25, 36.25, 37.25, 38.25, 39.25])
        L_people = []
        L_people.append(P1)
        L_people.append(P2)
        L_people.append(P3)
        P4 = random.choice([-3.75, -2.75, -1.75, .75, 1.75, 2.75, 3.75, 5.25])
        P5 = random.choice(
            [9.25, 10.25, 11.25, 12.25, 18.25, 19.25, 20.25, 21.25])
        P6 = random.choice(
            [27.25, 28.25, 29.25, 30.25, 36.25, 37.25, 38.25, 39.25])
        R_people = []
        R_people.append(P4)
        R_people.append(P5)
        R_people.append(P6)
        targ = random.choice(targets)
        if targ == 2.5:
            size = .051006
        if targ == 3.5:
            size = .071409
        if targ == 4.8:
            size = .097932
        if targ == 6.2:
            size = .126495
        if targ == 7.6:
            size = .155059
        if targ == 9:
            size = .183622
        if targ == 10.4:
            size = .212186
        if targ == 11.8:
            size = .240749
        if targ == 13.2:
            size = .269313
        if targ == 14.6:
            size = .297876
        if targ == 17.4:
            size = .355003
        if targ == 20.2:
            size = .41213
        if targ == 23:
            size = .469257
        if targ == 25.8:
            size = .526384
        if targ == 30:
            size = .612075
        if targ == 38:
            size = .775295
        print targ
        datafile.write('\n')
        datafile.write('%f' % (targ))
        sphere = vizshape.addSphere((size), 20, 20)
        sphere.color(1.02, .444, 0)
        sphere.setPosition([0, (size), (targ)])
        shadow = vizshape.addCircle((size), 20)
        shadow.color([.05, .05, .05])
        shadow.setEuler([0, 90, 0])
        shadow.setPosition([0, .001, (targ)])
        for z in np.asarray(L_doors):
            door = vizshape.addBox(size=[.04445, 2.13, .91])
            door.texture(wood)
            door.setPosition([-4.9733, 1.065, float(z)])
            doors.append(door)
            doorknob = vizshape.addSphere(radius=.045, axis=vizshape.AXIS_X)
            doorknob.color(viz.YELLOW)
            doorknob.setPosition(-4.9396, 1, (float(z) - .3364))
            doors.append(doorknob)
        for z in np.asarray(R_doors):
            door = vizshape.addBox(size=[.04445, 2.13, .91])
            door.texture(wood)
            door.setPosition([4.9683, 1.065, float(z)])
            doors.append(door)
            doorknob = vizshape.addSphere(radius=.045, axis=vizshape.AXIS_X)
            doorknob.color(viz.YELLOW)
            doorknob.setPosition(4.9396, 1, (float(z) - .3364))
            doors.append(doorknob)
        for z in np.asarray(L_people):
            object = random.choice([1, 2, 3])
            if object == 1:
                x = random.choice([0, 90, 180])
                person = viz.addAvatar('vcc_female.cfg',
                                       euler=(float(x), 0, 0))
                person.setPosition([-4.25, 0, float(z)])
                person.state(1)
                people.append(person)
            if object == 2:
                x = random.choice([0, 90, 180])
                person = viz.addAvatar('vcc_male.cfg', euler=(float(x), 0, 0))
                person.setPosition([-4.25, 0, float(z)])
                person.state(1)
                people.append(person)
            if object == 3:
                x = random.choice([0, 90, 180])
                person = viz.addAvatar('vcc_male2.cfg', euler=(float(x), 0, 0))
                person.setPosition([-4.25, 0, float(z)])
                person.state(1)
                people.append(person)
        for z in np.asarray(R_people):
            object = random.choice([1, 2, 3])
            if object == 1:
                x = random.choice([0, 180, 270])
                person = viz.addAvatar('vcc_female.cfg',
                                       euler=(float(x), 0, 0))
                person.setPosition([4.5, 0, float(z)])
                person.state(1)
                people.append(person)
            if object == 2:
                x = random.choice([0, 180, 270])
                person = viz.addAvatar('vcc_male.cfg', euler=(float(x), 0, 0))
                person.setPosition([4.5, 0, float(z)])
                person.state(1)
                people.append(person)
            if object == 3:
                x = random.choice([0, 180, 270])
                person = viz.addAvatar('vcc_male2.cfg', euler=(float(x), 0, 0))
                person.setPosition([4.5, 0, float(z)])
                person.state(1)
                people.append(person)
        targets.remove(targ)
        en_env()
        tic = time.time()
        yield viztask.waitTime(5.5)  #Actually is closer to 5 seconds
        toc = time.time()
        mask.enable(viz.RENDERING)
        dis_env()
        sphere.remove()
        shadow.remove()
        for door in np.asarray(doors):
            door.remove()
        for person in np.asarray(people):
            person.remove()
        yield viztask.waitTime(1)
        mask.disable(viz.RENDERING)
        print toc - tic
        datafile.write(' %f' % (toc - tic))
        viz.callback(viz.KEYDOWN_EVENT, KeyEvents)
        yield viztask.waitKeyDown(viz.KEY_KP_ENTER)
        if k == 1:
            targets.append(targ)
            datafile.write(' targ missed')
Exemple #20
0
#get table for experiment
table = viz.addChild( 'table.wrl' )
table.setPosition([9,0.5,15])
table.collideBox( node='Leg1', bounce = 0, friction = 1 )
table.collideBox( node='Leg2', bounce = 0, friction = 1 )
table.collideBox( node='Leg3', bounce = 0, friction = 1 )
table.collideBox( node='Leg4', bounce = 0, friction = 1 )
table.collideBox( node='Top', bounce = 0, friction = 0 )
viz.phys.enable()

#set up UI

import vizinfo
info = vizinfo.InfoPanel('R: ready, Space: start, A: reset',title='setting') 
title = viz.addText3D('Drop  Jump  Simulator',pos=[12.4,3.4,18], euler=[90,0,0])
title.scale([0.58,0.58,0.58])
title.font('Comic Sans MS')
startmenu = viz.addText3D('Please keep surrounding clear.\n\n  Make sure you are standing\n near the center of the platform.\n\n Press R when get ready!',pos=[12.4,2.5,18], euler=[90,0,0])
startmenu.scale([0.4,0.4,0.4])
startmenu.font('Comic Sans MS')
text3D = viz.addText(' Ready',pos=[13.8,1.4,16], euler=[90,0,0])
text3D.font('Calibri')

#set up the Avatar
experimenter = viz.addAvatar('vcc_female.cfg')
head = experimenter.getBone('Bip01 Head')
cameraPoint = experimenter.getBone('Bip01 Spine1')
neck = experimenter.getBone('Bip01 Neck')
global calfR, calfL
calfR = experimenter.getBone('Bip01 R Calf')
Exemple #21
0
        #hmd = oculus.Rift()

        import nvis
        hmd = nvis.nvisorSX111()

        #print "HMD IPD: " + str(hmd.getIPD())
        #print "Mainvtiew IPD: " + str(viz.MainWindow.getIPD())

    viz.window.setFullscreenMonitor([1, 2])
    viz.setMultiSample(4)

    viz.go(viz.FULLSCREEN)
    #Add a world axis with X,Y,Z labels
    world_axes = vizshape.addAxes()
    X = viz.addText3D('X',
                      pos=[1.1, 0, 0],
                      color=viz.RED,
                      scale=[0.3, 0.3, 0.3],
                      parent=world_axes)
    Y = viz.addText3D('Y',
                      pos=[0, 1.1, 0],
                      color=viz.GREEN,
                      scale=[0.3, 0.3, 0.3],
                      align=viz.ALIGN_CENTER_BASE,
                      parent=world_axes)
    Z = viz.addText3D('Z',
                      pos=[0, 0, 1.1],
                      color=viz.BLUE,
                      scale=[0.3, 0.3, 0.3],
                      align=viz.ALIGN_CENTER_BASE,
                      parent=world_axes)
Exemple #22
0
    def addDebugModel(self, node, label, model=None, color=None, size=None):
        """ Add a debug model, axes and label for any node3d object. 
        Debug nodes are shown in UI and displayed/hidden together with 
        the rest of the debug scene. 

        Args:
            node: any Vizard node, group, or sensor object
            label (str): Brief text to identify the node in UI and VR
            model (str): One of:
                - 'sphere', 'cube', 'axes': use a vizshape primitive
                - a valid model file name ('test.osg'): load and use model
            color (3-tuple): RGB color, None for random (ignored for model files)
            size (float): Size of primitive, or scaling factor for model files
        """
        if label in self.nodes.keys():
            raise ValueError('Label already exists - node labels must be unique!')
            return None

        if color is None:
            color = colorsys.hsv_to_rgb(random.uniform(0.0, 1.0), 
                                        random.uniform(0.4, 1.0), 
                                        random.uniform(0.5, 1.0))
        # Add model and label text objects
        if model is not None and os.path.isfile(model):
            if size is None:
                size = 1.0
            _m = viz.addChild(model, parent=node)
            _m.setScale([size,] * 3)

        else:
            if size is None:
                size = 0.05

            if model is None:
                _m = viz.addGroup(parent=node)
                
            elif model == 'sphere':
                _m = vizshape.addSphere(radius=size, color=color, parent=node)
        
            elif model == 'cube':
                _m = vizshape.addCube(size=size, color=color, parent=node)

            elif model == 'axes':
                _m = vizshape.addAxes(length=size, color=color, parent=node)

        _m.disable(viz.INTERSECTION)
        _text = viz.addText3D(str(label), scale=(self.VALUE_SCALE,) * 3,
                              color=color, parent=_m, pos=(size * 1.1, 0.01, 0))
        _text.alignment(alignment=viz.ALIGN_LEFT_CENTER)
        _text.setEuler(0, 45, 0)

        # Add UI section for debug nodes if this is the first one
        if len(self.nodes) == 0:
            self._ui.addSeparator()
            self._ui.addItem(viz.addText('Other Nodes'))

        _ui = viz.addText('N/A')
        lbl = self._ui.addLabelItem(str(label), _ui)
        lbl.label.color(color)
        self._obj.extend([_m, _text])
        _m.visible(self._enable)
        _text.visible(self._enable)

        self.nodes[str(label)] = {'model': _m,
                                  'text': _text,
                                  'ui': _ui}

        print('* Added extra node entry: {:s}'.format(str(label)))
        return _m
Exemple #23
0
    oriMode=oriMode,
)

# Displays are added to vizconnect viewpoints
vp.add(vizconnect.getDisplay())
vp2.add(vizconnect.getDisplay())
vp.setEnabled(viz.ON)

# Call reset viewpoints, which forces the display into the vizconnect viewpoint position.
vizconnect.resetViewpoints()
# add a reset key so when r is pressed the user is moved back to the viewpoint
vizact.onkeydown('r', vizconnect.resetViewpoints)
#crouch key
vizact.onkeydown('c', fc)

inorderprompt = viz.addText3D('It must be done in order', viz.SCREEN)

#made grabbable rbg spheres
sphere1 = vizshape.addSphere(radius=.1)
sphere1.setPosition(10.62, .3, 12)
sphere1.color(1, 0, 0)  #red
sphere1physics = sphere1.collideSphere(bounce=1.5)

sphere2 = vizshape.addSphere(radius=.1)
sphere2.setPosition(9.62, .3, 12)
sphere2.color(0, 1, 0)  #green
sphere2physics = sphere2.collideSphere(bounce=1.5)

sphere3 = vizshape.addSphere(radius=.1)
sphere3.setPosition(8.62, .3, 12)
sphere3.color(0, 0, 1)  #blue
Exemple #24
0
def finished():
    inorderprompt.remove()
    text3D = viz.addText3D('You\'ve beat the game.', viz.SCREEN)
    door.remove()
Exemple #25
0
posR = [0]

sd_Left_temp = []
sd_Right_temp = []

ankleHeightL = 0.125
ankleHeightR = 0.125

successL_count = 0
successR_count = 0
save_successL_count = []
save_successR_count = []

Text_3d = viz.addText3D('',
                        parent=viz.SCREEN,
                        scene=viz.MainScene,
                        fontSize=140,
                        pos=[0.1, .8, 2.5])
Text_3d.color(viz.RED)
Text_3d_right = viz.addText3D('',
                              parent=viz.SCREEN,
                              scene=viz.MainScene,
                              fontSize=140,
                              pos=[0.8, .8, 2.5])
Text_3d_right.color(viz.RED)

##########################################################################################################################################################

# Vizard window set up
viz.setMultiSample(4)
viz.setOption('viz.glFinish', 1)
Exemple #26
0
	def __init__(self,color=viz.CYAN,textColor=viz.WHITE,shadowColor=viz.BLACK):
		super(self.__class__, self).__init__()
		
		# Create front grid
		self._grid_front = vizshape.addGrid(size=(20,10))
		self._grid_front.color(color)
		self._grid_front.setPosition(0,5,-5)
		self._grid_front.setEuler(0,90,0)
		self._grid_front.setParent(self._root)

		# Create back grid
		self._grid_back = vizshape.addGrid(size=(20,10))
		self._grid_back.color(color)
		self._grid_back.setPosition(0,5,-5-24)
		self._grid_back.setEuler(0,90,0)
		self._grid_back.setParent(self._root)

		# Create bottom grid
		self._grid_bottom = vizshape.addGrid(size=(20,24))
		self._grid_bottom.color(color)
		self._grid_bottom.setPosition(0,0,-17)
		self._grid_bottom.setParent(self._root)
		
		# Create left grid
		self._grid_left = vizshape.addGrid(size=(10,24))
		self._grid_left.color(color)
		self._grid_left.setPosition(-10,5,-17)
		self._grid_left.setEuler(0,0,90)
		self._grid_left.setParent(self._root)
		
		# Create right grid
		self._grid_right = vizshape.addGrid(size=(10,24))
		self._grid_right.color(color)
		self._grid_right.setPosition(10,5,-17)
		self._grid_right.setEuler(0,0,-90)
		self._grid_right.setParent(self._root)
		
#		# Floating controls
#		self._controlsQuad = viz.addTexQuad(size=[20,20])
#		controlsPic = viz.addTexture('resources/gui/merged_mapping_truss.png',parent=self._controlsQuad)
#		self._controlsQuad.texture(controlsPic)		
#		self._grid_bottom.setPosition(0,0.1,-30)
#		self._controlsQuad.setEuler(0,90,0)
#		self._controlsQuad.setParent(self._root)
##		self._controlsQuad.disable(viz.LIGHTING)
		
		# Create floating measurements
		self._span_text = viz.addText3D('< 20 meters >',pos=[0,11,-5],scale=[1,1,1],parent=self._root,align=viz.ALIGN_CENTER)
		self._span_text_shadow = viz.addText3D('< 20 meters >',parent=self._span_text,align=viz.ALIGN_CENTER)
		self._span_text_shadow.setPosition([0,0,0.2])
		self._span_text_shadow.color(shadowColor)
		self._span_text_shadow.alpha(0.75)	
		
		self._height_text = viz.addText3D('< 10 meters >',pos=[-11,5,-5],scale=[1,1,1],euler=[0,0,90],parent=self._root,align=viz.ALIGN_CENTER)
		self._height_text_shadow = viz.addText3D('< 10 meters >',parent=self._height_text,align=viz.ALIGN_CENTER)
		self._height_text_shadow.setPosition([0,0,0.2])
		self._height_text_shadow.color(shadowColor)
		self._height_text_shadow.alpha(0.75)	
		
		#--Create orientation info text
		self._orientation_text = viz.addText3D('< View >',pos=[0,14,-5],scale=(2,2,.5),parent=self._root,align=viz.ALIGN_CENTER)
		self._orientation_text.color(textColor)
		self._orientation_text_shadow = viz.addText3D('< View >',parent=self._orientation_text,align=viz.ALIGN_CENTER)
		self._orientation_text_shadow.setPosition([0,0,0.2])
		self._orientation_text_shadow.color(shadowColor)
		self._orientation_text_shadow.alpha(0.75)
		
		self._info_text = viz.addText3D('< Info >',pos=[0,12.25,-5],scale=(.5,.5,.5),parent=self._root,align=viz.ALIGN_CENTER)
		self._info_text.color(textColor)
		self._info_text_shadow = viz.addText3D('< Info >',parent=self._info_text,align=viz.ALIGN_CENTER)
		self._info_text_shadow.setPosition([0,0,0.2])
		self._info_text_shadow.color(shadowColor)
		self._info_text_shadow.alpha(0.75)
Exemple #27
0
    def findDevices(self):
        """ Enumerate SteamVR devices and set up models """

        # HMD
        hmd = steamvr.HMD()
        self.hmd['sensor'] = hmd.getSensor()

        hmd_ui = viz.addText('N/A')
        self._ui.addItem(viz.addText('Headset'))        
        self._ui.addLabelItem('0', hmd_ui)
        self._ui.addSeparator()
        self.hmd['ui'] = hmd_ui

        hud = viz.addText3D('X: 0.00 (123.0°)', scale=(self.VALUE_SCALE * 2.5,) * 3, color=viz.GRAY)
        hud_link = viz.link(viz.MainView, hud)
        hud_link.preTrans(self.HUD_POS, viz.REL_LOCAL)
        self.hmd['hud'] = hud
        self._obj.append(hud)

        # Lighthouses
        for lidx, lighthouse in enumerate(steamvr.getCameraList()):
            lighthouse.model = lighthouse.addModel(parent=self._root)
            if not lighthouse.model:
                lighthouse.model = viz.addGroup()
            lighthouse.model.setCompositeAlpha(self.DEBUG_ALPHA)
            lighthouse.model.disable(viz.INTERSECTION)
            viz.link(lighthouse, lighthouse.model)
            
            l_text = viz.addText3D(str(lidx), scale=(self.LABEL_SCALE,) * 3, color=viz.YELLOW,
                                parent=lighthouse.model, pos=(0.1, 0, 0))
            l_text.setEuler(180, 0, 0)
            
            # Lighthouse normal vector
            l_normal = addRayPrimitive(origin=[0,0,0], direction=[0,0,1], color=viz.YELLOW, parent=lighthouse.model)
            l_normal.visible(False)

            self.lighthouses[lidx] = {'model': lighthouse.model,
                                      'normal': l_normal,
                                      'text': l_text}
            self._obj.append(lighthouse.model)
            print('* Found Lighthouse: {:d}'.format(lidx))

        # Controllers
        if steamvr.getControllerList():
            self._ui.addItem(viz.addText('Controllers'))

            for cidx, controller in enumerate(steamvr.getControllerList()):
                
                controller.model = controller.addModel(parent=self._root)
                if not controller.model:
                    controller.model = viz.addGroup(parent=self._root)
                controller.model.setCompositeAlpha(self.DEBUG_ALPHA)
                controller.model.disable(viz.INTERSECTION)
                viz.link(controller, controller.model)
                
                c_axes = vizshape.addAxes(scale=(0.1, 0.1, 0.1))
                viz.link(controller, c_axes)

                markers = {'axes': c_axes}
                for m in self._markers:
                    markers[m] = self._markers[m].copy()
                    markers[m].visible(False)
                    viz.link(controller, markers[m])

                c_text = viz.addText3D(str(cidx), scale=(self.LABEL_SCALE,) * 3, 
                                    parent=controller.model, pos=(-0.05, 0, 0))
                val_x = viz.addText3D('X: 0.00 (123.0°)', scale=(self.VALUE_SCALE,) * 3, 
                                    parent=controller.model, pos=(-0.18, 0.04, 0), color=viz.RED)
                val_y = viz.addText3D('Y: 0.00 (123.0°)', scale=(self.VALUE_SCALE,) * 3, 
                                    parent=controller.model, pos=(-0.18, 0.02, 0), color=viz.GREEN)
                val_z = viz.addText3D('Z: 0.00 (123.0°)', scale=(self.VALUE_SCALE,) * 3, 
                                    parent=controller.model, pos=(-0.18, 0, 0), color=viz.BLUE)
                
                self.controllers[cidx] = {'model': controller.model,
                                          'axes': c_axes,
                                          'text': c_text,
                                          'values': [val_x, val_y, val_z],
                                          'ui': viz.addText('N/A'),
                                          'markers': markers,
                                          'active_marker': 'axes'}

                self._ui.addLabelItem(str(cidx), self.controllers[cidx]['ui'])
                self._obj.extend([controller.model, c_axes, val_x, val_y, val_z])
                print('* Found Controller: {:d}'.format(cidx))

                self._callbacks.append(vizact.onsensordown(controller, steamvr.BUTTON_TRIGGER, self._storePoint, controller, cidx))
                self._callbacks.append(vizact.onsensordown(controller, steamvr.BUTTON_TRACKPAD, self._switchMarker, cidx))
                self._callbacks.append(vizact.onsensordown(controller, 1, self.savePoints))
                self._callbacks.append(vizact.onsensordown(controller, 0, self.saveScreenshot))
        else:
            print('* No controllers detected.')

        # Trackers
        if steamvr.getTrackerList():
            self._ui.addSeparator()
            self._ui.addItem(viz.addText('Trackers'))

            for tidx, tracker in enumerate(steamvr.getTrackerList()):
                
                tracker.model = tracker.addModel(parent=self._root)
                if not tracker.model:
                    tracker.model = viz.addGroup(parent=self._root)
                tracker.model.setCompositeAlpha(self.DEBUG_ALPHA)
                tracker.model.disable(viz.INTERSECTION)
                viz.link(tracker, tracker.model)

                t_axes = vizshape.addAxes(scale=(0.1, 0.1, 0.1))
                viz.link(tracker, t_axes)

                t_text = viz.addText3D(str(tidx), scale=(0.05, 0.05, 0.05), color=viz.BLUE,
                                    parent=tracker.model, pos=(-0.1, 0, 0))
                val_x = viz.addText3D('X: 0.00 (123.0°)', scale=(self.VALUE_SCALE,) * 3, 
                                    parent=tracker.model, pos=(0.18, 0.04, 0), color=viz.RED)
                val_x.setEuler([180, 0, 0], mode=viz.REL_LOCAL)
                val_y = viz.addText3D('Y: 0.00 (123.0°)', scale=(self.VALUE_SCALE,) * 3, 
                                    parent=tracker.model, pos=(0.18, 0.02, 0), color=viz.GREEN)
                val_y.setEuler([180, 0, 0], mode=viz.REL_LOCAL)
                val_z = viz.addText3D('Z: 0.00 (123.0°)', scale=(self.VALUE_SCALE,) * 3, 
                                    parent=tracker.model, pos=(0.18, 0, 0), color=viz.BLUE)
                val_z.setEuler([180, 0, 0], mode=viz.REL_LOCAL)

                self.trackers[tidx] = {'model': tracker.model,
                                       'axes': t_axes,
                                       'text': t_text,
                                       'values': [val_x, val_y, val_z],
                                       'ui': viz.addText('N/A')}
                self._ui.addLabelItem(str(tidx), self.trackers[tidx]['ui'])
                self._obj.extend([tracker.model, t_axes, val_x, val_y, val_z])
                print('* Found Vive tracker: {:d}'.format(tidx))
        else:
            print('* No trackers detected.')
def practice():
    practice_text = viz.addText3D('Practice trials', pos=[-2.5, 1.7, 20])
    practice_text.color(0, 0, 0)
    yield viztask.waitKeyDown(viz.KEY_KP_ENTER)
    practice_text.remove()
    targets = [5, 12, 24]
    while len(targets) > 0:
        global k
        k = 0
        yield viztask.waitTime(.5)
        ready_text = viz.addText3D('Get ready!', pos=[-2, 1.7, 20])
        ready_text.color(0, 0, 0)
        yield viztask.waitTime(1)
        ready_text.remove()
        yield viztask.waitTime(2)
        yield room()
        doors = []
        D1 = random.choice([-4.25, -3.25, -2.25, -1.25])
        D2 = random.choice([4.75, 5.75, 6.75, 7.75])
        D3 = random.choice([13.75, 14.75, 15.75, 16.75])
        D4 = random.choice([22.75, 23.75, 24.75, 25.75])
        D5 = random.choice([31.75, 32.75, 33.75, 34.75])
        L_doors = []
        L_doors.append(D1)
        L_doors.append(D2)
        L_doors.append(D3)
        L_doors.append(D4)
        L_doors.append(D5)
        D7 = random.choice([-4.25, -3.25, -2.25, -1.25])
        D8 = random.choice([4.75, 5.75, 6.75, 7.75])
        D9 = random.choice([13.75, 14.75, 15.75, 16.75])
        D10 = random.choice([22.75, 23.75, 24.75, 25.75])
        D11 = random.choice([31.75, 32.75, 33.75, 34.75])
        R_doors = []
        R_doors.append(D7)
        R_doors.append(D8)
        R_doors.append(D9)
        R_doors.append(D10)
        R_doors.append(D11)
        people = []
        P1 = random.choice(
            [9.25, 10.25, 11.25, 12.25, 18.25, 19.25, 20.25, 21.25])
        P2 = random.choice(
            [27.25, 28.25, 29.25, 30.25, 36.25, 37.25, 38.25, 39.25])
        L_people = []
        L_people.append(P1)
        L_people.append(P2)
        P3 = random.choice(
            [9.25, 10.25, 11.25, 12.25, 18.25, 19.25, 20.25, 21.25])
        P4 = random.choice(
            [27.25, 28.25, 29.25, 30.25, 36.25, 37.25, 38.25, 39.25])
        R_people = []
        R_people.append(P3)
        R_people.append(P4)
        targ = random.choice(targets)
        if targ == 5:
            size = .102012
        if targ == 12:
            size = .24483
        if targ == 24:
            size = .48966
        sphere = vizshape.addSphere((size), 20, 20)
        sphere.color(1.02, .444, 0)
        sphere.setPosition([0, (size), (targ)])
        shadow = vizshape.addCircle((size), 20)
        shadow.color(
            [.05, .05, .05]
        )  #proportion of 1 for amount of each color (red, green, blue). 0,0,0 = black, 1,1,1 = white.
        shadow.setEuler([0, 90, 0])
        shadow.setPosition([0, .001, (targ)])
        for z in np.asarray(L_doors):
            door = vizshape.addBox(size=[.04445, 2.13, .91])
            door.texture(wood)
            door.setPosition([-4.9733, 1.065, float(z)])
            doors.append(door)
            doorknob = vizshape.addSphere(radius=.045, axis=vizshape.AXIS_X)
            doorknob.color(viz.YELLOW)
            doorknob.setPosition(-4.9396, 1, (float(z) - .3364))
            doors.append(doorknob)
        for z in np.asarray(R_doors):
            door = vizshape.addBox(size=[.04445, 2.13, .91])
            door.texture(wood)
            door.setPosition([4.9683, 1.065, float(z)])
            doors.append(door)
            doorknob = vizshape.addSphere(radius=.045, axis=vizshape.AXIS_X)
            doorknob.color(viz.YELLOW)
            doorknob.setPosition(4.9396, 1, (float(z) - .3364))
            doors.append(doorknob)
        for z in np.asarray(L_people):
            x = random.choice([0, 90, 180])
            person = viz.addAvatar('vcc_female.cfg', euler=(float(x), 0, 0))
            person.setPosition([-4.25, 0, float(z)])
            person.state(1)
            people.append(person)
        for z in np.asarray(R_people):
            x = random.choice([0, 180, 270])
            person = viz.addAvatar('vcc_female.cfg', euler=(float(x), 0, 0))
            person.setPosition([4.5, 0, float(z)])
            person.state(1)
            people.append(person)
        targets.remove(targ)
        en_env()
        tic = time.time()
        yield viztask.waitTime(
            .01
        )  #this is necessary to keep the headset display on for the duration of time.sleep. Can't use time.sleep for any longer than 100 ms or so bc it pauses tracking
        time.sleep(
            .09
        )  #this is necessary to be as precise as possible in the display time. Still not perfect bc of unknown processing time of background functions
        toc = time.time()
        mask.enable(viz.RENDERING)
        dis_env()
        sphere.remove()
        shadow.remove()
        for door in np.asarray(doors):
            door.remove()
        for person in np.asarray(people):
            person.remove()
        yield viztask.waitTime(1)
        mask.disable(viz.RENDERING)
        print toc - tic
        viz.callback(
            viz.KEYDOWN_EVENT, KeyEvents
        )  #press Enter (main keyboard) if the participant misses the target and the target will be appended back into the list.
        yield viztask.waitKeyDown(viz.KEY_KP_ENTER)
        if k == 1:
            targets.append(targ)
    def createTheRoom(self):

        """<START OF DEFINING THE WORLD>"""
        self.setLighting()


        #creates the floor plane to be 35x80
        #rotated around the Z axis(perpendicular to Y axis)
        self.floor = vizshape.addPlane(size=(self.roomWidth, self.roomLength), axis=vizshape.AXIS_Y, cullFace=False)
        #makes the floor look like wood
        self.floor.texture(viz.addTexture('images/tile_wood.jpg'))
        #moves the floor +20 meters in the z direction
        self.floor.setPosition(0,0,0)
        #floor.alpha(0.8)

        #adds a ceiling(plane) that when facing the frontWall is to the camera's topside
        #wall is 35x80 meters**2
        #wall is rotated about the Z axis(perpendicular to Y axis)
        self.ceiling = vizshape.addPlane(size=(self.roomWidth, self.roomLength), axis=-vizshape.AXIS_Y, cullFace=False)
        #makes the ceiling appear Skyblue in color
        self.ceiling.color(viz.CYAN)
        #shifts the ceiling to rest on top of the four walls
        self.ceiling.setPosition(0,self.roomHeight,0)


        #If performance is an issue, set cullFace to True.

        #adds the wall(plane) farthest from the hand/person
        #35x10 meters**2
        #rotated around the X axis (perpendicular to Z axis)
        self.frontWall = vizshape.addPlane(size=(self.roomWidth, self.roomHeight), axis=-vizshape.AXIS_Z, cullFace = False)
        #moves the wall to match the edge of the 
        self.frontWall.setPosition(0,self.roomHeight/2,self.roomLength/2)
        #makes the wall appear white
        self.frontWall.color([0.6,0.6,0.6])
        self.wall_text_object = viz.addText3D( 'PerForM Lab',parent=self.frontWall,pos=[-3,1,-0.2])

        #adds a wall(plane) that when facing the frontWall is to the camera's back
        #wall is 35x10 meters**2
        #wall is rotated about the X axis(perpendicular to Z axis)
        self.backWall = vizshape.addPlane(size=(self.roomWidth, self.roomHeight), axis=vizshape.AXIS_Z, cullFace = False)
        #shifts the wall to match the edge of the floor
        self.backWall.setPosition(0,self.roomHeight/2,-self.roomLength/2)
        #makes the wall appear white
        self.backWall.color(viz.WHITE)

        #adds the wall(plane) that when facing the frontWall, is to the camera's left
        #wall is 80x10 meters**2
        #wall is rotated about the Y axis(perpendicular to X axis)
        self.leftWall = vizshape.addPlane(size=(self.roomLength, self.roomHeight), axis=-vizshape.AXIS_X, cullFace = False)
        #shifts the wall to match the edge of the floor
        self.leftWall.setPosition(self.roomWidth/2,self.roomHeight/2,0)
        #makes the wall appear white
        self.leftWall.color(viz.GRAY)

        #adds a wall(plane) that when facing the frontWall is to the camera's right
        #wall is 80x10 meters**2
        #wall is rotated about the Y axis(perpendicular to X axis)
        self.rightWall = vizshape.addPlane(size=(self.roomLength, self.roomHeight), axis=vizshape.AXIS_X, cullFace = False)
        #shifts the wall to match the edge of the floor
        self.rightWall.setPosition(-self.roomWidth/2,self.roomHeight/2,0)
        #makes the wall appear white
        self.rightWall.color(viz.GRAY)


        #add a meter marker at 0 meters along the z axis of the room
        #meter0 = vizshape.addPlane(size = (5,.3), axis = vizshape.AXIS_Y, cullFace = False)
        #meter0.setPosition(0,.3, 0)
        #makes the meter marker appear yellow
        #meter0.color(viz.WHITE)

        #adds a wall(plane) that when facing the frontWall is to the camera's back
        #wall is 35x10 meters**2
        #wall is rotated about the X axis(perpendicular to Z axis)
        self.ballPlane = vizshape.addPlane(size=(2,2), axis=vizshape.AXIS_Z, cullFace = False)
        #shifts the wall to match the edge of the floor
        self.ballPlane.setPosition(0,5,-20)
        #makes the wall appear white
        self.ballPlane.color(viz.WHITE)
        self.ballPlane.alpha(0.0)
        self.text_object = viz.addText3D( '',parent=self.ballPlane,pos=[-0.4,0.6,0])
        self.text_object.setScale(0.2,0.2,0.2)


        """</END OF DEFINING THE WORLD>"""
	def __init__(self,use_keyboard = True, desktop_mode = False):
		"""Initialization function."""
		
		caveapp.CaveApplication.__init__(self,desktop_mode) #call constructor of super class, you have to do this explicitly in Python		
		viz.phys.enable()
		
		self.view = viz.MainView;
		
		self.backGroundMusic = viz.addAudio('Windmill hut.wav')
		self.backGroundMusic.volume(0.5)
		self.backGroundMusic.loop(viz.ON)
		self.backGroundMusic.play()
		self.gameMusic = viz.addAudio('Battle.wav')
		self.gameMusic.volume(0.7)
		
		headLight = viz.MainView.getHeadLight()
		headLight.intensity(100)
		headLight.disable()
		
		for i in range(3):
			light = viz.addLight()
			light.setPosition(0, 2, (i*10))
			light.position(0,0,0,1)
				
		self.use_keyboard = use_keyboard #store if we want to use the keyboard
		self.scaleValue = 0.03
		
		self.shootingRange = viz.addChild('ShootingRange.FBX')
		self.shootingRange.setScale(self.scaleValue, self.scaleValue,self.scaleValue )
		self.shootingRange.name = 'shootingRange'
		self.shootingRange.collideMesh()
		self.shootingRange.disable(viz.DYNAMICS)		
		
		self.target = viz.addChild('target.FBX')
		self.target.name = 'target'
		self.target.setScale(0.9, 0.9, 0.9)
		self.target.collideBox(density = 100)
		self.target.enable(viz.COLLIDE_NOTIFY)
		self.target.setPosition(0,0, 15)
				
		self.enemyGun = viz.addChild('Gun.FBX')
		self.enemyGun.name = 'enemyGun'
		self.enemyGun.setScale(self.scaleValue, self.scaleValue, self.scaleValue)
		self.enemyGun.setPosition(0, 1.8, 14)
		self.enemyGun.setEuler(180,0,0)						
				
		self.bullet = viz.add('Bullet.FBX')
		self.bullet.setPosition(0,1,2)
		self.bullet.setScale(self.scaleValue, self.scaleValue,self.scaleValue)
		self.bullet.name = 'bullet'
		self.bullet.collideCapsule(0.2, 0.1, density = 1, hardness = 1)
		self.bullet.enable(viz.COLLIDE_NOTIFY)
		self.nextShot = True
		
		self.enemyBullet = viz.add('Bullet.FBX')
		self.enemyBullet.setPosition(0,1,10)
		self.enemyBullet.setScale(0.05, 0.05, 0.05)
		self.enemyBullet.name = 'enemyBullet'
		
		self.enemyShot = False
		
		self.enemyShootTimer = vizact.ontimer(3, self.repositionEnemyGun)
		self.moveEnemyBulletTimer = vizact.ontimer(0, self.moveEnemyBullet)
		
		self.moveEnemyBulletTimer.setEnabled(False)
		self.enemyShootTimer.setEnabled(False)
		
		self.shootTimer = vizact.ontimer(1, self.schootClick)
		self.shootTimer.setEnabled(False)	
		
		self.rings = ['Ring10', 'Ring20', 'Ring30', 'Ring40', 'Ring50'] 
									
		self.currentScore = 0		
		self.scoreBaseText = 'Score: '
		self.firstLabelText = self.scoreBaseText + str(self.currentScore)
		self.scoreLabel = viz.addText3D(self.firstLabelText)
		self.scoreLabel.setBackdrop(viz.BACKDROP_RIGHT_BOTTOM)
		self.scoreLabel.setPosition(-1.7, 1, 0)
		self.scoreLabel.setEuler(-90,0,0)
		self.scoreLabel.color(viz.SKYBLUE)
		self.scoreLabel.setScale(0.3, 0.3, 0.3)
		self.scoreLabel.alignment(viz.ALIGN_CENTER_BOTTOM)
		
		self.currentHighScore = 0		
		self.highScoreBaseText = 'Highscore: '
		self.firstHighScoreLabelText = self.highScoreBaseText + str(self.currentHighScore)
		self.highScoreLabel = viz.addText3D(self.firstHighScoreLabelText)
		self.highScoreLabel.setPosition(-1.7, 1.5, 0)
		self.highScoreLabel.setEuler(-90,0,0)
		self.highScoreLabel.color(viz.BLUE)
		self.highScoreLabel.setScale(0.3, 0.3, 0.3)
		self.highScoreLabel.alignment(viz.ALIGN_CENTER_BOTTOM)
		
		self.newPointLabel = viz.addText3D('')
		self.newPointLabel.color(viz.GREEN)
		self.newPointLabel.setPosition(self.target.getPosition()[0], self.target.getPosition()[1] + 2, self.target.getPosition()[2])
		self.newPointLabel.alignment(viz.ALIGN_CENTER_BOTTOM)
		self.maxTimeNewPointVisible = 1
		
		self.newHitLabel = viz.addText3D('')
		self.newHitLabel.color(viz.RED)
		self.newHitLabel.setPosition(self.target.getPosition()[0], self.target.getPosition()[1] + 2.5, self.target.getPosition()[2])
		self.newHitLabel.alignment(viz.ALIGN_CENTER_BOTTOM)
		self.maxTimeHitVisible = 1
		
		self.newPointTimer = vizact.ontimer(self.maxTimeNewPointVisible, self.makeNewPointLabelInvisible)
		self.newPointTimer.setEnabled(False)	
		
		self.newHitPointTimer = vizact.ontimer(self.maxTimeHitVisible, self.makeNewHitLabelInvisible)
		self.newHitPointTimer.setEnabled(False)	
									
		self.goodSound = viz.addAudio('good.mp3')
		self.coinSound = viz.addAudio('coin.wav')	
		self.hitSound = viz.addAudio('hit.mp3')
			
		self.playTimer = vizact.ontimer(1, self.timerClick)
		self.playTimer.setEnabled(False)
		self.playTime = 35		
		self.currentTime = 0
		self.isPlaying = False
		
		self.timeBaseText = 'Time: '
		self.timeLabel = viz.addText3D(self.timeBaseText)
		self.timeLabel.setPosition(1.1, 1.3, 3)
		self.timeLabel.setEuler(50,0,0)
		self.timeLabel.setScale(0.3, 0.3, 0.3)
		self.timeLabel.alignment(viz.ALIGN_CENTER_BOTTOM)
		self.timeLabel.visible(False)
				
		self.scope = viz.addChild('Scope.FBX')
		
		viz.startLayer(viz.LINES)
		viz.vertexColor(viz.RED)
		viz.vertex(-0.2, 0,0)
		viz.vertex(0.2, 0, 0)
		self.topLine = viz.endLayer()
		
		viz.startLayer(viz.LINES)
		viz.vertexColor(viz.RED)
		viz.vertex(0, 0,0)
		viz.vertex(0, -0.3, 0)
		self.leftLine = viz.endLayer()
		
		viz.startLayer(viz.LINES)
		viz.vertexColor(viz.RED)
		viz.vertex(0, 0,0)
		viz.vertex(0, -0.3, 0)
		self.rightLine = viz.endLayer()
		
		self.time = 0.0 
Exemple #31
0
def InitalSetup(train):
    #        t1 = viz.add('Assets/Textures/black.png')
    #        wall1 = vizshape.addCube() # Setup black room for start and fade transition
    #        wall1.setScale([10,5,0.2])
    #        wall1.setPosition(0,1,10)
    #        wall1.texture(t1)
    #
    #        wall2 = vizshape.addCube()
    #        wall2.setScale([10,5,0.2])
    #        wall2.setPosition(0,1,20)
    #        wall2.texture(t1)
    #
    #        wall3 = vizshape.addCube()
    #        wall3.setScale([0.2,5,10])
    #        wall3.setPosition(5,1,15)
    #        wall3.texture(t1)
    #
    #        wall4 = vizshape.addCube()
    #        wall4.setScale([0.2,5,10])
    #        wall4.setPosition(-5,1,15)
    #        wall4.texture(t1)
    #
    #        wall5 = vizshape.addCube()
    #        wall5.setScale([10,0.2,10])
    #        wall5.setPosition(0,2.5,15)
    #        wall5.texture(t1)
    #
    #        wall6 = vizshape.addCube()
    #        wall6.setScale([10,1.0,10])
    #        wall6.setPosition(0,1.0,15)
    #        wall6.texture(t1)

    text3D = viz.addText3D('Press Space to begin', pos=[
        0, 0.5, 20
    ])  # Create text & position infront of player at a readable distance
    text3D.alignment(viz.ALIGN_CENTER_BOTTOM)
    text3D.setScale(1, 1, 1)
    text3D.setEuler(0, 0, 0)
    text3D.setReferenceFrame(viz.RF_EYE)
    text3D.disable(
        [viz.LIGHTING, viz.INTERSECTION, viz.DEPTH_TEST, viz.SHADOW_CASTING])
    text3D.drawOrder(101)

    global spacePressed
    global playerOnTrain

    if (SetupHMD.hmdconnected):
        SetupHMD.SetRotation(0)
        SetupHMD.SetPos([0, 0, 15])
    else:
        viz.MainView.setPosition([0, 1, 11])

    while (spacePressed is not True):
        yield viztask.waitFrame(1)

    if (SetupHMD.hmdconnected):
        SetupHMD.SetRotation(180)
        trainPos = train.getPosition()
        trainPos[1] += 1.5
        trainPos[2] += 1.6
        SetupHMD.SetPos(trainPos)
    else:
        pos = train.getPosition(viz.ABS_GLOBAL)
        pos[0] += 0.3  # Along Seat
        pos[1] = 1.7  # Eye Height
        pos[2] += 1.3  # Depth
        viz.MainView.setPosition(pos)
        viz.MainView.setEuler(180, 0, 0)

    yield viztask.waitTime(0.1)
    text3D.remove()
    spacePressed = False
    playerOnTrain = True

    viztask.schedule(StationReached())
#    print 'Movable position',movable.getPosition(),'\n'
#vizact.ontimer(5, printData)
## Setup tracking if this is the main script
#if __name__ == "__main__":
#	import viztracker
#	viztracker.DEFAULT_HANDS = True
#	viztracker.go()

#so far so good

viz.setMultiSample(4)
viz.fov(60)
viz.go()
#Add a world axis with X,Y,Z labels
world_axes = vizshape.addAxes()
X = viz.addText3D('X',pos=[1.1,0,0],color=viz.RED,scale=[0.3,0.3,0.3],parent=world_axes)
Y = viz.addText3D('Y',pos=[0,1.1,0],color=viz.GREEN,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
Z = viz.addText3D('Z',pos=[0,0,1.1],color=viz.BLUE,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
#grids are good
grid = vizshape.addGrid(color=[0.2]*3)
viz.clearcolor(viz.GRAY)

#Create proximity manager
manager = vizproximity.Manager()
manager.setDebug(viz.ON)



#create our bisecting plane
mid_plane= vizshape.addPlane(size=(.00001,.00001),axis=vizshape.AXIS_X, cullFace=False)
Exemple #33
0
                alpha=(0))
mario_bgm = viz.addAudio('sound/スーパーマリオブラザーズ 地上BGM.wav', viz.LOOP, volume=0.1)

# ギーラボの紹介プレゼン、画像の用意
movieImages = viz.cycle([
    viz.addTexture('resource/introduction/glnagano%d.jpeg' % i)
    for i in range(1, 39)
])
screen = viz.addTexQuad()
screen.setPosition([0, 2.67, 6.33])
screen.setScale([0.789 * 3.01, 0.62 * 2.19, 1])

# ギークラボ長野へようこそ
text3D = viz.addText3D('welcome to geeklab NAGANO',
                       pos=[0, 2.3, 2],
                       align=viz.ALIGN_CENTER_BOTTOM,
                       color=viz.YELLOW,
                       scale=[0.1, 0.05, 0.1],
                       font='Comic Sans MS')

text3D.add(
    vizact.sequence(vizact.moveTo((0, 2.0, 2), speed=0.1),
                    vizact.moveTo((0, 2.3, 2), speed=0.1), viz.FOREVER))

# 取得元のURL http://dova-s.jp/bgm/play3394.html
sound = viz.addAudio('sound/基地出撃5分前.mp3', viz.LOOP, volume=0.1)
sound.volume(.1)
sound.play()


# ギークラボ長野紹介プレゼン資料表示
def NextMovieFrame():