def addAppendage(avatar, skinChoices, skin = 0, appendage = 0): global thirdAppendage, usingInvisibleRod thirdAppendageHorn = viz.addGroup() if(appendage == 0): #Third Arm usingInvisibleRod = False thirdAppendage = viz.addChild(resources.ARM) if skin == 9: texture = viz.addTexture("skin_tones/010.png") texture.wrap(viz.WRAP_S,viz.REPEAT) texture.wrap(viz.WRAP_T,viz.REPEAT) else: texture = viz.addTexture("skin_tones/00" + skinChoices[skin] + ".png") texture.wrap(viz.WRAP_S,viz.REPEAT) texture.wrap(viz.WRAP_T,viz.REPEAT) thirdAppendage.texture(texture) thirdAppendage.emissive([.75, .75, .75]) thirdAppendage.setScale(resources.ARM_SCALE) elif(appendage == 1): #Cylinder usingInvisibleRod = False thirdAppendage = viz.addChild(resources.CYLINDER) thirdAppendage.setScale(resources.ARM_SCALE) thirdAppendage.setParent(thirdAppendageHorn) global tahLink tahLink = viz.link(avatar.getBone('Bip01 Spine'), thirdAppendageHorn) global offsetOp offsetOp = tahLink.preTrans([0, 0.3, 0.1]) tahLink.preEuler([-90.0, 0.0, 0.0]) thirdAppendage.collideBox() thirdAppendage.disable(viz.DYNAMICS) TouchCube.thirdAppendage = thirdAppendage
def __init__(self, save_dir): '''Sets the internal variables to their initial conditions.''' self.previousMatrix = None self.save_dir = save_dir self.pos = None self.pos_screen_left = None self.pos_screen_right = None self.cross_tex = viz.addTexture('cross.png') self.circle_tex = viz.addTexture('circle.png') self.z = 0 self.dx = 0 self.dy = 0 self.stimScale = 10 self.offset = [0, 0] self.distance = 100 self.grid = None self.state = viz.OFF self.centerVertAngle = math.radians(-7) self.centerHorizAngle = math.radians(-2) self.horizAngle = math.radians(17) self.vertAngle = math.radians(13) self.offset = [0, 0] self.numCols = 3 self.numRows = 3 self.adjustDelta = .5
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 applyTexBlendWithGivenTextures(item, filePathToTex1, filePathToTex2): global texBlendEffect tex1 = viz.addTexture(filePathToTex1, type=viz.TEX_2D, wrap=viz.REPEAT) tex2 = viz.addTexture(filePathToTex2, type=viz.TEX_2D, wrap=viz.REPEAT) item.texture(tex1) item.texture(tex2, '', unit=1) item.apply(texBlendEffect) item.setUniformFloat('BlendAmount', 0.25)
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 groundCreator(): viz.startLayer(viz.QUADS) viz.texCoord(0,0) viz.vertex(100, 0, -100) viz.texCoord(1,0) viz.vertex(100, 0, 100) viz.texCoord(1,1) viz.vertex(-100, 0, 100) viz.texCoord(0,1) viz.vertex(-100, 0, -100) ground = viz.endLayer() AreaScale_f = [16, 16 ,1] matrix_area_f = vizmat.Transform() matrix_area_f.setScale(AreaScale_f) ground.texmat(matrix_area_f) wallTex = viz.addTexture('wallTex.jpg') wallTex.wrap(viz.WRAP_T,viz.REPEAT) wallTex.wrap(viz.WRAP_S,viz.REPEAT) ground.texture(wallTex) return ground
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 __init__(self): # base class constructor viz.EventClass.__init__(self) self.model = viz.addChild('piazza.osgb') # set up keyboard and timer callback methods self.callback(viz.KEYDOWN_EVENT,self.onKeyDown) self.callback(viz.MOUSEDOWN_EVENT,self.onMouseDown) #booleans for video self.check1 = False #avatar's postion and rotation angle self.x = 0.5 self.z = 0.5 #counts for animaions self.count = 0.0 self.count2 = 0.0 self.theta = 0 #inserting avater self.avatar = vizfx.addAvatar('mazinger/mazinger.cfg') self.avatar.state(0) #translating avatar to correct position mat = viz.Matrix() #mat.postAxisAngle(0,1,0,self.theta) mat.postTrans(0,7,0); self.avatar.setMatrix(mat) self.callback(viz.TIMER_EVENT,self.onTimer) #mazin.addAction(spin) #Music #add ground grass = viz.addTexture('images/tile_grass.jpg', wrap=viz.REPEAT)
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 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 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 GenerateStarDome(numStars, pointSize, minRadius, maxRadius, scene=1, yCenter=0): #Create a star dome of random points viz.startLayer(viz.POINTS) viz.pointSize(pointSize) for i in range(0, numStars): x = random() - 0.5 y = random() - 0.5 z = random() - 0.5 length = math.sqrt(x*x + y*y + z*z) rad = vizmat.GetRandom(minRadius,maxRadius) x = x / length * rad y = y / length * rad y += yCenter z = z / length * rad color = vizmat.GetRandom(0.4,1) viz.vertexColor([color,color,color-vizmat.GetRandom(0,0.2)]) viz.vertex([x, y, z]) stardome = viz.endLayer() stardome.setParent(viz.WORLD, scene=scene) stardome.texture( viz.addTexture('particle.rgb') ) stardome.blendFunc(viz.GL_SRC_ALPHA,viz.GL_DST_ALPHA) stardome.enable(viz.POINT_SPRITE) stardome.disable(viz.DEPTH_TEST) stardome.draworder(-100000)
def setupPathView (): import vizcam # viz.MainWindow.ortho(-25,25,-15,20,-1,1) viz.MainView.setEuler(0,90,0) flmap=viz.add('models/floor_map.IVE') flmap.texture(viz.addTexture('textures/map_view.png'),'',0) cam = vizcam.PivotNavigate(distance=50) cam.centerNode(flmap)
def loadEndofExperienceSnap(): globals_oa.EOE_TEXTURE = viz.addTexture(globals_oa.EOE_HIGH_SHOCK_TEXTURE_PATH) globals_oa.CANVAS_QUAD.texture(globals_oa.EOE_TEXTURE) globals_oa.CANVAS_QUAD.visible(True) yield viztask.waitTime(globals_oa.EOE_SNAP_TIME) removeZoneSnapShots = globals_oa.EOE_TEXTURE.remove() globals_oa.CANVAS_QUAD.visible(False) yield viztask.waitActionEnd(globals_oa.EOE_TEXTURE, removeZoneSnapShots)
def loadAcknowledgment(): globals_oa.ACKNOWLEDGMENT_QUAD_TEXTURE = viz.addTexture(globals_oa.ACKNOWLEDGMENT_TEXTURE_PATH) globals_oa.CANVAS_QUAD.texture(globals_oa.ACKNOWLEDGMENT_QUAD_TEXTURE) globals_oa.CANVAS_QUAD.visible(True) yield viztask.waitTime(globals_oa.TOTAL_FADING_DRAMA_TIME) removeAcknowledgment = globals_oa.ACKNOWLEDGMENT_QUAD_TEXTURE.remove() yield viztask.waitActionEnd(globals_oa.ACKNOWLEDGMENT_QUAD_TEXTURE, removeAcknowledgment)
def 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 addSphericalImage( enabled=False, scene=viz.MainScene ): landscape = vizshape.addSphere(radius=3.5, flipFaces=True, scene=scene) landscape.color(viz.GRAY) landscape.emissive(viz.GRAY) landscape.setPosition([0.45,1.38,-1.38]) landscape.alpha(1) if enabled else landscape.alpha(0) tex = viz.addTexture('resources/images/parkinglot.jpg') landscape.texture(tex)
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 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 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 __init__(self, save_dir): """Sets the internal variables to their initial conditions. """ self.previousMatrix = None self.save_dir = save_dir self.pos = None self.pos_screen_left = None self.pos_screen_right = None self.cross_tex = viz.addTexture('cross.png') self.circle_tex = viz.addTexture('circle.png') self.offset=[0,-10.5] self.numCols = 3 self.numRows = 3 self.adjustDelta = .4 self.z = 0; self.dx = 0 self.dy = 0 self.stimScale = 4 self.distance = 100; self.grid = None self.state = viz.OFF self.centerVertAngle = math.radians(-12) self.centerHorizAngle = math.radians(0) self.horizAngle = math.radians(9) self.vertAngle = math.radians(9) self.pointLocX_pt = [0] * (self.numCols * self.numRows) self.pointLocY_pt = [0] * (self.numCols * self.numRows) ## Use the DLL to set up initial settings self.importDLL()
def loadOpeningTitle(): global boatscene boatscene.loadTexQuads(1) globals_oa.TITLE_QUAD_TEXTURE = viz.addTexture(globals_oa.OPENING_TITLE_TEXTURE_PATH) globals_oa.CANVAS_QUAD.texture(globals_oa.TITLE_QUAD_TEXTURE) globals_oa.CANVAS_QUAD.visible(True) globals_oa.CANVAS_QUAD.emissive(viz.BLACK) yield viztask.waitTime(globals_oa.TOTAL_FADING_DRAMA_TIME - 1.2) removeOpeningTitle = globals_oa.TITLE_QUAD_TEXTURE.remove() globals_oa.CANVAS_QUAD.visible(False)
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 addArm(texturePath, pathToArm): # armPointer = viz.addChild(resources.ARM) armPointer = viz.addChild(pathToArm) texture = viz.addTexture(texturePath) texture.wrap(viz.WRAP_S,viz.REPEAT) texture.wrap(viz.WRAP_T,viz.REPEAT) armPointer.texture(texture) armPointer.emissive([.75, .75, .75]) armPointer.setScale(resources.ARM_SCALE) armPointer.collideBox() armPointer.disable(viz.DYNAMICS) armPointer.visible(False) return armPointer
def __init__(self, save_dir): """Sets the internal variables to their initial conditions. """ self.previousMatrix = None self.save_dir = save_dir self.pos = None self.pos_screen_left = None self.pos_screen_right = None self.cross_tex = viz.addTexture('cross.png') self.circle_tex = viz.addTexture('circle.png') self.offset = [0, -10.5] self.numCols = 3 self.numRows = 3 self.adjustDelta = .4 self.z = 0 self.dx = 0 self.dy = 0 self.stimScale = 4 self.distance = 100 self.grid = None self.state = viz.OFF self.centerVertAngle = math.radians(-12) self.centerHorizAngle = math.radians(0) self.horizAngle = math.radians(9) self.vertAngle = math.radians(9) self.pointLocX_pt = [0] * (self.numCols * self.numRows) self.pointLocY_pt = [0] * (self.numCols * self.numRows) ## Use the DLL to set up initial settings self.importDLL()
def addOutsideLighting(model=MODEL, scene=viz.MainScene): scenery = vizshape.addBox([2.8, 2.8, 2.8]) scenery.emissive(viz.SLATE) scenery.setPosition([1.15, 2.34, 4.73]) tex = viz.addTexture("resources/images/sfview.png") scenery.texture(tex) scenery.disable(viz.SHADOW_CASTING) light = vizfx.addDirectionalLight(scene=SCENE) light.quadraticattenuation(1) light.intensity(0.2) light.setPosition([0.24, 2, 3.73]) light.setEuler(144, 0, 0)
def loadStuffAtStartAndHideThemALL(): global rampTexture globals_oa.initBoatCalled = True if not globals_oa.transportSetUpCalled: transport_vhil.setUp() if not globals_oa.loadAudioAssetsCalled: audioCache.loadAudioAssets() global bigCO2, bigH2O, footprints, bubble, lowPolyMole, highPolyMole globals_oa.boat = vizfx.addChild(globals_oa.boatWithMoleculesPath) globals_oa.boat.disable(viz.ANIMATIONS) globals_oa.boat.setPosition(0,-0.5,-6) # globals_oa.boat.hint(viz.PRELOAD_HINT) globals_oa.boat.setEuler([-90,0,0]) oceanFloor = globals_oa.boat.getChild('OceanFloor.osgb') oceanFloor.setAnimationSpeed(0.25) H2O = globals_oa.boat.getChild('H2O_Molecule_Hovering') H2O.setPosition(.1,-0.13,0.05) # oceanFloor.visible(False) global h2co3molecule h2co3molecule = vizfx.addChild(globals_oa.pathToH2CO3molecule) h2co3moleculeScale = 7 h2co3molecule.setScale(h2co3moleculeScale,h2co3moleculeScale,h2co3moleculeScale) h2co3molecule.visible(viz.OFF) # h2co3molecule.setPosition(globals_oa.h2CO3LocationUntilWeChangeAgain) # h2co3molecule.setAnimationSpeed(0.1) # h2co3molecule.setAnimationTime(8.9) # bigCO2 = vizfx.addChild(globals_oa.co2HoveringMoleculePath) #bigCO2 = globals_oa.boat.getChild('fallingMoleculeToTouch.OSGB') bigCO2 = vizfx.addChild(globals_oa.specialCO2) bigCO2.setPosition(0,21,20) bigCO2.setScale(7,7,7) lowPolyMole = bigCO2.getChild('singleCO2_noAnimation.OSGB') lowPolyMole.disable(viz.RENDERING) highPolyMole = bigCO2.getChild('singleCO2_highPoly.OSGB') bubble = bigCO2.getChild('bubble.OSGB') bigH2O = globals_oa.boat.getChild('H2Oanimated.OSGB') footprintfootprints = globals_oa.boat.getChild('footprints_withText.OSGB') #getting the falling molecules from the model and disabling their rendering for mole in LIST_OF_FALLING_MOLES: node = globals_oa.boat.getChild(mole) node.disable(viz.RENDERING) rampTexture = viz.addTexture(r'resources\whitesquare.jpg') #Turning off the rendering for preload, only to turn on their rendering in showStuff hideStuff()
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 __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 __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 __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 addStreetlights(scene=viz.MainScene): global sphere, sphere2; # pic = viz.addTexture('streetlamp.jpg'); # sphere = vizshape.addQuad(size=[15, 4],scene=scene) # sphere2 = vizshape.addQuad(size=[15, 4],scene=scene) # sphere.setPosition([5, 2.5, 5]); # sphere2.setPosition([5,2.5,-5]); # pic = viz.addTexture('streetlamp.jpg') # sphere.texture(pic) # sphere.emissive(viz.WHITE) # sphere2.texture(pic) # sphere2.emissive(viz.WHITE) cylinder = vizshape.addCylinder(height=5.0,radius=11, topRadius=None, bottomRadius=None, axis=vizshape.AXIS_Y, slices=20, bottom=True,top=True, flipFaces = True) cylinder2 = vizshape.addCylinder(height=5.0,radius=11, topRadius=None, bottomRadius=None, axis=vizshape.AXIS_Y, slices=20, bottom=False,top=False, flipFaces = True) cylinder.setPosition([0, 2.5, -3]) cylinder2.setPosition([0, 2.5, 3]) pic = viz.addTexture('resources/images/streetlamp.jpg') cylinder.texture(pic) cylinder.emissive(viz.WHITE) cylinder.addAction(vizact.spin(0, 1, 0, -40)) cylinder2.texture(pic) cylinder2.emissive(viz.WHITE) cylinder2.addAction(vizact.spin(0, 1, 0, 40)) global timeToMove, origPOS, endPOS timeToMove = 2 origPOS = [ [5, 2.5, 5] , [5,2.5,-5] ] endPOS = [ [-11,2.5,5] , [-11,2.5,-5] ] leftLight = makeLight(scene) rightLight = makeLight(scene)
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 define_table(): """ Zusammenbau des Tischs. Quelle: Herr Hofmann """ table1_plate = vizshape.addBox(size=[2, 0.1, 2], pos=[0, 1, 5], alpha=1) table1_plate.collideBox() table1_plate.disable(viz.DYNAMICS) table1_foot1 = vizshape.addBox(size=[0.25, 1, 0.25], pos=[0.7, 0.5, 4.5], alpha=1) table1_foot1.collideBox() table1_foot1.disable(viz.DYNAMICS) table1_foot2 = vizshape.addBox(size=[0.25, 1, 0.25], pos=[-0.7, 0.5, 5.5], alpha=1) table1_foot2.collideBox() table1_foot2.disable(viz.DYNAMICS) table1_foot3 = vizshape.addBox(size=[0.25, 1, 0.25], pos=[-0.7, 0.5, 4.5], alpha=1) table1_foot3.collideBox() table1_foot3.disable(viz.DYNAMICS) table1_foot4 = vizshape.addBox(size=[0.25, 1, 0.25], pos=[0.7, 0.5, 5.5], alpha=1) table1_foot4.collideBox() table1_foot4.disable(viz.DYNAMICS) podest = vizshape.addBox( size=[1.3, 0.65, 1.7], #Podest für omnRobh pos=[-1.9, 0, 5.0], alpha=1) podest.color(.5, .5, .7) #KUKA-Logo logo = vizshape.addBox(size=[2.4, 2.0, 0.01], pos=[0, 4.0, 7], alpha=1) logo.texture(viz.addTexture('logo.jpg')) # Textures table1_plate.texture(viz.addTexture('Maserung.jpg')) table1_foot1.texture(viz.addTexture('Maserung.jpg')) table1_foot2.texture(viz.addTexture('Maserung.jpg')) table1_foot3.texture(viz.addTexture('Maserung.jpg')) table1_foot4.texture(viz.addTexture('Maserung.jpg'))
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 _setup_clip_plane(self): """ Create a plane with a sissors logo, a grid and a grey back. """ # Create the white center plane self._clip_plane = vizshape.addPlane(size=(.103, .103), axis=vizshape.AXIS_Y, cullFace=False, cornerRadius=0.0025, lighting=False) # Create the back side back = vizshape.addPlane(size=(.103, .103), axis=vizshape.AXIS_Y, cullFace=False, cornerRadius=0.0025, lighting=False, color=(0.7, 0.7, 0.7), parent=self._clip_plane) back.setPosition([0, 0.002, 0]) # Create the front side with the sissors logo sissors = vizshape.addPlane(size=(.08, .08), axis=vizshape.AXIS_Y, cullFace=False, lighting=False, parent=self._clip_plane) sissors.setPosition([0, -0.002, 0]) tex = viz.addTexture('assets/sissors.png') sissors.texture(tex) # Create the grid so the user sees better where the cut goes grid = vizshape.addGrid(size=(.5, .5), step=.01, boldStep=0.0, axis=vizshape.AXIS_Y, lighting=False, parent=self._clip_plane) # Hide the objects until the clipping function is activated self._clip_plane.visible(False)
def _setup_environment(self): """ Setup all objects to create the environments. Environments can be switched with the R key on the keyboard. """ # Add the comfortable "kitchen" room self._room = viz.addChild("Room.osgb") self._room.setScale(.01, .01, .01) # Create the clean "ground" environment (just a white round ground). # This environment isn't saved in a osgb file, because the lights couldn't be configured to use the light group 1 instead of 0. # Only 8 lights are allowed per light group. Room has already 8 lights. img = viz.addTexture('assets/ground.png') self._ground = vizshape.addQuad() self._ground.setScale(6, 6, 6) self._ground.setEuler(0, 90, 0) self._ground.texture(img) # Create the lights for the "ground" envirtonment. light_positions = [ [0, 5, 0], # From top [0, -5, 0], # From bottom [3, 1.5, 0], [-3, 1.5, 0], [0, 1.5, 3], [0, 1.5, -3] ] for light_position in light_positions: light = viz.addLight(group=1) light.setParent(self._ground) light.spread(45) light.intensity(1) light.spotexponent(3) light.setPosition(light_position, mode=viz.ABS_GLOBAL) light.lookAt(self._ground.getPosition()) # Hide the second environment until the environment gets changed self._ground.visible(False)
def addAvatar(): global shader, avatar, num, link global ghostAvatar global gender if gender == 0: avatar = viz.add("tweaked/female_050912/CC2_m002_hipoly_A3.cfg") if skin == 9: texture = viz.addTexture("skin_tones/010.png") texture.wrap(viz.WRAP_S, viz.REPEAT) texture.wrap(viz.WRAP_T, viz.REPEAT) else: texture = viz.addTexture("skin_tones/00" + skinChoices[skin] + ".png") texture.wrap(viz.WRAP_S, viz.REPEAT) texture.wrap(viz.WRAP_T, viz.REPEAT) avatar.texture(texture) avatar.emissive([0.75, 0.75, 0.75]) ghostAvatar = viz.add("tweaked/female_050912/CC2_m002_hipoly_A3.cfg") else: avatar = viz.add("tweaked/Male_New/CC2_m002_hipoly_A3.cfg") if skin == 9: texture = viz.addTexture("skin_tones/010.png") texture.wrap(viz.WRAP_S, viz.REPEAT) texture.wrap(viz.WRAP_T, viz.REPEAT) else: texture = viz.addTexture("skin_tones/00" + skinChoices[skin] + ".png") texture.wrap(viz.WRAP_S, viz.REPEAT) texture.wrap(viz.WRAP_T, viz.REPEAT) avatar.texture(texture) avatar.emissive([0.75, 0.75, 0.75]) ghostAvatar = viz.add("tweaked/Male_New/CC2_m002_hipoly_A3.cfg") ghostAvatar.visible(viz.OFF) avatar.neck = avatar.getBone("Bip01 Neck") avatar.head = avatar.getBone("Bip01 Head") avatar.head.lock() # Initialize Avatar bones if USE_HMD: bone = None pptExtension.mAvatarBones = avatar.getBoneList() numBones = len(pptExtension.mAvatarBones) for i in range(0, numBones): bone = pptExtension.mAvatarBones[i] bone.lock() # Disable automatic bone animatics on pptExtension.mAvatarBoneNames.append(bone.getName()) pptExtension.mAvatarBonePositions.append(bone.getPosition(viz.ABS_GLOBAL)) else: bone.lock() # Disable automatic bone animation pptSimulation.mAvatarBoneNames.append(bone.getName()) pptSimulation.mAvatarBonePositions.append(bone.getPosition(viz.ABS_GLOBAL)) ghostAvatarBones = ghostAvatar.getBoneList() for i in range(0, numBones): bone = ghostAvatarBones[i] bone.lock() avatar.state(1) avatar.setEuler([180.0, 0.0, 0.0]) ghostAvatar.setEuler([180.0, 0.0, 0.0]) avatar.setPosition([0, 0.0, -2]) ghostAvatar.setPosition([0, 0.0, -2]) num += 1 if num >= NUM_AVATARS: num = 0 # Add finger collisions leftFingerBones = ["Bip01 L Finger1Nub", "Bip01 L Finger2Nub", "Bip01 L Finger3Nub", "Bip01 L Finger4Nub"] # fingerBones.extend(['Bip01 R Finger1Nub', 'Bip01 R Finger2Nub', 'Bip01 R Finger3Nub', 'Bip01 R Finger4Nub']) rightFingerBones = ["Bip01 R Finger1Nub", "Bip01 R Finger2Nub", "Bip01 R Finger3Nub", "Bip01 R Finger4Nub"] # for bone in fingerBones: for bone in leftFingerBones: finColObj = vizshape.addSphere(radius=0.005) viz.link(avatar.getBone(bone), finColObj) finColObj.collideSphere() finColObj.disable(viz.DYNAMICS) finColObj.disable(viz.RENDERING) leftHandIDs.append(finColObj.id) for bone in rightFingerBones: finColObj = vizshape.addSphere(radius=0.005) viz.link(avatar.getBone(bone), finColObj) finColObj.collideSphere() finColObj.disable(viz.DYNAMICS) finColObj.disable(viz.RENDERING) rightHandIDS.append(finColObj.id)
def addTrench(self): trench = viz.addGroup() leftWall = vizshape.addBox(size=[200, 200, 20000]) rightWall = vizshape.addBox(size=[200, 200, 20000]) floor = vizshape.addBox(size=[200, 2, 20000]) ceiling = vizshape.addBox(size=[200, 2, 20000]) m = viz.Matrix() m.postTrans(-200, 50, 2500) leftWall.setMatrix(m) m = viz.Matrix() m.postTrans(200, 50, 2500) rightWall.setMatrix(m) m = viz.Matrix() m.postTrans(0, -50, 2500) floor.setMatrix(m) m = viz.Matrix() m.postTrans(0, 125, 2000) ceiling.setMatrix(m) trenchTex = viz.addTexture('trench2.jpg') leftWall.texture(trenchTex) rightWall.texture(trenchTex) floor.texture(trenchTex) ceiling.visible(viz.OFF) leftWall.setParent(trench) rightWall.setParent(trench) floor.setParent(trench) ceiling.setParent(trench) obs1 = vizshape.addBox(size=[400, 175, 50]) obs1.setPosition(0, 60, 650) obs1.texture(trenchTex) obs1.setParent(trench) obs2 = vizshape.addBox(size=[250, 150, 50]) obs2.setPosition(-60, 0, 750) obs2.texture(trenchTex) obs2.setParent(trench) obs3 = vizshape.addBox(size=[400, 125, 50]) obs3.setPosition(0, -60, 950) obs3.texture(trenchTex) obs3.setParent(trench) obs4_1 = vizshape.addBox(size=[400, 100, 50]) obs4_1.setPosition(0, 100, 1100) obs4_1.texture(trenchTex) obs4_1.setParent(trench) obs4_2 = vizshape.addBox(size=[400, 75, 50]) obs4_2.setPosition(0, -10, 1100) obs4_2.texture(trenchTex) obs4_2.setParent(trench) obs5_1 = vizshape.addBox(size=[75, 200, 1000]) obs5_1.setPosition(50, 0, 2000) obs5_1.texture(trenchTex) obs5_1.setParent(trench) obs5_2 = vizshape.addBox(size=[75, 200, 1000]) obs5_2.setPosition(-50, 0, 2000) obs5_2.texture(trenchTex) obs5_2.setParent(trench) obs6_1 = vizshape.addBox(size=[400, 100, 1000]) obs6_1.setPosition(0, 100, 3000) obs6_1.texture(trenchTex) obs6_1.setParent(trench) obs6_2 = vizshape.addBox(size=[400, 50, 1000]) obs6_2.setPosition(0, -10, 3000) obs6_2.texture(trenchTex) obs6_2.setParent(trench) obs7_1 = vizshape.addBox(size=[75, 200, 1000]) obs7_1.setPosition(50, 0, 4000) obs7_1.texture(trenchTex) obs7_1.setParent(trench) obs7_2 = vizshape.addBox(size=[75, 200, 1000]) obs7_2.setPosition(-50, 0, 4000) obs7_2.texture(trenchTex) obs7_2.setParent(trench) obs8_1 = vizshape.addBox(size=[400, 100, 1000]) obs8_1.setPosition(0, 100, 5000) obs8_1.texture(trenchTex) obs8_1.setParent(trench) obs8_2 = vizshape.addBox(size=[400, 50, 1000]) obs8_2.setPosition(0, -10, 5000) obs8_2.texture(trenchTex) obs8_2.setParent(trench) obs9 = vizshape.addBox(size=[200, 200, 1000]) obs9.setPosition(-50, 0, 6000) obs9.texture(trenchTex) obs9.setParent(trench) obs10 = vizshape.addBox(size=[200, 200, 1000]) obs10.setPosition(0, 100, 7000) obs10.texture(trenchTex) obs10.setParent(trench) obs11 = vizshape.addBox(size=[200, 200, 1000]) obs11.setPosition(50, 0, 8000) obs11.texture(trenchTex) obs11.setParent(trench) obs12_1 = vizshape.addBox(size=[200, 200, 1000]) obs12_1.setPosition(0, -100, 9000) obs12_1.texture(trenchTex) obs12_1.setParent(trench) obs12_2 = vizshape.addBox(size=[200, 100, 1000]) obs12_2.setPosition(0, 100, 9000) obs12_2.texture(trenchTex) obs12_2.setParent(trench) obs13_1 = vizshape.addBox(size=[200, 200, 1000]) obs13_1.setPosition(0, -100, 10000) obs13_1.texture(trenchTex) obs13_1.setParent(trench) obs13_2 = vizshape.addBox(size=[150, 100, 1000]) obs13_2.setPosition(50, 50, 10000) obs13_2.texture(trenchTex) obs13_2.setParent(trench) obs13_1 = vizshape.addBox(size=[200, 200, 1000]) obs13_1.setPosition(0, -100, 11000) obs13_1.texture(trenchTex) obs13_1.setParent(trench) obs13_2 = vizshape.addBox(size=[150, 100, 1000]) obs13_2.setPosition(60, 50, 11000) obs13_2.texture(trenchTex) obs13_2.setParent(trench) obs13_3 = vizshape.addBox(size=[200, 100, 1000]) obs13_3.setPosition(0, 100, 11000) obs13_3.texture(trenchTex) obs13_3.setParent(trench) return trench
def add(avatar, appendage, skinChoices, skin, controlSchema): global isCube1, isCube2, thirdAppendage, usingInvisibleRod thirdAppendageHorn = viz.addGroup() if(appendage == 0): #Third Arm usingInvisibleRod = False thirdAppendage = viz.addChild(resources.ARM) if skin == 9: texture = viz.addTexture("skin_tones/010.png") texture.wrap(viz.WRAP_S,viz.REPEAT) texture.wrap(viz.WRAP_T,viz.REPEAT) else: texture = viz.addTexture("skin_tones/00" + skinChoices[skin] + ".png") texture.wrap(viz.WRAP_S,viz.REPEAT) texture.wrap(viz.WRAP_T,viz.REPEAT) thirdAppendage.texture(texture) thirdAppendage.emissive([.75, .75, .75]) thirdAppendage.setScale(resources.ARM_SCALE) elif(appendage == 1): #Cylinder usingInvisibleRod = False thirdAppendage = viz.addChild(resources.CYLINDER) thirdAppendage.setScale(resources.ARM_SCALE) # elif(appendage == 2): # #Floating hand # usingInvisibleRod = True # thirdAppendage = viz.addChild(resources.FLOATING_HAND) # thirdAppendage.setScale(resources.ARM_SCALE) # if skin == 9: # texture = viz.addTexture("skin_tones/010.png") # texture.wrap(viz.WRAP_S,viz.REPEAT) # texture.wrap(viz.WRAP_T,viz.REPEAT) # else: # texture = viz.addTexture("skin_tones/00" + skinChoices[skin] + ".png") # texture.wrap(viz.WRAP_S,viz.REPEAT) # texture.wrap(viz.WRAP_T,viz.REPEAT) # thirdAppendage.texture(texture) # thirdAppendage.emissive([.75, .75, .75]) # elif(appendage ==3): # #Floating Chunk # usingInvisibleRod = True # thirdAppendage = viz.addChild(resources.FLOATING_CHUNK) # thirdAppendage.setScale(resources.ARM_SCALE) thirdAppendage.setParent(thirdAppendageHorn) global tahLink tahLink = viz.link(avatar.getBone('Bip01 Spine'), thirdAppendageHorn) global offsetOp offsetOp = tahLink.preTrans([0, 0.3, 0.1]) tahLink.preEuler([-90.0, 0.0, 0.0]) thirdAppendage.collideBox() thirdAppendage.disable(viz.DYNAMICS) TouchCube.thirdAppendage = thirdAppendage # EXTENSION: Add third appendage movement via intersense cube isense = viz.add('intersense.dle') isCube1 = isense.addTracker(port=6) isCube2 = isense.addTracker(port=7) # Link cubes pptextensionDK2.isCube1 = isCube1 pptextensionDK2.isCube2 = isCube2 # Setup thirdarm updating. #vizact.onupdate(0, updateThirdArm) #Control schema switch if (controlSchema == 0): vizact.onupdate(0, controlWithWristRotation) elif (controlSchema == 1): setupBimanualAsymmetricControl()
Laptop.setScale([.03,.03,.03]) Laptop.setEuler([-10,0,0]) avatar = viz.addAvatar('vcc_male2.cfg',pos=[-5.7,-5.2,0]) avatar.state(1) sofa=viz.addChild('F:\Objects\max\obj2.ive') sofa.setScale([.030,.030,.030]) sofa.setPosition([-9.2,0.15,-0]) sofa.setEuler([-90,0,0]) #stand=viz.addChild('F:\Objects\max\obj1.ive') #stand.setScale([.00030,.00030,.00030]) #stand.setPosition([-0,0.15,-0]) #stand.setEuler([0,0,0]) shadow_texture = viz.addTexture('shadow.png') shadow = vizshape.addQuad(parent=avatar,axis=vizshape.AXIS_Y) shadow.texture(shadow_texture) shadow.zoffset() avatarMove = [[-5.7,-5.2,300],[-5.7,6.5,270],[0,8,0],[5.7,6.5,70],[5.7,2.6,70],[5.7,1,130]] actions = [] RandomWait = vizact.waittime(vizact.randfloat(0,0)) for loc in avatarMove: if loc == avatarMove[2]: RandomWait = vizact.waittime(vizact.randfloat(5,10)) else: RandomWait = vizact.waittime(vizact.randfloat(0,0)) actions.append(vizact.method.playsound('footsteps.wav',viz.LOOP))
vizact.onupdate(0, UpdateTexture) global hmd view = viz.addView hmd = oculus.Rift() hmd.getSensor() # Setup navigation node and link to main view #this code is unique from previous revisions global navigationNode navigationNode = viz.addGroup() viewLink = viz.link(navigationNode, viz.MainView) viewLink.preMultLinkable(hmd.getSensor(), mask=viz.LINK_ORI) ####################################### im = viz.addTexture('Logo_final.jpg') #im2 = viz.addTexture('Logo_final.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) hmrl = viz.addChild('HMRL9.osgb') hmrl.setPosition(0, 0, 0)
#open data file & record par data def Data(): global datafile datafile = open("NewAngleData/%d.txt" % (IDNum), "w") datafile.write("Participant %d " % (IDNum)) datafile.write('\n') datafile.write("Age EyeHeight Gender Units") datafile.write('\n') datafile.write("%d " % (age)) datafile.write("%d " % (EHNum)) datafile.write("%s " % (data.gender)) datafile.write("%s" % (data.units)) #Load textures plaster = viz.addTexture('CeilingLarge.jpg') wallpaper = viz.addTexture('WallpaperLarge.jpg') wallpaperlong = viz.addTexture('WallpaperLong.jpg') carpet = viz.addTexture('CarpetLarge3.jpg') wood = viz.addTexture('Door.jpg') mask_img = viz.addTexture('Masktiny.jpg') #Create skylight viz.MainView.getHeadLight().disable() sky_light = viz.addLight(euler=(0, 90, 0)) #euler = yaw, pitch, roll sky_light.position(2, 0, -1, 0) sky_light.color(viz.WHITE) sky_light.intensity(2) #Create backlight back_light = viz.addLight(euler=(0, 215, 0)) #euler = yaw, pitch, roll
#check vizard4/bin/vizconfig to change which monitor displays the VR window viz.splashScreen('C:\Users\Gelsey Torres-Oviedo\Desktop\VizardFolderVRServer\Logo_final.jpg') 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')
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', pos=[0.00, 1.19, 2], align=viz.ALIGN_CENTER_BOTTOM, color=viz.WHITE, scale=[0.17, 0.2, 1], font='Times New Roman') # 画像の表示 pic = viz.addTexture('resource/logo.png') quad = viz.addTexQuad() quad.setSize([500 * 0.002, 688 * 0.002]) quad.setPosition([0, 1.8, 1.98]) #put quad in view quad.texture(pic) quad.alpha(0) def Logo(): '''ロゴの表示''' viztask.schedule(logo_start()) def logo_start(): sound = viz.addAudio('sound/Omega-FlyHyperspace.wav') sound.play()
def displayHeatmap(project=True): ''' - Load accumulated view textures - Add cube projector with given textures and shader converting intensities to heat map colors - Let projector affect scene - auto_update = True will set the shader uniforms automatically each frame ''' import viz import vizact import vizcam viz.setMultiSample(4) viz.go() #vizcam.WalkNavigate() if project: piazza = viz.addChild('piazza.osgb') cube_textures = { viz.POSITIVE_X: viz.addTexture('accumulated_p_x.bmp'), viz.NEGATIVE_X: viz.addTexture('accumulated_n_x.bmp'), viz.POSITIVE_Y: viz.addTexture('accumulated_p_y.bmp'), viz.NEGATIVE_Y: viz.addTexture('accumulated_n_y.bmp'), viz.POSITIVE_Z: viz.addTexture('accumulated_p_z.bmp'), viz.NEGATIVE_Z: viz.addTexture('accumulated_n_z.bmp') } heat_projector = HeatmapVisualizer(cube_textures, auto_update=True) heat_projector.setPosition(viz.MainView.getPosition()) heat_projector.affect(piazza) ## GUI for manipulation of the output heatmap i_slider = viz.addSlider() i_x = 1.0 - i_slider.getBoundingBox().width / 2.0 i_y = 0.0 + i_slider.getBoundingBox().height / 2.0 i_slider.setPosition([i_x, i_y, 0]) i_slider.set(0.5) i_text = viz.addText('intensity scale', parent=viz.SCREEN) i_text.setPosition([ i_x - i_text.getBoundingBox().width / 2 - i_slider.getBoundingBox().width / 2, 0.01, 0.0 ]) i_text.setScale([0.4, 0.4, 1.0]) def onSlider(obj, pos): if obj == i_slider: heat_projector.setIntensityScale(pos + 0.5) viz.callback(viz.SLIDER_EVENT, onSlider) else: import vizshape env = viz.addEnvironmentMap( 'accumulated.bmp', faces=['_p_x', '_n_x', '_p_y', '_n_y', '_p_z', '_n_z']) sb = vizshape.addSkyBox() sb.texture(env)
import Message_V2 from Annotations import AnnotationManager from DataSet import * import Gradient import TransferFunction_V2 as TransferFunction import math import SponsorOverlay import UVWTransform sponsor_overlay = SponsorOverlay.SponsorOverlay( viz.addTexture('RowanLogos\\VRLabTitle.png') ) messageManager = MessageManager() #Create shaders shader_gradient = GShader_Histogram_Lighting() shader_transfer = GShader_Transfer() #data = dataHeadScanSpindles data = dataFullBodyThresholded #data = dataSiemensHighRes_Masked #Create Volumetric Texture textureList = T3DLoading.loadImages( data.imageDirectory ) texDescriptor = T3DLoading.VizTextureDescriptor() texDescriptor.populateFromVizTexture( textureList[0] )
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)
import viz import vizmat viz.go() #create two textures # background color viz.clearcolor(viz.SKYBLUE) fName = 'textures\\strong_edge_redoutline.bmp' gtexture = viz.addTexture(fName) gtexture.wrap(viz.WRAP_T, viz.REPEAT) gtexture.wrap(viz.WRAP_S, viz.REPEAT) gplane1 = viz.addTexQuad() ## tilesize = 5 planesize = tilesize / 5.0 gplane1.setScale(tilesize, tilesize * 2, tilesize) gplane1.setEuler((0, 90, 0), viz.REL_LOCAL) texture_z_size = tilesize * 2 matrix = vizmat.Transform() matrix.setScale(planesize, planesize * 2, planesize) gplane1.texmat(matrix) gplane1.texture(gtexture) gplane1.visible(1) #create second texture fName2 = 'textures\\strong_edge_blueoutline.bmp'
keepsize = settings[u'keepsize'][0] cuelen = settings[u'cuelen'][0] textList = settings[u'controlCommand'] textposition = settings[u'textposition'] position = settings[u'position'] #framerate = settings[u'framerate'][0] framerate = 60.0 cueseries = settings[u'cueSeries'] #Set the video window size videoSquareSize = [12.8, 7.2] videoSquarePos = [0, 0, 19] viz.setMultiSample(4) pic = viz.addTexture('texture.jpg') viz.window.setFullscreenMonitor(viz.AUTO_COMPUTE) viz.go(viz.FULLSCREEN) viz.MainWindow.fov(60) viz.MainView.setPosition(0, 0, 3) attitudeDirector = viz.addChild('attitude.obj') attitudeDirector.setPosition(0, 0, 14) attitudeDirector.color([0, 1, 0]) attitudeDirector.setAxisAngle([0, 1, 0, 90]) attitudeDirector.setScale([0.2, 0.2, 0.2]) attitudeDirector.visible(viz.ON) quadBack = viz.addTexQuad(size=videoSquareSize) quadBack.setPosition(videoSquarePos)
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"
#trials per object trials_per_object = 4 initial_collect_per_object = 2 #timing ITI = 2 #intertrial interval, in seconds ##env shape global radius radius = 14.5 #in meters, made global for convenience so be careful ##ground ground = vizshape.addPlane(size=(40.0, 40.0), axis=vizshape.AXIS_Y) ground.setPosition(0, 0, 0) t1 = viz.addTexture('tex2.jpg', wrap=viz.REPEAT) ground.texture(t1) ground.texmat(viz.Matrix.scale(20, 20, 1)) ##sky color viz.clearcolor(0.1, 0.1, 0.2) ###CONTEXT GEN FUNCTION#### def ContextGen(runNum): if runNum % 2 == 0: if subject % 2 == 0: context = 1 else:
""" The disappearing cross task reimplemented from Blascovich & Katkin 1993. [email protected] """ from fmri_trigger import TRIGGER_EVENT, RIGHT_BUTTON_EVENT, LEFT_BUTTON_EVENT import viz, vizact, viztask, vizinfo # Images cue = viz.addTexture("images/cue.png") hbar = viz.addTexture("images/hbar.png") vbar = viz.addTexture("images/vbar.png") cross = viz.add("images/cross.png") # Sounds correct_sound = viz.addAudio("images/beep-8.wav") 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):
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): viz.EventClass.__init__(self) # curve that represents the track self.track = CoasterCurve() # controls the camera's view in 3rd person self.rotateView = 0 self.distView = -200 self.view = 3 # Environment map - puts the scene inside a large box and # texture maps sky images onto the six box sides. sky = viz.add(viz.ENVIRONMENT_MAP, 'sky.jpg') skybox = viz.add('skydome.dlc') skybox.texture(sky) # Create a coaster car consisting of a box with a spherical cap in front. # The front of the car faces down the -Z axis. self.car = viz.addGroup() c1 = vizshape.addBox([2, 2, 4], color=viz.GREEN) m = viz.Matrix() m.postTrans(0, 1, 0) # raise bottom of box to XY plane c1.setMatrix(m) c1.setParent(self.car) c1 = vizshape.addBox([1, 2, 1.9], color=viz.BLACK) m = viz.Matrix() m.postTrans(0, 1.5, 1) c1.setMatrix(m) c1.setParent(self.car) c2 = vizshape.addSphere(radius=1, color=viz.YELLOW) m = viz.Matrix() m.postTrans(0, 1, -2) # move to front of box c2.setMatrix(m) c2.setParent(self.car) viz.startLayer(viz.LINE_STRIP) viz.vertexColor(viz.BLACK) for i in range(1, 928): temp = self.track.getLocationAtDist(i) viz.vertex(temp) self.lineStrip = viz.endLayer() self.tunnel = vizshape.addCylinder(height=75, radius=10, bottom=False, top=False, cullFace=False) m = viz.Matrix() m.postAxisAngle(1, 0, 0, 90) m.postMult(self.track.getCurOrient()) m.postTrans(self.track.getCurLocation()) m.postTrans(75, 0, 0) self.tunnel.setMatrix(m) self.tunnelText = viz.addTexture('tunnel.jpg') self.tunnel.texture(self.tunnelText) # set key board callback function self.callback(viz.KEYDOWN_EVENT, self.onKeyDown) # call keyboard callback to initialize the view to 3rd person self.onKeyDown("3")
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')