Exemple #1
0
def main():
	global loc_list
	global active_location
	loc_list = []
	
	mainSceneWindow = None
	cameraWindow = None
	cameraWindowView = None
	cam = None
	pause_screen = None
	nunchuck_disconnect_screen = None
	message_screen = None
	wiimote = None
	nunchuck_wiimote = None
	should_it_run = None
	
	mainSceneWindow, cameraWindow, cameraWindowView, cam, pause_screen, nunchuck_disconnect_screen, message_screen, wiimote, nunchuck_wiimote, should_it_run = init_settings(mainSceneWindow, cameraWindow, cameraWindowView, cam, pause_screen, nunchuck_disconnect_screen, message_screen, wiimote, nunchuck_wiimote, should_it_run)
	
	vizact.ontimer(0, moveCamera, nunchuck_wiimote, should_it_run)
	viz.callback(wii.EXT_CONNECT_EVENT,onConnect)
	viz.callback(wii.EXT_DISCONNECT_EVENT,onDisconnect)
	
	initializer(loc_list)
	arMarkerLoader(cam)
	wiimoteInitializer(wiimote, nunchuck_wiimote, should_it_run, message_screen)
	
	viz.go() # Inicia VIZ
	
	for item in loc_list:
		if item.space_name == "piazza.osgb":
			active_location = item
			item.addLocation()
    def setup_world(self):
        viz.setOption('viz.fullscreen.monitor', 1)
        #viz.setOption('viz.window.width', 2560)
        #viz.setOption('viz.window.height', 1040)
        #viz.setMultiSample(4)
        #viz.MainWindow.clip(0.01, 500)
        #viz.vsync(1)

        vizconfig.register(nvis.nvisorSX111())

        viz.go(viz.FULLSCREEN)
def main():
    global TRACKER

    viz.go(0)

    # configure the phasespace.
    mocap = vrlab.Phasespace('192.168.1.230', freq=100., postprocess=True)
    mocap.start_thread()
    TRACKER = mocap.track_points(M)

    viztask.schedule(workflow)
	def go(self):
		"""Use this command to start the application."""
		
			
		if self.__cave_mode:
			viz.go(viz.STEREO | viz.FULLSCREEN)
		else:
			viz.go(viz.FULLSCREEN)
				
		viz.mouse.setOverride(viz.ON)
		
		self.callback(viz.UPDATE_EVENT,self.__onUpdate)
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 __setupVizParams__(self):
		
		#Just playing here#
		#viz.setMultiSample(8)
		#viz.fov(120)
		
		#Check monitor refresh rate and set stereo mode accordingly#
		monitor_RefreshRate = viz.getOption('viz.monitor.refresh_rate', type=int)
		#if(119 <= monitor_RefreshRate):
			#Turn on the physics engine
		viz.phys.enable() 
		viz.window.setFullscreenMonitor(2)
		viz.setMultiSample(8)
		viz.go(viz.FULLSCREEN | viz.QUAD_BUFFER)
		print "here"
	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()
Exemple #8
0
def InitHMD():
	global collisionLimbBoxes
	if(USE_HMD):
		pptExtension.setup();
		viz.go(viz.FULLSCREEN)
		viz.clip(0.1)
		vizact.onupdate(0, pptExtension.pptUpdate, avatar, ghostAvatar, collisionLimbBoxes);
		if(len(collisionLimbBoxes) > 0):
			vizact.ontimer(1, pptExtension.refreshAvatar, ghostAvatar, avatar, collisionLimbBoxes);
		else:
			vizact.ontimer(1, pptExtension.refreshAvatar, ghostAvatar, avatar, None);
	else:
		pptSimulation.setup(avatar);
		viz.clip(0.1)
		viz.go(viz.FULLSCREEN);
		vizact.onupdate(0, pptSimulation.pptUpdate, avatar, ghostAvatar, collisionLimbBoxes);
Exemple #9
0
def InitHMD():
#BL:start		
	global collisionLimbBoxes
#	if USE_HMD:
	pptextension.setup()
	if some_global_variables.headTrackingActive:
		viz.go(viz.HMD | viz.TRACKER)
	else:
		viz.go()
	viz.window.setSize(1260, 950)		
	#viz.go(viz.FULLSCREEN)
#BL:end
	viz.clip(0.1)
	vizact.onupdate(0, pptextension.pptUpdate, some_global_variables.avatar, some_global_variables.ghostAvatar, collisionLimbBoxes);
	if(len(collisionLimbBoxes) > 0):
		vizact.ontimer(1, pptextension.refreshAvatar, some_global_variables.ghostAvatar, some_global_variables.avatar, collisionLimbBoxes);
	else:
		vizact.ontimer(1, pptextension.refreshAvatar, some_global_variables.ghostAvatar, some_global_variables.avatar, None);
