def set_graphics_quality():
    """Vsync ON; Multisample 8, glFinish ON."""
    # Just to make sure vertical sync is ON, against tearing.
    viz.vsync(1)
    # Helps reduce latency.
    viz.setOption('viz.glFinish', 1)
    viz.setMultiSample(8)
def main():

    viz.vsync(viz.ON)
    viz.window.setFullscreenMonitor([2])
    viz.setMultiSample(4)
    viz.MainWindow.clip(0.01, 200)

    viz.go(viz.FULLSCREEN)

    environment = viz.addChild("piazza.osgb")
    environment.setPosition(2.75, 0, -0.75)

    mocap = phasespace.Phasespace()

    head = mocap.get_rigidTracker("hmd")

    # DOES NOT ACCOUNT FOR RIGID BODY OFFSET DURING RESET

    # mocap.track_rigid('Resources/hmd-nvisMount.rb', center_markers=(1,2))
    head.link_pose(viz.MainView)

    # glove = mocap.track_points([8, 9, 10])

    paddle = mocap.track_rigid({17: (0, 0, 1), 19: (0, 0, 0), 20: (1, 0, 0), 22: (0, 1, 0)})

    mocap.start_thread()
    # mocap.start_timer()

    def log_mocap(timer_id):
        # print 'glove#9 pos {0[1]:.2f} {0[1]:.2f} {0[2]:.2f}'.format(*glove.get_marker(9))
        print "head    pos {0[0]:.2f} {0[1]:.2f} {0[2]:.2f}, quat {1[0]:.3f} {1[1]:.3f} {1[2]:.3f} {1[3]:.3f}".format(
            *head.get_pose()
        )
        print "main    " + str(viz.MainView.getPosition())
        # print 'paddle  pos {0[0]:.2f} {0[1]:.2f} {0[2]:.2f}, quat {1[0]:.3f} {1[1]:.3f} {1[2]:.3f} {1[3]:.3f}'.format(*paddle.get_pose())

    viz.callback(viz.TIMER_EVENT, log_mocap)
    viz.starttimer(0, 1, viz.FOREVER)

    def keydown(key):

        if key == "h":
            head.reset()
        if key == "H":
            head.save()
        elif key == "1":

            print "Marker Pos: " + str(mocap.get_MarkerPos(1))

    viz.callback(viz.KEYDOWN_EVENT, keydown)
	def __init__(self):

		viz.go(viz.FULLSCREEN |viz.QUAD_BUFFER)
		viz.window.setFullscreen(1)

		#####################
		#setup CAVE
		polyMode = viz.POLY_WIRE
		#viz.setFarPlane(1)
		#viz.setMultiSample(4) #didn't observe a difference in landscapes with anti-aliasing.
		viz.window.setPolyMode(viz.POLY_WIRE)
		viz.vsync(viz.ON)#this may increase frame rate but may get tears
		viz.ipd(0.2) #20 cm apart eyes seemed right for our scaling.

		self.cave = vizcave.Cave()
Beispiel #4
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
Beispiel #5
0
    def __setupSystem(self):

        # Set up the wiimote
        ################################################################
        ################################################################
        ##  Misc. Design specific items here.
        if (self.sysCfg['use_wiimote']):
            # Create wiimote holder
            self.wiimote = 0
            self._connectWiiMote()

        #Set up the HMD
        if self.sysCfg['use_hmd']:
            self.hmd = HMD(self.sysCfg['hmd'], True)
            self.use_HMD = True
        else:
            self.hmd = HMD(self.sysCfg['hmd'], False)
            self.use_HMD = False

        viz.window.setFullscreenMonitor(self.sysCfg['displays'])

        viz.setMultiSample(self.sysCfg['antiAliasPasses'])
        viz.MainWindow.clip(0.01, 200)
        viz.vsync(1)

        viz.setOption("viz.glfinish", 1)
        viz.setOption("viz.dwm_composition", 0)

        #Set up recording
        if self.sysCfg['use_DVR'] == 1:
            self.use_DVR = True
        else:
            self.use_DVR = False
        self.writer = None  #Will get initialized later when the system starts

        #Set up the eye tracking callibration/configuration (eyeTrackingCal)

        if self.sysCfg['use_eyetracking']:
            self.use_eyeTracking = True
            if self.sysCfg['hmd']['type'] == 'nvis':

                import EyeTrackerCalibrationNVIS_MT
                self.eyeTrackingCal = EyeTrackerCalibrationNVIS_MT.EyeTrackerCalibrationNVIS(
                    self.sysCfg['eyetracker']['settingsDir'])
                self.eyeTrackingCal.changeDisplayNum(
                    self.sysCfg['displays'][0])

                print "Eye tracking enabled using NVIS visor"
            else:
                print "Error in VRLabConfig: Eye-tracking not setup for this HMD."
                sys.exit(1)
        else:
            self.use_eyeTracking = False
            self.eyeTrackingCal = None

        self.mocap = None
        self.bodyCam = None

        if self.sysCfg['use_phasespace']:

            from mocapInterface import phasespaceInterface
            self.mocap = phasespaceInterface(self.sysCfg)

            self.use_phasespace = True
        else:
            self.use_phasespace = False

        if self.sysCfg['use_virtualPlane']:

            isAFloor = self.sysCfg['virtualPlane']['isAFloor']
            planeName = self.sysCfg['virtualPlane']['planeName']
            planeCornerFile = self.sysCfg['virtualPlane']['planeCornerFile']
            self.virtualPlane = virtualPlane.virtualPlane(
                self, planeName, isAFloor, planeCornerFile)

        if self.sysCfg['use_virtualPlane']:
            viz.go(viz.FULLSCREEN | viz.QUAD_BUFFER)
        elif self.sysCfg['use_fullscreen']:
            viz.go(viz.FULLSCREEN)
        else:
            viz.go()
