def monsterMove(self): self.shortest = 9999 self.decidedX = -1 self.decidedZ = -1 if (self.monX == self.x and self.monZ == self.z): self.EndGame = True t = viz.addText("Total Points: " + str(self.points), viz.SCREEN, pos=[0, 0, 0]) p = viz.addText(str(self.points), viz.SCREEN, pos=[5, 0, 0]) if (self.EndGame == False): if (self.x > self.monX and self.maze[int(self.monX + 1)][int(self.monZ)] != 4): self.monX = self.monX + 1 elif (self.x < self.monX and self.maze[int(self.monX - 1)][int(self.monZ)] != 4): self.monX = self.monX - 1 elif (self.z > self.monZ and self.maze[int(self.monX)][int(self.monZ + 1)] != 4): self.monX = self.monX + 1 elif (self.z < self.monZ and self.maze[int(self.monX)][int(self.monZ - 1)] != 4): self.monZ = self.monZ - 1 elif (self.monX == self.x and self.monZ == self.z): self.EndGame = True m = viz.Matrix() m.postTrans(int(self.monX), self.monY, int(self.monZ)) self.monster.setMatrix(m)
def __init__(self): #init canvas and create themes for the test panel self.canvas = viz.addGUICanvas(align = viz.ALIGN_CENTER_CENTER) self.canvas.setPosition(0,0,0) viz.mouse.setVisible(False) self.name = 'test' self._theme = viz.Theme() self._theme.borderColor = (0.1,0.1,0.1,1) self._theme.backColor = (0.4,0.4,0.4,1) self._theme.lightBackColor = (0.6,0.6,0.6,1) self._theme.darkBackColor = (0.2,0.2,0.2,1) self._theme.highBackColor = (0.2,0.2,0.2,1) self._theme.textColor = (1,1,1,1) self._theme.highTextColor = (1,1,1,1) #initialize test panel vizdlg.Panel.__init__(self, parent = self.canvas, theme = self._theme, align = viz.ALIGN_CENTER_TOP, fontSize = 15) self.visible(viz.OFF) self.setScale(*[i*config.menuScale[self.name] for i in [1,1,1]]) self.alpha(0.6) # #title title = vizdlg.TitleBar('INSTRUCTIONS') self.addItem(title, align = viz.ALIGN_CENTER_TOP) #bones to be snapped. source snapped to target. source = 'a'*20 self.sourceText = viz.addTextbox(parent = self.canvas) self.sourceText.setLength(1.5) target = 'a'*20 self.targetText = viz.addTextbox(parent = self.canvas) self.targetText.setLength(1.5) #instructions self.Instruct1 = self.addItem(viz.addText('Snap the: ', parent = self.canvas), align = viz.ALIGN_CENTER_TOP) self.sourceCommand = self.addItem(self.sourceText, align = viz.ALIGN_CENTER_TOP) self.Instruct2 = self.addItem(viz.addText('To the: ', parent = self.canvas), align = viz.ALIGN_CENTER_TOP) self.targetCommand = self.addItem(self.targetText, align = viz.ALIGN_CENTER_TOP) #render canvas if config.dispMode == config.DisplayMode.monitor: self.canvas.billboard(viz.BILLBOARD_YAXIS) self.canvas.setPosition(-2,0,0) self.canvas.setBackdrop(viz.ALIGN_CENTER_TOP) if config.dispMode == config.DisplayMode.oculus: bb = self.canvas.getBoundingBox() self.canvas.setRenderWorldOverlay([bb.width*1, bb.height*1], fov = bb.height, distance = 0.4) self.canvas.setPosition(0,0.05,0) self.canvasViewPos = self.canvas.getPosition() self.canvas.setEuler(0,15,0) self.canvas.setPosition(0, -5, 0) self.canvasHidePos = self.canvas.getPosition() viztask.schedule(self.updatePanelPos()) vizact.onkeydown(viz.KEY_ESCAPE, self.toggle)
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, canvas, controller): super(ModeMenu, self).__init__(canvas, 'mode', 'Mode Selection') # Store controller instance self.controller = controller #Store modes from config to populate modemenu with self.modes = config.MenuConfig.Modes self.getPanel().fontSize(50) ########################## """creating modes panel""" ########################## #creating labels for modes self.modeLabels = {} for l in self.modes.iterkeys(): self.modeLabels[l] = viz.addText(l, parent=canvas) #creating radio buttons for modes self.modeGroup = viz.addGroup(parent=canvas) self.radioButtons = {} for rb in self.modes.iterkeys(): self.radioButtons[rb] = viz.addRadioButton(self.modeGroup, parent=canvas) self.radioButtons['Free Play'].set(1) #creating grid panel to add mode to modeGrid = vizdlg.GridPanel(parent=canvas) #adding modes and radio buttons to grid panel for i in self.modes.iterkeys(): modeGrid.addRow([self.modeLabels[i], self.radioButtons[i]]) ############################## """next and back buttons""" ############################## #creating grid panels to add next and back buttons to setGrid = vizdlg.GridPanel(parent=canvas) #create back and next buttons and add to grid panel backButton = viz.addButtonLabel('Back') startButton = viz.addButtonLabel('Next') setGrid.addRow([backButton, startButton]) #add back and state button actions self.backward = vizact.onbuttondown(backButton, self.controller.backMenu) self.forward = vizact.onbuttondown(startButton, self.controller.nextMenu) ############################### """add items to ModeMenu""" ############################### self.addItem(modeGrid) self.addItem(setGrid)
def __init__(self): viz.EventClass.__init__(self) self.done = viztask.Signal() self.callback(viz.BUTTON_EVENT, self.onButton) self.rowantext = """ Charactor Creation Enter Your Charactor's name: """ vizcam.PivotNavigate(center=[15, -10, 0], distance=70, sensitivity=[1.0, 1.0]) self.text_2D_world = viz.addText(self.rowantext, pos=[2, 2, 2], scene=2) self.myButton2 = viz.addButtonLabel('Done!', scene=2) #Add a button. self.myButton2.setPosition(.5, .5) #Set its position. self.myButton2.setScale(1, 1) #Scale it. #Add a text box. self.box = viz.addTextbox(scene=2) #self.box.message('default') #Make it twice as long. self.box.length(2) #Place it in window. self.box.setPosition(.5, .8) #Have it grow when text reaches its boundary. self.box.overflow(viz.OVERFLOW_GROW)
def staticCalibrationMethod(self): if ( self.calibrationInProgress == False ): self.calibrationBlockCounter += 100 self.toggleRoomWallsVisibility() self.calibrationInProgress = True self.calibrationCounter = 0 self.calibrationSphereRadius = self.initialValue self.calibrationSphere = vizshape.addSphere(self.calibrationSphereRadius, color = viz.PURPLE) self.calibrationSphere.emissive(viz.PURPLE) self.calibrationSphere.setParent(self.parentNode) self.setSphereRadius(self.parentNode.getPosition(viz.ABS_GLOBAL), self.calibrationPositions[self.calibrationCounter,:], 0) print 'FirstPos', self.calibrationPositions[self.calibrationCounter,:] newPos = [self.calibrationPositions[self.calibrationCounter,0], self.calibrationPositions[self.calibrationCounter,1], self.calibrationPositions[self.calibrationCounter,2]] self.calibrationSphere.setPosition(newPos[0], newPos[1], newPos[2],viz.ABS_PARENT) self.text_object = viz.addText('') self.text_object.setParent(self.calibrationSphere) self.text_object.renderOnlyToWindows([self.renderToWindows]) self.localAction = vizact.onupdate(viz.PRIORITY_INPUT+1,self.calculateAngularError, self.cyclopEyeSphere.node3D, 0.0, self.text_object)#self.currentTrial.ballObj.node3D print 'Static Calibration Started' else: self.calibrationInProgress = False self.calibrationCounter = 0 self.calibrationSphere.remove() self.localAction.remove() self.text_object.remove() self.toggleRoomWallsVisibility() print 'Quit Static Calibration!!'
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): # create simple GUI window with buttons for: pause, continue and a window to print strings self.pause_button = viz.addButtonLabel('pause Experiment') self.pause_button.setPosition(.5, .7) self.pause_button.setScale(2, 2) self.continue_button = viz.addButtonLabel('continue Experiment') self.continue_button.setPosition(.5, .5) self.continue_button.setScale(2, 2) self.text_screen = viz.addText('current marker:', viz.SCREEN) self.text_screen.setPosition(.25, .3) self.marker_field = viz.addButtonLabel('markers') self.marker_field.setPosition(.5, .2) self.marker_field.setScale(2, 2) # register callbacks for GUI to either pause or continue function viz.callback(viz.BUTTON_EVENT, self.on_button_press) # create network outlet self.connection_to_vr_machine = viz.addNetwork('BPN-C043') # register callback for network event handling viz.callback(viz.NETWORK_EVENT, self.write) # send behavioral to LSL stream (saved extra for faster testing of behavioral data) # create and start LSL marker stream self.behavior_stream_info = StreamInfo('BehavioralMarkerStream', 'Markers', 1, 0, 'string', socket.gethostname()) self.behavior_stream = StreamOutlet(self.behavior_stream_info)
def textScreen2(): textScreen = viz.addText( 'school bus, students who are travelling in this bus are rich and excellent in studies', viz.SCREEN) textScreen.alignment(viz.ALIGN_RIGHT_BOTTOM) textScreen.setPosition([0.95, 0.05, 0])
def strippedTrialTask(avatar, turningAngle, vLinear, tLegs, idxTrial, output = {}): """ master task that invokes all other tasks as subtasks to ensure right order """ # add text for instructions screenText = viz.addText('trial no. '+str(idxTrial),viz.SCREEN) screenText.setBackdrop(viz.BACKDROP_RIGHT_BOTTOM) screenText.setBackdropColor(viz.GRAY) screenText.setPosition(0.05, 0.5) # wait for key press and execute trial yield viztask.waitKeyDown(' ') screenText.message('') passage = passageAction(turningAngle, vLinear, tLegs) avatar.addAction(passage) yield viztask.waitActionEnd(avatar, passage) # get homing vectors yield helperFunctions.saveHomingVectors(avatar, output) print output # post trial instructions & position reset yield viztask.waitTime(0.2) screenText.message('please select your\nanswer for trial '+str(idxTrial)) yield viztask.waitKeyDown(' ') screenText.remove() yield helperFunctions.resetTask(avatar)
def __init__(self, Cave): viz.EventClass.__init__(self) #self.__speed = 0.223 #metres per frame. equates to 13.4 m/s therefore 30mph. #8ms = 8/60 = .1333 self.__speed = 8.0 #m./s self.__heading = 0.0 self.__pause = -50 #pauses for 50 frames at the start of each trial self.__view = Cave # self.__view = viz.MainView.setPosition(0,1.20,0) #Grabs the main graphics window # self.__view = viz.MainView # self.__view.moverelative(viz.BODY_ORI) self.__automation = False self.__dir = 1.0 # direction of the vehicle (+: ) #self.callback(viz.TIMER_EVENT,self.__ontimer) self.callback(viz.KEYDOWN_EVENT, self.keyDown) #enables control with the keyboard self.callback(vizjoy.BUTTONDOWN_EVENT, self.joyDown) self.callback(vizjoy.MOVE_EVENT, self.joymove) #self.txtSWA = viz.addText("SWA",parent=viz.SCREEN) self.txtSWA = viz.addText(" ", parent=viz.SCREEN) self.txtSWA.setPosition(.45, .4) self.txtSWA.fontSize(36) #self.starttimer(0,0,viz.FOREVER) global joy joy = vizjoy.add()
def updateLevelText(self): self.levelText.remove() self.levelMsg = "Level: " + str(self.level) self.levelText = viz.addText(self.levelMsg, viz.SCREEN, pos=[.15, .95, 0]) self.levelText.fontSize(33)
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 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 __init__(self): self.targetNumber = 3 self.maxNum = 7 self.buffSize = 7 self.updateRateSecs = 0.75 self.nextBuffer = np.array([]) self.lastBuffer = [] while(self.nextBuffer.size < self.buffSize): self.addInt() self.textObj = viz.addText('',parent=viz.SCREEN) self.textObj.setPosition(0.5,0.5) self.textObj.color(viz.WHITE) self.textObj.alignment( viz.ALIGN_CENTER_CENTER) self.textObj.fontSize(1000) self.targetTimer = [] self.updateAction = vizact.ontimer(self.updateRateSecs,self.presentNumber) self.stopPresentingNumbers() print 'Ready. To start countdown, run <numberCount>.startPresentingNumbers()'
def updateScoreText(self): self.scoreText.remove() self.scoreMsg = "Score: " + str(self.score) self.scoreText = viz.addText(self.scoreMsg, viz.SCREEN, pos=[.45, .95, 0]) self.scoreText.fontSize(33)
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 __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 display_fix(): fixation_cross = viz.addText('+', viz.SCREEN) fixation_cross.fontSize(72) fixation_cross.setPosition(.5, .5) yield viztask.waitTime(5) yield fixation_cross.remove()
def textScreen1(): textScreen = viz.addText( 'This is a new public school. students in this school are very intelligent', viz.SCREEN) textScreen.alignment(viz.ALIGN_RIGHT_BOTTOM) textScreen.setScale(0.2, 0.2, 0.2) textScreen.setPosition([0.95, 0.05, 0])
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 __init__(self, canvas, controller): super(ModeMenu, self).__init__(canvas, 'mode', 'Mode Selection') # Store controller instance self.controller = controller #Store modes from config to populate modemenu with self.modes = config.MenuConfig.Modes self.getPanel().fontSize(50) ########################## """creating modes panel""" ########################## #creating labels for modes self.modeLabels = {} for l in self.modes.iterkeys(): self.modeLabels[l] = viz.addText(l, parent = canvas) #creating radio buttons for modes self.modeGroup = viz.addGroup(parent = canvas) self.radioButtons = {} for rb in self.modes.iterkeys(): self.radioButtons[rb] = viz.addRadioButton(self.modeGroup, parent = canvas) self.radioButtons['Free Play'].set(1) #creating grid panel to add mode to modeGrid = vizdlg.GridPanel(parent = canvas) #adding modes and radio buttons to grid panel for i in self.modes.iterkeys(): modeGrid.addRow([self.modeLabels[i], self.radioButtons[i]]) ############################## """next and back buttons""" ############################## #creating grid panels to add next and back buttons to setGrid = vizdlg.GridPanel(parent = canvas) #create back and next buttons and add to grid panel backButton = viz.addButtonLabel('Back') startButton = viz.addButtonLabel('Next') setGrid.addRow([backButton, startButton]) #add back and state button actions self.backward = vizact.onbuttondown(backButton, self.controller.backMenu) self.forward = vizact.onbuttondown(startButton, self.controller.nextMenu) ############################### """add items to ModeMenu""" ############################### self.addItem(modeGrid) self.addItem(setGrid)
def __init__(self): """Init canvas and create themes for the test panel""" self.canvas = viz.addGUICanvas(parent = viz.ABS_GLOBAL) viz.mouse.setVisible(False) self.name = 'test' self._theme = viz.Theme() self._theme.borderColor = (0.1,0.1,0.1,1) self._theme.backColor = (0.4,0.4,0.4,1) self._theme.lightBackColor = (0.6,0.6,0.6,1) self._theme.darkBackColor = (0.2,0.2,0.2,1) self._theme.highBackColor = (0.2,0.2,0.2,1) self._theme.textColor = (1,1,1,1) self._theme.highTextColor = (1,1,1,1) # Initialize test panel vizdlg.Panel.__init__(self, parent = self.canvas, theme = self._theme, align = viz.ALIGN_CENTER, fontSize = 10) self.visible(viz.OFF) self.setScale(*[i*config.menuScale[self.name] for i in [1,1,1]]) # Title title = vizdlg.TitleBar('INSTRUCTIONS') self.addItem(title, align = viz.ALIGN_CENTER_TOP) # Bones to be snapped. source snapped to target. self.sourceText = viz.addTextbox(parent = self.canvas) self.sourceText.setLength(1.5) self.targetText = viz.addTextbox(parent = self.canvas) self.targetText.setLength(1.5) # Instructions self.Instruct1 = self.addItem(viz.addText('Snap the: ', parent = self.canvas), align = viz.ALIGN_CENTER_TOP) self.sourceCommand = self.addItem(self.sourceText, align = viz.ALIGN_CENTER_TOP) self.Instruct2 = self.addItem(viz.addText('To the: ', parent = self.canvas), align = viz.ALIGN_CENTER_TOP) self.targetCommand = self.addItem(self.targetText, align = viz.ALIGN_CENTER_TOP) # Render canvas bb = self.getBoundingBox() self.canvas.setRenderWorld([bb.height, bb.width],[4, 3*1.333]) # On esc toggle menu (doesn't interfere with in-game menu) # vizact.onkeydown(viz.KEY_ESCAPE, self.toggle) self.canvas.setPosition(0.0,2.0,4.0) self.canvas.resolution(self.canvas.getResolution())
def __update(self): msg = viz.addText("", parent=viz.SCREEN) t0 = 0 #for testing self.device.softReset() yield viztask.waitTime(1) print "Zeroing treadmill ... ", self.doZero() print "done" print "Started treadmill forceplates read" while self.going: results = self.device.getFeedback( self.feedbackArguments ) for j in range(self.numChannels): self.latestAinValues[j] = self.device.binaryToCalibratedAnalogVoltage(self.gainIndex, results[2+j]) self.lastForceMoments = list(self.latestForceMoments) self.latestForceMoments = self.M.dot(self.latestAinValues+self.zero) self.lastLeftOn = self.latestLeftOn self.lastRightOn = self.latestRightOn self.lastLeftCOP = list(self.latestLeftCOP) self.lastRightCOP = list(self.latestRightCOP) self.lastTime = self.latestTime self.latestTime = viz.tick() try: self.latestLeftOn = (self.latestForceMoments[2] < MIN_WEIGHT_NEWTONS) self.latestLeftCOP[0] = -1.0*self.latestForceMoments[4]/self.latestForceMoments[2] self.latestLeftCOP[1] = self.latestForceMoments[3]/self.latestForceMoments[2] self.latestRightOn = (self.latestForceMoments[8] < MIN_WEIGHT_NEWTONS) self.latestRightCOP[0] = -1.0*self.latestForceMoments[10]/self.latestForceMoments[8] self.latestRightCOP[1] = self.latestForceMoments[9]/self.latestForceMoments[8] except(ZeroDivisionError): print "div zero caught in ForcePlate ... ignoring" pass if self.recording: #self.data.append([viz.tick(), [x for x in self.latestAinValues]]) self.data.append([viz.tick(), [x for x in self.latestForceMoments]]) if self.lastLeftOn and not self.latestLeftOn: viz.sendEvent(LEFT_OFF_TREADMILL) if not self.lastLeftOn and self.latestLeftOn: viz.sendEvent(LEFT_ON_TREADMILL) if self.lastRightOn and not self.latestRightOn: viz.sendEvent(RIGHT_OFF_TREADMILL) if not self.lastRightOn and self.latestRightOn: viz.sendEvent(RIGHT_ON_TREADMILL) #testing t1 = t0 t0 = viz.tick() #msg.message("%3.3fs"%(t0-t1)) #msg.message("%6.3f %6.3f"%(self.latestLeftCOP[0], self.latestLeftCOP[1])) #if self.lastLeftOn: # msg.message("Left on") #elif self.lastRightOn: # msg.message("Right on") yield None
def dynamicCalibrationMethod(self): if ( self.calibrationInProgress == False ): self.calibrationInProgress = True self.toggleRoomWallsVisibility() self.calibrationCounter = 27 self.calibrationSphereRadius = self.initialValue self.calibrationSphere = vizshape.addSphere(self.calibrationSphereRadius, color = viz.PURPLE) self.calibrationSphere.emissive(viz.PURPLE) self.calibrationSphere.setParent(self.parentNode) newPos = [-3,-.5,12] self.setSphereRadius(self.parentNode.getPosition(viz.ABS_GLOBAL), newPos, 0) self.calibrationSphere.setPosition(newPos[0], newPos[1], newPos[2],viz.ABS_PARENT) self.targetMovingAction = vizact.onupdate(viz.PRIORITY_INPUT+1, self.checkActionDone) self.text_object = viz.addText('') self.text_object.setParent(self.calibrationSphere) self.text_object.renderOnlyToWindows([self.renderToWindows]) self.localAction = vizact.onupdate(viz.PRIORITY_INPUT+1,self.calculateAngularError, self.cyclopEyeSphere.node3D, 0.0, self.text_object)#self.currentTrial.ballObj.node3D print 'Dynamic Calibration Procedure Started' #Use a moveTo action to move a node to the point [0,0,25] at 2 meters per second self.moveAction = vizact.moveTo([-3,-0.5,12],speed=2) self.calibrationSphere.addAction(self.moveAction) self.moveAction = vizact.moveTo([3,-0.5,12],speed=2) self.calibrationSphere.addAction(self.moveAction) self.moveAction = vizact.moveTo([3,3,12],speed=2) self.calibrationSphere.addAction(self.moveAction) self.moveAction = vizact.moveTo([-3,3,12],speed=2) self.calibrationSphere.addAction(self.moveAction) self.moveAction = vizact.moveTo([-3,-0.5,12],speed=2) self.calibrationSphere.addAction(self.moveAction) self.moveAction = vizact.moveTo([-3,-0.5,6],speed=2) self.calibrationSphere.addAction(self.moveAction) self.moveAction = vizact.moveTo([3,-0.5,6],speed=2) self.calibrationSphere.addAction(self.moveAction) self.moveAction = vizact.moveTo([3,3,6],speed=2) self.calibrationSphere.addAction(self.moveAction) self.moveAction = vizact.moveTo([-3,3,6],speed=2) self.calibrationSphere.addAction(self.moveAction) self.moveAction = vizact.moveTo([-3,0,6],speed=2) self.calibrationSphere.addAction(self.moveAction) else: self.localAction.remove() self.text_object.remove() self.calibrationInProgress = False self.calibrationCounter = 0 self.calibrationSphere.remove() self.toggleRoomWallsVisibility() print 'Quit Dynamic Calibration!!'
def create_text2d(message='Bitte Warten', position=[0, 1, 4]): # Text instructions for participant. text2D = viz.addText(message, pos=position) text2D.alignment(viz.ALIGN_CENTER_BOTTOM) text2D.setBackdrop(viz.BACKDROP_RIGHT_BOTTOM) text2D.resolution(1) text2D.fontSize(1) text2D.setScale([0.2] * 3) text2D.disable(viz.LIGHTING) text2D.color(0, 0, 0) return text2D
def expertise_maze(): # setup viewpoint and positioning yield setup_view() # declare globals global signal global collide_coords global movement_time global coordinate_array global maze # clear the coordinate array coordinate_array = array([]) # Setup the objection "collision" signal = viztask.Signal() collide_coords = end_coords # Show instructions and wait for user signal until they are removed instructions = viz.addText('Please navigate to the blue wall', viz.SCREEN) instructions.fontSize(42) instructions.setPosition(.5, .5) instructions.alignment(viz.TEXT_CENTER_CENTER) yield viztask.waitKeyDown('m') instructions.remove() # show user fixation cross yield display_fix() # Load the maze maze_name = maze_root + '.IVE' maze = viz.add(maze_name) maze.visible(viz.OFF) yield maze.visible(viz.ON) # enable all of the global events joy_timer.setEnabled(viz.ON) coor_timer.setEnabled(viz.ON) write_onkey.setEnabled(viz.ON) quit_onkey.setEnabled(viz.ON) pos_timer.setEnabled(viz.ON) # reset and start the clock movement_time = TickTockTimer() movement_time.StartTimer() # wait for "collision" signal yield signal.wait() #disable and quit disable() write_trial_data() maze.remove()
def StartRun(runNum, openMess, closeMess): if openMess: viz.MainWindow.setScene(2) if runNum % 2 == 0: con = 2 else: con = 1 Message = 'Press t to start training in Arena ' + str(con) #info info = viz.addText(Message, viz.SCREEN, scene=2) info.fontSize(36) info.color(viz.WHITE) info.setPosition([0.3, 0.5, 0]) info.visible(1) #wait for response yield viztask.waitKeyDown(['t', 'T']) info.visible(0) yield viztask.waitTime(ITI - 1) else: viz.MainWindow.setScene(2) Message = 'Good job!' #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) yield viztask.waitTime(ITI) info.visible(0) if closeMess: Message = 'Training Complete. Please get experimenter' #info info = viz.addText(Message, viz.SCREEN, scene=2) info.fontSize(36) info.color(viz.WHITE) info.setPosition([0.3, 0.5, 0]) info.visible(1) yield viztask.waitTime(ITI) info.visible(0)
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 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 onTimer(self, num): if (num == 1): carPos = self.car.getPosition() circPos = self.circ.getPosition() print("pos[0]: " + (str)(carPos[0])) print("pos[2]: " + (str)(carPos[2])) if (carPos[0] >= 375 and carPos[0] <= 395): if (carPos[2] >= 345 and carPos[2] <= 375): m = viz.Matrix() m.postTrans(350, 100, 345) m.postTrans(-75, 0, 140) self.circ.setMatrix(m) if (carPos[0] >= 265 and carPos[0] <= 300): if (carPos[2] >= 514 and carPos[2] <= 554): print("Good Job!") textScreen = viz.addText(' Mike: "Thank you!" ', viz.SCREEN, pos=[.2, .5, 0]) textScreen.color(viz.BLUE) textScreen.fontSize(90) if (self.v > 1.5): self.v = 1.5 if (self.v < -1.5): self.v = -1.5 self.vx = math.sin(math.radians(self.theta)) * self.v self.vz = math.cos(math.radians(self.theta)) * self.v self.x = self.x + self.vx self.z = self.z + self.vz m = viz.Matrix() m.postAxisAngle(0, 1, 0, self.theta) m.postTrans(self.x, .1, self.z) self.car.setMatrix(m) #set view to match that of car self.view = viz.MainView m = viz.Matrix() # first position view wrt car when it is at origin and looking down z axis m.postAxisAngle(1, 0, 0, 20) # rotate the view down a bit m.postTrans(0, 4, -3.4) # then translate it up above car and back a bit # now align view with the current rotation/location of the car m.postAxisAngle(0, 1, 0, self.theta) m.postTrans(self.x, 0, self.z) self.view.setMatrix(m)
def __init__(self): # self.statsPanel = vizinfo.InfoPanel(title='Inspector',text=None,align=viz.ALIGN_CENTER_BASE,icon=False) # self.statsPanel.getTitleBar().fontSize(16) # self.diameter_stat = viz.addText('d (mm)') # self.statsPanel.addItem(self.diameter_stat) # self.thickness_stat = viz.addText('t (mm)') # self.statsPanel.addItem(self.thickness_stat) # self.length_stat = viz.addText('l (m)') # self.statsPanel.addItem(self.length_stat) # self.rotation_stat = viz.addText('angle') # self.statsPanel.addItem(self.rotation_stat) self.statsPanel = vizdlg.Panel(align=viz.ALIGN_CENTER_TOP,border=False) self.statsMsg = self.statsPanel.addItem(viz.addText('Highlight member to inspect element'))
def onCollideBegin(self, e): self.catches += 1 viz.playSound('ball_sound.wav') #Displays on the screen the score that the player scores by catching the snitch m = viz.Matrix() m.postTrans(-100, -100, 0) self.text.setMatrix(m) self.text = viz.addText('Score: ' + str(self.catches), viz.SCREEN, pos=[0.01, 0.92, 0]) self.text.setBackdrop(viz.BACKDROP_RIGHT_BOTTOM) self.text.color(0.95, 0.95, 0.95) self.text.disable(viz.LIGHTING)
def practice_maze(): # declare globals global coordinate_array global movement_time global maze # Display instructions until they are removed practice_instructions = viz.addText( 'This practice session is designed to help you get used to\n using the joystick. Navigate through the hallways using\n the joystick until you are comfortable using to move.', viz.SCREEN) practice_instructions.fontSize(42) practice_instructions.setPosition(.5, .5) practice_instructions.alignment(viz.TEXT_CENTER_CENTER) yield viztask.waitKeyDown('m') practice_instructions.remove() # show user fixation cross yield display_fix() # setup viewpoint and positioning yield setup_view() # load the maze maze_name = maze_root + '.IVE' maze = viz.add(maze_name) maze.visible(viz.OFF) yield maze.visible(viz.ON) # load coordinate_array in clear it so that previous trial data is gone coordinate_array = array([]) # enable all of the global events joy_timer.setEnabled(viz.ON) coor_timer.setEnabled(viz.ON) write_onkey.setEnabled(viz.ON) quit_onkey.setEnabled(viz.ON) # reset and start the clock movement_time = TickTockTimer() movement_time.StartTimer() # stay in maze until experimenter presses a key... yield viztask.waitKeyDown('m') # disable events and quit maze disable() write_trial_data() maze.remove()
def multipleTrialTask(avatar, angles): """ function to call multiple trials (needs to be a task to ensure proper time course) """ counter = 1 for angle in trialDict['turningAngles']: output = {} yield viztask.waitTask(strippedTrialTask(avatar, angle, trialDict['vLinear'], trialDict['tLegs'], counter)) counter+=1 # add text for instructions screenText = viz.addText('please open and fill out\nthe questionnaires now',viz.SCREEN) screenText.setBackdrop(viz.BACKDROP_RIGHT_BOTTOM) screenText.setBackdropColor(viz.GRAY) screenText.setPosition(0.05, 0.5)
def __init__(self): viz.EventClass.__init__(self) self.callback(viz.BUTTON_EVENT, self.onButton) self.rowantext = """ _____ _____ _ _ | __ |___ _ _ _ ___ ___ |__ |___ _____| |_|_|___ | -| . | | | | .'| | | __| . | | . | | -_| |__|__|___|_____|__,|_|_| |_____|___|_|_|_|___|_|___| _____ _ _ _____ _ _ | __|_ _ ___ _ _|_|_ _ ___| | | __|_ _|_|_| |___ |__ | | | _| | | | | | .'| | | | | | | | . | -_| |_____|___|_| \_/|_|\_/|__,|_| |_____|___|_|___|___| May 2004: Electrical and Computer Engineering Students work on a new bio-algorithm to create zombies for the Biology Department. July 2004: The Biology Department finds a major bug in the algorithm, and expects them to all die off, so he hides them under the Engineering Building. Feb 2014: The Zombies are still alive. Due to the Engineering Building sinking 6 inches, the Zombies are extremely uncomfortable and ESCAPE. Instructions: Fight off the zombies to get to the roof of the Engineering Building. From there, you will zipline to the Science Building where the Biology Department can give you a cure. Make sure to grab objects along the way, so you can increase your power and toughness GOOD LUCK. No pressure, just all of our lives depend on you """ vizcam.PivotNavigate(center=[15, -10, 0], distance=70, sensitivity=[1.0, 1.0]) self.text_2D_world = viz.addText(self.rowantext, pos=[2, 2, 2]) self.myButton = viz.addButtonLabel('continue', scene=1) #Add a button. self.myButton.setPosition(.5, .8) #Set its position. self.myButton.setScale(1, 1) #Scale it. self.done = viztask.Signal()
def WaitForTrig(Quick): if Quick!=1: viz.MainWindow.setScene(4) #wait for trigger message= 'Run ' + str(runNum) +', waiting for T' waitT = viz.addText(message,viz.SCREEN,scene=4) waitT.fontSize(18) waitT.color(viz.RED) waitT.setPosition([0,0,0]) waitT.visible(1) yield viztask.waitKeyDown(['s','S']) #trigger waitT.visible(0) startTime = time.clock() else: yield viztask.waitKeyDown(['s','S']) #trigger
def learn_move(): # declare globals global sub_trial_number global movement_time global trial_time # stop the trial timer until we are back in the maze trial_time.Pause() # disable events and turn maze off disable() write_trial_data() yield maze.visible(viz.OFF) # Display the insturctions instructions = viz.addText('Please follow the arrows again.', viz.SCREEN) instructions.fontSize(42) instructions.setPosition(.5, .5) instructions.alignment(viz.TEXT_CENTER_CENTER) yield viztask.waitKeyDown('m') yield instructions.remove() # show user fixation cross yield display_fix() # move the viewpoint and turn maze back on yield move() yield maze.visible(viz.ON) # enable events joy_timer.setEnabled(viz.ON) coor_timer.setEnabled(viz.ON) write_onkey.setEnabled(viz.ON) quit_onkey.setEnabled(viz.ON) pos_move_timer.setEnabled(viz.ON) time_timer.setEnabled(viz.ON) # start the clocks again movement_time = TickTockTimer() movement_time.StartTimer() trial_time.UnPause() # increase the sub_trial number by 1 sub_trial_number = sub_trial_number + 1
def updatePos(self): rad_to_deg = math.pi / 180.0 msg = viz.addText("", parent=viz.SCREEN, pos=(0.05, 0.9, 0), scale=(0.25, 0.25, 0)) msg.setBackdrop(viz.BACKDROP_OUTLINE) self.readTime = 0 t0 = viz.tick() while True: if self.going: #self.T1.ReadBothBeltsPosition() #self.T1.ReadBothBeltsSpeed() self.lbp = self.T1.plabTreadmill.leftBeltPosition.value self.rbp = self.T1.plabTreadmill.rightBeltPosition.value self.lbs = self.T1.plabTreadmill.leftBeltSpeed.value self.rbs = self.T1.plabTreadmill.rightBeltSpeed.value if self.verbose: self.message = "Left: %6.6f, %6.6f\nRight: %6.6f, %6.6f\nReadTime: %6.6f ms"%(\ self.lbp, self.lbs, self.rbp, self.rbs, 1000.0*self.readTime) else: self.message = "" msg.message(self.message) dt = viz.tick() - t0 dtheta_dt = (self.lbs - self.rbs) / self.separation dr_dt = 0.5 * (self.lbs + self.rbs) spinner = vizact.spin(0, 1, 0, dtheta_dt, dt) mover = vizact.move(0, 0, dr_dt, dt) spinmove = vizact.parallel(spinner, mover) #print "gh1",dr_dt, dt self.track.addAction(spinmove) yield viztask.waitActionEnd(self.track, spinmove) t0 = viz.tick() #for the recording if self.recording: #time, left pos, left speed, right pos, right speed, head pos (xyz, dir) pp = self.track.getPosition() self.history.append( (viz.tick(), self.lbp, self.lbs, self.rbp, self.rbs, pp[0], pp[1], pp[2], self.track.getEuler()[0])) #yield viztask.waitTime(1.0/19.0) yield viztask.waitEvent(TREADMILL_STATE_UPDATED)
def __update(self): msg = viz.addText("", parent = viz.SCREEN, pos=(0.75, 0.9,0), scale=(0.25,0.25,0)) msg.setBackdrop(viz.BACKDROP_OUTLINE) while True: if self.tmill.going and self.forceplates.going and self.enable: #catch the foot before it goes off the end if self.forceplates.latestLeftOn and self.forceplates.latestLeftCOP[1] < BACK_MAX and self.leftSpeed > 0: self.leftSpeed = 0 self.tmill.moveLeftBelt(spd=0, mpss=BACK_DECELERATION) if self.forceplates.latestRightOn and self.forceplates.latestRightCOP[1] < BACK_MAX and self.rightSpeed > 0: self.rightSpeed = 0 self.tmill.moveRightBelt(spd=0, mpss=BACK_DECELERATION) if self.forceplates.lastLeftOn: self.leftGSM = self.forceplates.latestForceMoments[1] if self.forceplates.lastRightOn: self.rightGSM = self.forceplates.latestForceMoments[7] msg.message("left dist, spd: %3.3f, %3.3f\nright dist,spd: %3.3f, %3.3f"%(\ self.leftDistToDesired, self.leftSpeed, \ self.rightDistToDesired, self.rightSpeed)) yield None
def changeMessage(a, breakQ=True): global maxNumber if a not in IntroQ: Panel.removeItem(maxNumber) maxNumber = Panel.addLabelItem('', viz.addText(surveyScale[a])) #maxNumber= Panel.addLabelItem(' Strongly disagree.............................................................................Strongly agree',viz.addText('')) maxNumber.fontSize(18) if breakQ: if len(a) > breakLimit: t = a.split() ttrunk1 = t[:breakLimit] ttrunk2 = t[breakLimit:] j = " ".join(ttrunk1) k = " ".join(ttrunk2) Question = Panel.setText(" " + j + "\n" + " " + k) else: Question = Panel.setText( " " + a + "\n" + " . ")
def nextPhase(phaseCommand): global testPhase, currentPhase, endPhase, instructionPanel, additionalInfo, separator testPhase = testPhase + 1 if testPhase > endPhase: testPhase = 0 currentPhase = "Phase " + str(testPhase) instructionPanel.setText(currentPhase) #additionalInfo.setText(phaseCommand); instructionPanel.removeItem(additionalInfo) instructionPanel.removeItem(separator) separator = instructionPanel.addSeparator() additionalInfo = instructionPanel.addLabelItem(phaseCommand, viz.addText("")) if phaseCommand == flattenCommand: additionalInfo.label.color(viz.BLUE) elif phaseCommand == foldCommand: additionalInfo.label.color(viz.GREEN)
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) # Create time limit text time_text = viz.addText('',parent=viz.ORTHO,fontSize=40) time_text.alignment(viz.ALIGN_CENTER_TOP) time_text.setBackdrop(viz.BACKDROP_OUTLINE) viz.link(viz.MainWindow.CenterTop,time_text,offset=[0,-20,0]) # Create score text score_text = viz.addText('',parent=viz.ORTHO,fontSize=40) score_text.alignment(viz.ALIGN_LEFT_TOP) score_text.setBackdrop(viz.BACKDROP_OUTLINE) viz.link(viz.MainWindow.LeftTop,score_text,offset=[20,-20,0]) # Create post process effect for blending to gray scale gray_effect = BlendEffect(None,GrayscaleEffect(),blend=0.0) gray_effect.setEnabled(False) vizfx.postprocess.addEffect(gray_effect)
yaw = 0 yawB = 0 yaws = [] yawsB = [] aveYaw = 0 aveYawB = 0 quadrant = 0 # 0,1,2,3 flag_out = 0 # turn on when camera A can't detect yaw flag_outB = 0 #turn on when camera B can't detect yaw flag_clockwise = 0 flag_side_cam = 0 #turn on when using side camera (B) YAW_SIZE = 20 finalYaw = 0 finalYaws = [] aveFinalYaw = 0 text1 = viz.addText("Start walking") stepCount = 0 mainYaw = 0 output2file = 1 now = datetime.datetime.now() counter = 0 filename = '../bin/Output files/output {}-{} {},{},{}.csv'.format(now.month,now.day,now.hour,now.minute,now.second) ''' ********************* End of Initializations ************************ ''' def setDown(): global prevStep prevStep = "DOWN" viz.MainView.velocity(0,0,0)
def onKeyDown(self,key): if key == ' ': text2 = viz.addText('"Hello"',parent=viz.SCREEN,pos=(0.5,0.5,0),align=viz.ALIGN_CENTER_CENTER) text2.color(viz.RED) pass
HistBallR.setPosition([rxdistance,0,Rdistance]) HistBallR.setEuler(180,0,0) HistBallR.alpha(0.8) #Add an extra light so the left target looks almost as bright as the right one newlight = viz.addLight(); newlight.setPosition([-1,0,0.25]) newlight.intensity(1.5) #setup counter panels global RCOUNT global LCOUNT RCOUNT = 0 LCOUNT = 0 #rightcounter = vizinfo.InfoPanel(str(RCOUNT),align=viz.ALIGN_RIGHT_TOP,fontSize=50,icon=False,key=None) rightcounter = viz.addText(str(RCOUNT),pos=[.4,-0.25,1],scale=[0.1,0.1,0.1]) #leftcounter = vizinfo.InfoPanel(str(LCOUNT),align=viz.ALIGN_LEFT_TOP,fontSize=50,icon=False,key=None) leftcounter = viz.addText(str(LCOUNT),pos=[-.46,-0.25,1],scale=[0.1,0.1,0.1]) global RGOB RGOB = 0 #this will be 0 or 1, depending on success or failure global LGOB LGOB = 0 global stepind #this keeps track of the total # of attempts stepind = 0 global RightBeltSpeed global LeftBeltSpeed RightBeltSpeed = 0 LeftBeltSpeed = 0
import viz viz.go() # Create arrow symbol at center of screen text = viz.addText("^", parent=viz.SCREEN, pos=(0.5, 0.5, 0), align=viz.ALIGN_CENTER_CENTER) # Import our new module import mymodule # Register callback for our mouse enter event def onMouseEnter(pos): text.setEuler(0, 0, -vizmat.AngleToPoint([0.5, 0.5], pos)) text.color(viz.WHITE) viz.callback(mymodule.MOUSE_ENTER_EVENT, onMouseEnter) # Register callback for our mouse leave event def onMouseLeave(pos): text.setEuler(0, 0, -vizmat.AngleToPoint([0.5, 0.5], pos)) text.color(viz.RED) viz.callback(mymodule.MOUSE_LEAVE_EVENT, onMouseLeave)
def __init__(self, fileName, SF = 1.0/200): """Pull the BodyParts3D mesh into an instance and set everything up""" self.metaData = ds.getMetaData(file = fileName) self.centerPoint = self.metaData['centerPoint'] self.centerPointScaled = [a*SF for a in self.centerPoint] self.centerPointScaledFlipped = [a*SF*-1 for a in self.centerPoint] print self.centerPointScaledFlipped self.name = self.metaData['name'] self.nameFormatted = '' for i, w in enumerate(self.name.split()): if (i + 1) % 2 == 0 and i != 0: self.nameFormatted += w + '\n' else: self.nameFormatted += w + ' ' #give a bone an information property # self.info = '' # for j,bd in enumerate(boneDesc['info'].split()): # if(j+1) % 10 ==0 and j != 0: # self.info += bd + ' \n' # else: # self.info += bd + ' ' # We are using a 'center' viznode to make manipulation easy self.center = vizshape.addCube(0.1) # An arbitrary placeholder cube super(Mesh, self).__init__(self.center.id) # This is the actual mesh we will see self.mesh = viz.addChild(config.DATASET_PATH + fileName + '.obj') self.mesh.setScale([SF,SF,SF]) # This is the viznode that will be moved around to check distances for snapping self.checker = vizshape.addCube(10.0) # Tooltip self.tooltip = viz.addText(self.nameFormatted) self.tooltip.color(0,5,1) self.tooltip.billboard(viz.BILLBOARD_VIEW) self.tooltip.setScale(0.001,0.001,0.001) #small scale for bounding box calc #Description # if display.displayMode == 2: # self.dialogue = viz.addText(self.info,pos = [0,3,0],parent=viz.WORLD) # self.dialogue.billboard(viz.BILLBOARD_VIEW) # self.dialogue.setBackdrop(viz.BACKDROP_CENTER_TOP) # self.dialogue.setScale(0.15,0.15,0.15) # self.dialogue.alignment(viz.ALIGN_CENTER_CENTER) # #self.dialogue.setPosition([0.03,0.85,0]) # #self.dialogue.color(viz.BLACK) # else: # self.dialogue = viz.addText(self.info,parent=viz.SCREEN) # #self.dialogue.setBackdrop(viz.BACKDROP_CENTER_TOP) # self.dialogue.setScale(0.3,0.3,0.0) # self.dialogue.alignment(viz.ALIGN_LEFT_BOTTOM) # self.dialogue.setPosition([0.03,0.85,0]) # #self.dialogue.color(viz.BLACK) # Setup heirarchy for proper movement behavior self.mesh.setParent(self) self.tooltip.setParent(self.center) self.checker.setParent(self.mesh) # Offset mesh to lie in center of center viznode self.mesh.setPosition(self.centerPointScaledFlipped, viz.ABS_PARENT) self.checker.setPosition(self.centerPoint) self.addSensor() # Tooltip formatting self.tooltip.setScale(0.1,0.1,0.1)#set to prefered scale self.tooltip.setPosition(0,0,-1) self.tooltip.alignment(viz.TEXT_CENTER_CENTER) self.tooltip.visible(viz.OFF) #Line between tooltip and mesh centerPoint # viz.startLayer(viz.LINES) # viz.vertexColor(viz.BLUE) # viz.lineWidth(5) # viz.vertex(self.getPosition(viz.ABS_GLOBAL)) # viz.vertex(self.tooltip.getPosition(viz.ABS_GLOBAL)) # self.nameLine = viz.endLayer() # self.nameLine.dynamic() # self.nameLine.visible(viz.OFF) # Turn off visibility of center and checker viznodes self.center.disable([viz.RENDERING]) self.color([0.3,0,0]) self.checker.disable([viz.RENDERING,viz.INTERSECTION,viz.PHYSICS]) self.scale = SF self._enabled = True self.nameAudioFlag = 1 #defualt: 1, 1 allows name to be played, 0 does not allow name playback self.descAudioFlag = 1 #default: 1, 1 allows description to be played, 0 does not allow dec playback self.grabbedFlag = 0 self.proxCounter = 0 # Group handling self.group = BoneGroup([self]) groups.append(self.group)
#set targets based on TM base behavior global targetUl targetUl =0.5369 global targetUr targetUr = 0.5369 global targetmean targetmean = (targetUr+targetUl)/2 global targettol targettol = 0.01 global messagewin #messagewin = vizinfo.InfoPanel('',align=viz.ALIGN_CENTER_TOP,fontSize=60,icon=False,key=None) messagewin = viz.addText(str(0),pos=[0.05,targetmean+0.2,0],scale=[0.05,0.05,0.05]) #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 = [] order = [1,2] * 5 while len(randy) < 2:#optimistically sample the solution space for test orders, reduced from 100 on 11/3/2015 to reduce calculation time for high stepnum random.shuffle(order) if order in randy: continue if all(len(list(group)) < 4 for _, group in itertools.groupby(order)): randy.append(order[:]) randy = [item for sublist in randy for item in sublist]
boxL.setEuler(0,90,0) global boxR boxR = viz.addChild('target2.obj',color=(0.063,0.102,0.898),scale=[0.2,0.005,targettol*2]) boxR.setPosition([0.2,targetR,0]) boxR.setEuler(0,90,0) viz.MainView.setPosition(0, 0.25, -1.25) viz.MainView.setEuler(0,0,0) #setup counter panels to count successful steps taken global RCOUNT global LCOUNT RCOUNT = 0 LCOUNT = 0 #rightcounter = vizinfo.InfoPanel(str(RCOUNT),align=viz.ALIGN_RIGHT_TOP,fontSize=50,icon=False,key=None) rightcounter = viz.addText(str(RCOUNT),pos=[4.6,3*targetR,12]) #rightcounter.visible(0) #leftcounter = vizinfo.InfoPanel(str(LCOUNT),align=viz.ALIGN_LEFT_TOP,fontSize=50,icon=False,key=None) leftcounter = viz.addText(str(LCOUNT),pos=[-5.5,3*targetL,12]) #leftcounter.visible(0) global cursorR cursorR = viz.add('box3.obj', color=viz.RED, scale=[0.1,0.1,0.0125], cache=viz.CACHE_NONE) cursorR.setPosition([0.2,0,0.05]) global cursorL cursorL = viz.add('box3.obj', color=viz.GREEN, scale=[0.1,0.1,0.0125], cache=viz.CACHE_NONE) cursorL.setPosition([-0.2,0,0.05]) global HistBallR HistBallR = viz.add('box.wrl', color=viz.YELLOW, scale=[0.2,0.01,0.0125], cache=viz.CACHE_NONE)
viz.MainView.move([0,0,-5]) #Add some avatars and place them in the room. male = viz.addAvatar('vcc_male.cfg') female = viz.addAvatar('vcc_female.cfg') female.setPosition([-2,0,0]) female.setEuler([90,0,0]) male.setPosition([2,0,0]) male.setEuler([-90,0,0]) #Animate them. male.state(1) female.state(1) #Add some text. question_text = viz.addText('Hit spacebar to start', viz.SCREEN) question_text.setScale([.4,.4,.4]) question_text.setPosition([.35,.75,0]) question_text.setBackdrop(viz.BACKDROP_OUTLINE) #Import the viztask module. import viztask #Create a task. def myTask(): #As long as the task is running . . . while True: question_text.message( 'Hit the spacebar to begin.' ) #Wait for a keypress. yield viztask.waitKeyDown( ' ' ) #Animate the female.
#fakebox.color(0,1,0) #fakebox.disable(viz.LIGHTING) #create latitudinal grid, "10" is the target step length, the grid expands above and belo lines = {}#create empty dictionary for x in range(1,12,1): lines["Tp{0}".format(x)]=vizshape.addBox(size=[1,0.002,0.001]) lines["Tp{0}".format(x)].setPosition(0,targetmean+0.05*targetmean+(x-1)*0.1*targetmean,0)#each gap represents 20 percent of target? lines["Tn{0}".format(x)]=vizshape.addBox(size=[1,0.002,0.001]) lines["Tn{0}".format(x)].setPosition(0,targetmean+0.05*targetmean-(x-1)*0.1*targetmean,0) # print((x-1)*0.02) global tnums tnums = {} for x in range(0,21,1): if (x<10): tnums["Num{0}".format(x)]=viz.addText(str(x),pos=[0,targetmean-0.95*targetmean-0.1*targetmean+x*0.1*targetmean+0.005,0],scale=[0.015,0.015,0.015]) else: tnums["Num{0}".format(x)]=viz.addText(str(x),pos=[-0.005,targetmean-0.95*targetmean-0.1*targetmean+x*0.1*targetmean+0.005,0],scale=[0.015,0.015,0.015]) viz.MainView.setPosition(0,targetmean+0.05*targetmean, -0.57) viz.MainView.setEuler(0,0,0) global histzR histzR = -500 global histzL histzL = -500 global rgorb rgorb = 0 global lgorb lgorb = 0
#Create annotation tool #annotationManager = AnnotationManager(messageManager) #annotationManager.setScale( viz.Vector( 0.1, 0.1, 0.1 ) ) tool_manager = ToolManager(messageManager) tool_manager.addTool( clipPlaneTool ) #tool_manager.addTool( annotationManager ) #resolution control res_control = viz.addSlider() res_control.ticksize(0.3, 0.6) res_control.setPosition( 0.2, 0.025 ) res_control.set( 0.5 ) res_control_text = viz.addText("Resolution Control:", parent = viz.SCREEN) res_control_text.setPosition(0.005, 0.0225) res_control_text.scale( 0.1, 0.1, 0.1 ) #Gradient control min_gradient_text = viz.addText("Gradient Minimum:", parent = viz.SCREEN) min_gradient_text.setPosition(0.005, 0.0725) min_gradient_text.scale( 0.1, 0.1, 0.1 ) min_gradient_control = viz.addSlider() min_gradient_control.setPosition(0.2, 0.075) min_gradient_control.set(0.0) min_gradient_control.ticksize(0.3, 0.6) max_gradient_text = viz.addText("Gradient Maximum:", parent = viz.SCREEN) max_gradient_text.setPosition(0.005, 0.0475) max_gradient_text.scale( 0.1, 0.1, 0.1 )
def initialize(zonePointer, fileWithListOfObjects): global species, nodesToHuntForEachSpecies, nodeNamesToHuntForEachSpecies, numObjectsToFind, displayObjects, dictionaryMappingHuntItemsToNamesFromZoneModel, flagPileSensor vizact.onkeydown('-', endHunt) if globals_oa.scavengerHuntInProgress: print "Please finish the previous species search first!" return #format of the input files: # each line has one species, and the nodes of that species from the zone model, which are to be hunted # the first name in each line is the name of the species and the following names are the names of the nodes # there should be no spaces before or after the commas separating the names # speciesWithNodeNamesToHunt = createListFromInputFile(fileWithListOfObjects, False) createListFromInputFile(fileWithListOfObjects) # for s in speciesWithNodeNamesToHunt: # species.append(s[0]) # numObjectsToFind.append(0) # nodesToHuntForEachSpecies[s[0]] = [] # speciesRegex[s[0]] = re.compile(s[1] + '[ ]*\d*$') #Assuming node names are of the form 'species + maybe a space + number' hud = None if globals_oa.hmdUsed == globals_oa.HMD_TYPE['RIFT']: hud = globals_oa.rift.getHUD() displayPos = [0, 0.05, 1] print "TO FIND:" # for zone in [zonePointer]:#, terrainZone2, terrainZone3]: for name in zonePointer.getNodeNames(): # nameBlocks = name.split(' ') # if 'Ocinebrina' in nameBlocks: # print name item = None speciesIndexCounter = 0 for s in species: # if speciesRegex[s].match(name):#s in name: if name in nodeNamesToHuntForEachSpecies[s]: item = zonePointer.getChild(name) if item: nodesToHuntForEachSpecies[s].append(item) dictionaryMappingHuntItemsToNamesFromZoneModel[item] = [] dictionaryMappingHuntItemsToNamesFromZoneModel[item].append(name) numObjectsToFind[speciesIndexCounter] += 1 if 'octopus' in name.lower(): Octopus.append(item) if 'eel' in name.lower(): Eel.append(item) if 'grass' in name.lower(): Grass.append(item) else: print name + ' cannot be located' break else: speciesIndexCounter += 1 # if globals_oa.currentZoneNumber == 3: # addHiddenSnailInZone3() #adding the display objects for each species for the current zone # for s in species: # displaySpeciesLoc = globals_oa.DISPLAY_OBJECT_DIRECTORY + str(globals_oa.currentZoneNumber) + '/' + str(s).lower()+ '.osgb' # print "loading display object from " + displaySpeciesLoc # if hud is not None: # displaySpeciesNode = vizfx.addChild(displaySpeciesLoc, pos=displayPos, parent=hud) # # displayEdwardsii = vizfx.addChild(FAUNA_DIRECTORY + globals_oa.SNAIL, pos=displayPos, parent=hud) # displaySpeciesNode.visible(False) # displayObjects.append(displaySpeciesNode) print "SPECIES:" print str(len(species)) # print species print nodesToHuntForEachSpecies print numObjectsToFind #set up display objects (all invisible) # hud = transport_vhil.rift.getHUD() # displayEdwardsii = vizfx.addChild(FAUNA_DIRECTORY + globals_oa.SNAIL, pos=displayPos, parent=hud) # displayEdwardsii.visible(False) # displayObjects.append(displayEdwardsii) # displayOctopus = vizfx.addChild(FAUNA_DIRECTORY + 'octopus_vulgaris/octopus vulgaris.osgb', pos=displayPos, parent=hud) # displayOctopus.visible(False) # displayObjects.append(displayOctopus) # global slate if globals_oa.slate is not None: # slate = vizfx.addChild(EQUIPMENT_DIRECTORY + 'Slate_New.osgb') # slateLink = viz.link(viz.MainView, globals_oa.slate, offset = (0, -0.75, 0.0)) # slateLink.setEuler([None,0,0], 1) # slateLink.preTrans(globals_oa.INITIAL_POSITIONAL_OFFSET_FOR_SLATE, 0) # slateLink.preEuler(globals_oa.INITIAL_ROTATIONAL_OFFSET_FOR_SLATE) # slateLink.clampPosY([-1.25, -0.75]) # else: globals_oa.slate.visible(True) # if globals_oa.lhModel is not None: globals_oa.slate.setParent(globals_oa.lhModel) # globals_oa.slate.setPosition([0.01, 0, -0.5]) # globals_oa.slate.setEuler([-90,0,0]) # globals_oa.slate.setScale([0.8,0.8,0.8]) # global basket # basket = vizfx.addChild(EQUIPMENT_DIRECTORY + 'diveBasket.osgb') # basket.setScale([0.75, 0.85, 0.75]) globals_oa.basket.visible(True) if globals_oa.currentZoneNumber == 1: #globals_oa.basket.setPosition([0,-1.74,0]) old basket position #globals_oa.basket.setPosition([2,-.2,0]) # globals_oa.basket.setPosition([2,-1.3,2]) globals_oa.basket.setPosition(globals_oa.basketPosInCGscene1) elif globals_oa.currentZoneNumber == 3: globals_oa.basket.setPosition([58.8, -1.78, 0.281726598739624])#947296142578125 # basketLink = viz.link(viz.MainView, basket, offset = (0, -0.75, 0.0)) # basketLink.setEuler([None,0,0], 1) # basketLink.preTrans([.5, 0, 0.70], 0) # basketLink.preEuler([50,0,0]) # basketLink.clampPosY([-1.25, -0.75]) global basketManager basketManager = vizproximity.Manager() basketSensor = vizproximity.addBoundingBoxSensor(globals_oa.basket, scale = (1.5, 2, 1.5)) basketManager.addSensor(basketSensor) # basketManager.onEnter(None, selectObject) # vizact.onkeydown('f',basketManager.setDebug,viz.TOGGLE) # global slateFadingManager # slateFadingManager = vizproximity.Manager() # # ## slateFadingManager.addSensor(globals_oa.oceanFloorCollisionSensor) ## slateFadingManager.addSensor(globals_oa.rockChunkCollisionSensor1) ## slateFadingManager.addSensor(globals_oa.rockChunkCollisionSensor2) ## slateFadingManager.addSensor(globals_oa.rockChunkCollisionSensor3) # # target = vizproximity.Target(globals_oa.slate) # slateFadingManager.addTarget(target) # # slateFadingManager.onEnter(None,EnterProximity) # slateFadingManager.onExit(None,ExitProximity) # # vizact.onkeydown('0',slateFadingManager.setDebug,viz.TOGGLE) textScale = 0.05 slateEuler = [0,0,0] averageInitPos = [0.0, 1.5, -0.15] # Create time limit text global time_text # if time_text is None: # time_text_link.setEuler([None,90,0], 2) # time_text_link.preTrans([0.0, 0.01, 0.1], 1) # else: if time_text is not None: time_text.visible(True) # time_text = viz.addText3D('', pos = [0, 0, 0]) time_text.alignment(viz.ALIGN_CENTER_TOP) time_text.setParent(globals_oa.slate) # time_text.setPosition([0,0.01,0.25]) time_text.setPosition(averageInitPos[0], averageInitPos[1] + 0.5, averageInitPos[2]) time_text.setEuler(slateEuler) # time_text_link = viz.link(globals_oa.slate, time_text)#, offset = (0, 0.01,0.05)) time_text.setScale(textScale, textScale, textScale) # Create score text # global score_text # if score_text is None: # #score_text = viz.addText3D('',pos = [-0.4, 0.3, 1], parent=hud) # score_text = viz.addText('',pos = [0, 0.01, -0.05]) # score_text.setScale(textScale, textScale, textScale) # score_text.alignment(viz.ALIGN_CENTER_TOP) # score_text.setParent(globals_oa.slate) # score_text.setPosition([0,0.01,-0.05]) # score_text.setEuler([180,-90,0]) ## score_text_link = viz.link(globals_oa.slate, score_text) ## #score_text_link.setMask(viz.LINK_POS) ## #score_text.setEuler([0, 90, 0], mode = viz.REL_LOCAL) ## score_text_link.setEuler([None,90,0], 2) ### score_text_link.preTrans([0.0, 0.01, -0.05], 1) ## score_text_link.preTrans([0.05, 0.01, 0.0], 1) ## # score_text.color(viz.BLACK) # #score_text.alignment(viz.ALIGN_LEFT_TOP) # #score_text.setBackdrop(viz.BACKDROP_OUTLINE) # #viz.link(viz.MainWindow.LeftTop,score_text,offset=[20,-20,0]) # else: # score_text.visible(True) # 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 count_text1 global count_text2 global count_text3 global quad1 global quad2 global quad3 if quad1 is not None: quad1.visible(True) quad2.visible(True) quad3.visible(True) count_text1.visible(True) count_text2.visible(True) count_text3.visible(True) # if quad1 is None: #need to be initialized # quad1 = viz.addTexQuad(size = 0.15) # quad2 = viz.addTexQuad(size = 0.15) # quad3 = viz.addTexQuad(size = 0.15) # count_text1 = viz.addText('count: 0') # count_text2 = viz.addText('count: 0') # count_text3 = viz.addText('count: 0') #the following should be read from a file carrying textures names for species to be hunted, specific to each zone horizontalShift = 0.1 if globals_oa.currentZoneNumber == 1: quad1.setTexQuadDisplayMode(viz.TEXQUAD_FIT) quad1.setParent(globals_oa.slate) # quad1.setPosition([-.1,0.01,0.1]) quad1.setPosition(averageInitPos[0] - horizontalShift, averageInitPos[1] + 0.25, averageInitPos[2]) quad1.setEuler(slateEuler) #quad1.setScale([0.75,0.75,0.75]) quad1.texture(pics[0]) pics[0].hint(viz.PRELOAD_HINT) count_text1.setScale(textScale, textScale, textScale) count_text1.alignment(viz.ALIGN_CENTER_TOP) count_text1.setParent(globals_oa.slate) count_text1.setPosition(averageInitPos[0] + horizontalShift, averageInitPos[1] + 0.25, averageInitPos[2])#[0.1,0.01,0.15]) count_text1.setEuler(slateEuler) count_text1.color(viz.BLACK) # quad2.setTexQuadDisplayMode(viz.TEXQUAD_FIT) # quad2.setParent(globals_oa.slate) ## quad2.setPosition([-.1,0.01,-0.1]) # quad2.setPosition(averageInitPos[0] - horizontalShift, averageInitPos[1] + 0.2, averageInitPos[2]) # quad2.setEuler(slateEuler) # #quad2.setScale([0.75,0.75,0.75]) # quad2.texture(pics[1]) # pics[1].hint(viz.PRELOAD_HINT) # # count_text2.setScale(textScale, textScale, textScale) # count_text2.alignment(viz.ALIGN_CENTER_TOP) # count_text2.setParent(globals_oa.slate) ## count_text2.setPosition([0.1,0.01,-0.05]) # count_text2.setPosition(averageInitPos[0] + horizontalShift, averageInitPos[1] + 0.2, averageInitPos[2]) # count_text2.setEuler(slateEuler) # count_text2.color(viz.BLACK) quad2.visible(False) count_text2.visible(False) # quad3.setTexQuadDisplayMode(viz.TEXQUAD_FIT) # quad3.setParent(globals_oa.slate) ## quad3.setPosition([-0.1,0.01,-0.3]) # quad3.setPosition(averageInitPos[0] - horizontalShift, averageInitPos[1] + 0.05, averageInitPos[2]) # quad3.setEuler(slateEuler) # #quad3.setScale([0.75,0.75,0.75]) # quad3.texture(pics[2]) # pics[2].hint(viz.PRELOAD_HINT) # # count_text3.setScale(textScale, textScale, textScale) # count_text3.alignment(viz.ALIGN_CENTER_TOP) # count_text3.setParent(globals_oa.slate) ## count_text3.setPosition([0.1,0.01,-0.25]) # count_text3.setPosition(averageInitPos[0] + horizontalShift, averageInitPos[1] + 0.05, averageInitPos[2]) # count_text3.setEuler(slateEuler) # count_text3.color(viz.BLACK) quad3.visible(False) count_text3.visible(False) elif globals_oa.currentZoneNumber == 3: quad1.setTexQuadDisplayMode(viz.TEXQUAD_FIT) quad1.setParent(globals_oa.slate) # quad1.setPosition([-0.1,0.01,0.1]) quad1.setPosition(averageInitPos[0] - horizontalShift, averageInitPos[1] + 0.3, averageInitPos[2]) quad1.setEuler(slateEuler) quad1.texture(pics[0]) pics[0].hint(viz.PRELOAD_HINT) count_text1.setScale(textScale, textScale, textScale) count_text1.alignment(viz.ALIGN_CENTER_TOP) count_text1.setParent(globals_oa.slate) # count_text1.setPosition([0.1,0.01,0.15]) count_text1.setPosition(averageInitPos[0] + horizontalShift, averageInitPos[1] + 0.3, averageInitPos[2]) count_text1.setEuler(slateEuler) count_text1.color(viz.BLACK) count_text1.message('found: 0') quad2.setTexQuadDisplayMode(viz.TEXQUAD_FIT) quad2.setParent(globals_oa.slate) # quad2.setPosition([-0.1,0.01,-0.1]) quad2.setPosition(averageInitPos[0] - horizontalShift, averageInitPos[1] + 0.1, averageInitPos[2]) quad2.setEuler(slateEuler) quad2.texture(pics[3]) pics[3].hint(viz.PRELOAD_HINT) count_text2.setScale(textScale, textScale, textScale) count_text2.alignment(viz.ALIGN_CENTER_TOP) count_text2.setParent(globals_oa.slate) # count_text2.setPosition([0.1,0.01,-0.05]) count_text2.setPosition(averageInitPos[0] + horizontalShift, averageInitPos[1] + 0.1, averageInitPos[2]) count_text2.setEuler(slateEuler) count_text2.color(viz.BLACK) count_text2.message('found: 0') quad3.visible(False) count_text3.visible(False) # Create surface to wrap the texture on # global quad # if quad is None: # quad = viz.addTexQuad(size = 0.25) # quad.setTexQuadDisplayMode(viz.TEXQUAD_FIT) # quad.setParent(globals_oa.slate) # quad.setPosition([0,0.01,0]) # quad.setEuler([180,-90,0]) # quad.setScale([0.5,0.5,0.5]) # # Wrap texture on quad # display_image_link = viz.link(globals_oa.slate, quad)# offset = (0.0, 0.01, 0.25)) # #display_image_link = viz.addTexQuad(texture=viz.add('resources/Ocinebrina Edwardsii.tif'), size=0.1) # #display_image_link.setMask(viz.LINK_POS) # display_image_link.setEuler([None,90,0], 1) # display_image_link.preTrans([0.0, 0.01, 0.25], 0) # #quad.setEuler([0, 90, 0], mode = viz.REL_LOCAL) # quad.disable(viz.INTERSECTION) # quad.disable(viz.LIGHTING) # quad.disable(viz.FOG) else: quad.visible(True) textPos = [0, -0.05, 1] speciesTextScale = 0.05 global speciesText if speciesText is None: if hud is not None: speciesText = viz.addText("", pos=textPos, parent=hud) speciesText.alignment(viz.ALIGN_CENTER_TOP) speciesText.setScale(speciesTextScale, speciesTextScale, speciesTextScale) speciesText.color(viz.BLACK) speciesText.visible(False) #viz.callback(viz.TIMER_EVENT,onTimer) if (((globals_oa.currentZoneNumber == 0) and globals_oa.scavengerHuntCompleteInTestZone) or ((globals_oa.currentZoneNumber == 1) and globals_oa.scavengerHuntCompleteInZone1) or ((globals_oa.currentZoneNumber == 2) and globals_oa.scavengerHuntCompleteInZone2) or ((globals_oa.currentZoneNumber == 3) and globals_oa.scavengerHuntCompleteInZone3)): print "This scavenger hunt is already completed! Please try the hunt in a different zone." return print 'Scavenger Hunt started' global scavengerHuntStartSound if scavengerHuntStartSound is None: scavengerHuntStartSound = loadAudioFile(AUDIO_DIRECTORY + 'bell.wav') #adding a manager for touching the snails global snailTouchManager snailTouchManager = vizproximity.Manager() # snailTouchManager.setDebug(viz.ON) vizact.onkeydown('k',snailTouchManager.setDebug,viz.TOGGLE) #adding sensor for the flag pile global flagPileManager flagPileSensor = vizproximity.Sensor(vizproximity.Sphere(.3,center=[1.3, -1.23484, 0.8]), source=flagPile) flagPileManager = vizproximity.Manager() flagPileManager.addSensor(flagPileSensor) vizact.onkeydown(';', flagPileManager.setDebug, viz.TOGGLE) #scavengerHuntStartSound.play() #vizact.onsensordown(globals_oa.wiimote, globals_oa.wii.BUTTON_B,selectObject) if (globals_oa.hmdUsed == globals_oa.HMD_TYPE['VIVE']) and (globals_oa.rhViveTracker is not None): print "USING VIVE" #vizact.onsensordown(globals_oa.rhViveTracker, steamvr.BUTTON_TRIGGER,selectObject) # if globals_oa.rhViveTracker: # handModel1 = globals_oa.rhViveTracker.addModel() # link1 = viz.link(globals_oa.rightHandLink, handModel1) # if globals_oa.lhViveTracker: # handModel2 = globals_oa.lhViveTracker.addModel() # link2 = viz.link(globals_oa.leftHandLink, handModel2) # from tools import grabber # from tools import highlighter # global rhtool, lhtool # # if rhtool is None: # rhtool = grabber.Grabber(usingPhysics=False, usingSprings=False, highlightMode=highlighter.MODE_BOX) # if lhtool is None: # lhtool = grabber.Grabber(usingPhysics=False, usingSprings=False, highlightMode=highlighter.MODE_BOX) # rhtool.setUpdateFunction(rUpdateGrabber) # if globals_oa.rhModel is not None:rhtool.setParent(globals_oa.rhModel) # # lhtool.setUpdateFunction(lUpdateGrabber) # if globals_oa.lhModel is not None: lhtool.setParent(globals_oa.lhModel) #sphere = vizshape.addSphere(radius = 0.3) #sphere.setParent(globals_oa.rhModel) global rhandtar, lhandtar if globals_oa.rhModel is not None: rhsphere = vizshape.addSphere(radius = 0.05) rhsphere.setParent(globals_oa.rhModel) rhsphere.setPosition([0,0,.55]) rhsphere.disable(viz.RENDERING) rhandtar = vizproximity.Target(rhsphere)#globals_oa.rhModel) snailTouchManager.addTarget(rhandtar) flagPileManager.addTarget(rhandtar) if globals_oa.lhModel is not None: lhsphere = vizshape.addSphere(radius = 0.05) lhsphere.setParent(globals_oa.lhModel) lhsphere.setPosition([0,0,.55]) lhsphere.disable(viz.RENDERING) lhandtar = vizproximity.Target(lhsphere)#globals_oa.lhModel) snailTouchManager.addTarget(lhandtar) flagPileManager.addTarget(lhandtar) # basketManager.addTarget(rhandtar) # basketManager.addTarget(lhandtar) #adding the sensors around the snails for snailAndFlagItem in globals_oa.snailAndFlagItemsInZone1: snailSensor = vizproximity.addBoundingSphereSensor(snailAndFlagItem.snailItemFromZoneModel, scale = (1.0)) snailTouchManager.addSensor(snailSensor) def EnterProximity(e): global snapFlagLeftHand, snapFlagRightHand if e.target == lhandtar: snapFlagLeftHand() elif e.target ==rhandtar: snapFlagRightHand() flagPileManager.onEnter(flagPileSensor, EnterProximity) #viz.link(globals_oa.rhModel, tool) # viz.callback(grabber.GRAB_EVENT,grabObject) # viz.callback(grabber.RELEASE_EVENT, releaseObject) snailTouchManager.onEnter(None, ShowFlagAtSnail) if globals_oa.currentZoneNumber == 1: globals_oa.MOVEMENT_DATA_RECORDING_TAG = globals_oa.TAG_SCAVENGER_HUNT_START_ZONE_1 else: globals_oa.MOVEMENT_DATA_RECORDING_TAG = globals_oa.TAG_SCAVENGER_HUNT_START_ZONE_3 global speciesIndex, numFound speciesIndex = 0 numFound = 0 viztask.schedule( findObject() )
global targetAmean targetAmean = (targetAr+targetAl)/2 global targetXmean # X target, CJS 12/17/2016 targetXmean = (targetXXr+targetXXl)/2 global targettol targettol = 0.0375 global reftime reftime=time.time() global messagewin #messagewin = vizinfo.InfoPanel('',align=viz.ALIGN_CENTER_TOP,fontSize=60,icon=False,key=None) #messagewin = viz.addText(str(0),pos=[0.05,targetXmean+0.2,0],scale=[0.05,0.05,0.05]) messagewin = viz.addText(str(0),pos=[-0.05,targetXmean-0.2,0],scale=[0.05,0.05,0.05]) messagewin.visible(0) global messagephase #messagephase = viz.addText(str(0),pos=[0.05,targetXmean-0.32,0],scale=[0.05,0.05,0.05]) messagephase = viz.addText(str(0),pos=[-.11,0.3,0],scale=[0.05,0.05,0.05]) messagephase.visible(0) global prompt4TwoChoice #prompt4TwoChoice = viz.addText('Which Leg had a longer X?',pos=[-0.2,0.4,0],scale=[0.05,0.05,0.05]) prompt4TwoChoice = viz.addText('Which step was Longer?',pos=[-.2,0.4,0],scale=[0.05,0.05,0.05]) prompt4TwoChoice.visible(0) #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 =10
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): print "acc",acc
def addValue(self, days, money): cost = viz.addText(str(money)) label = self.menu.addLabelItem('Days left: ' + str(days) + " | " + 'Amount of money needed: ', cost) self.labels.append(label)
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 LCOUNT = 0 #rightcounter = vizinfo.InfoPanel(str(RCOUNT),align=viz.ALIGN_RIGHT_TOP,fontSize=50,icon=False,key=None) rightcounter = viz.addText(str(RCOUNT),pos=[4,targetR+0.6,12]) #leftcounter = vizinfo.InfoPanel(str(LCOUNT),align=viz.ALIGN_LEFT_TOP,fontSize=50,icon=False,key=None) leftcounter = viz.addText(str(LCOUNT),pos=[-4.4,targetL+0.6,12]) global Rforceold global Lforceold Rforceold = 0 Lforceold = 0 # ////////////////////////////////////////////////// # START OF CODE DEMONSTRATING USE OF MMSERVER MODULE # ////////////////////////////////////////////////// # Import the MotionMonitor Server module. import mmserver
viz.go() #Prompt for the participant's identification number. subject = vizinput.input('What is the participant number?') viz.move([0,0,2]) #Add the environment piazza = viz.addChild('piazza.osgb') #Add the pigeon. pigeon = viz.addAvatar('pigeon.cfg',pos=[-0.9, 2.88, 11.3],euler=[100,0,0]) pigeon.state(1) #ask the question we will record data for critical_question = viz.addText('Do you see a pigeon?',viz.SCREEN) yes = viz.addText('Yes!',viz.SCREEN) no = viz.addText('No!',viz.SCREEN) critical_question.alignment(viz.ALIGN_CENTER_TOP) critical_question.setPosition(.5,.9) yes.alignment(viz.ALIGN_LEFT_TOP) yes.setPosition(.25,.75) no.alignment(viz.ALIGN_LEFT_TOP) no.setPosition(.75,.75) yes_button = viz.addButton() yes_button.setPosition(.22,.71)