示例#1
0
if __name__ == "__main__":

    expConfigName = 'exampleExpConfig.cfg'
    import vrlabConfig
    config = vrlabConfig.VRLabConfig(expConfigName)

    #def __init__(self, config=None, planeName = 'floor', isAFloor = 1, caveCornersFileName = None, debug = True):
    env = virtualPlane(caveCornersFileName='caveWallDimensions.cave',
                       config=config,
                       planeName='floor',
                       isAFloor=1)

    import visEnv
    #def __init__(self,room,shape,size,position=[0,.25,-3],color=[.5,0,0],alpha = 1):

    room = visEnv.room(config)
    room.walls.remove()

    viz.addChild('piazza.osgb')

    shutterRigid = config.mocap.returnPointerToRigid('shutter')

    eyeSphere = visEnv.visObj(room, 'sphere', size=0.1, alpha=1)
    eyeSphere.setMocapRigidBody(config.mocap, 'shutter')

    eyeSphere.toggleUpdateWithRigid()

    env.attachViewToGlasses(eyeSphere.visNode, shutterRigid)

    markerNum = 0
示例#2
0
    import visEnv

    viz.window.setFullscreenMonitor([1])
    viz.setMultiSample(4)
    viz.MainWindow.clip(0.01, 200)

    viz.go(viz.FULLSCREEN)
    viz.MainView.setPosition([-5, 2, 10.75])
    viz.MainView.lookAt([0, 2, 0])

    print str(viz.phys.getGravity())

    viz.vsync(1)

    # Configure the simulation using VRLABConfig
    # This also enables mocap

    # Create environment
    room = visEnv.room()

    ballInitialPos = [0, 3, 0]
    ballInitialVel = [0, 0, 0]

    ball = visEnv.visObj(room, 'sphere', .07, ballInitialPos)

    ball.enablePhysNode()
    ball.linkToPhysNode()

    ball.setBounciness(0.5)
    ball.physNode.enableMovement()  # Turns on kinematics
示例#3
0
if __name__ == "__main__":

	import vizact
	import visEnv

	viz.window.setFullscreenMonitor([1]) 
	viz.setMultiSample(4)
	viz.MainWindow.clip(0.01 ,200)

	viz.go(viz.FULLSCREEN)
	viz.MainView.setPosition([-5,2,10.75])
	viz.MainView.lookAt([0,2,0])

	print str( viz.phys.getGravity() )

	viz.vsync(1)

	# Configure the simulation using VRLABConfig
	# This also enables mocap

	# Create environment
	room = visEnv.room()

	ballInitialPos = [0,3,0]
	ballInitialVel = [0,0,0]

	ball = visEnv.visObj(room,'sphere',.07,ballInitialPos)
	ball.toggleUpdateWithPhys() # Visobj are inanimate until either tied to a physics or motion capture object
	ball.setBounciness(0.5)
	ball.physNode.enableMovement() # Turns on kinematics
示例#4
0
	def __init__(self, config):
		
		# Event classes can register their own callback functions
		# This makes it possible to register callback functions (e.g. activated by a timer event)
		# within the class (that accept the implied self argument)
		# eg self.callbackFunction(arg1) would receive args (self,arg1)
		# If this were not an eventclass, the self arg would not be passed = badness.
		
		viz.EventClass.__init__(self)
		
		##############################################################
		##############################################################
		## Use config to setup hardware, motion tracking, frustum, eyeTrackingCal.
		##  This draws upon the system config to setup the hardware / HMD
		
		self.config = config 

		# Eventually, self.config.writables is passed to DVRwriter
		# self.config.writables is a list
		# dvrwriter will attempt to run .getOutput on every member of the list
		# One could then add experiment, theBall, theRacquet, eyeTrackingCal to the list, assuming 
		# they include the member function .getOutput().
		# I prefer to do all my data collection in one place: experiment.getOutput()
		
		self.config.writables = [self]
		
		################################################################
		################################################################
		## Set states
		
		self.inCalibrateMode = False
		self.inHMDGeomCheckMode = False
		self.setEnabled(False)
		self.test_char = None

		################################################################
		################################################################
		# Create visual and physical objects (the room)
	
		self.room = visEnv.room(config)
		
		# self.room.physEnv 
		self.hmdLinkedToView = False
		
		################################################################
		################################################################
		# Build block and trial list
		
		self.blockNumber = 0;
		self.trialNumber = 0;
		self.inProgress = True;
		
		self.blocks_bl = []
		
		for bIdx in range(len(config.expCfg['experiment']['blockList'])):
			self.blocks_bl.append(block(config,bIdx));
		
		self.currentTrial = self.blocks_bl[self.blockNumber].trials_tr[self.trialNumber]
		
#		################################################################
#		################################################################
#		##  Misc. Design specific items here.

		if( config.wiimote ):
			self.registerWiimoteActions()
		
		# Setup launch trigger
		#self.launchKeyIsCurrentlyDown = False
		
		#self.minLaunchTriggerDuration = config.expCfg['experiment']['minLaunchTriggerDuration']
		
		# maxFlightDurTimerID times out balls a fixed dur after launch
		#self.maxFlightDurTimerID = viz.getEventID('maxFlightDurTimerID') # Generates a unique ID. 
		
		################################################################
		##  LInk up the hmd to the mainview
		
		if( self.config.use_phasespace == True ):
			
			################################################################
			##  Link up the hmd to the mainview
			if( self.config.use_HMD and  config.mocap.returnPointerToRigid('hmd') ):
				self.config.mocap.enableHMDTracking()
						# If there is a paddle visObj and a paddle rigid...
		
		#self.setupPaddle()
					
			
		##############################################################
		##############################################################
		## Callbacks and timers
		
		vizact.onupdate(viz.PRIORITY_PHYSICS,self._checkForCollisions)
		
		#self.callback(viz.TIMER_EVENT, self.timer_event)
		self.callback(viz.KEYDOWN_EVENT,  self.onKeyDown)
		self.callback(viz.KEYUP_EVENT, self.onKeyUp)
		self.callback( viz.TIMER_EVENT,self._timerCallback )
		
		self.perFrameTimerID = viz.getEventID('perFrameTimerID') # Generates a unique ID. 
		self.starttimer( self.perFrameTimerID, viz.FASTEST_EXPIRATION, viz.FOREVER)
		
		# DVR snaps a shot of the frame, records eye data, and contents of self.writables is written out to the movie
		self.callback(viz.POST_SWAP_EVENT, self.config.__record_data__, viz.PRIORITY_LAST_UPDATE)
	
		# Use text output!
		if( config.sysCfg['use_DVR'] >0):
			
			vizact.ontimer(3,self.checkDVRStatus)
			
			now = datetime.datetime.now()
			dateTimeStr = str(now.year) + '-' + str(now.month) + '-' + str(now.day) + '-' + str(now.hour) + '-' + str(now.minute)
			
			dataOutPutDir = config.sysCfg['writer']['outFileDir']
			
			self.expDataFile = open(dataOutPutDir + 'exp_data-' + dateTimeStr + '.txt','a')
			
			if( self.config.sysCfg['use_eyetracking']):
				self.eyeDataFile = open(dataOutPutDir + 'eye_data-' + dateTimeStr + '.txt','a')
			
			vizact.onupdate(viz.PRIORITY_LAST_UPDATE,self.writeDataToText)
		
		# Create an event flag object
		# This var is set to an int on every frame
		# The int saves a record of what was happening on that frame
		# It can be configured to signify the start of a trial, the bounce of a ball, or whatever
		
		self.eventFlag = eventFlag()