def main():
    viz.setOption('viz.fullscreen.monitor', 1)
    viz.setOption('viz.window.width', 2 * 640)
    viz.setOption('viz.window.height', 480)
    viz.setMultiSample(4)
    viz.MainWindow.clip(0.01, 500)

    vizconfig.register(nvis.nvisorSX111())

    viz.go(viz.FULLSCREEN)

    piazza = viz.addChild('piazza.osgb')

    mocap = phasespace.Mocap('192.168.1.230')

    head = mocap.track_rigid('Resources/hmd-nvis.rb', center_markers=(0, 5))
    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 '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(*args):
        head.reset()
        paddle.reset()

    viz.callback(viz.KEYDOWN_EVENT, keydown)
Exemple #11
0
def vhilGo(rift=False, ppt1=False, OH=False, otherTrackerVirtualIDs=[], debug=False, homePos=[0,1.82,0], homeOri=[0,0,0]): #, **kwargs
	global RIFT
	global PPT1
	global DEBUG
	global HOME_POS
	global HOME_ORI
	
	# Run-context constants #
	RIFT = rift # Indicates whether we are going to run the simulation on an Oculus Rift.
	PPT1 = ppt1 # Indicates whether we are going to run the simulation in PPT1.
	DEBUG = debug # Indicates whether we are going to run the simulation in debug mode, enabling extra controls and features
	
	# HOME_POS, HOME_ORI: Starting position and orientation of viz.MainView.
	# reset() resets to the home position and home orientation by default.
	HOME_POS = homePos
	HOME_ORI = homeOri

	viz.go()
	reset()
	return setupHardware(OH, otherTrackerVirtualIDs)
Exemple #12
0
def InitHMD():
    # BL:start
    global collisionLimbBoxes, isLeftHanded
    if USE_HMD:
        viz.go(viz.HMD | viz.TRACKER)
        viz.window.setSize(1260, 950)
        pptExtension.setup(isLeftHanded)
        # viz.go(viz.FULLSCREEN)
        # BL:end
        viz.clip(0.1)
        vizact.onupdate(0, pptExtension.pptUpdate, avatar, ghostAvatar, collisionLimbBoxes)
        if len(collisionLimbBoxes) > 0:
            vizact.ontimer(1, pptExtension.refreshAvatar, ghostAvatar, avatar, collisionLimbBoxes)
        else:
            vizact.ontimer(1, pptExtension.refreshAvatar, ghostAvatar, avatar, None)
    else:
        pptSimulation.setup(avatar)
        viz.clip(0.1)
        viz.go(viz.FULLSCREEN)
        vizact.onupdate(0, pptSimulation.pptUpdate, avatar, ghostAvatar, collisionLimbBoxes)
Exemple #13
0
def InitHMD():
	global collisionLimbBoxes
	if(USE_HMD):
#BL:start		
		viz.go(viz.HMD | viz.TRACKER)
		viz.window.setSize(1260, 950)		
		pptExtension.setup();
		#viz.go(viz.FULLSCREEN)
#BL:end
		viz.clip(0.1)
		vizact.onupdate(0, pptExtension.pptUpdate, avatar, ghostAvatar, collisionLimbBoxes);
		if(len(collisionLimbBoxes) > 0):
			vizact.ontimer(1, pptExtension.refreshAvatar, ghostAvatar, avatar, collisionLimbBoxes);
		else:
			vizact.ontimer(1, pptExtension.refreshAvatar, ghostAvatar, avatar, None);
	else:
		pptSimulation.setup(avatar);
		viz.clip(0.1)
		viz.go(viz.FULLSCREEN);
		vizact.onupdate(0, pptSimulation.pptUpdate, avatar, ghostAvatar, collisionLimbBoxes);
Exemple #14
0
def setUp():
	global currentCondition
	
	viz.setMultiSample(8)
	initGlobals()
	
	currentCondition = viz.choose('Select condition:', CONDITION_CHOICES)
	print "CurCondition:", currentCondition
	
	setFlags()

#	setUpRecording()
#
#	if YOKE_F:
#		setUpYoke()
#
#	if not FLYING_F:
#		setUpHelicopter()
#	
#	if(not confirmStates(currentCondition)):
#		viz.quit()
#		finish()  #TODO make it so that on failure no files are created.
#		return
#
#	#configData()
	
	if USE_HMD_F:
		setUpHMD()
		if not FLYING_F:
			setHeliInitPos()
	else:
		viz.go()
		viz.MainView.setPosition(START_POSITION_HELI)

	setUpWorld()

	setUpChild()
	
	setUpSound()
    def __init__(self, filename=''):
        '''Opens and interprets configuration files for running experiments.

        This constructor opens both the system config (as defined by the
        <platform>.cfg file) and the experiment config (as defined by the given
        filename).

        Both configurations must conform the specs given in SYSTEM.ini and
        experiment.ini respectively. It also initializes the system as specified
        in the system config.
        '''
        self.exp = self.create_exp_config(filename)
        self.sys = self.create_sys_config()
        for path in self.sys['set_path']:
            viz.res.addPath(path)

        viz.window.setFullscreenMonitor(self.sys['displays'])
        viz.setMultiSample(self.sys['antiAliasPasses'])
        viz.MainWindow.clip(0.01, 200)

        self.writables = []
        self.writer = None
        self.mocap = None
        self.body_camera = None

        self._setup_hmd()
        self._setup_recorder()
        self._setup_eyetracking()
        self._setup_phasespace()
        self._setup_hiball()

        self.writables.append(self.mocap)
        self.writables.append(self.body_camera)

        if self.sys['use_fullscreen']:
            viz.go(viz.FULLSCREEN)
        else:
            viz.go()