Beispiel #6
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.enablePhysNode()
    ball.linkToPhysNode()
Beispiel #7
0
import vizcam
import numpy
import vizinput
import random

# Owned
__author__ = "Josh Julian"
__license__ = "MIT"


viz.fov(40)
viz.setMultiSample(4)
viz.go(viz.FULLSCREEN)
viz.mouse.setVisible(viz.OFF)
viz.antialias = 4
viz.vsync(viz.ON)

###################
##OPEN DATA FILE ##
###################

global runNum
subject = vizinput.input('What is the sub number?') 
runNum = vizinput.input('What is the run rumber?') 
dpath = '..\Data\TestingData\\'
runNum = int(runNum)
runLength = 8.075*60 #in seconds

fname = dpath + 'TEST_tracking_'+str(subject)+'_'+ str(runNum)+'.txt'

###check for existing data file <-uncomment for actual testing, along with input function above
C0 = 0,6,0   # Front  Wall: C1,C2,C5,C6 
C1 = 0,6,8   # Left   Wall: C0,C1,C4,C5 
C2 = 8,6,8   # Right  Wall: C2,C3,C6,C7 
C3 = 8,6,0   # Bottom Wall: C5,C6,C4,C7 
C4 = 0,0,0 
C5 = 0,0,8 
C6 = 8,0,8 
C7 = 8,0,0

#Create front wall 
FrontWall = vizcave.Wall(   upperLeft=C1, 
                            upperRight=C2, 
                            lowerLeft=C5, 
                            lowerRight=C6, 
                            name='Front Wall' ) 

cave = vizcave.Cave()
cave.addWall(FrontWall, mask=viz.MASTER)


viz.window.setFullscreenMonitor(1)
viz.window.setFullscreen(viz.ON)
vizconnect.go('test_projection_config.py')


viz.vsync(viz.ON)

#viz.MainWindow.setStereoSwap(viz.TOGGLE)

piazza = viz.addChild('piazza.osgb')
	subj = CrossSubject()
	yield subj.grab_info()
	
	# -- Where will the trigger pulses be coming from?
	yield get_trigger()
	
	# -- Load the timings for this experiment
	subj.get_experiment()
	
	# -- Start the experiment, waiting for a trigger
	for nblock,block in enumerate(subj.blocks):
		blockdata = yield cross_block(block,training=subj.is_training)
		subj.add_block_data(nblock,blockdata)
	
	# -- write the data we just collected to text
	subj.write_data()
	
	# -- Close the program
	viz.quit()

if __name__=="__main__":
	viz.go()
	viz.window.setFullscreenMonitor(1)
	viz.window.setFullscreen(viz.ON)
	# ------ Options for vizard display
	viz.vsync(0)
	viz.setOption('viz.max_frame_rate',60)
	viz.clearcolor(viz.GRAY)
	
	# ------ Run the experiment!
	viztask.schedule(experiment())
