def initialise_display(): # viz.message('Calibration on Pupil Capture must be set to Manual Marker') #load scene for luminance. # start empty world EH = 1.2 #metres from ground. Eye_ScreenDist = 1 #distance from screen of ocular point Proj_V = 1.12 #measured on 18/01/18 #vertical extent of projection (m) Proj_H = 1.965 #horizontal extent of projection (m) # setting Field-of-View fov(vertical degree, horizontal ratio(vertical*ratio[deg])) vfov = ((np.arctan((Proj_V/2)/Eye_ScreenDist))*2) * (180/np.pi) h2v = Proj_H/Proj_V #viz.setDisplayMode(1920,1080) viz.go() viz.window.setSize(1920,1080) #viz.fov(vfov,h2v) #sets window aspect ratio. viz.fov(vfov,h2v) #sets window aspect ratio. #viz.window.setSize([1920,1080]) #viz.window.setBorder(viz.BORDER_NONE) #viz.window.setFullscreen(1) #viz.window.setFullscreenMonitor(2) #viz.window.setFullscreenRectangle( [0,0,1920,1080] ) viz.eyeheight(1.2)#viz.MainView.setPosition(0,EH,0) viz.clip(1,60) #clips world at 60m # background color viz.clearcolor(viz.SKYBLUE)
def __init__(self, x=0, y=0, angle=0, scale=4, speed=DEFAULT_MAX_SPEED, center_offset=0, callback=None, **kwargs): print 'Initializing Joystick.movement' global __JOYSTICK_VAR frequency = 0.01 timer_id = 1 self.motion = __JOYSTICK_VAR = InputHandler(frequency, speed * scale / 8, **kwargs) self.scale = float(scale) self.callbacks = {timer_id: self.UpdateLocation} self.coords = (x, y, angle) self.callback = callback self.center_offset = center_offset viz.eyeheight(0.0) viz.setfov(70, 1) viz.mouse(viz.OFF) # don't want vizard mouse navigation viz.callback(viz.TIMER_EVENT, self.TimerCallback) viz.starttimer(timer_id, frequency, -1)
def __init__(self, callbackFrequency, maxSpeed=DEFAULT_MAX_SPEED, joyCalFile=None, joystick=True, keyboard=False, mouse=False, forward=True, backward=True, turn=True): self.JOY_MOVE_FREQUENCY = callbackFrequency self.REAL_MAX_SPEED = maxSpeed self.COLLISION_BUFFER = 5.0 * maxSpeed * callbackFrequency self.joystick = joystick self.keyboard = keyboard self.mouse = mouse self.forward = forward self.backward = backward self.turn = turn if joystick: if joyCalFile: self.LoadJoyCalFile(joyCalFile) else: self.LoadJoyCalFile() self.lastObjectIntersected = None viz.eyeheight(0.15) #viz.setfov(70,1) viz.mouse(viz.OFF) # don't want mouse input self.MoveTo([0, 0, 0]) self.CONVERT_SPEED = maxSpeed self.CONVERT_ROTSPEED = REAL_MAX_ROTSPEED
def setup_view(): # turn off headlight headLight = viz.MainView.getHeadLight() headLight.disable() # setup view point collision with a large buffer to account for large maze size viz.MainView.collision(viz.ON) viz.collisionbuffer(10) # Create a larger FOV to make the maze seem wider viz.fov(80, 1.1) # Set position, orientation, and eyeheight, and stepsize viz.MainView.setPosition(start_coords, viz.ABS_GLOBAL) viz.MainView.setEuler((0, 0, 0), viz.ABS_GLOBAL) viz.MainView.setEuler(start_ori, viz.BODY_ORI, viz.ABS_GLOBAL) viz.eyeheight(40) viz.stepsize(10)
def Init(LayoutFile=None,scale=4,speed=None,center_offset=0): """ Initialize the module. Must be called before any of the module functions can be called. Parameters: All parameters are optional. LayoutFile: <String> The name of the text file defining the map. If this parameter is provided, then the module will keep track of the subject's position in the layout and the subject will be prevented from moving through walls. This parameter must be given to use CanMoveForward and GetView. scale: <Float> The distance in meters between the center of two nodes in the environment. This is the distance that the subject will move when GoForward is called. speed: <Float> The speed that the subject will move forward in meters per second. If None, then the speed will be set to scale. center_offset: <Float> The distance in meters that the subject is separated from his axis of rotation. The axis of rotation is always the center of a node. Return Value: None. """ global __MOVEMENT_VAR, __PLAT_VAR if not speed: speed = scale __MOVEMENT_VAR = __MOVEMENT_CLASS(0,0,0,scale,speed,center_offset) viz.eyeheight(0.0) #viz.setfov(70,1) viz.mouse(viz.OFF) # don't want mouse input viz.callback(viz.TIMER_EVENT, TimerCallback) if LayoutFile: try: # use __PLAT_VAR to hold info about LayoutFile width, height, size = Navigator.getPlatDim(LayoutFile) __PLAT_VAR = Navigator.PLAT(width,height,size) __PLAT_VAR.ReadTextImage(LayoutFile) __PLAT_VAR.ComputeAllViews(100) except: __PLAT_VAR = None raise ("\n****** Error in Movement.Init ******\nUnable to initialize Plat Object with '%s'\n"%LayoutFile)
import viz from spaceInvadersModule import * window = viz.MainWindow window.ortho(-100, 100, -100, 100, -1, 1) window.clearcolor(viz.WHITE) viz.eyeheight(0) #s = Ship(0,0) #print(s.getX()) #print(s.getY()) #a = Alien(0,0) #print(a.getX()) #print(a.getY()) b = Bullet(0, 0) print(b.getX()) print(b.getY()) viz.go()
# Zach Ballard # File: runShapes.py import viz from Controller import * window = viz.MainWindow window.ortho(-320, 320, -240, 240, -1, 1) viz.window.setName( "Space Invaders" ) viz.eyeheight(0); Controller() vizact.onkeydown('b', viz.window.startRecording,'c:\\Temp\\spaceinvaders.avi') vizact.onkeydown('e', viz.window.stopRecording) viz.go()
out = "-1" # start empty world ################### PERSPECTIVE CORRECT ################## ###SET UP PHYSICAL DIMENSIONS OF SCREEN#### EH = 1.2 #metres from ground. Eye_ScreenDist = 1 #distance from screen of ocular point Proj_V = 1.115 #vertical extent of projection (m) Proj_H = 1.965 #horizontal extent of projection (m) # setting Field-of-View fov(vertical degree, horizontal ratio(vertical*ratio[deg])) vfov = ((np.arctan((Proj_V / 2) / Eye_ScreenDist)) * 2) * (180 / np.pi) h2v = Proj_H / Proj_V viz.go() viz.fov(vfov, h2v) #sets window aspect ratio. viz.eyeheight(1.2) #viz.MainView.setPosition(0,EH,0) viz.clip(1, 150) #Further clip means higher band of dots. ##Create array of trials. global radiiPool, occlPool #radiiPool = [50, 150, 250, 900, 1100, 1300, 2500, 3000, 3500, -1] #This was the selection used for Pilot. radiiPool = [ 300, 600, 900, 1200, 1500, 1800, 2100, 2400, 2700, 3000, 3300, 3600, -1 ] #13 radii conditions. 300m steps. occlPool = [0, .5, 1] #3 occlusion conditions N = len(radiiPool) * len(occlPool) ###Number of conditions. TRIALS = 10 #is this enough? Let's see. TotalN = N * TRIALS TRIALSEQ = range(1, N + 1) * TRIALS direc = [1, -1] * (TotalN / 2)
def changeViewBack(): viz.MainView.collision( viz.ON ) viz.eyeheight(1.7)
globalCrns.append( (x,y,z) ) # remove this vertex #cV.remove() i = i+1 return globalCrns # scale factor scFac = 60 viz.setMultiSample(4) viz.go() viz.eyeheight(ct.EYE_HEIGHT) # add code to navigate through scene via "wasd" control vizcam.WalkNavigate(forward='w', backward='s', left='a', right='d', moveScale=ct.MOVE_SPEED, turnScale=1.0) #Get a handle to the main headlight and disable it headLight = viz.MainView.getHeadLight() #dheadLight.disable() # add sky sky = viz.add('sky_day.osgb') # add grassy plane surrounded by mountains gScale = 1.1 hills = vizfx.addChild(os.path.join(ct.PATH_TO_OSGB, 'hills.osgb'))
# Start vrpn vrpn = viz.addExtension('vrpn7.dle') #desktop trackerLocationA = '[email protected]' #laptop trackerLocationB = '[email protected]' for i in range (24): trackers.append(vrpn.addTracker(trackerLocationA,i)) trackersB.append(vrpn.addTracker(trackerLocationB,i)) trueTrackers = trackers #######################view stuff###################### view = viz.MainView view.collision(viz.OFF) viz.eyeheight(PART_HEIGHT) view.setPosition(0,PART_HEIGHT,0) viz.link(tracker, view) #########################step stuff######################## foot = False #false left foot, true right foot, mostly used for debugging aIsTrue = False RIDICULOUS = 56 ###################gaze angle stuff####################### finalYaw = 0 previousYaw = 0 turning = 0 stepCount = 0 ########################foot angle stuff##################### aveFootAngle1 = 0 aveFootAngle2 = 0
self.belts['laval'].Stop() if self.belts.has_key(m): #check if this machine has wheels b = self.belts[m] b.Stop() def RemoveFactory (self): self.factory.remove(children = True) if __name__ == '__main__': import vizcam viz.setMultiSample(8) viz.go() viz.phys.enable() viz.eyeheight(1.75) viz.MainView.setPosition(-10,2,-5) #viz.MainView.setEuler(-90,0,0) #viz.fov(60) #viz.collision(viz.ON) viz.clearcolor(viz.SKYBLUE) viz.MainView.getHeadLight().disable() machines = ('scale') # machines = ('millR', 'millL', 'pressL', 'pressR', 'pumpL', 'pumpR', 'loader', 'lavalL', 'lavalR', 'oilPump', 'engine', 'boiler', 'scale') oliveFactory = Factory('GR') oliveFactory.AddMachinery(machines) oliveFactory.AddAllTools() # oliveFactory.AddOtherStuff() # pivot around object
def changeViewBack(): viz.MainView.collision( viz.ON ) viz.MainView.setPosition(0,0,0) viz.eyeheight(1.7)
def startNewTrial(self): # first trial: wait for space to start task if self.trialCtr < 0: text2D = viz.addText('Please press s to start', viz.SCREEN) text2D.setPosition(0.5,0.5,0.5) text2D.setScale([0.5, 0.5, 0.5]) text2D.alignment(viz.ALIGN_CENTER_CENTER) WalkNavigate(forward='w', backward='s', left='a', right='d', moveScale=0, turnScale=0) yield viztask.waitKeyDown('s') text2D.remove() # increment trial counter self.trialCtr = self.trialCtr+1 # did we reach end of round? if self.trialCtr <= len(self.trials)-1: self.cTrial = self.trials[self.trialCtr] else: self.logHdl.saveLogs('pointingTask') viz.quit() # reset log dict self.trialData.clear() # log trial data self.trialData['trialNr'] = self.trialCtr self.trialData['srcBuilding'] = self.cTrial.getName('src') self.trialData['srcCtxt'] = self.cTrial.getContext('src') x,_,z = self.cTrial.getPos('src', 'near') self.trialData['srcXZ'] = (x,z) self.trialData['trgBuilding'] = self.cTrial.getName('trg') self.trialData['trgCtxt'] = self.cTrial.getContext('trg') x,_,z = self.cTrial.getPos('trg', 'center') self.trialData['trgXZ'] = (x,z) # hide all buildings self.hideBuildings() # hide grid self.cross90.visible(viz.OFF) self.grid.visible(viz.OFF) # block user navigation WalkNavigate(forward='w', backward='s', left='a', right='d', moveScale=0, turnScale=0) # show source building self.cTrial.showBuilding('src', 'opaque') # move & refVert view to far pos x,_,z = self.cTrial.getPos('src', 'far') viz.MainView.setPosition(x, 0, z) # align mainview to src building _,_,_,degs = self.cTrial.getAngle('src', 'far') viz.MainView.setAxisAngle(0, 1, 0, -degs) viz.eyeheight(ct.EYE_HEIGHT) viztask.schedule( self.moveView() ) # log reference angle self.trialData['refAngle'] = degs print "Please look at: %s"%self.cTrial.getName('trg')