Exemple #16
0
def setUpHMD():
	global lhTracker, rhTracker, flyingLink, headTracker
	viz.window.setSize(1520,1205)
	viz.go(viz.TRACKER)

	
	view = viz.MainView
#	isense = viz.add('intersense.dle')
#	headTracker = isense.addTracker(port=1)
#	vizact.onkeydown('r',headTracker.resetHeading)
	#vrpn = viz.add('vrpn7.dle')
	#Tracker_HOSTNAME = '171.64.33.43'
	
	from vizconnect.util.virtual_trackers import OpticalHeading
	
	import steamvr
	# vive view will take the Main View (viz.MainView)
	hmd = steamvr.HMD()


		
### Trackers ###

	ORI_TRACKER = hmd.getSensor()
	offsetMarkerNode = viz.addGroup()
	headTracker = viz.link(ORI_TRACKER, offsetMarkerNode)

	lhTracker = steamvr.getControllerList()[0]
	rhTracker = steamvr.getControllerList()[1]
	
	viveViewLink = viz.link(headTracker, viz.MainView)

	
	if FLYING_F:
		flyingLink = viveViewLink
		flyingLink.postTrans(START_POSITION_BASE)
def vhilGo(
    vive=False,
    ppt1=False,
    OH=False,
    otherTrackerVirtualIDs=[],
    debug=False,
    homePos=[0, 1.82, 0],
    homeOri=[0, 0, 0],
    keyboardcontrol=True,
    mode=0,
    **kwargs
):
    global VIVE
    global PPT1
    global DEBUG
    global HOME_POS
    global HOME_ORI

    # Run-context constants #
    VIVE = vive  # Indicates whether we are going to run the simulation on an HTC Vive.
    PPT1 = ppt1  # Indicates whether we are going to run the simulation in PPT1.
    DEBUG = (
        debug
    )  # Indicates whether we are going to run the simulation in debug mode, enabling extra controls and features

    # HOME_POS, HOME_ORI: Starting position and orientation of viz.MainView.
    # reset() resets to the home position and home orientation by default.
    HOME_POS = homePos
    HOME_ORI = homeOri

    viz.go(mode)

    if keyboardcontrol:
        keyboardControl(viz.MainView)

    return setupHardware(OH, otherTrackerVirtualIDs, **kwargs)
Exemple #18
0
	def display(self):
		"""
		Initialize the display
		
		Mode selection:
			0 - Regular computer
			1 - 3D TV
			2 - Oculus rift
		"""
		if self.displayMode == 0:
			viz.setMultiSample(4)
			viz.fov(60)
			viz.window.setSize([1280,720])
			viz.go()
			viz.window.setFullscreenMonitor(1)
#			viz.go(viz.FULLSCREEN) #viz.FULLSCREEN

		elif self.displayMode == 1:
			viz.setMultiSample(4)
			viz.go(viz.STEREO_HORZ | viz.FULLSCREEN)
			
		elif self.displayMode == 2:
			viz.go(viz.STEREO_HORZ)
			viz.setMultiSample(16)
			viz.window.setSize([1280,720])
			
			KEYS = {
				'reset'		: 'r',
				'camera'	: 'c'}
			
			# Helps reduce latency
			#do not use ? makes things worse.
			#viz.setOption('viz.glFinish',1)
		
		elif self.displayMode == 3:
			viz.setMultiSample(4)
			viz.fov(60)
			viz.go(viz.FULLSCREEN) #viz.FULLSCREEN
			viz.window.setFullscreenMonitor(2)

		# Initial direction of main view
		viz.MainView.setEuler([0,0,0])
		viz.MainView.setPosition([0,0,-3], viz.ABS_GLOBAL)
Exemple #19
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()

        ################################################################
        ##  HMD

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

        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)

        ################################################################
        ##  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)

        ################################################################
        ##  Eyetracking

        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

        ################################################################
        ##  Mocap

        #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);

            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()
