def displayInputPanel(): global inputPanel, names inputPanel = viz.addGUIGroup() # endG = viz.addGroup(viz.SCREEN) splashScreen = viz.addTexQuad(parent=viz.SCREEN,pos=[0.5,0.5,0],scale=[13,10.5,1]) splashScreen.texture(viz.addTexture('textures/splash_screen'+LANG+'.jpg')) splashScreen.setParent(inputPanel) names = [] pl = range(condition%2*2+1) pl.reverse() for i,p in enumerate(pl): name = viz.addTextbox() nameText = {'':'Player %s name:', 'GR':'Όνομα παίκτη %s:'} title = viz.addText(nameText[LANG]%str(i+1), viz.SCREEN) title.fontSize(24) title.addParent(inputPanel) title.setPosition([.4, .53+.1*p, 0]) name.setPosition([.5, .5+.1*p, 0]) name.addParent(inputPanel) names.append(name) startB = viz.addButtonLabel('START') startB.setPosition(.5,.4) startB.addParent(inputPanel) vizact.onbuttonup(startB, initialize)
def __init__(self, fig): self.canvasData = viz.Data(lock = threading.Lock(), havenewData=False ) self.fig = fig self.t = threading.Thread(target=self.computeFigureThread) self.t.start() #IMPORTANT: Wait for thread to finish before exiting vizact.onexit(self.t.join) #Create a blank texture to display canvas data self.tex = viz.addBlankTexture([1,1]) #Create onscreen quad to display texture self.quad = viz.addTexQuad(parent=viz.ORTHO,texture=self.tex) self.quad.alpha(0.5) self.link = viz.link(viz.MainWindow.CenterCenter,self.quad) # self.link.setOffset([400,200,0]) self.drawer = vizact.ontimer(0, self.drawPlot) self.rate_ctr = time.time() self.drawrate_txt = viz.addText('', viz.SCREEN) self.drawrate_txt.setPosition(0,0.01) self.drawrate_txt.scale(.7,.7) self.drawrate_txt.color(viz.WHITE) self.drawrate_txt.visible(0) self.rate = 0 #scale variables to change size of plot image self.scale_x = 1 self.scale_y = 1
def play_bounce_vid(video_position, video_name, video_length): """ Plays a video at a given position in the 3D world for an indicated length. Example: bounceVid = viz.add('testPNGtoRAW_multi.avi',loop=0,play=0) bounceVid.setRate(myRate) self.collisionPoint = [iSectX,iSectY,iSectZ] viztask.schedule(play_bounce_vid(self.collisionPoint, bounceVid)) Args: video_position: [x, y, z] position where the video should be displayed in the world video_name: name of the video file to play (.avi works, others not tested) video_length: duration of the video to play """ video_position[2] = video_position[2] - .05 quad = viz.addTexQuad(texture=video_name, pos=video_position) # quad.zoffset(-15) video_name.play() yield viztask.waitTime(video_length) quad.remove()
def onKeyDown(self,key): if key == '1': self.avatar.stopAction(1) self.avatar.state(0) elif key == "2": self.avatar.state(1) elif key == "3": mySound = viz.addAudio( 'mazin.mp3' ) mySound.loop( viz.ON ) mySound.play() #self.avatar.execute(1) #opening video test #title text self.textScreen = viz.addText('Mazinger Animation Demo',viz.SCREEN) #self.textScreen.alignment(viz.ALIGN_CENTER_BOTTOM) self.textScreen.setScale([1,1,1]) #self.textScreen.setPosition([0,10,0]) self.starttimer(2,1,22) self.object = viz.addTexQuad(size=2) video = viz.addVideo('open.avi') video.setRate(1) video.volume(0) video.play() #fixing video position self.object.texture(video) self.object.setAxisAngle( [0, 1, 0 , 180] ) self.object.setPosition([0,10,18]) #self.avatar.setAnimationSpeed(1, .5) #run at half speed elif key == "4": viz.MainView.setPosition([0,10,20]) viz.lookAt([0,10,0]) self.starttimer(1,1,8) self.avatar.execute(2)
def load(sceneRef=viz.MainScene): global SCENE, ENABLE_LANDSCAPE, car, call_screen SCENE = sceneRef car = vizfx.addChild("Car_Final.OSGB", scene=SCENE) car.scale([CAR_SCALE,CAR_SCALE,CAR_SCALE]) pic = viz.addTexture('resources/images/phone_screen_mail.jpg', scene = SCENE) call_screen = viz.addTexQuad(scene = SCENE) call_screen.setPosition(.075,.8,-2.4) call_screen.setEuler(-180,22,0) call_screen.setScale(.06,.06,.06) call_screen.texture(pic) PosessionHunting.load(car, SCENE) head = viz.MainView.getHeadLight() head.disable() light.addDirectionalLights(CAR_SCALE, SCENE) light.addFog(SCENE) addSphericalLandscape(ENABLE_LANDSCAPE, SCENE) # vizact.onkeydown('b',police.addSirens,SCENE) # vizact.onkeydown('l',police.moveFlashlightToCar,SCENE,POLICE_WALK_TIME) global dc dc = DataCollector(filePrefix='Data/CarSceneTracking_Participant', fileSuffix='.csv') dc.addMainviewTracker() dc.startCollecting()
def ShowErrorOnMap(self, machine, mPos, flag): if flag == 0: #remove error if there is one for this machine if self._alerts.has_key(machine): self._alerts[machine].remove() del self._alerts[machine] del self._messages[machine] else: #add or update the alert icon in every other case #aPos = self._window.worldToScreen(mPos) #newAlert = viz.addTexQuad(parent=viz.ORTHO, scene=self._window, size=50, pos=aPos) #add new alert if there is NOT one already for this machine alertSymbols = {1:'a', 2:'w'} if not self._alerts.has_key(machine): self.SOUNDS['alert'].play() newAlert = viz.addTexQuad(size=1.25) newAlert.texture(self._alertIcons[alertSymbols[flag]]) newAlert.renderOnlyToWindows([self._window]) newAlert.setPosition(mPos[0], 0, mPos[2]) newAlert.setEuler(0, 90, 0) self._alerts[machine] = newAlert else: #update the machine error if an alert if already defined self._alerts[machine].texture(self._alertIcons[alertSymbols[flag]]) #show or hide the alert panel depending on the current alerts self._alertPanel.setPanelVisible(len(self._alerts)>0) if len(self._alerts) == 0: self._alertPanel.setIconTexture(self._alertIcons['a'])
def placeMirror(): mirrorPos = [0, 1.5, -2]; global wall, mirrorRight, mirrorLeft, mirrorPlane wall = viz.addTexQuad() wall.setPosition(0, 0, mirrorPos[2] - 0.02) wall.setScale(20, 20, 1) # Apply nice repeating brick texture wallmatrix = vizmat.Transform() wallmatrix.setScale(20, 20, 1) wall.texmat( wallmatrix ) bricks = viz.addTexture('brick.jpg') bricks.wrap(viz.WRAP_T, viz.REPEAT) bricks.wrap(viz.WRAP_S, viz.REPEAT) wall.texture(bricks) mirrorPlane = vizshape.addPlane() mirrorPlane.setPosition(mirrorPos, viz.ABS_GLOBAL) mirrorPlane.setEuler(0, 90, 0) mirrorPlane.setScale(0.09, 1, 0.05) windowBox = mirrorPlane.getBoundingBox(mode = viz.ABS_GLOBAL) x0 = windowBox.xmin x1 = windowBox.xmax y0 = windowBox.ymin y1 = windowBox.ymax z = windowBox.zmax viz.startlayer(viz.QUADS) viz.texcoord(0,0) viz.vertex( x0 , y0 , z ) viz.texcoord(0,1) viz.vertex( x0 , y1, z ) viz.texcoord(1,1) viz.vertex( x1 , y1, z) viz.texcoord(1,0) viz.vertex( x1 , y0 , z) mirrorRight = viz.endlayer( ) mirrorLeft = mirrorRight.copy() #specify the matrix m = viz.Matrix() #Try moving the mirror #print "z: " + str(z); m.setPosition([0, 0, z]) m.setEuler(0, 0, 0) #Apply mirror settings to mirror object mirrorPlane.alpha(0.0) addMirror(mirrorRight,m,viz.RIGHT_EYE) addMirror(mirrorLeft,m,viz.LEFT_EYE) # Add collision mirrorPlane.collideBox() wall.visible(viz.OFF) mirrorRight.visible(viz.OFF) mirrorLeft.visible(viz.OFF)
def __init__(self, fig): self.canvasData = viz.Data(lock=threading.Lock(), havenewData=False) self.fig = fig self.t = threading.Thread(target=self.computeFigureThread) self.t.start() #IMPORTANT: Wait for thread to finish before exiting vizact.onexit(self.t.join) #Create a blank texture to display canvas data self.tex = viz.addBlankTexture([1, 1]) #Create onscreen quad to display texture self.quad = viz.addTexQuad(parent=viz.ORTHO, texture=self.tex) self.quad.alpha(0.5) self.link = viz.link(viz.MainWindow.CenterCenter, self.quad) # self.link.setOffset([400,200,0]) self.drawer = vizact.ontimer(0, self.drawPlot) self.rate_ctr = time.time() self.drawrate_txt = viz.addText('', viz.SCREEN) self.drawrate_txt.setPosition(0, 0.01) self.drawrate_txt.scale(.7, .7) self.drawrate_txt.color(viz.WHITE) self.drawrate_txt.visible(0) self.rate = 0 #scale variables to change size of plot image self.scale_x = 1 self.scale_y = 1
def Pau(): #Menu principal global current_scene current_scene = 4 bgTexture = viz.add(image['pau']) quad_bgtexture = viz.addTexQuad(parent=viz.SCREEN, scene=scenePau) quad_bgtexture.texture(bgTexture) quad_bgtexture.setScale(12.8, 10.24, 0) quad_bgtexture.setPosition(0.5, 0.5) viz.scene(scenePau) #Botones de interaccion btn_atras = viz.addButton(scene=scenePau) btn_atras.setPosition(0.60, 0.05) btn_atras.setScale(7, 1.6) btn_atras.downpicture(button['regresar']) btn_atras.uppicture(button['regresar']) #Botones de interaccion btn_sig = viz.addButton(scene=scenePau) btn_sig.setPosition(0.87, 0.05) btn_sig.setScale(7, 1.6) btn_sig.downpicture(button['portada_A']) btn_sig.uppicture(button['portada_A']) vizact.onbuttonup(btn_atras, Conant) vizact.onbuttonup(btn_sig, Diego)
def Instruction(objName, ITI, phase, feedback): viz.MainWindow.setScene(2) if phase: if feedback > 0: smile = viz.add('smile' + str(feedback) + '.tif') feed = viz.addTexQuad(parent=viz.SCREEN, scene=2, size=[500, 400]) feed.setPosition([0.5, 0.5, 0]) #put quad in view feed.texture(smile) yield viztask.waitTime(ITI - 1) feed.visible(0) Message = 'Collect ' + objName else: Message = 'Replace ' + objName #info info = viz.addText(Message, viz.SCREEN, scene=2) info.fontSize(36) info.color(viz.WHITE) info.setPosition([0.4, 0.5, 0]) info.visible(1) #wait for iti yield viztask.waitTime(ITI + 1) info.visible(0)
def setStage(): """Creates grass textured groundplane""" ###should set this hope so it builds new tiles if you are reaching the boundary. fName = 'C:/VENLAB data/shared_modules/textures/strong_edge.bmp' #fName = 'strong_edge.bmp' # add groundplane (wrap mode) groundtexture = viz.addTexture(fName) groundtexture.wrap(viz.WRAP_T, viz.REPEAT) groundtexture.wrap(viz.WRAP_S, viz.REPEAT) groundtexture.anisotropy(16) groundplane = viz.addTexQuad() ##ground for right bends (tight) tilesize = 500 #planesize = tilesize/5 planesize = 40 groundplane.setScale(tilesize, tilesize, tilesize) groundplane.setEuler((0, 90, 0), viz.REL_LOCAL) #groundplane.setPosition((0,0,1000),viz.REL_LOCAL) #move forward 1km so don't need to render as much. matrix = vizmat.Transform() matrix.setScale(planesize, planesize, planesize) groundplane.texmat(matrix) groundplane.texture(groundtexture) groundplane.visible(1) viz.clearcolor(viz.SKYBLUE) return groundplane
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()
def loadTexQuads(num): if num == 2: globals_oa.CANVAS_QUAD = viz.addTexQuad(size=globals_oa.promptQuadSize, scene=viz.Scene2) else: globals_oa.CANVAS_QUAD = viz.addTexQuad(size=globals_oa.promptQuadSize) globals_oa.CANVAS_QUAD.drawOrder(10000) globals_oa.CANVAS_QUAD.disable(viz.DEPTH_TEST) globals_oa.CANVAS_QUAD.setPosition(globals_oa.promptQuadPos) globals_oa.CANVAS_QUAD_1_TEXTURE = viz.addTexture('resources/card_species.jpg') globals_oa.CANVAS_QUAD_1_TEXTURE.hint(viz.PRELOAD_HINT) globals_oa.CANVAS_QUAD_2_TEXTURE = viz.addTexture('resources/card_pickup.jpg') globals_oa.CANVAS_QUAD_2_TEXTURE.hint(viz.PRELOAD_HINT) globals_oa.CANVAS_QUAD_3_TEXTURE = viz.addTexture('resources/divebasketslate.jpg') globals_oa.CANVAS_QUAD_3_TEXTURE.hint(viz.PRELOAD_HINT) globals_oa.MOVIE_INSTRUCTION_QUAD = viz.addVideo('resources/swim_card.MOV') #globals_oa.MOVIE_INSTRUCTION_QUAD.hint(viz.PRELOAD_HINT) globals_oa.CANVAS_QUAD.disable(viz.FOG) globals_oa.CANVAS_QUAD.visible(False)
def AddMap (self): self.flmap=viz.add('models/floor_map2.IVE') # self.flmap.texture(viz.addTexture('textures/map_view.png'),'',0) self.flmap.setPosition(0, .01, 0) #self.flmap.setScale(1, 1, 1.1) self.flmap.renderOnlyToWindows([self._window]) self.bg = viz.addTexQuad(parent=viz.ORTHO, scene=self._window) self.CreateInfoPanels() self.CreateScorePanel()
def init_settings(mainSceneWindow, cameraWindow, cameraWindowView, cam, pause_screen, nunchuck_disconnect_screen, message_screen, wiimote, nunchuck_wiimote, should_it_run): viz.MainWindow.visible(viz.OFF) #Hago invisible la main window viz.setMultiSample(8) # FSAA de 8 viz.fogcolor = viz.BLACK # Color de sombra = negro viz.fog(0.15) # Agrega sombra de tipo exponencial viz.collision(viz.ON) # Habilita colisiones en el mundo viz.phys.enable() # Habilita la fisica #Desabilita mouse viz.mouse.setOverride(viz.ON) #Mouse invisible viz.mouse.setVisible(viz.OFF) #Subventana que renderea viz.MainWindow mainSceneWindow = viz.addWindow() mainSceneWindow.setSize(0.7,1) mainSceneWindow.setPosition(0,1) mainSceneWindow.fov(40, 1.3) # Coloca el FOV de la ventana principal en la actual con los valores de default (40 grados verticales, 1.3 aspect ratio) #Creando una ventana y un punto de vista para la camara cameraWindow = viz.addWindow(pos =[.7,1],size=(0.4,1)) #Creando la ventana cameraWindowView = viz.addView() #Creando un viewpoint cameraWindowView.setScene(2) #Poniendo la nueva ventana en la escena 2 cameraWindow.setView(cameraWindowView) #Ligando el viewpoint con la nueva ventana #Vincular camara web a plugin de AR cam = ar.addWebCamera(window=cameraWindow) #Agregando una camara en la ventada nueva # Configuracion de mensajes de la pantalla message_screen = viz.addTexQuad(parent=viz.SCREEN, pos=[0.5,0.5,1], scale=[12.80,10.24,1]) pause_screen = viz.add("PAUSA.png") nunchuck_disconnect_screen = viz.add("NUNCHUCK_DISCONNECTED.png") message_screen.texture(pause_screen) message_screen.visible(viz.OFF) #Cuando should_it_run sea False, viz.ON es el valor a usar. # Conecta al primer wiimote disponible wiimote = wii.addWiimote() # Prende el LED 1 del wiimote wiimote.led = wii.LED_1 # Obten el nunchuck del wiimote nunchuck_wiimote = wiimote.nunchuk #Determines wheter the program should run or not. #It will run if the Nunchuck is connected; otherwise, it won't. should_it_run = True #Ensures that the program won't run without the NUNCHUCK plug'd in. if(wiimote.getExtension() == wii.EXT_NUNCHUK): should_it_run = True else: print "Please plug-in the Wii NUNCHUCK." message_screen.texture(nunchuck_disconnect_screen) message_screen.visible(viz.ON) should_it_run = False return mainSceneWindow, cameraWindow, cameraWindowView, cam, pause_screen, nunchuck_disconnect_screen, message_screen, wiimote, nunchuck_wiimote, should_it_run
def setStage(TILING=True): global ndots, tilesize fName = 'textures\\black.jpg' gtexture = viz.addTexture(fName) gtexture.wrap(viz.WRAP_T, viz.REPEAT) gtexture.wrap(viz.WRAP_S, viz.REPEAT) # #add groundplane (wrap mode) ###UNCOMMENT FOR TILING # Tiling saves memory by using two groundplane tiles instead of a massive groundplane. Since the drivers are essentially driving linearly forward, they cover a lot of distance across the z axis. gplane1 = viz.addTexQuad() ## tilesize = 2000 texture_z_size = tilesize * 2 planesize = tilesize / 5.0 gplane1.setScale(tilesize, tilesize * 2, tilesize) gplane1.setEuler((0, 90, 0), viz.REL_LOCAL) matrix = vizmat.Transform() matrix.setScale(planesize, planesize * 2, planesize) gplane1.texmat(matrix) gplane1.texture(gtexture) gplane1.visible(1) # if TILING: fName2 = 'textures\\black.jpg' gtexture2 = viz.addTexture(fName2) gtexture2.wrap(viz.WRAP_T, viz.REPEAT) gtexture2.wrap(viz.WRAP_S, viz.REPEAT) gplane2 = gplane1.copy() #create duplicate. gplane2.setScale(tilesize, tilesize * 2, tilesize) gplane2.setEuler((0, 90, 0), viz.REL_LOCAL) gplane2.setPosition( (0, 0, 1000), viz.REL_LOCAL) #move forward 1km so don't need to render as much. gplane2.texmat(matrix) gplane2.texture(gtexture2) gplane2.visible(1) gplane2.setPosition(0, 0, tilesize * 2) gplane2.zoffset(-1) else: gplane2 = [] # viz.startlayer(viz.POINTS) # viz.vertexColor(viz.WHITE) # viz.pointSize(2) # for i in range (0,trial_dots): # x = (random.random() - .5) * tilesize # z = (random.random() - .5) * tilesize # viz.vertex([x,0,z]) # dots = viz.endLayer() # dots.setPosition(0,0,0) # dots.visible(1) return (gplane1, gplane2, texture_z_size)
def setStage(TILING=True): """Creates grass textured groundplane""" global gtexture # background color viz.clearcolor(viz.SKYBLUE) #CODE UP TILE-WORK WITH GROUNDPLANE. ##should set this up so it builds new tiles if you are reaching the boundary. #fName = 'textures\\strong_edge_redoutline.bmp' fName = 'textures\\strong_edge.bmp' gtexture = viz.addTexture(fName) gtexture.wrap(viz.WRAP_T, viz.REPEAT) gtexture.wrap(viz.WRAP_S, viz.REPEAT) # #add groundplane (wrap mode) ###UNCOMMENT FOR TILING # Tiling saves memory by using two groundplane tiles instead of a massive groundplane. Since the drivers are essentially driving linearly forward, they cover a lot of distance across the z axis. gplane1 = viz.addTexQuad() ## tilesize = 3000 texture_z_size = tilesize * 2 #planesize = tilesize/5 planesize = tilesize / 5.0 gplane1.setScale(tilesize, tilesize * 2, tilesize) gplane1.setEuler((0, 90, 0), viz.REL_LOCAL) #groundplane.setPosition((0,0,1000),viz.REL_LOCAL) #move forward 1km so don't need to render as much (was originally commented out) matrix = vizmat.Transform() matrix.setScale(planesize, planesize * 2, planesize) gplane1.texmat(matrix) #gplane1.texture(gtexture) gplane1.texture(gtexture) gplane1.visible(1) # if TILING: # fName2 = 'textures\\strong_edge_blueoutline.bmp' #fName2 = 'textures\\strong_edge_blueoutline.bmp' fName2 = 'textures\\strong_edge.bmp' gtexture2 = viz.addTexture(fName2) gtexture2.wrap(viz.WRAP_T, viz.REPEAT) gtexture2.wrap(viz.WRAP_S, viz.REPEAT) gplane2 = gplane1.copy() #create duplicate. gplane2.setScale(tilesize, tilesize * 2, tilesize) gplane2.setEuler((0, 90, 0), viz.REL_LOCAL) #groundplane.setPosition((0,0,1000),viz.REL_LOCAL) #move forward 1km so don't need to render as much. gplane2.texmat(matrix) #gplane1.texture(gtexture) gplane2.texture(gtexture2) gplane2.visible(1) gplane2.setPosition(0, 0, tilesize * 2) gplane2.zoffset(-1) else: gplane2 = [] return (gplane1, gplane2, texture_z_size)
def nextRoundAnimation(): global nextRoundPlaque, nextRoundSound if nextRoundPlaque is None: nextRoundPlaque = viz.addTexQuad() nextRoundPlaque.texture(viz.addTexture('./Resources/Misc/confetti.jpg')) nextRoundSound = nextRoundPlaque.playsound('./Resources/Misc/partyHorn.wav', viz.STOP, volume=0.1) nextRoundPlaque.setPosition(NRP_POS) nextRoundPlaque.setEuler(180, 0, 0) nextRoundPlaque.visible(viz.OFF) nextRoundSound.play() viztask.schedule(_plaqueAni)
def CreateScorePanel(self): self._newScore = None #holds the temp score after each update self._scorePanel = vizdlg.GridPanel(window=self._window, skin=vizdlg.ModernSkin, spacing=-10, align=vizdlg.ALIGN_RIGHT_TOP, margin=0) row1text = viz.addText(self.tooltips['points']) row1text.font("Segoe UI") self._scoreIcon = viz.addTexQuad(size=25, texture=viz.add('textures/star_yellow_256.png')) self._score= viz.addText('000') self._score.font("Segoe UI") self._score.alignment(viz.ALIGN_RIGHT_BASE) self._scorePanel.addRow([self._scoreIcon, row1text, self._score]) row2text = viz.addText(self.tooltips['oil']) row2text.font("Segoe UI") self._oilIcon = viz.addTexQuad(size=25, texture=viz.add('textures/oil_icon.png')) self._oil= viz.addText('000') self._oil.font("Segoe UI") self._oil.alignment(viz.ALIGN_RIGHT_BASE) self._scorePanel.addRow([self._oilIcon, row2text, self._oil]) self._scorePanel.setCellAlignment(vizdlg.ALIGN_RIGHT_TOP) #place the score board at the top right corner of the window viz.link(self._window.RightTop, self._scorePanel, offset=(-10,-45,0))
def ShowTotalScore (self): #add third row with the total score if not added already try: self._total.alignment(viz.ALIGN_RIGHT_BASE) except: row3text = viz.addText(self.tooltips['score']) row3text.font("Segoe UI") row3icon = viz.addTexQuad(size=25, texture=viz.add('textures/total_icon.png')) self._total= viz.addText('000') self._total.font("Segoe UI") self._total.alignment(viz.ALIGN_RIGHT_BASE) self._scorePanel.addRow([row3icon, row3text, self._total])
def __init__(self, factory, pos): self.object = factory.add('models/boiler.ive') self.hatch = (self.object.insertGroupBelow('HatchDoorL'), self.object.insertGroupBelow('HatchDoorR')) self.gauge = self.object.insertGroupBelow('velona') fire = viz.add('textures/fire.mov', loop=1, play=1) self.fire = viz.addTexQuad(texture=fire, pos=[.15,1.2,0], size=1.2, alpha=0) self.fire.setParent(self.object) self.fire.visible(0) self.object.setPosition(pos) self.getComponents() #this is called by the AddProximitySensors() of the main module self.proximityData = (vizproximity.RectangleArea([5,5]), self.object)
def show(self): """Turns on the grid, destroys any prior grid, and writes the current grid to file.""" if not self.previousMatrix: self.previousMatrix = viz.MainView.getMatrix() self.state = viz.ON viz.MainView.reset(viz.HEAD_POS | viz.HEAD_ORI) if (self.grid): self.grid.remove() self.grid = viz.addGroup() m = viz.MainWindow.getMatrix() horizOffset = math.tan(self.centerHorizAngle)*self.distance + self.offset[0] vertOffset = math.tan(self.centerVertAngle)*self.distance + self.offset[1] horizDelta = math.tan(self.horizAngle) * self.distance + self.dx vertDelta = math.tan(self.vertAngle) * self.distance + self.dy topLeftPos = [horizOffset - horizDelta * (self.numCols -1) / 2, vertOffset - vertDelta * (self.numRows - 1) / 2, self.distance] self.pos = [[[0, 0, 0]] * self.numRows for k in range(self.numCols)] self.pos_screen_left = [[[0, 0, 0]] * self.numRows for k in range(self.numCols)] self.pos_screen_right = [[[0, 0, 0]] * self.numRows for k in range(self.numCols)] for i in range(0, self.numCols): for j in range(0, self.numRows): #print i,j self.pos[i][j] = [topLeftPos[0] + i * horizDelta, topLeftPos[1] + j * vertDelta, self.distance] pt = viz.MainWindow.worldToScreen(self.pos[i][j], eye=viz.LEFT_EYE) pt[2] = 0 self.pos_screen_left[i][j] = pt #print pt pt = viz.MainWindow.worldToScreen(self.pos[i][j], eye=viz.RIGHT_EYE) pt[2] = 0 self.pos_screen_right[i][j] = pt q = viz.addTexQuad(parent=self.grid) q.texture(self.cross_tex) q.setScale(self.stimScale, self.stimScale, 1) q.setPosition(self.pos[i][j]) q.billboard() #Makes always visible to viewer #print self.pos self.writeoutSettings() self.writeCustomCalPoints()
def AddPanel(self, langu): self._hud = viz.addGroup(viz.ORTHO, scene=self._window) panel = viz.addTexQuad(parent=viz.ORTHO, scene=self._window, size=200) panel.texture(viz.addTexture('textures/panel.png', useCache = True)) panel.setParent(self._hud) self.tag = viz.addTexQuad(parent=viz.ORTHO, scene=self._window, size=200) self.tag.texture(viz.addTexture('textures/p'+str(self._player)+'_tag.png', useCache = True)) self.tag.setParent(self._hud) #add the player name as a child of the panel self._name = viz.addText(self._name, panel) self._name.alignment(viz.ALIGN_CENTER_TOP) self._name.font("Segoe UI") self._name.color(viz.BLACK) self._name.fontSize(14) self._name.resolution(.5) self._name.setScale(1.5,.75,1) self._name.setPosition(3,92,0) self._name.setParent(self._hud) #add the user feedback message self._message = viz.addText('', viz.ORTHO, self._window) self._message.alignment(viz.ALIGN_LEFT_TOP) self._message.font("Segoe UI") self._message.color(viz.BLACK) self._message.fontSize(13) self._message.resolution(.5) self._message.setScale(1.5,.75,1) self._message.setPosition(-80,32,0) self._message.setParent(self._hud) #add the collab icon self._collabTextures = [viz.add('textures/signs'+langu+'/collab0.png'), viz.add('textures/signs'+langu+'/collab1.png')] self._collabIcon = viz.addTexQuad(parent=viz.ORTHO, scene=self._window, size=150) self._collabIcon.texture(self._collabTextures[0]) self._collabIcon.setParent(self._hud) self._collabIcon.drawOrder(20) self._collabIcon.setPosition(0, -65, 10) self._collabIcon.setScale(1,.4,1) self._collabIcon.alpha(0) self.ResizePanel() #add the info panels self.CreateInfoPanels()
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 __init__(self, IDsToSelect, mouse=False, scene=viz.Scene1, audio="Audio/ChaChingSound.wav"): self.scene = scene viz.MainWindow.setScene(scene) self.selectables = IDsToSelect self.crosshair = viz.addTexQuad( viz.ORTHO, texture=viz.add("crosshair.png"), size=64 ) # TODO: Does this work for Rift? crosshairLink = viz.link(viz.CenterCenter, self.crosshair) self.foundObj = None self.fadetime = 1 self.delay = 1.5 self.timer = vizact.ontimer(0.1, self.sellObject) self.mouse = mouse self.audio = audio self.disable()
def AddToToolbox (self, tool): if len(self._toolbox) < 4: if tool == 'mat' and 'mat' in self._toolbox: self._feedback = 'oneOnly' return False obj = viz.addTexQuad(parent=viz.ORTHO, scene=self._window, size=75) obj.setParent(self._hud) obj.setPosition(-60+len(self._toolbox)*45, 60, 0) obj.setScale(1,.4,1) tool = self._factory.FilterAddedTool(tool) # adds 'ful' for 'can' if full textur = viz.addTexture('textures/tool_'+tool+'.png', useCache=True) textur_sel = viz.addTexture('textures/tool_'+tool+'_sel.png', useCache=True) obj.texture(textur) self._toolbox[tool] = {'obj': obj, 'tex': textur, 'sel': textur_sel} return True else: self._feedback = 'inventory' self.DisplayLocalMessage('inventory')
def __init__(self, physEnv, dimensions, axisAngle, position, texPath, texScale, planeABCD): # A wall object invludes a specialized node3D # This node3D is actually a texQuad ################################################################################################ ################################################################################################ ## Set variables self.dimensions = dimensions self.axisAngle = axisAngle self.position = position self.texPath = texPath self.texScale = texScale ################################################################################################ ################################################################################################ ## Create node3D: a texture quad self.node3D = viz.addTexQuad() self.node3D.setScale(dimensions[0], dimensions[1]) self.node3D.setPosition(position) self.node3D.setAxisAngle(axisAngle) self.node3D.disable(viz.DYNAMICS) self.node3D.enable([viz.LIGHTING, viz.CULL_FACE]) # Put texture on the quad matrix = vizmat.Transform() matrix.setScale( [dimensions[0] / texScale, dimensions[1] / texScale, texScale]) self.node3D.texmat(matrix) self.texObj = viz.addTexture(texPath) self.texObj.wrap(viz.WRAP_T, viz.REPEAT) self.texObj.wrap(viz.WRAP_S, viz.REPEAT) self.node3D.texture(self.texObj) ################################################################################################ ################################################################################################ ## Create physNode plane self.physNode = physEnv.makePhysNode('plane', planeABCD)
def Controls(): #Menu principal global current_scene current_scene = 1 bgTexture = viz.add(image['controles']) quad_bgtexture = viz.addTexQuad(parent=viz.SCREEN, scene=sceneControls) quad_bgtexture.texture(bgTexture) quad_bgtexture.setScale(12.8, 10.24, 0) quad_bgtexture.setPosition(0.5, 0.5) viz.scene(sceneControls) #Botones de interaccion btn_atras = viz.addButton(scene=sceneControls) btn_atras.setPosition(0.85, 0.05) btn_atras.setScale(7, 1.6) btn_atras.downpicture(button['regresar']) btn_atras.uppicture(button['regresar']) vizact.onbuttonup(btn_atras, MainMenu)
def __init__(self,physEnv,dimensions,axisAngle,position,texPath,texScale,planeABCD): # A wall object invludes a specialized visNode # This visNode is actually a texQuad ################################################################################################ ################################################################################################ ## Set variables self.dimensions = dimensions; self.axisAngle = axisAngle; self.position = position; self.texPath = texPath; self.texScale = texScale; ################################################################################################ ################################################################################################ ## Create visNode: a texture quad self.visNode = viz.addTexQuad() self.visNode.setScale(dimensions[0],dimensions[1]) self.visNode.setPosition(position) self.visNode.setAxisAngle(axisAngle) self.visNode.disable(viz.DYNAMICS) self.visNode.enable([viz.LIGHTING,viz.CULL_FACE]) # Put texture on the quad matrix = vizmat.Transform() matrix.setScale([dimensions[0]/texScale,dimensions[1]/texScale,texScale]) self.visNode.texmat(matrix) self.texObj = viz.addTexture(texPath) self.texObj.wrap(viz.WRAP_T, viz.REPEAT) self.texObj.wrap(viz.WRAP_S, viz.REPEAT) self.visNode.texture(self.texObj) ################################################################################################ ################################################################################################ ## Create physNode plane self.physNode = physEnv.makePhysNode('plane',planeABCD)
def build_env(): spaceSize = SIZE half = SIZE / 2 borders = [viz.addTexQuad(size=spaceSize) for x in range(6)] borders[0].setPosition([half, 0, 0]) borders[1].setPosition([-half, 0, 0]) borders[2].setPosition([0, half, 0]) borders[3].setPosition([0, -half, 0]) borders[4].setPosition([0, 0, half]) borders[5].setPosition([0, 0, -half]) borders[0].setAxisAngle([0, 1, 0, -90]) borders[1].setAxisAngle([0, 1, 0, 90]) borders[2].setAxisAngle([1, 0, 0, 90]) borders[3].setAxisAngle([1, 0, 0, -90]) borders[4].setAxisAngle([0, 0, 0, 90]) borders[5].setAxisAngle([0, 0, 0, -90]) grid = viz.addTexture('grid.png') roof = viz.addTexture('roof.png') floor = viz.addTexture('floor.png') wall = viz.addTexture('wall.png') for t in [grid, floor, roof, wall]: t.wrap(viz.WRAP_S, viz.REPEAT) t.wrap(viz.WRAP_T, viz.REPEAT) matrix = vizmat.Transform() scale = matrix.getScale() scale[0] = scale[1] = SIZE matrix.setScale(scale) def setTex(b, t): b.texture(t, '', 0) b.texmat(matrix, '', 0) #print(b.getAxisAngle()) setTex(borders[0], wall) setTex(borders[1], wall) setTex(borders[4], wall) setTex(borders[5], wall) setTex(borders[2], roof) setTex(borders[3], floor)
def __init__(self, physenv, dimensions, axis_angle, position, texture_path, texture_scale, plane_abcd): # A wall object invludes a specialized visNode # This visNode is actually a texQuad ################################################################################################ ################################################################################################ # Set variables self.dimensions = dimensions self.axis_angle = axis_angle self.position = position self.texture_path = texture_path self.texture_scale = texture_scale ################################################################################################ ################################################################################################ # Create visNode: a texture quad self.vis_node = viz.addTexQuad() self.vis_node.setScale(dimensions[0], dimensions[1]) self.vis_node.setPosition(position) self.vis_node.setAxisAngle(axis_angle) self.vis_node.disable(viz.DYNAMICS) self.vis_node.enable([viz.LIGHTING, viz.CULL_FACE]) # Put texture on the quad matrix = vizmat.Transform() matrix.setScale([dimensions[0] / texture_scale, dimensions[1] / texture_scale, texture_scale]) self.vis_node.texmat(matrix) self.texture_object = viz.addTexture(texture_path) self.texture_object.wrap(viz.WRAP_T, viz.REPEAT) self.texture_object.wrap(viz.WRAP_S, viz.REPEAT) self.vis_node.texture(self.texture_object) ################################################################################################ ################################################################################################ # Create physNode plane self.phys_node = physenv.makePhysNode('plane', plane_abcd)
def setStage(): global groundplane, groundtexture fName = 'textures\strong_edge.bmp' # add groundplane (wrap mode) groundtexture = viz.addTexture(fName) groundtexture.wrap(viz.WRAP_T, viz.REPEAT) groundtexture.wrap(viz.WRAP_S, viz.REPEAT) groundplane = viz.addTexQuad() ##ground for right bends (tight) tilesize = 300 planesize = tilesize/5 groundplane.setScale(tilesize, tilesize, tilesize) groundplane.setEuler((0, 90, 0),viz.REL_LOCAL) matrix = vizmat.Transform() matrix.setScale( planesize, planesize, planesize ) groundplane.texmat( matrix ) groundplane.texture(groundtexture) groundplane.visible(1)
def addGroundPlane(): """adds a scene""" fName = 'C:/VENLAB data/shared_modules/textures/strong_edge.bmp' # add groundplane (wrap mode) groundtexture = viz.addTexture(fName) groundtexture.wrap(viz.WRAP_T, viz.REPEAT) groundtexture.wrap(viz.WRAP_S, viz.REPEAT) groundplane = viz.addTexQuad() ##ground for right bends (tight) tilesize = 300 planesize = tilesize / 5 groundplane.setScale(tilesize, tilesize, tilesize) groundplane.setEuler((0, 90, 0), viz.REL_LOCAL) matrix = vizmat.Transform() matrix.setScale(planesize, planesize, planesize) groundplane.texmat(matrix) groundplane.texture(groundtexture) groundplane.visible(1) viz.clearcolor(viz.SKYBLUE)
def __init__ (self, view, color, eyeH): self._view = view # self._player_matrix = viz.Matrix() #self.view.getMatrix() self._avatar = Robot.Steve() self._avatar.disable([viz.INTERSECTION, viz.PICKING], op=viz.OP_ROOT) self._avatar.head.setScale([1.5,1.5,1.5]) self._avatar.body_root.setScale([1.5,1.5,1.5]) #self._avatar.disable(viz.PHYSICS) bodyColor = [float(c)/255 for c in color[0]] shadeColor= [float(c)/255 for c in color[1]] self._avatar.setBodyColor(bodyColor) self._avatar.setShadeColor(shadeColor) # self._avatar.setTracker(self._player_matrix) self._avatar.setTracker(viz.link(self._view, viz.NullLinkable,offset=[0,-0.25,0])) self._view.collision(viz.ON) self._view.eyeheight(eyeH) # add the representation on the map self._mapAva = viz.addTexQuad(size=.75) #self._mapAva = vizshape.addSphere(.5,10,10) self._mapAva.texture(viz.addTexture('textures/mapAva_icon.png'),'',0) self._mapAva.color(bodyColor) self._updateFunc = vizact.onupdate(0, self.UpdatePlayer)
def setStage(): global groundplane, groundtexture ###should set this hope so it builds new tiles if you are reaching the boundary. fName = 'textures\strong_edge.bmp' # add groundplane (wrap mode) groundtexture = viz.addTexture(fName) groundtexture.wrap(viz.WRAP_T, viz.REPEAT) groundtexture.wrap(viz.WRAP_S, viz.REPEAT) groundplane = viz.addTexQuad() ##ground for right bends (tight) tilesize = 5000 #300 #F***ING MASSIVE planesize = tilesize / 5 groundplane.setScale(tilesize, tilesize, tilesize) groundplane.setEuler((0, 90, 0), viz.REL_LOCAL) #groundplane.setPosition((0,0,1000),viz.REL_LOCAL) #move forward 1km so don't need to render as much. matrix = vizmat.Transform() matrix.setScale(planesize, planesize, planesize) groundplane.texmat(matrix) groundplane.texture(groundtexture) groundplane.visible(1)
def Instruction(objName,ITI,endMessage): viz.MainWindow.setScene(4) if endMessage!=1: collectMessage = 'Replace ' + objName #info info = viz.addText(collectMessage,viz.SCREEN,scene=4) info.fontSize(36) info.color(viz.WHITE) info.setPosition([0.4,0.5,0]) info.visible(1) #wait for iti yield viztask.waitTime(ITI) yield viztask.waitTime(numpy.random.randint(4)) #add random jitter, eventually add a wait for t here as well info.visible(0) else: error = objName threshold = [3,5,7,9] if error < threshold[0]: feedback = 1 elif error > threshold[0] and error < threshold[1]: feedback = 2 elif error > threshold[1] and error < threshold[2]: feedback = 3 elif error > threshold[2] and error < threshold[3]: feedback = 4 elif error > threshold[3]: feedback = 5 smile = viz.add('smile' + str(feedback) + '.tif') feed = viz.addTexQuad(parent=viz.SCREEN,scene=4,size=[500,400]) feed.setPosition([0.5, 0.5, 0]) #put quad in view feed.texture(smile) yield viztask.waitTime(ITI+2) viz.quit()
def MainMenu(): #Menu principal global current_scene current_scene = 0 isActive[6] = True bgTexture = viz.add(image['portada']) quad_bgtexture = viz.addTexQuad(parent=viz.SCREEN, scene=viz.Scene6) quad_bgtexture.texture(bgTexture) quad_bgtexture.setScale(12.8, 10.24, 0) quad_bgtexture.setPosition(0.5, 0.5) viz.scene(viz.Scene6) #Botones de interaccion btn_juego = viz.addButton(scene=viz.Scene6) btn_juego.setPosition(0.75, 0.50) btn_juego.setScale(8, 2.3) btn_juego.downpicture(button['portada_A']) btn_juego.uppicture(button['portada_A']) #Botones de interaccion btn_controles = viz.addButton(scene=viz.Scene6) btn_controles.setPosition(0.75, 0.35) btn_controles.setScale(8, 2.3) btn_controles.downpicture(button['portada_B']) btn_controles.uppicture(button['portada_B']) #Botones de interaccion btn_creditos = viz.addButton(scene=viz.Scene6) btn_creditos.setPosition(0.75, 0.20) btn_creditos.setScale(8, 2.3) btn_creditos.downpicture(button['portada_C']) btn_creditos.uppicture(button['portada_C']) vizact.onbuttonup(btn_juego, accionbuttonNewGame) vizact.onbuttonup(btn_controles, Controls) vizact.onbuttonup(btn_creditos, Daniel)
incorrect_sound = viz.addAudio("images/beep-3.wav") # Text for feedback block_text = viz.addText("",parent=viz.SCREEN) block_text.setPosition(0.5,0.8) block_text.alignment(viz.ALIGN_CENTER_CENTER) block_text.font("times.ttf") MESSAGE_TIME = 1 # ---------- Configure so responses are mapped to cross components -- HBAR_RESPONSE = viztask.waitEvent(LEFT_BUTTON_EVENT,all=True) VBAR_RESPONSE = viztask.waitEvent(RIGHT_BUTTON_EVENT,all=True) # ------------------------------------------------------------------- #Add quad to screen quad = viz.addTexQuad( viz.SCREEN , pos=(0.5,0.5,0) , scale=(5,5,5) ) #quad.texture(cross) def training_display(rt,acc): print "acc",acc if acc: msg = "RIGHT" correct_sound.play() else: msg = "WRONG" incorrect_sound.play() block_text.message(msg + " %.2fs"%rt) vizact.ontimer2(rate=MESSAGE_TIME, repeats=0,func=clear_text) def success_display(rt): #block_text.message("Success") #vizact.ontimer2(rate=MESSAGE_TIME, repeats=0,func=clear_text)
import viz video = viz.add('VideoCamera.dle') #cam_r = video.addWebcam() cam_l= video.addWebcam(id = 0) quad = viz.addTexQuad(pos = (0,1.8,1), texture = cam_l) quad.setEuler([0,0,-90]) #quad1 = viz.addTexQuad(pos = (-5,1.8,1), texture = cam_l) #fr = cam.getData() #fr = cam.getFrameRate() #print(fr) viz.go()
import viz import vizact viz.go() viz.clearcolor(viz.SLATE) #Create a quad to display texture quad = viz.addTexQuad(pos=[0,1.8,3]) #Create texture with repeating wrap mode tex = viz.addTexture('images/tile_grass.jpg', wrap=viz.REPEAT) tex.pos = 0 #Apply texture to quad quad.texture(tex) ANIMATE_SPEED = 0.1 def animateTexture(): #Increment texture position tex.pos += ANIMATE_SPEED * viz.elapsed() #Create transform for texture mat = viz.Transform() mat.setTrans(tex.pos,0,0) #Apply transform to texture quad.texmat(mat) vizact.ontimer(0,animateTexture)
def __init__(self): #function to add headmarkers self.file_hm1 = 'C:/VENLAB data/shared_modules/textures/marker1_white.png' self.file_hm2 = 'C:/VENLAB data/shared_modules/textures/marker2_white.png' self.file_hm3 = 'C:/VENLAB data/shared_modules/textures/marker3_white.png' self.file_hm4 = 'C:/VENLAB data/shared_modules/textures/marker4_white.png' self.file_hm5 = 'C:/VENLAB data/shared_modules/textures/marker5_white.png' self.file_hm6 = 'C:/VENLAB data/shared_modules/textures/marker6_white.png' self.file_hm7 = 'C:/VENLAB data/shared_modules/textures/marker7_white.png' boxsize = [.8,.5] #xy box size lowerleft = [.1,.1] #starting corner #counter-scale it to adjust for the aspect ratio. defaultscale = 800.0/600.0 aspect = 1920.0 / 1080.0 scale = aspect/defaultscale sc = .8 sc_v = .8 sc_h = sc_v*scale #two ways of doing it #bottom left self.hm1 = viz.addTexQuad(parent=viz.SCREEN, scene=viz.MainWindow) self.hm1.texture(viz.add(self.file_hm1)) self.hm1.setPosition([lowerleft[0],lowerleft[1],0]) self.hm1.scale(sc_v,sc_h,sc) #top left self.hm2 = viz.add(viz.TEXQUAD,viz.SCREEN) self.hm2.texture(viz.add(self.file_hm2)) self.hm2.setPosition([lowerleft[0],lowerleft[1]+boxsize[1],0]) self.hm2.scale(sc_v,sc_h,sc) #bottom right self.hm3 = viz.add(viz.TEXQUAD,viz.SCREEN) self.hm3.texture(viz.add(self.file_hm3)) self.hm3.setPosition([lowerleft[0]+boxsize[0],lowerleft[1],0]) self.hm3.scale(sc_v,sc_h,sc) #top right self.hm4 = viz.add(viz.TEXQUAD,viz.SCREEN) self.hm4.texture(viz.add(self.file_hm4)) self.hm4.setPosition([lowerleft[0]+boxsize[0],lowerleft[1]+boxsize[1],0]) self.hm4.scale(sc_v,sc_h,sc) #add middle markers # #middle top # self.hm5 = viz.add(viz.TEXQUAD,viz.SCREEN) # self.hm5.texture(viz.add(self.file_hm5)) # self.hm5.setPosition([lowerleft[0]+boxsize[0]/2,lowerleft[1]+boxsize[1],0]) # self.hm5.scale(sc,sc,sc) #middle top right self.hm6 = viz.add(viz.TEXQUAD,viz.SCREEN) self.hm6.texture(viz.add(self.file_hm6)) self.hm6.setPosition([lowerleft[0]+(boxsize[0]*2)/3,lowerleft[1]+boxsize[1],0]) self.hm6.scale(sc_v,sc_h,sc) #middle top left self.hm7 = viz.add(viz.TEXQUAD,viz.SCREEN) self.hm7.texture(viz.add(self.file_hm7)) self.hm7.setPosition([lowerleft[0]+(boxsize[0]*1)/3,lowerleft[1]+boxsize[1],0]) self.hm7.scale(sc_v,sc_h,sc)
pigeon_root.visible(False) pigeon = viz.addAvatar('pigeon.cfg',parent=pigeon_root) # Add idle animation random_walk = vizact.walkTo(pos=[vizact.randfloat(-0.5,0.5),0,vizact.randfloat(-0.5,0.5)]) random_animation = vizact.method.state(vizact.choice([1,3],vizact.RANDOM)) random_wait = vizact.waittime(vizact.randfloat(4.0,8.0)) pigeon_idle = vizact.sequence( random_walk, random_animation, random_wait, viz.FOREVER) pigeon.runAction(pigeon_idle) # Adding sound to pigeon hooting = pigeon.playsound('birds.wav',viz.LOOP) hooting.pause() # Create flash screen quad flash_quad = viz.addTexQuad(parent=viz.ORTHO) flash_quad.color(viz.WHITE) flash_quad.alignment(viz.ALIGN_LEFT_BOTTOM) flash_quad.drawOrder(-10) flash_quad.blendFunc(viz.GL_ONE,viz.GL_ONE) flash_quad.visible(False) viz.link(viz.MainWindow.WindowSize,flash_quad,mask=viz.LINK_SCALE) # Create status bar background status_bar = viz.addTexQuad(parent=viz.ORTHO) status_bar.color(viz.BLACK) status_bar.alpha(0.5) status_bar.alignment(viz.ALIGN_LEFT_BOTTOM) status_bar.drawOrder(-1) viz.link(viz.MainWindow.LeftTop,status_bar,offset=[0,-80,0]) viz.link(viz.MainWindow.WindowSize,status_bar,mask=viz.LINK_SCALE)
boxL.setPosition([-0.2,targetL*scalorxx,0]) #place quad behind to show movie global rvideo global lvideo global Rquad global Lquad rvideo = viz.addVideo('RightSuccess0001-0040.avi') lvideo = viz.addVideo('LeftSuccess0001-0040.avi') #rvideo.loop() #lvideo.loop() #rvideo.play() #lvideo.play() Rquad = viz.addTexQuad(pos=[0.5,targetR*scalorxx,0],scale = [.5,.5,0]) Rquad.texture(rvideo) Lquad = viz.addTexQuad(pos=[-.5,targetL*scalorxx,0],scale = [.5,.5,0]) Lquad.texture(lvideo) global boxR boxR = viz.addChild('target.obj',color=(0.063,0.102,0.898),scale=[0.1,(targettol+0.04)*0.75,0.0125]) boxR.setPosition([0.2,targetR*scalorxx,0]) viz.MainView.setPosition(0, 0.5, -1.5) viz.MainView.setEuler(0,0,0) #setup counter panels global RCOUNT global LCOUNT RCOUNT = 0
def onCollideBegin(self, e): if (e.obj1 == self.cyl1) and self.cyl1hei >= -7.6 and self.tower == 1: self.cyl1hei -= 0.2 mat = viz.Matrix() mat.postTrans(0, self.cyl1hei, 0) self.cyl1.setMatrix(mat) self.score += 2 self.t.remove() self.t = viz.addText("Score:" + "" + ` self.score `, viz.SCREEN, pos=[0, 0, 0]) self.t.fontSize(100) self.t.font('Chiller') e.obj2.remove() if (self.cyl1hei <= -7.6) and self.tower == 1: self.cyl1hei = 0 self.ship.move(4.5, .7, 11, 5) self.ship.setOrientation(4.5, .7, 11, 0.06, 180) self.bZ = self.ship.getZ() + 0.05 self.tower = 2 viz.playSound('level.wav') view = viz.MainView mat = viz.Matrix() mat.postTrans(0, 0, -1.9) view.setMatrix(mat) pic = viz.addTexture('egypt.jpg') # Create surface to wrap the texture on self.egypt = viz.addTexQuad() mat = viz.Matrix() mat.postScale(1.995, 1.5, 1.5) self.egypt.setMatrix(mat) self.egypt.setPosition([0, 0, 0]) #put quad in view # Wrap texture on quad self.egypt.texture(pic) mat = viz.Matrix() mat.postTrans(0, self.cyl1hei, 0) self.cyl1.setMatrix(mat) elif (e.obj1 == self.cyl2) and self.cyl1hei >= -7.6 and self.tower == 2: self.cyl1hei -= 0.2 mat = viz.Matrix() mat.postTrans(0, self.cyl1hei, 0) self.cyl2.setMatrix(mat) self.score += 2 self.t.remove() self.t = viz.addText("Score:" + "" + ` self.score `, viz.SCREEN, pos=[0, 0, 0]) self.t.fontSize(100) self.t.font('Chiller') e.obj2.remove() if (self.cyl1hei <= -7.6) and self.tower == 2: self.cyl1hei = 0 self.ship.move(13.5, .7, 11, 5) self.ship.setOrientation(13.5, .7, 11, 0.06, 180) self.bZ = self.ship.getZ() + 0.05 self.tower = 3 viz.playSound('level.wav') view = viz.MainView mat = viz.Matrix() mat.postTrans(0, 0, -1.9) view.setMatrix(mat) pic = viz.addTexture('city.jpg') # Create surface to wrap the texture on self.city = viz.addTexQuad() mat = viz.Matrix() mat.postScale(1.995, 1.5, 1.5) self.city.setMatrix(mat) self.city.setPosition([0, 0, 0]) #put quad in view # Wrap texture on quad self.city.texture(pic) mat = viz.Matrix() mat.postTrans(0, self.cyl1hei, 0) self.cyl2.setMatrix(mat) elif (e.obj1 == self.cyl3) and self.cyl1hei >= -7.6 and self.tower == 3: self.cyl1hei -= 0.2 mat = viz.Matrix() mat.postTrans(0, self.cyl1hei, 0) self.cyl3.setMatrix(mat) self.score += 2 self.t.remove() self.t = viz.addText("Score:" + "" + ` self.score `, viz.SCREEN, pos=[0, 0, 0]) self.t.fontSize(100) self.t.font('Chiller') e.obj2.remove() if (self.cyl1hei <= -7.6) and self.tower == 3: self.cyl1hei = 0 self.ship.move(13.5, .7, 4, 5) self.ship.setOrientation(13.5, .7, 4, 0.06, 180) self.bZ = self.ship.getZ() + 0.05 self.tower = 4 viz.playSound('level.wav') view = viz.MainView mat = viz.Matrix() mat.postTrans(0, 0, -1.9) view.setMatrix(mat) pic = viz.addTexture('forest.jpg') # Create surface to wrap the texture on self.forest7 = viz.addTexQuad() mat = viz.Matrix() mat.postScale(1.995, 1.5, 1.5) self.forest7.setMatrix(mat) self.forest7.setPosition([0, 0, 0]) #put quad in view # Wrap texture on quad self.forest7.texture(pic) mat = viz.Matrix() mat.postTrans(0, self.cyl1hei, 0) self.cyl3.setMatrix(mat) elif (e.obj1 == self.cyl4) and self.cyl1hei >= -7.6 and self.tower == 4: self.cyl1hei -= 0.2 mat = viz.Matrix() mat.postTrans(0, self.cyl1hei, 0) self.cyl4.setMatrix(mat) self.score += 2 self.t.remove() self.t = viz.addText("Score:" + "" + ` self.score `, viz.SCREEN, pos=[0, 0, 0]) self.t.fontSize(100) self.t.font('Chiller') e.obj2.remove() if (self.cyl1hei <= -7.6) and self.tower == 4: self.cyl1hei = 0 self.ship.move(4.5, .7, 4, 5) self.ship.setOrientation(4.5, .7, 4, 0.06, 180) self.bZ = self.ship.getZ() + 0.05 self.tower = 1 viz.playSound('level.wav') view = viz.MainView mat = viz.Matrix() mat.postTrans(0, 0, -1.9) view.setMatrix(mat) pic = viz.addTexture('snow.jpg') # Create surface to wrap the texture on self.snow = viz.addTexQuad() mat = viz.Matrix() mat.postScale(1.995, 1.5, 1.5) self.snow.setMatrix(mat) self.snow.setPosition([0, 0, 0]) #put quad in view # Wrap texture on quad self.snow.texture(pic) mat = viz.Matrix() mat.postTrans(0, self.cyl1hei, 0) self.cyl4.setMatrix(mat) elif self.bullet!= None and ((e.obj1 == self.barricade11 and e.obj2 == self.bullet) \ or (e.obj1 == self.barricade12 and e.obj2 == self.bullet) \ or (e.obj1 == self.barricade13 and e.obj2 == self.bullet)\ or (e.obj1 == self.barricade14 and e.obj2 == self.bullet) \ or (e.obj1 == self.barricade21 and e.obj2 == self.bullet) \ or (e.obj1 == self.barricade22 and e.obj2 == self.bullet) \ or (e.obj1 == self.barricade23 and e.obj2 == self.bullet)\ or (e.obj1 == self.barricade24 and e.obj2 == self.bullet) \ or (e.obj1 == self.barricade31 and e.obj2 == self.bullet) \ or (e.obj1 == self.barricade32 and e.obj2 == self.bullet) \ or (e.obj1 == self.barricade33 and e.obj2 == self.bullet)\ or (e.obj1 == self.barricade34 and e.obj2 == self.bullet) \ or (e.obj1 == self.barricade41 and e.obj2 == self.bullet) \ or (e.obj1 == self.barricade42 and e.obj2 == self.bullet) \ or (e.obj1 == self.barricade43 and e.obj2 == self.bullet)\ or (e.obj1 == self.barricade44 and e.obj2 == self.bullet)): self.t1.remove() viz.playSound('oof.wav') self.life -= 1 self.t1 = viz.addText("Lives:" + "" + ` self.life `, viz.SCREEN, pos=[0.8, 0, 0]) self.t1.fontSize(100) self.t1.font('Chiller') if self.life == 0: viz.playSound('over.wav') pic = viz.addTexture('end.png') # Create surface to wrap the texture on self.end = viz.addTexQuad() mat = viz.Matrix() mat.postScale(1.995, 1.5, 1.5) self.end.setMatrix(mat) self.end.setPosition([0, 0, 0]) #put quad in view # Wrap texture on quad self.end.texture(pic) view = viz.MainView mat = viz.Matrix() mat.postTrans(0, 0, -1.9) view.setMatrix(mat) self.t1.remove() self.t.remove() self.t2 = viz.addText("Final Score:" + ` self.score `, viz.SCREEN, pos=[0.18, 0.3, 0]) self.t2.fontSize(200) self.t2.font('Chiller') elif self.bullet!= None and ((e.obj1 == self.barricade21 and e.obj2 == self.bullet) \ or (e.obj1 == self.barricade22 and e.obj2 == self.bullet) \ or (e.obj1 == self.barricade23 and e.obj2 == self.bullet)\ or (e.obj1 == self.barricade24 and e.obj2 == self.bullet)): self.t1.remove() self.life -= 1 self.t1 = viz.addText("Lives:" + "" + ` self.life `, viz.SCREEN, pos=[0.8, 0, 0]) self.t1.fontSize(100) self.t1.font('Chiller')
viz.startLayer(viz.LINES) viz.vertex(0, 1, -0.0001) #Vertices are split into pairs. viz.vertex(0, -1, -0.0001) myLines = viz.endLayer() viz.startLayer(viz.LINES) viz.vertex(-1, 0, -0.0001) #Vertices are split into pairs. viz.vertex(1, 0, -0.0001) myLines = viz.endLayer() viz.startLayer(viz.LINES) viz.vertex(-1, -0.25, -0.0001) #Vertices are split into pairs. viz.vertex(1, -0.25, -0.0001) myLines = viz.endLayer() targetR = viz.addTexQuad(pos=[0.2, 0, 0], scale=[.2, 2 * targettol, 0]) targetR.color(0, 0.5, 1) viz.MainView.setPosition(0, 0, -1) viz.MainView.setEuler(0, 0, 0) #math for view angles theta1 = 2 * math.atan2(targettol, 2 * 1) print(theta1) distanceL = ttL / (2 * math.tan(theta1 / 2)) print(distanceL) theta2 = 2 * math.atan2(0.2, 2 * 1) print(theta2) widthL = 2 * (distanceL) * math.tan(theta2 / 2) print(widthL)
avatar.addAction(vizact.sequence(actions,viz.FOREVER)) music = viz.addAudio('bach_air.mid',loop=1) # Add fall sound fallSound = viz.addAudio('sounds/pit_fall.wav') # Add blur effect for fall action import vizfx.postprocess from vizfx.postprocess.blur import DirectionalBlurEffect blurEffect = DirectionalBlurEffect(samples=3,angle=90) vizfx.postprocess.addEffect(blurEffect) # Add red quad to flash screen after falling flash_quad = viz.addTexQuad(parent=viz.ORTHO) flash_quad.color(viz.RED) flash_quad.alignment(viz.ALIGN_LEFT_BOTTOM) flash_quad.blendFunc(viz.GL_ONE,viz.GL_ONE) flash_quad.visible(False) viz.link(viz.MainWindow.WindowSize,flash_quad,mask=viz.LINK_SCALE) def FallAction(): """Flashes screen red and animates blur effect""" fallSound.stop() fallSound.play() flash_quad.visible(True) flash_quad.color(viz.RED) fade_out = vizact.fadeTo(viz.BLACK,time=2.5) flash_quad.runAction(vizact.sequence(fade_out,vizact.method.visible(False))) flash_quad.runAction(vizact.call(blurEffect.setDistance,vizact.mix(50,0,time=2.5)),pool=1)
viz.go( #viz.FULLSCREEN ) view = viz.addView hmd = oculus.Rift() hmd.getSensor viz.link(hmd.getSensor(),viz.MainView) viz.MainView.collision(viz.ON) viz.MainView.collisionBuffer(0.5) viz.fov(90) im = viz.addTexture('801109.jpg') im2 = viz.addTexture('galaxy.jpg') background = viz.addTexQuad() background.setPosition(0,2,6) background.setScale(21,7,1) background.texture(im) roof = viz.addTexQuad() roof.setPosition(0.5,2.9,-4) roof.setEuler(0,90,0) roof.setScale(6,12,1) roof.texture(im2) #sky = viz.addChild('sky_day.osgb') #ground = viz.addChild('ground_grass.osgb') #ground.setPosition(0,-0.25,0) hmrl = viz.addChild('HMRL.osgb') hmrl.setPosition(0,0,0)
cpps = subprocess.Popen( '"C:/Users/Gelsey Torres-Oviedo/Documents/Visual Studio 2013/Projects/Vicon2Python_DK2_rev2/x64/Release/Vicon2Python_DK2_rev2.exe"' ) time.sleep(4) #check vizard4/bin/vizconfig to change which monitor displays the VR window viz.splashScreen( 'C:\Users\Gelsey Torres-Oviedo\Desktop\VizardFolderVRServer\Logo_final_DK2.jpg' ) viz.setMultiSample(8) viz.go( #viz.FULLSCREEN ) monoWindow = viz.addWindow(size=(1, 1), pos=(0, 1), scene=viz.addScene()) monoQuad = viz.addTexQuad(parent=viz.ORTHO, scene=monoWindow) monoQuad.setBoxTransform(viz.BOX_ENABLED) monoQuad.setTexQuadDisplayMode(viz.TEXQUAD_FILL) texture = vizfx.postprocess.getEffectManager().getColorTexture() def UpdateTexture(): monoQuad.texture(texture) vizact.onupdate(0, UpdateTexture) global hmd view = viz.addView hmd = oculus.Rift() hmd.getSensor()
import struct import array import math import vizlens import imp oculus = imp.load_source('oculus', 'C:\Program Files\WorldViz\Vizard5\python\oculus.py') import subprocess import vizfx viz.splashScreen('C:\Users\Gelsey Torres-Oviedo\Desktop\VizardFolderVRServer\Logo_final_DK2.jpg') viz.setMultiSample(8) viz.go( #viz.FULLSCREEN #run world in full screen ) monoWindow = viz.addWindow(size=(1,1), pos=(0,1), scene=viz.addScene()) monoQuad = viz.addTexQuad(parent=viz.ORTHO, scene=monoWindow) monoQuad.setBoxTransform(viz.BOX_ENABLED) monoQuad.setTexQuadDisplayMode(viz.TEXQUAD_FILL) texture = vizfx.postprocess.getEffectManager().getColorTexture() def UpdateTexture(): monoQuad.texture(texture) global hmd view = viz.addView hmd = oculus.Rift() hmd.getSensor() viz.MainView.setPosition(0,0.15,-1.27*3/2+0.002) viz.MainView.setEuler(0,0,0)
#place quad behind to show movie global rvideo global lvideo global Rquad global Lquad #rvideo = viz.addVideo('RightSuccess0001-0040.avi') #lvideo = viz.addVideo('LeftSuccess0001-0040.avi') rvideo = viz.addVideo('Righthair.avi') lvideo = viz.addVideo('Lefthair.avi') #rvideo.loop() #lvideo.loop() #rvideo.play() #lvideo.play() Rquad = viz.addTexQuad(pos=[0.5,targetR,0.10],scale = [.5,.5,0]) Rquad.texture(rvideo) Lquad = viz.addTexQuad(pos=[-0.5,targetL,0.10],scale = [.5,.5,0]) Lquad.texture(lvideo) #declare the total number of steps to attempt (this is the accumulation of steps total, i.e. 75 R and 75 L means 150 total attempts) global STEPNUM STEPNUM =20 #setup array of randomly picked steps global randy randy = [1] * STEPNUM + [2] * STEPNUM # create list of 1's and 2's random.shuffle(randy)#randomize the order of tests random.shuffle(randy)#randomize the order of tests again #print(randy) global boxL #left target box
import viz viz.go() ch = viz.addTexQuad(texture=viz.add('crosshair.png'), size=.1 ) link = viz.link(viz.MainView, ch) link.preTrans([0,0,2])
global scaling scaling = 1 #R Rigth leg global R R = 1.54 #R left leg global R2 R2 = 1.73 global targettol #targettol = 0.025 targettol = 0.0375 global boxL boxL = viz.addTexQuad(pos=[-0.2, targetL, 0], scale=[0.2, 2 * targettol, 0]) boxL.color(0, 0.7, 1) boxL.alpha(0.7) global boxR boxR = viz.addTexQuad(pos=[0.2, targetR, 0], scale=[0.2, 2 * targettol, 0]) boxR.color(0, 0.7, 1) boxR.alpha(0.7) viz.MainView.setPosition(0, 0.25, -1.25) viz.MainView.setEuler(0, 0, 0) #setup explosions global fire1 fire1 = viz.addChild('fire2.osg', scale=[2, 2, 2], pos=[0.2, targetR, 0]) #right side global fire2
global cpps cpps = subprocess.Popen( '"C:/Users/Gelsey Torres-Oviedo/Documents/Visual Studio 2013/Projects/Vicon2Python_DK2_rev2/x64/Release/Vicon2Python_DK2_rev2.exe"' ) time.sleep(3) viz.splashScreen( 'C:\Users\Gelsey Torres-Oviedo\Desktop\VizardFolderVRServer\Logo_final_DK2.jpg' ) viz.setMultiSample(8) viz.go( #viz.FULLSCREEN #run world in full screen ) monoWindow = viz.addWindow(size=(1, 1), pos=(0, 1), scene=viz.addScene()) monoQuad = viz.addTexQuad(parent=viz.ORTHO, scene=monoWindow) monoQuad.setBoxTransform(viz.BOX_ENABLED) monoQuad.setTexQuadDisplayMode(viz.TEXQUAD_FILL) texture = vizfx.postprocess.getEffectManager().getColorTexture() def UpdateTexture(): monoQuad.texture(texture) vizact.onupdate(0, UpdateTexture) global hmd view = viz.addView hmd = oculus.Rift() hmd.getSensor()
catchflag = 1 global stridecounter stridecounter = 0 #set target tolerance for stride length global targetL targetL = 0.25 global targetR targetR = 0.25 global targettol targettol = 0.025 global targetto2 targetto2 = 0.0375 ################################################################################## global boxR boxR = viz.addTexQuad(pos=[0.2,0,0.001],scale=[0.2,2*targettol,0]) boxR.color(0,0,1) boxR.alpha(0.9) global boxR2 boxR2 = viz.addTexQuad(pos=[0.2,0,0.001],scale=[0.2,2*targetto2,0]) boxR2.color(0.2,0.8,1) boxR2.alpha(0.9) global boxL boxL = viz.addTexQuad(pos=[-0.2,0,0.001],scale=[0.2,2*targettol,0]) boxL.color(0,0,1) boxL.alpha(0.9) global boxL2 boxL2 = viz.addTexQuad(pos=[-0.2,0,0.001],scale=[0.2,2*targetto2,0]) boxL2.color(0.2,0.8,1)
import vizfx #global cpps #cpps = subprocess.Popen('"C:/Users/Gelsey Torres-Oviedo/Documents/Visual Studio 2013/Projects/Vicon2Python_DK2_rev2/x64/Release/Vicon2Python_DK2_rev2.exe"') #time.sleep(3) viz.splashScreen( 'C:\Users\Gelsey Torres-Oviedo\Desktop\VizardFolderVRServer\Logo_final_DK2.jpg' ) viz.setMultiSample(8) viz.go( #viz.FULLSCREEN #run world in full screen ) monoWindow = viz.addWindow(size=(1, 1), pos=(0, 1), scene=viz.addScene()) monoQuad = viz.addTexQuad(parent=viz.ORTHO, scene=monoWindow) monoQuad.setBoxTransform(viz.BOX_ENABLED) monoQuad.setTexQuadDisplayMode(viz.TEXQUAD_FILL) texture = vizfx.postprocess.getEffectManager().getColorTexture() def UpdateTexture(): monoQuad.texture(texture) vizact.onupdate(0, UpdateTexture) global hmd view = viz.addView hmd = oculus.Rift() hmd.getSensor()
def onKeyDown(self, key): if (key == viz.KEY_LEFT): # turn self.avatar ccw, as viewed from above self.ship.yrot -= 2 self.theta -= 2 elif (key == viz.KEY_RIGHT): # turn self.avatar cw, as viewed from above self.ship.yrot += 2 self.theta += 2 elif (key == viz.KEY_UP): # move avatar forward dx = 0.2 * math.sin(math.radians(self.theta)) dz = 0.2 * math.cos(math.radians(self.theta)) self.ship.x = self.ship.x + dx self.ship.z = self.ship.z + dz self.x = self.x + dx self.z = self.z + dz elif (key == viz.KEY_DOWN): # increase the velocity of the ball dx = 0.2 * math.sin(math.radians(self.theta)) dz = 0.2 * math.cos(math.radians(self.theta)) self.ship.x = self.ship.x - dx self.ship.z = self.ship.z - dz self.x = self.x - dx self.z = self.z - dz elif (key == "1"): self.start.remove() pic = viz.addTexture('snow.jpg') # Create surface to wrap the texture on self.snow = viz.addTexQuad() mat = viz.Matrix() mat.postScale(1.995, 1.5, 1.5) self.snow.setMatrix(mat) self.snow.setPosition([0, 0, 0]) #put quad in view # Wrap texture on quad self.snow.texture(pic) self.mylight.color(.3, .3, .3) view = viz.MainView mat = viz.Matrix() mat.postTrans(0, 0, -1.9) view.setMatrix(mat) self.t1.remove() self.t.remove() self.t = viz.addText("Score:" + "" + ` self.score `, viz.SCREEN, pos=[0, 0, 0]) self.t.fontSize(100) self.t.font('Chiller') self.t1 = viz.addText("Lives:" + "" + ` self.life `, viz.SCREEN, pos=[0.8, 0, 0]) self.t1.fontSize(100) self.t1.font('Chiller') elif (key == "2"): viz.playSound('soundtrack.wav') self.mode = "firstperson" elif key == 'w': if self.deskPressed: self.desk.setOrientation(self.desk.getX(), self.desk.getY(), self.desk.getZ() + 1, 1, 90) elif self.shelfPressed: self.shelf.setOrientation(self.shelf.getX(), self.shelf.getY(), self.shelf.getZ() + 1, 1, 0) elif key == 'a': if self.deskPressed: self.desk.setOrientation(self.desk.getX() - 1, self.desk.getY(), self.desk.getZ(), 1, 90) elif self.shelfPressed: self.shelf.setOrientation(self.shelf.getX() - 1, self.shelf.getY(), self.shelf.getZ(), 1, 0) elif key == 's': if self.deskPressed: self.desk.setOrientation(self.desk.getX(), self.desk.getY(), self.desk.getZ() - 1, 1, 90) elif self.shelfPressed: self.shelf.setOrientation(self.shelf.getX(), self.shelf.getY(), self.shelf.getZ() - 1, 1, 0) elif key == 'd': if self.deskPressed: self.desk.setOrientation(self.desk.getX() + 1, self.desk.getY(), self.desk.getZ(), 1, 90) elif self.shelfPressed: self.shelf.setOrientation(self.shelf.getX() + 1, self.shelf.getY(), self.shelf.getZ(), 1, 0) elif (key == " "): if self.life > 0: self.boolean = True self.bullet = vizshape.addSphere(radius=.07, color=viz.BLACK) mat = viz.Matrix() mat.postTrans(self.ship.getX(), self.ship.getY(), self.bZ + 0.05) self.bullet.setMatrix(mat) self.bullet.collideSphere(bounce=3) self.bullet.enable(viz.COLLIDE_NOTIFY) self.bullet.setVelocity([0, 0, 5]) elif (key == viz.KEY_RETURN): if self.tower == 1: self.snow.remove() view = viz.MainView mat = viz.Matrix() mat.postAxisAngle(1, 0, 0, 30) mat.postTrans(4.5, 3.5, .5) view.setMatrix(mat) viz.playSound('start.wav') elif self.tower == 2: self.egypt.remove() view = viz.MainView mat = viz.Matrix() mat.postAxisAngle(1, 0, 0, 30) mat.postTrans(4.5, 3.5, 7.5) view.setMatrix(mat) viz.playSound('start.wav') elif self.tower == 3: self.city.remove() view = viz.MainView mat = viz.Matrix() mat.postAxisAngle(1, 0, 0, 30) mat.postTrans(13.5, 3.5, 7.5) view.setMatrix(mat) viz.playSound('start.wav') elif self.tower == 4: self.forest7.remove() view = viz.MainView mat = viz.Matrix() mat.postAxisAngle(1, 0, 0, 30) mat.postTrans(13.5, 3.5, 0.5) view.setMatrix(mat) viz.playSound('start.wav') if (self.mode == "firstperson"): self.start.remove() self.mylight.color(.7, .7, .7) dx = 0.1 * math.sin(math.radians(self.theta)) dz = 0.1 * math.cos(math.radians(self.theta)) view = viz.MainView mat = viz.Matrix() mat.postAxisAngle(0, 1, 0, self.theta) mat.postTrans(self.x, self.y, self.z + 0.15) view.setMatrix(mat) self.ship.setOrientation(4.5, -17, 4, 0.06, 180) self.ship.setTransMatrix()
def __init__(self): self.mylight = viz.addLight() self.mylight.position(9, 500, -25) self.mylight.color(.3, .3, .3) # base class constructor self.boolean = False viz.EventClass.__init__(self) self.callback(viz.TIMER_EVENT, self.onTimer) self.starttimer(1, 1 / 5.0, viz.FOREVER) self.cyl1hei = 0 self.bZ = 0 self.startbZ = 0 self.ang = 10 self.tower = 1 self.score = 0 self.life = 5 self.t = viz.addText("Score:" + "" + ` self.score `, viz.SCREEN, pos=[0, 0, 0]) self.t.fontSize(100) self.t.font('Chiller') self.t1 = viz.addText("Lives:" + "" + ` self.life `, viz.SCREEN, pos=[0.8, 0, 0]) self.t1.fontSize(100) self.t1.font('Chiller') self.bullet = None # Load texture pic = viz.addTexture('start.jpg') # Create surface to wrap the texture on self.start = viz.addTexQuad() mat = viz.Matrix() mat.postScale(1.995, 1.5, 1.5) self.start.setMatrix(mat) self.start.setPosition([0, 0, 0]) #put quad in view # Wrap texture on quad self.start.texture(pic) self.t1.remove() self.t.remove() #snow self.bigSnowman = Model('snowman\\model.dae') self.snowman = Model('snowman\\model.dae') self.glacier = Model('glacier\\model.dae') self.bigGlacier = Model('glacier\\model.dae') self.bigSnowman.setOrientation(8, .1, 5, .5, -50) self.snowman.setOrientation(3.1, .1, .7, .2, 75) self.glacier.setOrientation(7, .1, 2, .2, -90) self.bigGlacier.setOrientation(2.7, .1, 4.5, .32, 0) #desert self.bigPyr = Model('pyramidsmooth\\model.dae') self.pyr = Model('pyramidsmooth\\model.dae') self.sphinx = Model('sphinx\\model.dae') self.bigSphinx = Model('sphinx\\model.dae') self.bigPyr.setOrientation(7.3, -0.2, 12, .7, -50) self.pyr.setOrientation(8, -0.2, 17, .4, 75) self.sphinx.setOrientation(5.5, 0.2, 15.1, .6, 0) self.bigSphinx.setOrientation(2.9, 0.1, 10, 2, -90) #city self.city = Model('city\\model.dae') self.sCity = Model('city\\model.dae') self.empstbu = Model('empire\\model.dae') self.skyskr = Model('skyskraper\\model.dae') self.towe = Model('tower\\model.dae') self.city.setOrientation(14, 0.2, 9.8, .0087, 0) self.sCity.setOrientation(13, 0.2, 13.4, .006, 180) self.empstbu.setOrientation(14.8, -0.1, 15.17, .0082, 0) self.skyskr.setOrientation(11.8, 0.2, 9.7, .006, 0) self.towe.setOrientation(11.5, 0.2, 15.5, .03, 0) #forest self.fores = Model('forest\\model.dae') self.fores1 = Model('forest\\model.dae') self.garde = Model('garden\\model.dae') self.fores.setOrientation(18.4, 0.1, .3, 0.07, 0) self.fores1.setOrientation(18.4, 0.1, 9, 0.04, -90) self.garde.setzScale(0.8) #spaceship self.ship = Model('ship\\model.dae') self.ship.setOrientation(4.5, .7, 4, 0.06, 180) self.bZ = self.ship.getZ() + 0.05 self.startbZ = self.ship.getZ() # set up keyboard and timer callback methods self.callback(viz.KEYDOWN_EVENT, self.onKeyDown) self.callback(viz.COLLIDE_BEGIN_EVENT, self.onCollideBegin) #avatar's postion and rotation angle self.x = 4.5 self.y = 0.85 self.z = 2 self.theta = 0 # The 2D array below stores the representation of a maze. # Array entries containing a 2 represent 1 x 2 x 1 wall blocks. # Array entries containing a 0 represent 1 x 0.1 x 1 floor blocks. self.maze = [] self.maze = [[ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 ]] + self.maze # row 17 self.maze = [[ 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 12 ]] + self.maze # row 17 self.maze = [[ 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 12 ]] + self.maze # row 16 self.maze = [[ 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 12 ]] + self.maze # row 15 self.maze = [[ 11, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 12 ]] + self.maze # row 14 self.maze = [[ 11, 0, 0, 0, 1, 0, 0, 0, 0, 0, 4, 4, 4, 1, 4, 4, 4, 4, 4, 12 ]] + self.maze # row 13 self.maze = [[ 11, 0, 0, 0, 8, 0, 0, 0, 0, 0, 4, 4, 4, 7, 4, 4, 4, 4, 4, 12 ]] + self.maze # row 12 self.maze = [[ 11, 0, 0, 0, 1, 0, 0, 0, 0, 0, 4, 4, 4, 1, 4, 4, 4, 4, 4, 12 ]] + self.maze # row 11 self.maze = [[ 11, 0, 0, 0, 10, 0, 0, 0, 0, 0, 4, 4, 4, 10, 4, 4, 4, 4, 4, 12 ]] + self.maze # row 10 self.maze = [[ 11, 0, 0, 0, 1, 0, 0, 0, 0, 0, 4, 4, 4, 1, 4, 4, 4, 4, 4, 12 ]] + self.maze # row 9 self.maze = [[ 13, 3, 3, 3, 1, 3, 3, 3, 3, 3, 6, 6, 6, 1, 5, 5, 5, 5, 5, 14 ]] + self.maze # row 8 self.maze = [[ 13, 3, 3, 3, 1, 3, 3, 3, 3, 3, 6, 6, 6, 1, 5, 5, 5, 5, 5, 14 ]] + self.maze # row 7 self.maze = [[ 13, 3, 3, 3, 1, 3, 3, 3, 3, 3, 6, 6, 6, 1, 5, 5, 5, 5, 5, 14 ]] + self.maze # row 6 self.maze = [[ 13, 3, 3, 3, 2, 3, 3, 3, 3, 3, 6, 6, 6, 9, 5, 5, 5, 5, 5, 14 ]] + self.maze # row 5 self.maze = [[ 13, 3, 3, 3, 1, 3, 3, 3, 3, 3, 6, 6, 6, 1, 5, 5, 5, 5, 5, 14 ]] + self.maze # row 4 self.maze = [[ 13, 3, 3, 3, 10, 1, 1, 1, 1, 1, 1, 1, 1, 10, 5, 5, 5, 5, 5, 14 ]] + self.maze # row 3 self.maze = [[ 13, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 14 ]] + self.maze # row 2 self.maze = [[ 13, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 14 ]] + self.maze # row 1 self.maze = [[ 13, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 14 ]] + self.maze # row 0 # Code to create blocks forming the maze goes here for r in range(0, len(self.maze)): for c in range(0, len(self.maze[0])): self.cVal = c self.rVal = r #Desert floor if (self.maze[r][c] == 0): box = vizshape.addCube(size=1, color=[.92, .90, .68]) mat = viz.Matrix() mat.postScale(1, .1, 1) mat.postTrans(c + .5, 0.05, r + .5) box.setMatrix(mat) elif (self.maze[r][c] == 11): box = vizshape.addCube(size=1, color=[.92, .90, .68]) mat = viz.Matrix() mat.postScale(1, 10, 1) mat.postTrans(c + .5, 0.05, r + .5) box.setMatrix(mat) #Snow tower elif (self.maze[r][c] == 2): self.tower1 = vizshape.addCube(size=1, color=[1, .98, .98]) mat = viz.Matrix() mat.postScale(1, 0.5, 1) mat.postTrans(c + .5, 0.25, r + .5) self.tower1.setMatrix(mat) y = 0.4 self.cyl1 = vizshape.addCylinder(height=15.2, radius=0.375, color=[1, 1, 1], alpha=0) for i in range(19): water = vizshape.addCylinder(height=0.2, radius=0.375, slices=20, stacks=20, color=[0.13, .53, .85]) mat = viz.Matrix() mat.postTrans(0, y, 0) water.setMatrix(mat) y += 0.2 snow = vizshape.addCube(size=0.6, color=[0.76, .87, 1]) mat = viz.Matrix() mat.postTrans(0, y, 0) snow.setMatrix(mat) y += 0.2 snow.setParent(self.cyl1) water.setParent(self.cyl1) self.cyl1.setParent(self.tower1) self.cyl1.collideMesh() self.cyl1.enable(viz.COLLIDE_NOTIFY) self.barricade11 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade11.setParent(self.tower1) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.postTrans(0, 0.7, -0.48) self.barricade11.setMatrix(mat) self.barricade11.collideMesh() self.barricade11.enable(viz.COLLIDE_NOTIFY) self.barricade12 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade12.setParent(self.tower1) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.postTrans(0, 0.7, 0.48) self.barricade12.setMatrix(mat) self.barricade12.collideMesh() self.barricade12.enable(viz.COLLIDE_NOTIFY) self.barricade13 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade13.setParent(self.tower1) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.setAxisAngle(0, 1, 0, 90) mat.postTrans(0.48, 0.7, 0) self.barricade13.setMatrix(mat) self.barricade13.collideMesh() self.barricade13.enable(viz.COLLIDE_NOTIFY) self.barricade14 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade14.setParent(self.tower1) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.setAxisAngle(0, 1, 0, 90) mat.postTrans(-0.48, 0.7, 0) self.barricade14.setMatrix(mat) self.barricade14.collideMesh() self.barricade14.enable(viz.COLLIDE_NOTIFY) #City tower elif (self.maze[r][c] == 7): self.tower3 = vizshape.addCube(size=1, color=[.43, .49, .50]) mat = viz.Matrix() mat.postScale(1, 0.5, 1) mat.postTrans(c + .5, 0.25, r + .5) self.tower3.setMatrix(mat) y = 0.4 self.cyl3 = vizshape.addCylinder(height=15.2, radius=0.375, color=[1, 1, 1], alpha=0) for i in range(19): sand = vizshape.addCylinder(height=0.2, radius=0.375, slices=20, stacks=20, color=[0.31, 0.31, 0.31]) mat = viz.Matrix() mat.postTrans(0, y, 0) sand.setMatrix(mat) y += 0.2 pyra = vizshape.addCube(size=0.6, color=[0.88, 0.88, 0.88]) mat = viz.Matrix() mat.postTrans(0, y, 0) pyra.setMatrix(mat) y += 0.2 sand.setParent(self.cyl3) pyra.setParent(self.cyl3) self.cyl3.setParent(self.tower3) self.cyl3.collideMesh() self.cyl3.enable(viz.COLLIDE_NOTIFY) self.barricade21 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade21.setParent(self.tower3) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.postTrans(0, 0.7, -0.48) self.barricade21.setMatrix(mat) self.barricade21.collideMesh() self.barricade21.enable(viz.COLLIDE_NOTIFY) self.barricade22 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade22.setParent(self.tower3) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.postTrans(0, 0.7, 0.48) self.barricade22.setMatrix(mat) self.barricade22.collideMesh() self.barricade22.enable(viz.COLLIDE_NOTIFY) self.barricade23 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade23.setParent(self.tower3) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.setAxisAngle(0, 1, 0, 90) mat.postTrans(0.48, 0.7, 0) self.barricade23.setMatrix(mat) self.barricade23.collideMesh() self.barricade23.enable(viz.COLLIDE_NOTIFY) self.barricade24 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade24.setParent(self.tower3) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.setAxisAngle(0, 1, 0, 90) mat.postTrans(-0.48, 0.7, 0) self.barricade24.setMatrix(mat) self.barricade24.collideMesh() self.barricade24.enable(viz.COLLIDE_NOTIFY) #Desert tower elif (self.maze[r][c] == 8): self.tower2 = vizshape.addCube(size=1, color=[.92, .90, .68]) mat = viz.Matrix() mat.postScale(1, 0.5, 1) mat.postTrans(c + .5, 0.25, r + .5) self.tower2.setMatrix(mat) y = 0.4 self.cyl2 = vizshape.addCylinder(height=15.2, radius=0.375, color=[1, 1, 1], alpha=0) for i in range(19): street = vizshape.addCylinder(height=0.2, radius=0.375, slices=20, stacks=20, color=[0.74, 0.49, 0.24]) mat = viz.Matrix() mat.postTrans(0, y, 0) street.setMatrix(mat) y += 0.2 pole = vizshape.addCube(size=0.6, color=[0.86, 0.72, 0.58]) mat = viz.Matrix() mat.postTrans(0, y, 0) pole.setMatrix(mat) y += 0.2 street.setParent(self.cyl2) pole.setParent(self.cyl2) self.cyl2.setParent(self.tower2) self.cyl2.collideMesh() self.cyl2.enable(viz.COLLIDE_NOTIFY) self.barricade31 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade31.setParent(self.tower2) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.postTrans(0, 0.7, -0.48) self.barricade31.setMatrix(mat) self.barricade31.collideMesh() self.barricade31.enable(viz.COLLIDE_NOTIFY) self.barricade32 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade32.setParent(self.tower2) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.postTrans(0, 0.7, 0.48) self.barricade32.setMatrix(mat) self.barricade32.collideMesh() self.barricade32.enable(viz.COLLIDE_NOTIFY) self.barricade33 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade33.setParent(self.tower2) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.setAxisAngle(0, 1, 0, 90) mat.postTrans(0.48, 0.7, 0) self.barricade33.setMatrix(mat) self.barricade33.collideMesh() self.barricade33.enable(viz.COLLIDE_NOTIFY) self.barricade34 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade34.setParent(self.tower2) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.setAxisAngle(0, 1, 0, 90) mat.postTrans(-0.48, 0.7, 0) self.barricade34.setMatrix(mat) self.barricade34.collideMesh() self.barricade34.enable(viz.COLLIDE_NOTIFY) #Forrest tower elif (self.maze[r][c] == 9): self.tower4 = vizshape.addCube(size=1, color=[.27, .40, .20]) mat = viz.Matrix() mat.postScale(1, 0.5, 1) mat.postTrans(c + .5, 0.25, r + .5) self.tower4.setMatrix(mat) y = 0.4 self.cyl4 = vizshape.addCylinder(height=15.2, radius=0.375, color=[1, 1, 1], alpha=0) for i in range(19): grass = vizshape.addCylinder(height=0.2, radius=0.375, slices=20, stacks=20, color=[0.88, 1, 0.18]) mat = viz.Matrix() mat.postTrans(0, y, 0) grass.setMatrix(mat) y += 0.2 leaf = vizshape.addCube(size=0.6, color=[0.00, 0.46, 0.00]) mat = viz.Matrix() mat.postTrans(0, y, 0) leaf.setMatrix(mat) y += 0.2 grass.setParent(self.cyl4) leaf.setParent(self.cyl4) self.cyl4.setParent(self.tower4) self.cyl4.collideMesh() self.cyl4.enable(viz.COLLIDE_NOTIFY) self.barricade41 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade41.setParent(self.tower4) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.postTrans(0, 0.7, -0.48) self.barricade41.setMatrix(mat) self.barricade41.collideMesh() self.barricade41.enable(viz.COLLIDE_NOTIFY) self.barricade42 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade42.setParent(self.tower4) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.postTrans(0, 0.7, 0.48) self.barricade42.setMatrix(mat) self.barricade42.collideMesh() self.barricade42.enable(viz.COLLIDE_NOTIFY) self.barricade43 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade43.setParent(self.tower4) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.setAxisAngle(0, 1, 0, 90) mat.postTrans(0.48, 0.7, 0) self.barricade43.setMatrix(mat) self.barricade43.collideMesh() self.barricade43.enable(viz.COLLIDE_NOTIFY) self.barricade44 = vizshape.addCube( size=0.2, color=[0.93, 0.82, 0.008]) self.barricade44.setParent(self.tower4) mat = viz.Matrix() mat.postScale(1, 1, 0.4) mat.setAxisAngle(0, 1, 0, 90) mat.postTrans(-0.48, 0.7, 0) self.barricade44.setMatrix(mat) self.barricade44.collideMesh() self.barricade44.enable(viz.COLLIDE_NOTIFY) #Pink track elif (self.maze[r][c] == 1): box = vizshape.addCube(size=1, color=[0.85, 0.44, .57]) mat = viz.Matrix() mat.postScale(1, 0.5, 1) mat.postTrans(c + .5, 0.25, r + .5) box.setMatrix(mat) #pink track with mesh elif (self.maze[r][c] == 10): box = vizshape.addCube(size=1, color=[0.85, 0.44, .57]) mat = viz.Matrix() mat.postScale(1, 0.5, 1) mat.postTrans(c + .5, 0.25, r + .5) box.setMatrix(mat) box.collideMesh() box.enable(viz.COLLIDE_NOTIFY) #Snow floor elif (self.maze[r][c] == 3): box = vizshape.addCube(size=1, color=[1, .98, .98]) mat = viz.Matrix() mat.postScale(1, .1, 1) mat.postTrans(c + .5, 0.05, r + .5) box.setMatrix(mat) elif (self.maze[r][c] == 13): box = vizshape.addCube(size=1, color=[1, .98, .98]) mat = viz.Matrix() mat.postScale(1, 10, 1) mat.postTrans(c + .5, 0.05, r + .5) box.setMatrix(mat) #City floor elif (self.maze[r][c] == 4): box = vizshape.addCube(size=1, color=[.43, .49, .50]) mat = viz.Matrix() mat.postScale(1, .1, 1) mat.postTrans(c + .5, 0.05, r + .5) box.setMatrix(mat) elif (self.maze[r][c] == 12): box = vizshape.addCube(size=1, color=[.43, .49, .50]) mat = viz.Matrix() mat.postScale(1, 10, 1) mat.postTrans(c + .5, 0.05, r + .5) box.setMatrix(mat) #Outside Forrest floor elif (self.maze[r][c] == 5): box = vizshape.addCube(size=1, color=[.27, .40, .20]) mat = viz.Matrix() mat.postScale(1, .1, 1) mat.postTrans(c + .5, 0.05, r + .5) box.setMatrix(mat) elif (self.maze[r][c] == 14): box = vizshape.addCube(size=1, color=[.27, .40, .20]) mat = viz.Matrix() mat.postScale(1, 10, 1) mat.postTrans(c + .5, 0.05, r + .5) box.setMatrix(mat) #Inside Forrest floor elif (self.maze[r][c] == 6): box = vizshape.addCube(size=1, color=[.325, .478, .239]) mat = viz.Matrix() mat.postScale(1, .1, 1) mat.postTrans(c + .5, 0.05, r + .5) box.setMatrix(mat) self.mode = "thirdperson"