Beispiel #10
0
	def __setupSystem(self):
		
		# Set up the wiimote
		################################################################
		################################################################
		##  Misc. Design specific items here.
		if( self.sysCfg['use_wiimote']):
			# Create wiimote holder
			self.wiimote = 0
			self._connectWiiMote()
		
		#Set up the HMD
		if self.sysCfg['use_hmd']:
			self.hmd = HMD(self.sysCfg['hmd'], True)
			self.use_HMD = True
		else:
			self.hmd = HMD(self.sysCfg['hmd'], False)
			self.use_HMD = False
		
		
		viz.window.setFullscreenMonitor(self.sysCfg['displays'])
		
		viz.setMultiSample(self.sysCfg['antiAliasPasses'])
		viz.MainWindow.clip(0.01 ,200)
		viz.vsync(1)
		
		viz.setOption("viz.glfinish", 1)
		viz.setOption("viz.dwm_composition", 0)
		
		#Set up recording
		if self.sysCfg['use_DVR'] == 1:
			self.use_DVR = True
		else:
			self.use_DVR = False
		self.writer = None #Will get initialized later when the system starts
		
		#Set up the eye tracking callibration/configuration (eyeTrackingCal)
		
		if self.sysCfg['use_eyetracking']:
			self.use_eyeTracking = True
			if self.sysCfg['hmd']['type'] == 'nvis':
			
				import EyeTrackerCalibrationNVIS_MT
				self.eyeTrackingCal = EyeTrackerCalibrationNVIS_MT.EyeTrackerCalibrationNVIS(self.sysCfg['eyetracker']['settingsDir'])
				self.eyeTrackingCal.changeDisplayNum(self.sysCfg['displays'][0])
				
				
				print "Eye tracking enabled using NVIS visor"
			else:
				print "Error in VRLabConfig: Eye-tracking not setup for this HMD."
				sys.exit(1)
		else:
			self.use_eyeTracking = False
			self.eyeTrackingCal = None
			
		#self.writables.append(self.eyeTrackingCal)
			
		self.mocap = None
		self.bodyCam = None
		
		if self.sysCfg['use_phasespace']:
			
			from mocapInterface import phasespaceInterface			
			self.mocap = phasespaceInterface(self.sysCfg);
				
			self.use_phasespace = True
		else:
			self.use_phasespace = False
		
		if self.sysCfg['use_hiball']:
			from HiBallCameraMT import HiBallCamera
			#self.mocap = HiBallCamera(self.sysCfg['hiball']['origin'], self.sysCfg['hiball']['scale'], None, None, self.sysCfg, None);
			self.mocap = HiBallCamera(self.sysCfg['hiball']['origin'], particle=None, sensorNum=self.sysCfg['hiball']['headCam'], attachTo=viz.MainView, preTrans = self.sysCfg['hiball']['preTransHead'])
			if self.sysCfg['hiball']['bodyCam'] != -1:
				self.bodyCam = HiBallCamera(self.sysCfg['hiball']['origin'], particle=None, sensorNum=self.sysCfg['hiball']['bodyCam'], attachTo=None, preTrans = self.sysCfg['hiball']['preTransBody'])
			else:
				self.bodyCam = None
			self.use_hiball = True
		else:
			self.use_hiball = False
		

		self.writables.append(self.mocap)
		self.writables.append(self.bodyCam)
		
		if self.sysCfg['use_fullscreen']:
			viz.go(viz.FULLSCREEN)
		else:
			viz.go()
		
		self._setWinPriority(priority=5)
	
	mocap.enableHMDTracking()
	
	# Auto-update the mainview with the rigid body position
	# Note the use of 'hmd' as a partial string.
	# This is used to find a rigid body file that contains this string
	# In my case, hmd-oculus.rb
	#vizact.onupdate(viz.PRIORITY_FIRST_UPDATE,mocap.updateMainViewWithRigid,'hmd')
	#vizact.onupdate(viz.PRIORITY_FIRST_UPDATE,mocap.getMarkerPosition,1)
	
	#import oculus
	#hmd = oculus.Rift()
	import nvis
	hmd = nvis.nvisorSX111()
	
	hmdRigid = mocap.allRigidBodyObjects[mocap.rigidHMDIdx];			
	
	viz.vsync(viz.OFF)
	
	viz.window.setFullscreenMonitor([1,2]) 
	viz.setMultiSample(4)
	viz.MainWindow.clip(0.01 ,200)
	
	viz.go(viz.FULLSCREEN)
	
	vizact.onkeydown( 'h', mocap.resetRigid, 'hmd' );
	vizact.onkeydown( 'H', mocap.saveRigid, 'hmd' );
	vizact.onkeydown( 'p', mocap.resetRigid, 'paddle' );
	vizact.onkeydown( 'P', mocap.saveRigid, 'paddle' );
	vizact.onkeydown( 'e', mocap.enableHMDTracking);