Exemple #20
0
    def __init__(self):
        viz.EventClass.__init__(self)

        ### Real - world measurements of the display. Specifies a 'viewport' into the virtual world.

        self.EH = 1.2
        Proj_Dist = 1.0  #front projection distance to Eye

        Proj_V_F = 1.115  #vertical extent of projection (m)
        Proj_H_F = 1.985  #1.96#horizontal extent of projection (m)

        Proj_HfG = .665  #Front projection height from ground.

        FB = Proj_HfG  #FrontBottom
        FT = Proj_HfG + Proj_V_F  #FrontTop

        FL = -Proj_H_F / 2  #Front Left
        FR = Proj_H_F / 2  #Front Right

        FC0 = FL, FB, Proj_Dist  # Front  Wall: FC0,FC1,FC2,FC3
        FC1 = FR, FB, Proj_Dist
        FC2 = FL, FT, Proj_Dist
        FC3 = FR, FT, Proj_Dist

        self.FrontWall = vizcave.Wall(upperLeft=FC2,
                                      upperRight=FC3,
                                      lowerLeft=FC0,
                                      lowerRight=FC1,
                                      name='Front Wall')  #Create front wall

        viz.setMultiSample(8)  #set anti-aliasing

        #Initialize graphics window
        viz.go()
        #	viz.eyeheight(1.2)
        #for monitor in viz.window.getMonitorList():
        #    print monitor.name
        #    print '   ',monitor

        viz.window.setFullscreenMonitor(2)
        viz.window.setFullscreen(viz.ON)

        self.cave = vizcave.Cave(stereo=0)
        self.cave.addWall(self.FrontWall)  #,window=self.frontWindow)

        # print ("1_N: ", self.cave.getNearPlane()) #default is [.1, -1.]
        # print ("1_F: ", self.cave.getFarPlane())

        #set near and far plane.
        self.cave.setNearPlane(1.0)
        self.cave.setFarPlane(100.0)

        view = viz.MainView

        self.track = viztracker.Keyboard6DOF()  #tracker object
        self.track.setPosition(0, self.EH, 0)

        viz.link(self.track, view)  #linked to mainview
        self.cave.setTracker(pos=self.track)

        #change euler
        #self.cave.setTracker(pos=self.track)

        ##Create CaveView object for manipulating the entire cave environment
        ##The caveorigin is a node that can be adjusted to move the entire cave around the virtual environment, it needs a tracker object to initialise it.
        self.caveview = vizcave.CaveView(self.track)
        #print file,string.find(file,name)
        if string.find(file, name) >= 0:
            dirFiles.append(file)
            #print "Found matches for ",name,": ",file
    return dirFiles


if __name__ == '__main__':
    prefix = "MTM"
    dirPrefix = ""
    env = "Demo"
    InitMsg = None
    prompt = True
    if prompt:
        print __doc__
        viz.go(viz.PROMPT | viz.FULLSCREEN)
        InitMsg = viz.get(viz.INITMESG)
        giveDirs = viz.get(viz.OPTION1)
        skipTraining = viz.get(viz.OPTION2)
        movie = viz.get(viz.TRACKER)
        if viz.get(viz.HMD): group = 1
        else: group = 0
    else:
        viz.go(viz.FULLSCREEN)
        InitMsg = "MTM Grid D 1 1"
        giveDirs = 0
        skipTraining = 0
        movie = 0
        movement = 0
        group = 0
    viz.mouse(viz.OFF)
Exemple #22
0
def main():
    # global variables
    global debug
    global pieces
    global shape
    global sidebar
    global sidebarBG
    global blockState
    global cursor
    global cursorPos
    global highlightedObj
    global highlightedObjType
    global selectedObj
    global selectedObjType
    global animRot
    global identity
    global selectedIndex
    global won
    global is900Sensor1
    global old_data
    global all_data
    global iSenseMode

    # ---------------------------------------------------------------------------
    # init vizard

    # initialize pdb if debugging is needed
    # pdb.set_trace()

    # init intersense tracker
    iSenseMode = False
    # 	isense = viz.add('intersense.dle')
    # 	# wand.
    # 	if isense.valid() == True :
    # 		iSenseMode = True
    # 		is900Sensor1 = isense.addTracker(port=1,station=2)

    # 	viz.add('court.ive')

    """
	Set the pivot point 2 meters above the origin.
	Set the rotation mode to blend its orientation
	from its current orientation to that associated
	with the pivot.
	"""
    # 	gotoRight = vizact.goto([2,1,-2],rotate_mode=viz.BLEND_ROTATE,pivot=[0,2,0],ori_mask=viz.BODY_ORI)
    # 	gotoLeft = vizact.goto([-2,2,-2],rotate_mode=viz.BLEND_ROTATE,pivot=[0,2,0],ori_mask=viz.BODY_ORI)

    # Use keyboard actions to move the viewpoint.
    # 	vizact.onkeydown(viz.KEY_ALT_L, viz.MainView.runAction, gotoRight )
    #
    # 	vizact.onkeydown(viz.KEY_ALT_R, viz.MainView.runAction, gotoLeft )

    # 	cam = vizcam.PivotNavigate(center=[0,1,0],distance=4)
    # 	viz.cam.setHandler(cam)
    #
    # 	cam.enabled = True
    # 	viz.cam.setHandler(vizcam.KeyboardCamera())

    # 	vizcam.PivotNavigate(center=[0,1,0],distance=5)

    # assign space mouse callbacks
    # viz.callback(vizspace.ROTATE_EVENT,spaceRot)

    old_data = []
    all_data = []

    # set the maximum frame rate to something lower than the minimum the application runs
    # so that the FPS is constant throughout the run
    viz.setOption("viz.max_frame_rate", "60")

    # set the full screen monitor to 1
    viz.setOption("viz.fullscreen.monitor", 2)

    # start in full screen
    # viz.go(viz.FULLSCREEN)
    viz.go()

    # 	vizcam.PivotNavigate(center=[0,1,0],distance=5)

    # set cursor visibility
    # viz.mouse.setVisible(viz.OFF)

    # enable backface culling
    viz.enable(viz.CULL_FACE)

    # set clear color for raster
    viz.clearcolor(Colors.WHITE)

    # ---------------------------------------------------------------------------
    # init variables

    # flag to toggle debug breakpoints - Use 'x' to toggle
    debug = False

    # list of pieces available
    pieces = []

    # won the game
    won = False

    # group with all cubes in their final position - read from file
    shape = viz.add(viz.GROUP, viz.WORLD)

    # input file with description of pieces and
    # input_file = open('puzzle.txt','r')
    # parseInputFile(input_file)
    # since we still don't have an input format, we build the puzzle manually
    buildPuzzle(3, 3, 3)

    # create sidebar to indicate existing pieces/possibilities
    sidebar = []
    sidebarBG = createQuad([0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0])
    sidebarBG.depthFunc(viz.GL_ALWAYS)
    sidebarBG.drawOrder(100)
    buildSideBar()

    animRot = 0

    identity = vizmat.Transform()
    identity.makeIdent()

    cursor = vizshape.addSphere(radius=0.2)
    cursor.color(Colors.LIGHT_BLUE)
    cursorPos = [0.0, 0.0, 3.0]

    selectedObj = None
    selectedObjType = None
    selectedIndex = -1
    highlightedObj = None
    highlightedObjType = None

    # assign keyDown and keyUp as callback functions for events
    viz.callback(viz.KEYDOWN_EVENT, keyDown)
    viz.callback(viz.KEYUP_EVENT, keyUp)

    # register the update function to be called every iteration of the main loop
    vizact.ontimer(0, update)
import viz
import vizshape

viz.go(

    #viz.FULLSCREEN
)

#viz.MainView.setPosition(0, 0, -1)
#viz.MainView.setEuler(0,0,0)

#set target tolerance for step time
global targetL
targetL = 1

global targetR
targetR = 1

global targettol
targettol = 0.05

global boxL
boxL = viz.addChild('target.obj',
                    color=(0.063, 0.102, 0.898),
                    scale=[0.2, targettol, 0.0125])
boxL.setPosition([-0.3, targetL - targettol, 0])
#boxL.alpha(0.6)

global boxR
boxR = viz.addChild('target.obj',
                    color=(0.063, 0.102, 0.898),
							upperLeft=(-2.26977050781, 0.0, 1.05118676758),
							upperRight=(0.988239257812, 0.0, 0.967888549805),
							lowerLeft=(-2.25686572266, 0.0, -0.73389465332),
							lowerRight=(0.874583740234, 0.0, -0.748521972656),
							name='Bottom' )
'''

import vizshape
#Add a world axis with X,Y,Z labels
world_axes = vizshape.addAxes()
X = viz.addText3D('X',pos=[1.1,0,0],color=viz.RED,scale=[0.3,0.3,0.3],parent=world_axes)
Y = viz.addText3D('Y',pos=[0,1.1,0],color=viz.GREEN,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
Z = viz.addText3D('Z',pos=[0,0,1.1],color=viz.BLUE,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)

#Initialize graphics window
viz.go(viz.FULLSCREEN | viz.QUAD_BUFFER)

viz.window.setFullscreenMonitor(1)

#Create cave object with power wall
cave = vizcave.Cave()
cave.load('caveWallDimensions.cave')
#cave.addWall(BottomWall)

phaseSpaceIP = '192.168.1.230'
owlParamMarkerCount = 25

# Dir where textures and rb files are located
phaseSpaceFilePath = 'MocapResources/'

# Rb files in phaseSpaceFilePath
Exemple #25
0
import socket
import sys
import io
import re
from xml.etree import ElementTree
import viz
import threading
import Queue

viz.go()  #start worldviz


def UpdateViz(root, q):  #thread to update WorldViz objects
    while 1:
        root = q.get()  #pull xml from the queue

        # parse xml...

        #update Worldviz objects...


def runclient(root, q):  #client to receive xml from c++ server

    #illegal characters to remove from string later before going to xml
    RE_XML_ILLEGAL = u'([\u0000-\u0008\u000b-\u000c\u000e-\u001f\ufffe-\uffff])' + \
         u'|' + \
         u'([%s-%s][^%s-%s])|([^%s-%s][%s-%s])|([%s-%s]$)|(^[%s-%s])' % \
          (unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),
           unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),
           unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff))
    HOST = 'localhost'
Exemple #26
0
import viz
import vizact
import viztask
import vizshape
import vizmultiprocess

import SetupHMD
import NPCSpawner

import EnvironmentSetup
import HeartRate

#viz.setMultiSample(4)
#viz.fov(60)

viz.go(viz.EMBEDDED)


def RecordHR():
    while not viz.done():
        yield viztask.waitTime(
            3)  # Record Heart Rate into Array every 3 seconds
        global recordedHR

        if (HeartRate.heartRate > 20):
            recordedHR.append(HeartRate.heartRate)  # Add value to Array


# Setup Audio
trainAtStation = viz.addAudio('Assets/Audio/AtStation.wav')
trainAtStation.loop(viz.OFF)
Exemple #27
0
def main():
	# global variables
	global debug
	global pieces
	global shape
	global sidebar
	global sidebarBG
	global blockState
	global cursor
	global cursorPos
	global highlightedObj
	global highlightedObjType
	global selectedObj
	global selectedObjType
	global animRot
	global identity
	global selectedIndex
	global won
	
	#---------------------------------------------------------------------------
	# init vizard
	
	# initialize pdb if debugging is needed
	#pdb.set_trace()

	# set the maximum frame rate to something lower than the minimum the application runs
	# so that the FPS is constant throughout the run
	viz.setOption('viz.max_frame_rate','60')
	
	# set the full screen monitor to 1
	viz.setOption('viz.fullscreen.monitor',2)  

	# start in full screen
	#viz.go(viz.FULLSCREEN)
	viz.go()

	# set cursor visibility
	#viz.mouse.setVisible(viz.OFF)

	# enable backface culling
	viz.enable(viz.CULL_FACE)
	
	# set clear color for raster
	viz.clearcolor(Colors.WHITE)

	#---------------------------------------------------------------------------
	# init variables
	
	# flag to toggle debug breakpoints - Use 'x' to toggle
	debug = False
	
	# list of pieces available
	pieces = []
	
	# won the game
	won = False
	
	# group with all cubes in their final position - read from file
	shape = viz.add(viz.GROUP,viz.WORLD)
	
	# input file with description of pieces and
	#input_file = open('puzzle.txt','r')
	#parseInputFile(input_file)	
	# since we still don't have an input format, we build the puzzle manually
	buildPuzzle(3,3,3)
	
	# create sidebar to indicate existing pieces/possibilities
	sidebar = []
	sidebarBG = createQuad([0,0,0],[0,0,0],[0,0,0],[0,0,0])
	sidebarBG.depthFunc(viz.GL_ALWAYS)
	sidebarBG.drawOrder(100)
	buildSideBar()
	
	animRot = 0

	identity = vizmat.Transform()
	identity.makeIdent()
	
	cursor = vizshape.addSphere(radius=0.2)
	cursor.color(Colors.LIGHT_BLUE)
	cursorPos = [0.0,0.0,3.0]
	
	selectedObj = None
	selectedObjType = None
	selectedIndex = -1
	highlightedObj = None
	highlightedObjType = None
	
	# assign keyDown and keyUp as callback functions for events
	viz.callback(viz.KEYDOWN_EVENT, keyDown)
	viz.callback(viz.KEYUP_EVENT, keyUp)

	# register the update function to be called every iteration of the main loop
	vizact.ontimer(0,update)
Exemple #28
0
import viz
import random
import viztask
import math

tracker = viz.add('intersense.dls')
#viz.mouse.setVisible(viz.OFF)
viz.window.setFullscreen(viz.ON)
viz.window.setBorder( viz.BORDER_NONE )
viz.go( viz.STENCIL_BUFFER )
viz.phys.enable()
#viz.disable( viz.LIGHTING )
light1 = viz.addLight()
light1.position(0,5,0)
light1.color(viz.WHITE)

#env = viz.add(viz.ENVIRONMENT_MAP, 'eucalyptus\eucalyptus.jpg',scene=viz.MainScene)
env = viz.add(viz.ENVIRONMENT_MAP, 'sky.jpg',scene=viz.MainScene)
sky = viz.add('skydome.dlc')
sky.texture(env)

TRANSLATE_INC = .2
ROTATION_INC = 2
SCALE = [0.03, 0.03, 0.03]
room = viz.add("../models/room2/room2.wrl")
room.setScale(SCALE)

vizact.whilekeydown(viz.KEY_UP,viz.move,0,0,TRANSLATE_INC) #Move forward while up key is pressed
vizact.whilekeydown(viz.KEY_DOWN,viz.move,0,0,-TRANSLATE_INC) #Move backward while down key is pressed
vizact.whilekeydown(viz.KEY_LEFT,viz.rotate,viz.BODY_ORI,-ROTATION_INC,0,0) #Turn left while left arrow pressed
vizact.whilekeydown(viz.KEY_RIGHT,viz.rotate,viz.BODY_ORI,ROTATION_INC,0,0) #Turn right while right arrow pressed
Exemple #29
0
screenMode=viz.FULLSCREEN

if data["hmd"]["resolutions"][0]["display_mode"] != "full_screen":
    if data["hmd"]["resolutions"][0]["display_mode"]== "vert_side_by_side":
        screenMode=viz.FULLSCREEN | viz.STEREO_VERT
    else:
        screenMode=viz.FULLSCREEN | viz.STEREO_HORZ

hmd=CustomHMD(data["hmd"]["field_of_view"]["monocular_horizontal"],
    data["hmd"]["field_of_view"]["monocular_vertical"],
    overlap=1.0*data["hmd"]["field_of_view"]["overlap_percent"]*data["hmd"]["field_of_view"]["monocular_horizontal"]/100,
    leftRollShift=data["hmd"]["rendering"]["left_roll"],
    rightRollShift=data["hmd"]["rendering"]["right_roll"],
    verticalShift=data["hmd"]["field_of_view"]["pitch_tilt"],
    stereo=screenMode);


viz.window.setFullscreenMonitor(1)
viz.enable(viz.AUTO_COMPUTE)

viz.go(screenMode)

#Create skylight
sky_light = viz.addLight(euler=(0,0,0))
sky_light.position(0,0,0,0)
sky_light.color(viz.WHITE)
sky_light.ambient([5,5,5]) # necessary to light up images in Vizard 5

#Add the gallery mode
gallery = viz.addChild('gallery.osgb')
Exemple #30
0
import socket
import sys
import io
import re
from xml.etree import ElementTree
import viz
import threading
import Queue
import time
import json
import vizact
import math

#viz.splashScreen('C:\Users\Gelsey Torres-Oviedo\Desktop\VizardFolderVRServer\Logo_final.jpg')
viz.go(
#viz.FULLSCREEN
)

targettol = 0.025
boxL = viz.addChild('target2.obj',color=viz.WHITE,scale=[0.1,0.005,targettol*2])
boxL.setPosition([0,0,0])
boxL.setEuler(0,90,0)

origin  = viz.addChild('box.wrl',color=viz.GREEN,scale=[0.1,0.0009,0.001])
origin.setPosition([0,0,0])

h = viz.addChild('box.wrl',color=viz.RED,scale=[0.1, 0.0009, 0.001])
h.setPosition([0,-targettol,0])

g = viz.addChild('box.wrl',color=viz.RED,scale=[0.1,0.0009,0.001])
g.setPosition([0,+targettol,0])
Subject is intended to stand still on the treadmill wearing typical plugin gait with hip marker set.
Targets are displayed showing how far a subject should step forward.

In version 3 rev3, feedback, cursor, and target are on.

Treadmill moves the feet back to neutral after a step

rev 3 incorps a counter of successful steps
"""
import viz
import vizshape
import time
import vizinfo

viz.go(

viz.FULLSCREEN #run world in full screen
)

#viz.addChild('dojo.osgb')
# code to add the grid to the environment
#grid = vizshape.addGrid()

#initExtraWindows()

#viz.MainView.setPosition(0, 0, -1)
#viz.MainView.setEuler(0,0,0)

#set target tolerance for stride length

global targetL
targetL = 0.3
Exemple #32
0
import socket
import sys
import io
import re
from xml.etree import ElementTree
import viz
import threading
import Queue

viz.go()#start worldviz

def UpdateViz(root,q):#thread to update WorldViz objects
	while 1:
		root = q.get()#pull xml from the queue
		
		# parse xml...
		
		#update Worldviz objects...
	
def runclient(root,q):#client to receive xml from c++ server
	
	#illegal characters to remove from string later before going to xml
	RE_XML_ILLEGAL = u'([\u0000-\u0008\u000b-\u000c\u000e-\u001f\ufffe-\uffff])' + \
					 u'|' + \
					 u'([%s-%s][^%s-%s])|([^%s-%s][%s-%s])|([%s-%s]$)|(^[%s-%s])' % \
					  (unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),
					   unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),
					   unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff))
	HOST = 'localhost'   
	PORT = 50008
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#Stridetime revision 6 introduces new biofeedback realization -- firworks explotion
#WDA 6/4/2014

import viz
import vizshape
import vizinfo

viz.go(

viz.FULLSCREEN
)

#viz.MainView.setPosition(0, 0, -1)
#viz.MainView.setEuler(0,0,0)

#setup a variable to scale the height of objects so that the screen setup is optimized for viewing base on target values
global scalorxx
scalorxx = 0.6667

#set target tolerance for step time
global targetL
targetL = 1

global targetR
targetR = 1

global targettol
targettol = 0.05

global boxL
boxL = viz.addChild('target.obj',color=(0.063,0.102,0.898),scale=[0.1,(targettol+0.04)*0.75,0.0125])
Exemple #34
0
 def main(self, fullscreen=True):
     logging.info('running experiment')
     viz.go(viz.FULLSCREEN if fullscreen else 0)
     viztask.schedule(self.workflow)
Exemple #35
0
import vizact
import vizinfo
import vizproximity
import vizshape
import time
import viznet
import vizinput
import random
import numpy as np
from Environments import *  # import the virtual environments
import oculus
import os

# Initialize window
viz.setMultiSample(8)
viz.go()  # Should call this early to avoid some errors
viz.mouse.setVisible(False)

# Read the information from the folder name
# The folder name contains all information including:
# 	- participant id
# 	- condition sequence
# 	- prism direction sequence
path = os.getcwd()
folder = path.split('\\')
folder = folder[-1]
folder = folder.split('_')

id = folder[0]
Sequence = folder[1]
side = folder[2]
Exemple #36
0
sys.path.append(rootpath)

#Purpose of File is to pilot cognitive load task.
#File interfaces with module 'Count_Adjustable', which serves to load a trial at a time.
#Experiment name: Orca18

import viz  # vizard library
import vizact  # vizard library for timers
import numpy as np  # numpy library - such as matrix calculation
import random  # python library
import vizdriver_Orca18_pilotnosteering as vizdriver  # vizard library
import viztask  # vizard library
import math as mt  # python library
import Count_Adjustable  #distractor task

viz.go()
viz.window.setFullscreenMonitor(2)
viz.window.setFullscreen(viz.ON)

# Prompt for filename
ExpID = "Orca19_Distractor_Baseline_"
DEG_SYM = unichr(176).encode("latin-1")
pname = viz.input('Participant code: ')

########### CHANGE HERE TO TOGGLE PRACTICE ANDS BLOCK #############

#SP CHANGE HERE

PRACTICE = False  #if practice, they only do one of each.
DISTRACTOR_TYPE = "Middle"  #(2 targets)# "Hard" #"Easy" (1 target) or "Hard" (3 targets).
import viz
import vizact
import vizshape
import math
import datetime
import time
import Queue


viz.go()#viz.PROMPT)


''' *************************** Set Up Scene **************************** '''
#ground = viz.add('tut_ground.wrl')
#sky = viz.clearcolor(viz.SKYBLUE)
#gallery = viz.addChild('gallery.osgb')

grid = vizshape.addGrid()
''' *********************** End of Scene set up ************************* '''


''' *************************** KINECT CODE ***************************** '''
#myHead = vrpn.addTracker( 'Tracker0@localhost', HEAD)
HEAD = 0
NECK = 1
TORSO = 2
WAIST = 3
LEFTCOLLAR = 4
LEFTSHOULDER = 5
LEFTELBOW = 6
LEFTWRIST = 7
Exemple #38
0
'''
Project  
Jourdan Kerl & Bisoye Olaleye
Performer plays music as the crowd dances
'''
import viz
import vizshape
import vizact
from random import randint

viz.setMultiSample(4)#Enable full screen anti-aliasing (FSAA) to smooth edges
viz.go() #starts an empty world 
viz.MainWindow.fov(60)#Increase the Field of View
#viz.MainView.move([0,0,7]) #X,Z,Y
viz.MainView.setPosition([-0,0,-15])
#viz.MainView.setEuler([0,30,0])
piazza = viz.addChild('piazza.osgb') #adds the plazza

sound = viz.addAudio('Panda.mp3') 
sound.loop(viz.ON)
sound.play() 

platform = viz.addChild('platform.osg')
platform.setPosition([0, .2, -11])
micStand = viz.addChild('pole.wrl',parent=platform)
micStand.setPosition([0, 0, .5])
micStand.setScale([0.5,0.36,0.5])
micStand.color(1,1,1)

mic = viz.addChild('pole.wrl')
mic.setPosition([0, 1.6, -10.5])
import viz
import viztask
import vizjoy
import math
import random
import time
import vizshape
import vizact
import datetime
import time
import Queue


viz.go(viz.PROMPT)
viz.collision(viz.ON)


''' *************************** KINECT CODE ***************************** '''
#myHead = vrpn.addTracker( 'Tracker0@localhost', HEAD)
HEAD = 0
NECK = 1
TORSO = 2
WAIST = 3
LEFTCOLLAR = 4
LEFTSHOULDER = 5
LEFTELBOW = 6
LEFTWRIST = 7
LEFTHAND = 8
LEFTFINGERTIP = 9
RIGHTCOLLAR = 10
RIGHTSHOULDER = 11
import socket
import sys
import io
import re
from xml.etree import ElementTree
import viz
import threading
import Queue
import time
import json
import vizact

viz.splashScreen('C:\Users\Gelsey Torres-Oviedo\Desktop\VizardFolderVRServer\Logo_final.jpg')
viz.go(
viz.FULLSCREEN
)

#indicate flag for post-catch targets, which last for the first 12 steps
global catchflag
catchflag = 0
global stridecounter
stridecounter = 0

#set target tolerance for stride length
global targetL
targetL = 0.5

global targetR
targetR = 0.5 
Exemple #41
0
import viz
import vizact

viz.go()
ball = viz.add('ball.wrl')
ball.center([1,0,0])
ball.setPosition([0,1.82,2])
spinForever = vizact.spin(0,1,0, 90, viz.FOREVER)
ball.addAction(spinForever)

vizact.onkeydown('1', ball.endAction)
vizact.onkeydown('2', ball.addAction, spinForever)
""" Biofeedback routine used to train subjects to take a step forward of various length

Subject is intended to stand still on the treadmill wearing typical plugin gait with hip marker set.
Targets are displayed showing how far a subject should step forward.

In version 2, upon toe-off the target and cursor disappear. When Heel strike occurs the target is re-displayed and a history marker
shows the subject where they landed. 

Eventually the treadmill will slowly move the displaced foot back to a neutral position...

"""
import viz
import vizshape
import time

viz.go(viz.FULLSCREEN  #run world in full screen
       )

#viz.addChild('dojo.osgb')
# code to add the grid to the environment
grid = vizshape.addGrid()

#initExtraWindows()

#viz.MainView.setPosition(0, 0, -1)
#viz.MainView.setEuler(0,0,0)

#set target tolerance for stride length
global targetL
targetL = 0.3

global targetR