コード例 #1
0
ファイル: Flying_Demo_2015.py プロジェクト: vhilab/Demos
def setUpSound():
	global windAudio, endingAudio, aboveLocation, endingAudioBasic, trumpetAudio
	if USE_HMD_F:
		#Adjusted head location to spatalize towards center of room
		#Next, create 4 subviews to attach sounds to around the room for whooshing
		userView = viz.addView()
		userView.setPosition(0,1.6,0)
		headLocation = viz.addGroup()
		viz.link(userView, headLocation)
		#Good adjustment for reverb and room, might not work as well for the city
		#vizsonic.setReverb (30.0, 0.2, 0.5, 0.9, 0.1)
		vizsonic.setSimulatedRoomRadius(30,30)
		vizsonic.setShaker(1.0)
		viz.setOption('sound3d.useViewRotation', 0)
		#Set auarlizer to play towards center of room
		viz.setListenerSound3D(headLocation)
		#Turn on sound debugging?
		viz.setDebugSound3D(False)
		#Turn on windy city sounds
		vizsonic.setAmbient('windy_edit.wav', 0.75, 0)
		#Configure wind playing based on speed, play at higher location
		aboveView = viz.addView()
		aboveView.setPosition(0,3,0)
		aboveLocation = viz.addGroup()
		viz.link(aboveView, aboveLocation)
		windAudio = aboveLocation.playsound('windMono.wav', viz.STOP, volume=WIND_MIN_VOLUME)
		trumpetAudio = aboveLocation.playsound('audio/hero_trumpet.wav', viz.STOP, volume = 0.75)
	chooseExpStateNLoadSound()
コード例 #2
0
	def __postVizConnectSetup(self):
		''' 
		This is where one can run any system-specific code that vizconnect can't handle
		'''
		dispDict = vizconnect.getRawDisplayDict()
		
		self.clientWindow = dispDict['exp_display']
		self.riftWindow = dispDict['rift_display']
		
		if( self.sysCfg['use_wiimote']):
			# Create wiimote holder
			self.wiimote = 0
			self.__connectWiiMote()

		if self.sysCfg['use_phasespace']:
			
			from mocapInterface import phasespaceInterface			
			self.mocap = phasespaceInterface(self.sysCfg);
			self.linkObjectsUsingMocap()
			
			self.use_phasespace = True
		else:
			self.use_phasespace = False
		
		if self.sysCfg['use_hmd'] and self.sysCfg['hmd']['type'] == 'DK2':
			#self.__setupOculusMon()
			self.hmd = oculus.Rift()
			self.setupExperimenterDisplay()
			self.placeEyeNodes()
			
		viz.setOption("viz.glfinish", 1)
		viz.setOption("viz.dwm_composition", 0)
コード例 #3
0
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)
コード例 #4
0
ファイル: vhil_darpa.py プロジェクト: mwlow/vhil-darpa
def configureSound():
    #Good adjustment for reverb and room
    vizsonic.setReverb (6.0, 0.2, 0.5, 0.9, 0.1)
    vizsonic.setSimulatedRoomRadius(30,30)
    vizsonic.setShaker(1.0)
    viz.setOption('sound3d.useViewRotation', 0)
    #Set auarlizer to play towards center of room
    #viz.setListenerSound3D(subview)
    #Turn on sound debugging?
    viz.setDebugSound3D(False)
コード例 #5
0
    def setLighting(self):
        # TODO: think about lighting!!!
        viz.MainView.getHeadLight().disable()
        viz.setOption('viz.lightModel.twoSided', 1)
        viz.setOption('viz.lightModel.ambient', [.6, .6, .6])

        self.light_source = viz.addLight()
        # print self.light_source.getEuler()
        self.light_source2 = viz.addLight()
        self.light_source2.setEuler(180, 0, 0)
コード例 #6
0
    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)
コード例 #7
0
ファイル: main.py プロジェクト: erikmessier/anatomy-puzzle
def main():
	### Configuration parameters
	# moved to config.py

	### Game startup
	#overwrite escape key
	viz.setOption('viz.default_key.quit','0')
	
	# Physics
	viz.phys.enable()
	#viz.phys.setGravity(0,0,0)

	# Initialize pointer tool
	# Unused?
	glove = viz.addChild('.\\dataset\\Hand\\handPoint_Reduced.ply')
	glove.disable([viz.PHYSICS, viz.DYNAMICS])

	glovePhys = glove.collideSphere()
	glove.setPosition([0,1,0])
	glove.setScale([1,1,1])

	# Initialize environment this will load the coliseum and sky
	sky = viz.addChild('sky_day.osgb')
	sky.collideMesh()
	sky.disable(viz.DYNAMICS)
	init.loadTemple()

	# Initialize pointer controls
	device = init.pointerInput(config.pointerMode, glove, sky)

	# Initialize display
	puzzle.model.display = init.DisplayInstance(config.dispMode,config.camMode,device,glove)
	#init.display(config.dispMode)

	# Initialize camera controls
	#init.cameraInput(config.camMode,config.dispMode, device, glove)

	# Launch menu system
	menu.init()
	puzzle.model.pointer = glove
	puzzle.model.pointer.setScale(0.015, 0.015, 0.015)
	puzzle.model.pointer.setEuler(0, -115, 0)
	
	# Override default escape key map to call main menu
	vizact.onkeydown(viz.KEY_ESCAPE, menu.toggle)
	
#	# Record moviefilms
#	viz.setOption('viz.AVIRecorder.maxWidth', '1280')
#	viz.setOption('viz.AVIRecorder.maxHeight', '720')
#	vizact.onkeydown(viz.KEY_F11, viz.window.startRecording, 'D:\\recording.avi')
#	vizact.onkeydown(viz.KEY_F12, viz.window.stopRecording)
	
	# Stuff to run on program termination
	vizact.onexit(puzzle.controller.end)
コード例 #8
0
ファイル: main.py プロジェクト: erikmessier/anatomy-puzzle
def main():
    ### Configuration parameters
    # moved to config.py

    ### Game startup
    # overwrite escape key
    viz.setOption("viz.default_key.quit", "0")

    # Physics
    viz.phys.enable()
    # viz.phys.setGravity(0,0,0)

    # Initialize pointer tool
    # Unused?
    glove = viz.addChild(".\\dataset\\Hand\\handPoint_Reduced.ply")
    glove.disable([viz.PHYSICS, viz.DYNAMICS])

    glovePhys = glove.collideSphere()
    glove.setPosition([0, 1, 0])
    glove.setScale([1, 1, 1])

    # Initialize environment this will load the coliseum and sky
    sky = viz.addChild("sky_day.osgb")
    sky.collideMesh()
    sky.disable(viz.DYNAMICS)
    init.loadTemple()

    # Initialize pointer controls
    device = init.pointerInput(config.pointerMode, glove, sky)

    # Initialize display
    puzzle.model.display = init.DisplayInstance(config.dispMode, config.camMode, device, glove)
    # init.display(config.dispMode)

    # Initialize camera controls
    # init.cameraInput(config.camMode,config.dispMode, device, glove)

    # Launch menu system
    menu.init()
    puzzle.model.pointer = glove
    puzzle.model.pointer.setScale(0.015, 0.015, 0.015)
    puzzle.model.pointer.setEuler(0, -115, 0)

    # Override default escape key map to call main menu
    vizact.onkeydown(viz.KEY_ESCAPE, menu.toggle)

    # 	# Record moviefilms
    # 	viz.setOption('viz.AVIRecorder.maxWidth', '1280')
    # 	viz.setOption('viz.AVIRecorder.maxHeight', '720')
    # 	vizact.onkeydown(viz.KEY_F11, viz.window.startRecording, 'D:\\recording.avi')
    # 	vizact.onkeydown(viz.KEY_F12, viz.window.stopRecording)

    # Stuff to run on program termination
    vizact.onexit(puzzle.controller.end)
コード例 #9
0
ファイル: hardware.py プロジェクト: RothkopfLab/catchingballs
def setup(conf):
    """
    Set up all the hardware used in the ball catching experiment
    :param conf: config['hardware'] entry of full config dict
    :return: None
    """
    global config
    global hmd
    global head_tracker
    global eye_tracker
    global link

    config = conf

    print '\nSetting up hardware modules...'

    # configure Oculus Rift
    if config['use_hmd']:
        hmd = oculus.Rift()
        hmd.setMonoMirror(True)
        hmd.getSensor().reset()

        # setup position tracking (WorldViz PPTX)
        if config['use_ppt']:
            head_tracker = ppt.add_tracker(0)

            link = ppt.link(tracker=head_tracker, ori=hmd.getSensor(), target=viz.MainView,
                            pre_trans=[-0.05, -0.05, 0.02])

            head_tracker = head_tracker
        # no ppt
        else:

            link = viz.link(hmd.getSensor(), viz.MainView, mask=viz.LINK_ORI)
            link.setOffset([0, 1.8, 0])
            viz.MainView.setPosition([0, 1.8, -3])

        # setup eye tracker
        if config['eye_tracking']:
            eye_tracker = EyeTracker()

    # configure screen setup
    else:
        viz.MainView.setPosition(0, 0, -4, viz.REL_LOCAL)
        viz.setOption('viz.fullscreen.monitor', 2)
        keyboard_cam = vizcam.KeyboardCamera()

    link = link

    # keys for hardware control
    viz.callback(viz.KEYDOWN_EVENT, on_key_down)
コード例 #10
0
ファイル: MirrorTouchCubes3.py プロジェクト: vhilab/thirdArm
def configureSound():
	global subview
	subview = viz.addView()
	subview.setPosition(0,1.6,-1)
	headLocation = viz.addGroup()
	viz.link(subview, headLocation)
	vizsonic.setReverb (6.0, 0.2, 0.5, 0.9, 0.1)
	vizsonic.setSimulatedRoomRadius(3,1.5)
	vizsonic.setShaker(1.0)
	viz.setOption('sound3d.useViewRotation', 0)
	#Set auarlizer to play towards center of room
	viz.setListenerSound3D(subview)
	#Turn on sound debugging?
	viz.setDebugSound3D(False)
コード例 #11
0
def initTools(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawTool = vizconnect.getRawToolDict()

	#VC: initialize a new tool
	_name = 'grabber'
	if vizconnect.isPendingInit('tool', _name, initFlag, initList):
		#VC: init which needs to happen before viz.go
		if initFlag&vizconnect.INIT_PREVIZGO:
			viz.setOption('viz.display.stencil',1)
	
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: initialization code needed by the parameters
			import tools
			from tools import grabber
			from tools import highlighter
			
			#VC: set some parameters
			usingPhysics = False
			highlightMode = tools.highlighter.MODE_OUTLINE
			placementMode = tools.placer.MODE_MID_AIR
			
			#VC: create the raw object
			rawTool[_name] = grabber.Grabber(usingPhysics=usingPhysics, usingSprings=usingPhysics, highlightMode=highlightMode, placementMode=placementMode, updatePriority=vizconnect.PRIORITY_ANIMATOR+3)
	
		#VC: init the mappings for the raw object
		if initFlag&vizconnect.INIT_MAPPINGS:
			#VC: per frame mappings
			if initFlag&vizconnect.INIT_MAPPINGS_PER_FRAME:
				#VC: get the raw input dict so we have access to signals
				import vizact
				rawInput = vizconnect.getConfiguration().getRawDict('input')
				#VC: set the update function which checks for input signals
				def update(tool):
					if rawInput['r_hand_input'].getState()&viz.MOUSEBUTTON_LEFT:# make=Generic, model=Mouse Buttons, name=r_hand_input, signal=Left Mouse Button
						tool.grabAndHold()
				rawTool[_name].setUpdateFunction(update)
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addTool(rawTool[_name], _name, make='Virtual', model='Grabber')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getTool(_name).setParent(vizconnect.getAvatar('main_avatar').getAttachmentPoint('r_hand'))

	#VC: return values can be modified here
	return None
コード例 #12
0
def initTools(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawTool = vizconnect.getRawToolDict()

	#VC: initialize a new tool
	_name = 'grabber'
	if vizconnect.isPendingInit('tool', _name, initFlag, initList):
		#VC: init which needs to happen before viz.go
		if initFlag&vizconnect.INIT_PREVIZGO:
			viz.setOption('viz.display.stencil',1)
	
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: initialization code needed by the parameters
			import tools
			from tools import grabber
			from tools import highlighter
			
			#VC: set some parameters
			usingPhysics = False
			highlightMode = tools.highlighter.MODE_OUTLINE
			placementMode = tools.placer.MODE_MID_AIR
			
			#VC: create the raw object
			rawTool[_name] = grabber.Grabber(usingPhysics=usingPhysics, usingSprings=usingPhysics, highlightMode=highlightMode, placementMode=placementMode, updatePriority=vizconnect.PRIORITY_ANIMATOR+3)
	
		#VC: init the mappings for the raw object
		if initFlag&vizconnect.INIT_MAPPINGS:
			#VC: per frame mappings
			if initFlag&vizconnect.INIT_MAPPINGS_PER_FRAME:
				#VC: get the raw input dict so we have access to signals
				import vizact
				rawInput = vizconnect.getConfiguration().getRawDict('input')
				#VC: set the update function which checks for input signals
				def update(tool):
					if rawInput['mouse_buttons'].getState()&viz.MOUSEBUTTON_LEFT:# make=Generic, model=Mouse Buttons, name=mouse_buttons, signal=Left Mouse Button
						tool.grabAndHold()
				rawTool[_name].setUpdateFunction(update)
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addTool(rawTool[_name], _name, make='Virtual', model='Grabber')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getTool(_name).setParent(vizconnect.getAvatar('head_and_hand').getAttachmentPoint('r_hand'))

	#VC: return values can be modified here
	return None
コード例 #13
0
ファイル: vhil_darpa.py プロジェクト: mwlow/vhil-darpa
def option_handler(option):
    global hmd

    options = {}
    print_options = []
    
    options["trial"] = option_handler.trial
    option_handler.trial += 1

    # Position Lock - 1st bit
    options["yaw"] = options["pitch"] = options["roll"] = True
    options["x"] = options["y"] = options["z"] = (True, False)[bool(option & (1 << 0))]
    if option & (1 << 0):
        print_options.append("Position Lock")

    # FOV X - 2nd bit
    option_handler.shader.fov_x = (1.0, 0.75)[bool(option & (1 << 1))]
    options["fov_x"] = ("normal", "restricted")[bool(option & (1 << 1))]
    if option & (1 << 1):
        print_options.append("FOV X")

    # Mono Stereo - 3rd bit
    oculus._DistortionCorrectionEffect = option_handler.shader
    hmd.remove()
    hmd = oculus.Rift()
    hmd.getSensor().setPrediction(True)
    hmd.setIPD( (0.06, 0)[bool(option & (1 << 2))] )
    options["stereo"] = ("stereo", "mono")[bool(option & (1 << 2))]
    if option & (1 << 2):
        print_options.append("Mono")

    # Latency - 4th bit
    options["delay"] = (0, (3 if option & (1 << 4) else 4))[bool(option & (1 << 3))]
    if option & (1 << 3):
        print_options.append("Latency")

    # Framerate - 5th bit
    viz.setOption('viz.max_frame_rate', (60, 45)[bool(option & (1 << 4))])
    #options["framerate"] = (60, 40)[bool(option & (1 << 4))]
    if option & (1 << 4):
        print_options.append("Framerate")

    if option_handler.render_event:
        option_handler.render_event.remove()
    
    option_handler.render_event = vizact.ontimer(0, update_tracking, **(options))
    print print_options
コード例 #14
0
def initTools(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawTool = vizconnect.getRawToolDict()

    #VC: initialize a new tool
    _name = 'grabber'
    if vizconnect.isPendingInit('tool', _name, initFlag, initList):
        #VC: init which needs to happen before viz.go
        if initFlag & vizconnect.INIT_PREVIZGO:
            viz.setOption('viz.display.stencil', 1)

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: initialization code needed by the parameters
            import tools
            from tools import grabber
            from tools import highlighter

            #VC: set some parameters
            usingPhysics = True
            highlightMode = tools.highlighter.MODE_OUTLINE
            placementMode = tools.placer.MODE_MID_AIR

            #VC: create the raw object
            rawTool[_name] = grabber.Grabber(
                usingPhysics=usingPhysics,
                usingSprings=usingPhysics,
                highlightMode=highlightMode,
                placementMode=placementMode,
                updatePriority=vizconnect.PRIORITY_ANIMATOR + 3)

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addTool(rawTool[_name],
                               _name,
                               make='Virtual',
                               model='Grabber')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getTool(_name).setParent(
                vizconnect.getAvatar('main_avatar').getAttachmentPoint(
                    'r_hand'))

    #VC: return values can be modified here
    return None
コード例 #15
0
def initDisplays(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawDisplay = vizconnect.getRawDisplayDict()

    #VC: initialize a new display
    _name = 'projector'
    if vizconnect.isPendingInit('display', _name, initFlag, initList):
        #VC: init which needs to happen before viz.go
        if initFlag & vizconnect.INIT_PREVIZGO:
            viz.setOption('viz.stereo', viz.QUAD_BUFFER)

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set the window for the display
            _window = viz.MainWindow

            #VC: set the fullscreen monitor
            viz.window.setFullscreenMonitor(3)
            viz.window.setFullscreen(True)

            #VC: set some parameters
            VFOV = 60
            aspect = viz.AUTO_COMPUTE
            stereo = viz.QUAD_BUFFER

            #VC: create the raw object
            _window.fov(VFOV, aspect)
            _window.stereo(stereo)
            rawDisplay[_name] = _window

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addDisplay(rawDisplay[_name],
                                  _name,
                                  make='Generic',
                                  model='Custom Window')

    #VC: return values can be modified here
    return None
コード例 #16
0
def addUser():
	global mainUser
	# ---- Trackers ----
	# Initialize an empty composite object to store all the trackers
	# The composite.storeTracker() method is used to combine the individual trackers for the user's body within the composite
	composite = VU.VUCompositeTrackers()
	vrpn = viz.add('vrpn7.dle')

	headPos = vrpn.addTracker( 'PPT0@'+PPT_MACHINE,PPT_HEAD_ID) 
	
	if not OPTICAL_HEADING:
		iLabs = viz.addExtension( 'inertiallabs.dle' )
		headOri = iLabs.addSensorBus(port=INERTIALLABS_HEAD_PORT)[0]
		VU.onkeydownspecial('r', resetHead, headOri, 90 )
		

	# ---- Display ----
	import sensics
	sensics.zSight_60()
	
	if not OPTICAL_HEADING:
		headTracker = viz.mergeLinkable( headPos, headOri )
	else:
		headTracker = headPos
	composite.storeTracker (composite.HEAD, headTracker )
	viz.setOption('viz.fullscreen', 1 ) # Go fullscreen on monitor 1 
	viz.setOption('viz.fov', [37.5, 1.25]) # Set fov to match sensics specs
	viz.setOption('viz.setDisplayMode', [1280,1024]) # Change resolution of displays
	
	# ---- Input ----
	wandpos = vrpn.addTracker('PPT0@' + PPT_MACHINE, PPT_WAND_ID)

	wandori = iLabs.addSensorBus(port=INERTIALLABS_HAND_PORT)[0]
	wandtracker = viz.mergeLinkable( wandpos, wandori )
#	wandjoy = VU.VUJoystickPPTWandVRPN(hostname=PPT_MACHINE, markerid=PPT_WAND_ID+1)
#	wandflyer = VU.VUTrackerWandFlyerSmooth(wandjoy, wandtracker,accelerationSteps=Config.WAND_ACCELERATION_STEPS, decelerationSteps=Config.WAND_DECELERATION_STEPS, speed=Config.WAND_SPEED_SCALE, keystrokes=[Config.WAND_BUTTON1,Config.WAND_BUTTON2,Config.WAND_BUTTON3,Config.WAND_BUTTON4,Config.WAND_BUTTON5,Config.WAND_BUTTON6],buttonReset=None, buttonForward=None, buttonFist=None, oriSteer=False )
#	wandflyer.getHandSensor().joystick = wandjoy
#	composite.addDriverNode(wandflyer)
#	composite.storeTracker( composite.RHAND, wandtracker )
#the following is beta:
	global main_sphere
	composite.storeTracker(composite.RHAND,wandtracker)
	viz.link(wandtracker, main_sphere)
#end beta.
#not sure if u need this in beta:	composite.createRightHand(wandori)
	VU.onkeydownspecial('r', resetHand, wandori, 90 )
#	composite.storeTracker( composite.RHAND, wandtracker )
	#composite.createRightHand(wandori)
#	viz.link(wandtracker,ball)

	# ---- Avatar ----
	composite.createAvatarNone()
	
	# ---- Finalize Composite ----
	composite.finishTrackers() # Build up internal links for all the tracking devices
	composite.defineViewpoint() # Attach viewpoint to default location on the user
	mainUser = composite
	manager.addComposite(mainUser, 'Main-User')
コード例 #17
0
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)
コード例 #18
0
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)
コード例 #19
0
ファイル: Experiment.py プロジェクト: dlcen/VizardCode
# Participant information
path = os.getcwd()  # Information contained in the folder title
folder = path.split('\\')
folder = folder[-1]
folder = folder.split('_')

sub_id = folder[0]  # Subject No.
Sequence = folder[1]  # Environment Sequence
global distance, freq, ipd, height, cloudFreq
distance = 7
freq = 37
cloudFreq = 5250
SPEED = 1

# Helps reduce latency
viz.setOption('viz.glFinish', 1)
#viz.vsync(0)
viz.setOption('viz.max_frame_rate', 75)

# Setup Oculus Rift HMD
hmd = oculus.Rift()
if not hmd.getSensor():
    sys.exit('Oculus Rift not detected')

# Go fullscreen if HMD is in desktop display mode
if hmd.getSensor().getDisplayMode() == oculus.DISPLAY_DESKTOP:
    viz.window.setFullscreen(True)

# # Apply user profile eye height to view
profile = hmd.getProfile()
if profile:
def initDisplays(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawDisplay = vizconnect.getRawDisplayDict()

    #VC: initialize a new display
    CAVE_CONFIG_NAME = 'cave_manual_configuration'

    if vizconnect.isPendingInit('display', CAVE_CONFIG_NAME, initFlag,
                                initList):
        #VC: init which needs to happen before viz.go
        if initFlag & vizconnect.INIT_PREVIZGO:
            viz.setOption('viz.stereo', viz.QUAD_BUFFER)

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set the window for the display
            _window = viz.MainWindow

            #APG: constants, 5 total instances running...
            FRONT_WALL_CLUSTER_CLIENT = viz.CLIENT1
            LEFT_WALL_CLUSTER_CLIENT = viz.CLIENT2
            RIGHT_WALL_CLUSTER_CLIENT = viz.CLIENT3
            FLOOR_LEFT_CLUSTER_CLIENT = viz.CLIENT4
            FLOOR_RIGHT_CLUSTER_CLIENT = viz.CLIENT5

            #These are determined by testing the monitors
            FRONT_WALL_MONITOR_ID = 1
            LEFT_WALL_MONITOR_ID = 4
            RIGHT_WALL_MONITOR_ID = 5
            FLOOR_LEFT_MONITOR_ID = 3
            FLOOR_RIGHT_MONITOR_ID = 2

            #==============================================
            #Cave calculations

            #VC: create the raw object
            # Create a cave object
            import vizcave
            cave = vizcave.Cave(stereo=viz.QUAD_BUFFER)

            # get an origin node
            originName = CAVE_CONFIG_NAME
            initGroups(vizconnect.INIT_INDEPENDENT,
                       [originName])  # ensure it's been created
            originNode = vizconnect.getGroup(originName).getNode3d()

            frontImageWidth = 5.5372
            imageHeight = 2.2225
            imageRise = 0.0
            originLeft = 3.5503
            originRight = 3.5503
            sideImageWidth = 2.9591
            shiftRight = 0
            shiftUp = 0
            shiftForward = 0

            # get the originLeft angle from the origin measurements
            import math
            aOR = math.pi / 4.0
            aAOR = (originRight**2 - originLeft**2 -
                    frontImageWidth**2) / (-2 * originLeft * frontImageWidth)
            if abs(aAOR) <= 1:
                aOR = math.acos(aAOR)

            # convert the angle to front and right shifts
            Sr = -(math.cos(aOR) * originLeft - frontImageWidth / 2.0)
            Sf = (math.sin(aOR) * originLeft - sideImageWidth / 2.0)

            # find left/right, up/down, front/back (x,y,z) extent of caves
            R = frontImageWidth / 2.0 + Sr + shiftRight  # right
            L = -frontImageWidth / 2.0 + Sr + shiftRight  # left
            U = imageRise + imageHeight + shiftUp  # up/top
            D = imageRise + shiftUp  # bottom/down
            F = sideImageWidth / 2.0 + Sf + shiftForward  # front
            B = -sideImageWidth / 2.0 + Sf + shiftForward  # back

            # find corners
            # e.g.
            # Front Wall: C1,C2,C5,C6
            # Left  Wall: C0,C1,C4,C5
            # Right Wall: C2,C3,C6,C7
            C0 = L, U, B
            C1 = L, U, F
            C2 = R, U, F
            C3 = R, U, B
            C4 = L, D, B
            C5 = L, D, F
            C6 = R, D, F
            C7 = R, D, B
            C8 = L, D, 0
            C9 = R, D, 0
            C10 = -0.19939, D, F
            C11 = 0.19939, D, F
            C12 = -0.19939, D, 0
            C13 = 0.19939, D, 0

            #			wall_list = [C0, C1, C2, C3, C4,
            #						C5, C6, C7, C8,
            #						C9, C10, C11, C12, C13]
            #
            #			for item in wall_list:
            #				print(item)

            #==============================================

            WALL_CORNERS = "corners"
            WALL_NAME = "name"
            WALL_CLUSTER_ID = "cluster_id"
            WALL_MONITOR_ID = "monitor_id"

            #Creates wall, then adds it to the vizcave obj
            def config_wall(wall_config, window):
                points = wall_config[WALL_CORNERS]
                cluster_client_id = wall_config[WALL_CLUSTER_ID]
                monitor_id = wall_config[WALL_MONITOR_ID]

                new_wall = vizcave.Wall(upperLeft=points[0],
                                        upperRight=points[1],
                                        lowerLeft=points[2],
                                        lowerRight=points[3],
                                        name=wall_config[WALL_NAME])

                cave.addWall(new_wall, mask=cluster_client_id, window=window)

                with viz.cluster.MaskedContext(cluster_client_id):
                    viz.window.setFullscreenMonitor(monitor_id)
                    _window.setStereoSwap(False)
                    viz.window.setFullscreen(True)

            #Create front wall
            #==================================
            wall_config = {}
            wall_config[WALL_CORNERS] = [C1, C2, C5, C6]
            wall_config[WALL_NAME] = "Front Wall"
            wall_config[WALL_CLUSTER_ID] = FRONT_WALL_CLUSTER_CLIENT
            wall_config[WALL_MONITOR_ID] = FRONT_WALL_MONITOR_ID

            config_wall(wall_config, _window)

            #Create right wall
            #==================================
            wall_config = {}
            wall_config[WALL_CORNERS] = [C2, C3, C6, C7]
            wall_config[WALL_NAME] = "Right Wall"
            wall_config[WALL_CLUSTER_ID] = RIGHT_WALL_CLUSTER_CLIENT
            wall_config[WALL_MONITOR_ID] = RIGHT_WALL_MONITOR_ID

            config_wall(wall_config, _window)

            # #Create left wall
            # #=================================
            wall_config = {}
            wall_config[WALL_CORNERS] = [C0, C1, C4, C5]
            wall_config[WALL_NAME] = "Left Wall"
            wall_config[WALL_CLUSTER_ID] = LEFT_WALL_CLUSTER_CLIENT
            wall_config[WALL_MONITOR_ID] = LEFT_WALL_MONITOR_ID

            config_wall(wall_config, _window)

            #Create floor_left
            #==================================
            wall_config = {}
            wall_config[WALL_CORNERS] = [C5, C11, C8, C13]
            wall_config[WALL_NAME] = "Floor Left"
            wall_config[WALL_CLUSTER_ID] = FLOOR_LEFT_CLUSTER_CLIENT
            wall_config[WALL_MONITOR_ID] = FLOOR_LEFT_MONITOR_ID

            config_wall(wall_config, _window)

            #Create floor_right
            #==================================
            wall_config = {}
            wall_config[WALL_CORNERS] = [C10, C6, C12, C9]
            wall_config[WALL_NAME] = "Floor Right"
            wall_config[WALL_CLUSTER_ID] = FLOOR_RIGHT_CLUSTER_CLIENT
            wall_config[WALL_MONITOR_ID] = FLOOR_RIGHT_MONITOR_ID

            config_wall(wall_config, _window)

            #==================================

            # We need to pass an object which will be used to update the projection
            # or the display to the view's position, typically this would be the
            # node attached to an avatar's head tracker.
            viewpoint = viz.addGroup()
            cave.setTracker(viewpoint)

            # Create a CaveView object for manipulating the entire cave environment.
            # The caveView is a node that can be adjusted to move the entire
            # cave around the virtual environment.
            caveView = vizcave.CaveView(viewpoint)

            _window.originLink = viz.link(originNode,
                                          caveView,
                                          dstFlag=viz.ABS_GLOBAL,
                                          srcFlag=viz.ABS_GLOBAL)
            _window.caveView = caveView
            _window.originNode = originNode
            _window.displayNode = cave
            _window.viewpointNode = viewpoint

            rawDisplay[CAVE_CONFIG_NAME] = _window

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addDisplay(rawDisplay[CAVE_CONFIG_NAME],
                                  CAVE_CONFIG_NAME,
                                  make='Generic',
                                  model='Cave Manual Configuration')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getDisplay(CAVE_CONFIG_NAME).setParent(
                vizconnect.getAvatar('head_and_hand').getAttachmentPoint(
                    'head'))

    #VC: set the name of the default
    vizconnect.setDefault('display', 'cave_manual_configuration')

    #VC: return values can be modified here
    return None
コード例 #21
0
import os
import time

import numpy as np

import memSpace.scene  as sc
import memSpace.agents as ag
import memSpace.delivery as dl

import memSpace.constants as ct

if __name__ == '__main__':


    viz.setOption('viz.dwm_composition', '0')

    # get global coords of building corners
    # by locally adding helper vertices to corners 
    def getCornerCoords(cNode, quSpace):
    
        nBox = cNode.getBoundingBox(viz.ABS_LOCAL)
        
        cCrns      = [ (nBox.xmin, 0, nBox.zmin), (nBox.xmin, 0, nBox.zmax), (nBox.xmax, 0, nBox.zmax), (nBox.xmax, 0, nBox.zmin) ]
        globalCrns = []
        singleVertChildren = []
        
        for c in cNode.getChildren():
            if c.__class__ == viz.VizPrimitive:
                singleVertChildren.append( c )
        
コード例 #22
0
def initDisplays(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawDisplay = vizconnect.getRawDisplayDict()
	

	#VC: initialize a new display
	_name = 'cave_manual_configuration'
	if vizconnect.isPendingInit('display', _name, initFlag, initList):
		#VC: init which needs to happen before viz.go
		if initFlag&vizconnect.INIT_PREVIZGO:
			#viz.setOption('viz.stereo', viz.QUAD_BUFFER)
			viz.setOption('viz.fullscreen', 1)
			viz.setOption('viz.antialias', 8)
	
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set the window for the display
			_window = viz.MainWindow
			
			#VC: set some parameters
			frontWall = [1,2]
			rightWall = [3,4]
			backWall = -1
			leftWall = [5,6]
			floor = -1
			ceiling = -1
			frontImageWidth = 3.6
			imageHeight = 2.5
			imageRise = 0.02
			originLeft = 1.725
			originRight = 2.205
			sideImageWidth = 4
			shiftRight = 0
			shiftUp = 0
			shiftForward = 0
			stereo = viz.QUAD_BUFFER
			frontWallSwapStereo = False
			rightWallSwapStereo = False
			backWallSwapStereo = False
			leftWallSwapStereo = False
			floorSwapStereo = False
			ceilingSwapStereo = False
			
			#VC: create the raw object
			# Create a cave object
			import vizcave
			cave = vizcave.Cave(stereo=stereo)
			
			# get an origin node
			originName = _name
			initGroups(vizconnect.INIT_INDEPENDENT, [originName])# ensure it's been created
			originNode = vizconnect.getGroup(originName).getNode3d()
			
			if sideImageWidth == 0:
				sideImageWidth = frontImageWidth
			
			# extra configuration options to more explicitly control which wall goes where.
			frontWallClientIndex=-1
			rightWallClientIndex=-1
			backWallClientIndex=-1
			leftWallClientIndex=-1
			floorClientIndex=-1
			ceilingClientIndex=-1
			
			# get the originLeft angle from the origin measurements
			import math
			aOR = math.pi/4.0
			aAOR = (originRight**2 - originLeft**2 - frontImageWidth**2)/(-2*originLeft*frontImageWidth)
			if abs(aAOR) <= 1:
				aOR = math.acos(aAOR)
			
			# convert the angle to front and right shifts
			Sr =-(math.cos(aOR)*originLeft-frontImageWidth/2.0)
			Sf = (math.sin(aOR)*originLeft-sideImageWidth/2.0)
			
			# find left/right, up/down, front/back (x,y,z) extent of caves
			R = frontImageWidth/2.0+Sr+shiftRight# right
			L =-frontImageWidth/2.0+Sr+shiftRight# left
			U = imageRise+imageHeight+shiftUp# up/top
			D = imageRise+shiftUp# bottom/down
			F = sideImageWidth/2.0+Sf+shiftForward# front
			B =-sideImageWidth/2.0+Sf+shiftForward# back
			
			# find corners
			# e.g.
			# Front Wall: C1,C2,C5,C6
			# Left  Wall: C0,C1,C4,C5
			# Right Wall: C2,C3,C6,C7
			C0 = L, U, B
			C1 = L, U, F
			C2 = R, U, F
			C3 = R, U, B
			C4 = L, D, B
			C5 = L, D, F
			C6 = R, D, F
			C7 = R, D, B
			
			clients = 0
			
			#Create front wall
			if frontWall >= 0:
				wall = vizcave.Wall(	upperLeft=C1,
										upperRight=C2,
										lowerLeft=C5,
										lowerRight=C6,
										name='Front Wall' )
				
				if frontWallClientIndex == -1:
					frontWallClientIndex = clients
				cave.addWall(wall, mask=2**frontWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**frontWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(frontWall)
					_window.setStereoSwap(frontWallSwapStereo)
					viz.window.setFullscreenRectangle([2563, 15, 2260, 1585])
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create right wall
			if rightWall >= 0:
				wall = vizcave.Wall(	upperLeft=C2,
										upperRight=C3,
										lowerLeft=C6,
										lowerRight=C7,
										name='Right Wall' )
				
				if rightWallClientIndex == -1:
					rightWallClientIndex = clients
				cave.addWall(wall, mask=2**rightWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**rightWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(rightWall)
					_window.setStereoSwap(rightWallSwapStereo)
					viz.window.setFullscreenRectangle([5120, 12, 2526, 1587])
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create back wall
			if backWall >= 0:
				wall = vizcave.Wall(	upperLeft=C3,
										upperRight=C0,
										lowerLeft=C7,
										lowerRight=C4,
										name='Back Wall' )
				
				if backWallClientIndex == -1:
					backWallClientIndex = clients
				cave.addWall(wall, mask=2**backWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**backWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(backWall)
					_window.setStereoSwap(backWallSwapStereo)
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create left wall
			if leftWall >= 0:
				wall = vizcave.Wall(	upperLeft=C0,
										upperRight=C1,
										lowerLeft=C4,
										lowerRight=C5,
										name='Left Wall' )
				
				leftWallClientIndex = clients
				cave.addWall(wall, mask=2**leftWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**leftWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(leftWall)
					_window.setStereoSwap(leftWallSwapStereo)
					viz.window.setFullscreenRectangle([32, 20, 2525, 1580])
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create floor
			if floor >= 0:
				wall = vizcave.Wall(	upperLeft=C5,
										upperRight=C6,
										lowerLeft=C4,
										lowerRight=C7,
										name='Floor' )
				
				floorClientIndex = clients
				cave.addWall(wall, mask=2**floorClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**floorClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(floor)
					_window.setStereoSwap(floorSwapStereo)
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create ceiling
			if ceiling >= 0:
				wall = vizcave.Wall(	upperLeft=C0,
										upperRight=C3,
										lowerLeft=C1,
										lowerRight=C2,
										name='Ceiling' )
				
				ceilingClientIndex = clients
				cave.addWall(wall, mask=2**ceilingClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**ceilingClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(ceiling)
					_window.setStereoSwap(ceilingSwapStereo)
					viz.window.setFullscreen(True)
				clients += 1
			
			# We need to pass an object which will be used to update the projection
			# or the display to the view's position, typically this would be the
			# node attached to an avatar's head tracker. 
			viewpoint = viz.addGroup()
			cave.setTracker(viewpoint)
			
			# Create a CaveView object for manipulating the entire cave environment.
			# The caveView is a node that can be adjusted to move the entire 
			# cave around the virtual environment.
			caveView = vizcave.CaveView(viewpoint)
			
			_window.originLink = viz.link(originNode, caveView, dstFlag=viz.ABS_GLOBAL, srcFlag=viz.ABS_GLOBAL)
			_window.caveView = caveView
			_window.originNode = originNode
			_window.displayNode = cave
			_window.viewpointNode = viewpoint
			
			
			rawDisplay[_name] = _window
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addDisplay(rawDisplay[_name], _name, make='Generic', model='Cave Manual Configuration')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getDisplay(_name).setParent(vizconnect.getAvatar('head_and_hand').getAttachmentPoint('head'))

	#VC: return values can be modified here
	return None
コード例 #23
0
ファイル: Grabber.py プロジェクト: NazS2/WorldVizMenu
"""  
Mouse movements move the arrow left,right,up,down.  
Scroll wheel moves the arrow forward,back.  
Left mouse button grabs,releases.  
""" 

import viz
import vizshape
import vizact
import vizinfo
vizinfo.InfoPanel(align=viz.ALIGN_LEFT_BOTTOM)

viz.setOption('viz.display.stencil',1)

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

environment = viz.addChild('sky_day.osgb')
soccerball = viz.addChild('soccerball.osgb',pos=[-0.5,1.8,1.5])
basketball = viz.addChild('basketball.osgb',pos=[0,1.8,1.5])
volleyball = viz.addChild('volleyball.osgb',pos=[0.5,1.8,1.5])

#Initialize the Grabber and items that can be grabbed
#Change hightlight mode from default outline to box
usingPhysics=False
from tools import grabber
from tools import highlighter
tool = grabber.Grabber(usingPhysics=usingPhysics, usingSprings=usingPhysics, highlightMode=highlighter.MODE_OUTLINE)
tool.setItems([soccerball,basketball,volleyball])
コード例 #24
0
		
def OnMouseUp(button):
	if(button == viz.MOUSEBUTTON_LEFT):
		print 'mouse left up'
		
def OnMouseDown(button):
	if(button == viz.MOUSEBUTTON_LEFT):
		print 'mouse left down'

def OnButtonClicked():
	print 'clicked'
		
if __name__ == '__main__':		
	# Run scene
	viz.setMultiSample(8)
	viz.setOption('viz.dwm_composition',viz.OFF)
	viz.go()
	
	nav = None
	nav = getNavigator()
	if nav is not None:
		nav.setPosition([0,0,0])
		
	def printPos():
		print nav.getPosition()
#	vizact.onkeyup(' ',printPos)
	
#	viz.mouse(viz.OFF)
#	viz.mouse.setVisible(False)
	viz.mouse.setTrap()
コード例 #25
0
ファイル: CTScanViewer_6_8.py プロジェクト: glecakes/GitTest
"""
Created By: George Lecakes
Version: 6.6
Additions:
	6.9 - Git Test
	6.8 - UVW Transform added
	6.7 - Improved transfer GUI system added
	6.6 - Transfer function shader system added 
	6.5 - Gradient system added, updated GUI
	Annotation Module and Annotation tools of bone system
"""
import viz
#from BodyPlanes import *

viz.setOption( "viz.fullscreen.monitor", "1" )
viz.go( viz.FULLSCREEN )

#import BoundingBoxIntersection_V3 as BoundingBox
import Texture3DLoading as T3DLoading

from Tools import *
from ToolManager import *
from GUIs import *
from HistrogramTool import *
from GShader_Histogram_Gradient import *
from GShader_Histogram_Transfer import *
from Message import *

import Message_V2

from Annotations import AnnotationManager
コード例 #26
0
ファイル: HuntPigeon.py プロジェクト: vhilab/VRITS-2015
viz.setMultiSample(4)
viz.fov(60)
viz.go(viz.FULLSCREEN)

subject = vizinput.input("What is the participant number?")
tracking_data = open("tracking_" + str(subject) + ".txt", "a")
score_data = open("score_" + str(subject) + ".txt", "a")


# Setup directional light
viz.MainView.getHeadLight().disable()
sky_light = viz.addDirectionalLight(euler=(0, 20, 0))
sky_light.color(viz.WHITE)
sky_light.ambient([0.8] * 3)
viz.setOption("viz.lightModel.ambient", [0] * 3)

# Setup keyboard/mouse tracker
tracker = vizcam.addWalkNavigate(moveScale=2.0)
tracker.setPosition([0, 1.8, 0])
viz.link(tracker, viz.MainView)
viz.mouse.setVisible(False)

# Load piazza environment
piazza = viz.addChild("piazza.osgb")
viz.addChild("piazza_animations.osgb")

# Loop fountain sound
piazza.playsound("fountain.wav", viz.LOOP, node="fountain-sound")

# Swap out sky with animated sky dome
コード例 #27
0
def initDisplays(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawDisplay = vizconnect.getRawDisplayDict()

    #VC: initialize a new display
    _name = 'main_display'
    if vizconnect.isPendingInit('display', _name, initFlag, initList):
        #VC: init which needs to happen before viz.go
        if initFlag & vizconnect.INIT_PREVIZGO:
            viz.setOption('viz.stereo', viz.QUAD_BUFFER)
            viz.setOption('viz.fullscreen', 1)

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set the window for the display
            _window = viz.MainWindow

            #VC: set some parameters
            imageWidth = 3
            imageHeight = 2.25
            imageRise = 0.045
            originLeft = 2.897
            originRight = 2.934
            shiftRight = 0
            shiftUp = 0
            shiftForward = 0
            stereo = viz.QUAD_BUFFER
            swapStereo = False

            #VC: create the raw object
            # Create a cave object
            import vizcave
            cave = vizcave.Cave(stereo=stereo)

            # get an origin node
            originName = _name
            initGroups(vizconnect.INIT_INDEPENDENT,
                       [originName])  # ensure it's been created
            originNode = vizconnect.getGroup(originName).getNode3d()

            # get the originLeft angle from the origin measurements
            import math
            aOR = math.pi / 4.0
            aAOR = (originRight**2 - originLeft**2 -
                    imageWidth**2) / (-2 * originLeft * imageWidth)
            if abs(aAOR) <= 1:
                aOR = math.acos(aAOR)

            # convert the angle to front and right shifts
            Sr = -(math.cos(aOR) * originLeft - imageWidth / 2.0)
            distanceToFront = math.sin(aOR) * originLeft

            # find left/right, up/down, front/back (x,y,z) extent of caves
            R = imageWidth / 2.0 + Sr + shiftRight  # right
            L = -imageWidth / 2.0 + Sr + shiftRight  # left
            U = imageRise + imageHeight + shiftUp  # up/top
            D = imageRise + shiftUp  # bottom/down
            F = distanceToFront + shiftForward  # front

            C0 = L, U, F
            C1 = R, U, F
            C2 = L, D, F
            C3 = R, D, F

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

            cave.addWall(wall, window=_window)

            _window.setStereoSwap(swapStereo)

            #_window.setSize([1, 1])

            # We need to pass an object which will be used to update the projection
            # or the display to the view's position, typically this would be the
            # node attached to an avatar's head tracker.
            viewpoint = viz.addGroup()
            cave.setTracker(viewpoint)

            # Create a CaveView object for manipulating the entire cave environment.
            # The caveView is a node that can be adjusted to move the entire
            # cave around the virtual environment.
            caveView = vizcave.CaveView(viewpoint, view=_window.getView())
            _window.originLink = viz.link(originNode,
                                          caveView,
                                          dstFlag=viz.ABS_GLOBAL,
                                          srcFlag=viz.ABS_GLOBAL)
            _window.caveView = caveView
            _window.originNode = originNode
            _window.displayNode = cave
            _window.viewpointNode = viewpoint

            rawDisplay[_name] = _window

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addDisplay(rawDisplay[_name],
                                  _name,
                                  make='Generic',
                                  model='Powerwall')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getDisplay(_name).setParent(
                vizconnect.getAvatar('main_avatar').getAttachmentPoint('head'))

    #VC: set the name of the default
    vizconnect.setDefault('display', 'main_display')

    #VC: return values can be modified here
    return None
コード例 #28
0
def initTools(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawTool = vizconnect.getRawToolDict()

    #VC: initialize a new tool
    _name = 'grabber'
    if vizconnect.isPendingInit('tool', _name, initFlag, initList):
        #VC: init which needs to happen before viz.go
        if initFlag & vizconnect.INIT_PREVIZGO:
            viz.setOption('viz.display.stencil', 1)

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: initialization code needed by the parameters
            import tools
            from tools import grabber
            from tools import highlighter

            #VC: set some parameters
            usingPhysics = False
            highlightMode = tools.highlighter.MODE_OUTLINE
            placementMode = tools.placer.MODE_MID_AIR

            #VC: create the raw object
            rawTool[_name] = grabber.Grabber(
                usingPhysics=usingPhysics,
                usingSprings=usingPhysics,
                highlightMode=highlightMode,
                placementMode=placementMode,
                updatePriority=vizconnect.PRIORITY_ANIMATOR + 3)

        #VC: init the mappings for the raw object
        if initFlag & vizconnect.INIT_MAPPINGS:
            #VC: per frame mappings
            if initFlag & vizconnect.INIT_MAPPINGS_PER_FRAME:
                #VC: get the raw input dict so we have access to signals
                import vizact
                rawInput = vizconnect.getConfiguration().getRawDict('input')
                #VC: set the update function which checks for input signals
                #def update(tool):
                #if rawInput['joystick'].isInMode('super') and rawInput['joystick'].isButtonDown(4):# make=Generic, model=Joystick, name=joystick, signal=Button 4
                #tool.grab()
                #rawTool[_name].setUpdateFunction(update)

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addTool(rawTool[_name],
                               _name,
                               make='Virtual',
                               model='Grabber')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getTool(_name).setParent(
                vizconnect.getTracker('ppt_rhand'))

    #VC: initialize a new tool
    _name = 'grabber2'
    if vizconnect.isPendingInit('tool', _name, initFlag, initList):
        #VC: init which needs to happen before viz.go
        if initFlag & vizconnect.INIT_PREVIZGO:
            viz.setOption('viz.display.stencil', 1)

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: initialization code needed by the parameters
            import tools
            from tools import grabber
            from tools import highlighter

            #VC: set some parameters
            usingPhysics = True
            highlightMode = tools.highlighter.MODE_OUTLINE
            placementMode = tools.placer.MODE_MID_AIR

            #VC: create the raw object
            rawTool[_name] = grabber.Grabber(
                usingPhysics=usingPhysics,
                usingSprings=usingPhysics,
                highlightMode=highlightMode,
                placementMode=placementMode,
                updatePriority=vizconnect.PRIORITY_ANIMATOR + 3)

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addTool(rawTool[_name],
                               _name,
                               make='Virtual',
                               model='Grabber')

    #VC: set the name of the default
    vizconnect.setDefault('tool', 'grabber')

    #VC: return values can be modified here
    return None
コード例 #29
0
import spherical_player_Vive
from vhil_devkit_Vive import *

import vizfx.postprocess

#DK2 demo
import viz
#import oculus_08 as oculus
import steamvr
import vizfx
import vector3
from vector3 import *
from random import *

viz.setOption('viz.model.hint', viz.PRELOAD_HINT)
viz.setOption('viz.preload', 1)
viz.go()

if globals_oa.fader is None: globals_oa.fader = View_Fader.addFader()



#def setup():
#	# Setup Oculus Rift HMD
#	headTracker = None
#	hmd = oculus.Rift()
#	headTracker = hmd.getSensor()
#
#	if not headTracker:
#		hmd = steamvr.HMD()
コード例 #30
0
	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())
コード例 #31
0
ファイル: BaseDirect.py プロジェクト: Andywood10/UI3D_c
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)
コード例 #32
0
def start():
	"""
	Run everything necessary for game startup
	"""
	# Physics
	viz.phys.enable()

	### Initialize pointer tool
	model.pointer = viz.addChild('.\\dataset\\Hand\\handPoint_reduced.ply')
	pointer = model.pointer
	
	pointer.setScale(0.012, 0.012, 0.012)
	pointer.setEuler(0, -115, 0)
	pointer.disable([viz.PHYSICS, viz.DYNAMICS])
	
#	### Alpha slice plane setup
#	viz.startLayer(viz.POINTS)
#	viz.vertex(0,0,0)
#	planeVert = viz.endLayer(parent = pointer)
#	planeVert.dynamic()
#	
#	# Setup normal vector for alpha slicing plane calculation
#	planeVert.setNormal(0,[0,1,0])
#	model.planeVert = planeVert
#	slicePlane = vizshape.addPlane(size = [20, 20, 20], parent = pointer, cullFace = False)
#	slicePlane.alpha(0.20)
#	slicePlane.color(viz.ORANGE)
	
	### Initialize environment this will load the coliseum and sky
	sky = viz.addChild('gallery.osgb')
	sky.setPosition([0, 0, -5])
	sky.collideMesh()
	sky.disable(viz.DYNAMICS)

	# Lighting
	lights = []
	[lights.append(viz.addLight()) for _ in range(2)]
	lights[0].setEuler(90, 40, 0)
	lights[0].intensity(0.5)
	lights[1].setEuler(270, 40, 0)
	lights[1].intensity(0.3)
	
	# Initialize pointer controls
	device = init.pointerInput(config.pointerMode, pointer, sky)
	### Initialize display
	model.display = init.DisplayInstance(config.dispMode,config.camMode,device,pointer)
	
	### Launch menu system
	model.menu = menu.MenuController()
	
	### Override escape key to toggle menu
	viz.setOption('viz.default_key.quit','0')
	
#	# Record moviefilms
#	viz.setOption('viz.AVIRecorder.maxWidth', '1280')
#	viz.setOption('viz.AVIRecorder.maxHeight', '720')
#	vizact.onkeydown(viz.KEY_F11, viz.window.startRecording, 'D:\\recording.avi')
#	vizact.onkeydown(viz.KEY_F12, viz.window.stopRecording)
	
	# Stuff to run on program termination
	vizact.onexit(endGame)
コード例 #33
0
def start():
    """
	Run everything necessary for game startup
	"""
    # Physics
    viz.phys.enable()

    ### Initialize pointer tool
    model.pointer = viz.addChild('.\\dataset\\Hand\\handPoint_reduced.ply')
    pointer = model.pointer

    pointer.setScale(0.012, 0.012, 0.012)
    pointer.setEuler(0, -115, 0)
    pointer.disable([viz.PHYSICS, viz.DYNAMICS])

    #	### Alpha slice plane setup
    #	viz.startLayer(viz.POINTS)
    #	viz.vertex(0,0,0)
    #	planeVert = viz.endLayer(parent = pointer)
    #	planeVert.dynamic()
    #
    #	# Setup normal vector for alpha slicing plane calculation
    #	planeVert.setNormal(0,[0,1,0])
    #	model.planeVert = planeVert
    #	slicePlane = vizshape.addPlane(size = [20, 20, 20], parent = pointer, cullFace = False)
    #	slicePlane.alpha(0.20)
    #	slicePlane.color(viz.ORANGE)

    ### Initialize environment this will load the coliseum and sky
    sky = viz.addChild('gallery.osgb')
    sky.setPosition([0, 0, -5])
    sky.collideMesh()
    sky.disable(viz.DYNAMICS)

    # Lighting
    lights = []
    [lights.append(viz.addLight()) for _ in range(2)]
    lights[0].setEuler(90, 40, 0)
    lights[0].intensity(0.5)
    lights[1].setEuler(270, 40, 0)
    lights[1].intensity(0.3)

    # Initialize pointer controls
    device = init.pointerInput(config.pointerMode, pointer, sky)
    ### Initialize display
    model.display = init.DisplayInstance(config.dispMode, config.camMode,
                                         device, pointer)

    ### Launch menu system
    model.menu = menu.MenuController()

    ### Override escape key to toggle menu
    viz.setOption('viz.default_key.quit', '0')

    #	# Record moviefilms
    #	viz.setOption('viz.AVIRecorder.maxWidth', '1280')
    #	viz.setOption('viz.AVIRecorder.maxHeight', '720')
    #	vizact.onkeydown(viz.KEY_F11, viz.window.startRecording, 'D:\\recording.avi')
    #	vizact.onkeydown(viz.KEY_F12, viz.window.stopRecording)

    # Stuff to run on program termination
    vizact.onexit(endGame)
コード例 #34
0
def initDisplays(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawDisplay = vizconnect.getRawDisplayDict()

    #VC: initialize a new display
    _name = 'cave_data_file'
    if vizconnect.isPendingInit('display', _name, initFlag, initList):
        #VC: init which needs to happen before viz.go
        if initFlag & vizconnect.INIT_PREVIZGO:
            viz.setOption('viz.stereo', viz.QUAD_BUFFER)
            viz.setOption('viz.fullscreen', 1)

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set the window for the display
            _window = viz.MainWindow

            #VC: set some parameters
            stereo = viz.QUAD_BUFFER
            filename = 'C:/demos/Cave_settings.txt'

            #VC: create the raw object
            # Create a cave object
            import vizcave
            cave = vizcave.Cave(stereo=stereo)
            try:
                cave.load(filename)
            except IOError:
                viz.logError(
                    "** Error: unable to load cave configuration file {}.".
                    format(filename))

            # get an origin node
            originName = _name
            initGroups(vizconnect.INIT_INDEPENDENT,
                       [originName])  # ensure it's been created
            originNode = vizconnect.getGroup(originName).getNode3d()

            # We need to pass an object which will be used to update the projection
            # or the display to the view's position, typically this would be the
            # node attached to an avatar's head tracker.
            viewpoint = viz.addGroup()
            cave.setTracker(viewpoint)

            # Create a CaveView object for manipulating the entire cave environment.
            # The caveView is a node that can be adjusted to move the entire
            # cave around the virtual environment.
            caveView = vizcave.CaveView(viewpoint)

            _window.originLink = viz.link(originNode,
                                          caveView,
                                          dstFlag=viz.ABS_GLOBAL,
                                          srcFlag=viz.ABS_GLOBAL)
            _window.caveView = caveView
            _window.originNode = originNode
            _window.displayNode = cave
            _window.viewpointNode = viewpoint

            rawDisplay[_name] = _window

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addDisplay(rawDisplay[_name],
                                  _name,
                                  make='Generic',
                                  model='Cave Data File')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getDisplay(_name).setParent(
                vizconnect.getAvatar('head_and_hand').getAttachmentPoint(
                    'head'))

    #VC: return values can be modified here
    return None
コード例 #35
0
ファイル: vrlabConfig.py プロジェクト: bmj8778/CatchB
    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()
コード例 #36
0
# Import modules.
import viz
import vizconnect
import vizfx
import vizmat
import viztask
import vizinfo
import vizproximity
import vizshape
import tools
import time
import vizact
from math import *

maxPossPerSec = 0.1
viz.setOption('viz.stereo', viz.QUAD_BUFFER)
viz.setOption('viz.fullscreen', 1)

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

# add a stencil buffer for the outline highlight
if __name__ == "__main__":
    viz.setOption('viz.display.stencil', 8)
    #vizconnect.go('./vizconnect_config.py')
    vizconnect.go('./xylo_vizconnect_config2017.py')
    for tracker in vizconnect.ConfigurationManager.get().getDict('tracker'):
        print(tracker)
    # get the quality setting of the demo if specified
コード例 #37
0
ファイル: vrlabConfig.py プロジェクト: performlabrit/StepOver
    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()
コード例 #38
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)
コード例 #39
0
ファイル: D2C3.py プロジェクト: vhilab/VRITS-2015
RESULTS = """You found {} of {} pigeons.
Press spacebar to start over or escape to exit."""

TRIAL_SUCCESS = 'You caught the pigeon!'
TRIAL_FAIL = 'The pigeon flew away!'

viz.setMultiSample(4)
viz.fov(60)
viz.go(viz.FULLSCREEN)

# Setup directional light
viz.MainView.getHeadLight().disable()
sky_light = viz.addDirectionalLight(euler=(0,20,0))
sky_light.color(viz.WHITE)
sky_light.ambient([0.8]*3)
viz.setOption('viz.lightModel.ambient',[0]*3)

# Setup keyboard/mouse tracker
tracker = vizcam.addWalkNavigate(moveScale=2.0)
tracker.setPosition([0,1.8,0])
viz.link(tracker,viz.MainView)
viz.mouse.setVisible(False)

# Load piazza environment
piazza = viz.addChild('piazza.osgb')
viz.addChild('piazza_animations.osgb')

# Loop fountain sound
piazza.playsound('fountain.wav',viz.LOOP,node='fountain-sound')

# Swap out sky with animated sky dome
コード例 #40
0
def initDisplays(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawDisplay = vizconnect.getRawDisplayDict()

	#VC: initialize a new display
	_name = 'cave_manual_configuration'
	if vizconnect.isPendingInit('display', _name, initFlag, initList):
		#VC: init which needs to happen before viz.go
		if initFlag&vizconnect.INIT_PREVIZGO:
			viz.setOption('viz.stereo', viz.QUAD_BUFFER)
	
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set the window for the display
			_window = viz.MainWindow
			
			#VC: set some parameters
			frontWall = 1
			rightWall = -1
			backWall = -1
			leftWall = -1
			floor = -1
			ceiling = -1
			frontImageWidth = 2
			imageHeight = 2
			imageRise = 0.1
			originLeft = 1.4142
			originRight = 1.4142
			sideImageWidth = 0
			shiftRight = 0
			shiftUp = 0
			shiftForward = 0
			stereo = viz.QUAD_BUFFER
			frontWallSwapStereo = False
			rightWallSwapStereo = False
			backWallSwapStereo = False
			leftWallSwapStereo = False
			floorSwapStereo = False
			ceilingSwapStereo = False
			
			#VC: create the raw object
			# Create a cave object
			import vizcave
			cave = vizcave.Cave(stereo=stereo)
			
			# get an origin node
			originName = _name
			initGroups(vizconnect.INIT_INDEPENDENT, [originName])# ensure it's been created
			originNode = vizconnect.getGroup(originName).getNode3d()
			
			if sideImageWidth == 0:
				sideImageWidth = frontImageWidth
			
			# extra configuration options to more explicitly control which wall goes where.
			frontWallClientIndex=-1
			rightWallClientIndex=-1
			backWallClientIndex=-1
			leftWallClientIndex=-1
			floorClientIndex=-1
			ceilingClientIndex=-1
			
			# get the originLeft angle from the origin measurements
			import math
			aOR = math.pi/4.0
			aAOR = (originRight**2 - originLeft**2 - frontImageWidth**2)/(-2*originLeft*frontImageWidth)
			if abs(aAOR) <= 1:
				aOR = math.acos(aAOR)
			
			# convert the angle to front and right shifts
			Sr =-(math.cos(aOR)*originLeft-frontImageWidth/2.0)
			Sf = (math.sin(aOR)*originLeft-sideImageWidth/2.0)
			
			# find left/right, up/down, front/back (x,y,z) extent of caves
			R = frontImageWidth/2.0+Sr+shiftRight# right
			L =-frontImageWidth/2.0+Sr+shiftRight# left
			U = imageRise+imageHeight+shiftUp# up/top
			D = imageRise+shiftUp# bottom/down
			F = sideImageWidth/2.0+Sf+shiftForward# front
			B =-sideImageWidth/2.0+Sf+shiftForward# back
			
			# find corners
			# e.g.
			# Front Wall: C1,C2,C5,C6
			# Left  Wall: C0,C1,C4,C5
			# Right Wall: C2,C3,C6,C7
			C0 = L, U, B
			C1 = L, U, F
			C2 = R, U, F
			C3 = R, U, B
			C4 = L, D, B
			C5 = L, D, F
			C6 = R, D, F
			C7 = R, D, B
			
			clients = 0
			
			#Create front wall
			if frontWall >= 0:
				wall = vizcave.Wall(	upperLeft=C1,
										upperRight=C2,
										lowerLeft=C5,
										lowerRight=C6,
										name='Front Wall' )
				
				if frontWallClientIndex == -1:
					frontWallClientIndex = clients
				cave.addWall(wall, mask=2**frontWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**frontWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(frontWall)
					_window.setStereoSwap(frontWallSwapStereo)
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create right wall
			if rightWall >= 0:
				wall = vizcave.Wall(	upperLeft=C2,
										upperRight=C3,
										lowerLeft=C6,
										lowerRight=C7,
										name='Right Wall' )
				
				if rightWallClientIndex == -1:
					rightWallClientIndex = clients
				cave.addWall(wall, mask=2**rightWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**rightWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(rightWall)
					_window.setStereoSwap(rightWallSwapStereo)
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create back wall
			if backWall >= 0:
				wall = vizcave.Wall(	upperLeft=C3,
										upperRight=C0,
										lowerLeft=C7,
										lowerRight=C4,
										name='Back Wall' )
				
				if backWallClientIndex == -1:
					backWallClientIndex = clients
				cave.addWall(wall, mask=2**backWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**backWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(backWall)
					_window.setStereoSwap(backWallSwapStereo)
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create left wall
			if leftWall >= 0:
				wall = vizcave.Wall(	upperLeft=C0,
										upperRight=C1,
										lowerLeft=C4,
										lowerRight=C5,
										name='Left Wall' )
				
				leftWallClientIndex = clients
				cave.addWall(wall, mask=2**leftWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**leftWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(leftWall)
					_window.setStereoSwap(leftWallSwapStereo)
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create floor
			if floor >= 0:
				wall = vizcave.Wall(	upperLeft=C5,
										upperRight=C6,
										lowerLeft=C4,
										lowerRight=C7,
										name='Floor' )
				
				floorClientIndex = clients
				cave.addWall(wall, mask=2**floorClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**floorClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(floor)
					_window.setStereoSwap(floorSwapStereo)
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create ceiling
			if ceiling >= 0:
				wall = vizcave.Wall(	upperLeft=C0,
										upperRight=C3,
										lowerLeft=C1,
										lowerRight=C2,
										name='Ceiling' )
				
				ceilingClientIndex = clients
				cave.addWall(wall, mask=2**ceilingClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**ceilingClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(ceiling)
					_window.setStereoSwap(ceilingSwapStereo)
					viz.window.setFullscreen(True)
				clients += 1
			
			# We need to pass an object which will be used to update the projection
			# or the display to the view's position, typically this would be the
			# node attached to an avatar's head tracker. 
			viewpoint = viz.addGroup()
			cave.setTracker(viewpoint)
			
			# Create a CaveView object for manipulating the entire cave environment.
			# The caveView is a node that can be adjusted to move the entire 
			# cave around the virtual environment.
			caveView = vizcave.CaveView(viewpoint)
			
			_window.originLink = viz.link(originNode, caveView, dstFlag=viz.ABS_GLOBAL, srcFlag=viz.ABS_GLOBAL)
			_window.caveView = caveView
			_window.originNode = originNode
			_window.displayNode = cave
			_window.viewpointNode = viewpoint
			
			rawDisplay[_name] = _window
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addDisplay(rawDisplay[_name], _name, make='Generic', model='Cave Manual Configuration')

	#VC: return values can be modified here
	return None
コード例 #41
0
ファイル: ProximityTest.py プロジェクト: kevinsp/DvB

#Kommentar entfernen fuer 3D-Labor
"""
# connect to tracker
vrpn7 = viz.add('vrpn7.dle')
hostname = '141.82.50.174'

# connect eye tracker
pptEyes = vrpn7.addTracker('PPT0@'+hostname,0)
link = viz.link(pptEyes, viz.Mainview)
"""


# Display
viz.setOption('viz.fullscreen',1)
viz.fov(40.0,1.333)
#viz.setOption('viz.stereo',viz.QUAD_BUFFER)

viz.mouse.setVisible(True)

# increase the Field of View
viz.MainWindow.fov(60)

viz.go()


# ADD CAD-Modell
cad = viz.addChild(r'C:\VIZARD\Buero.osgt')
#cad = viz.addChild(r'C:\Users\Informatik\Desktop\RRBBB\RRBBB.wrl')
コード例 #42
0
ファイル: Final.py プロジェクト: ghe10/Virtual_Reality
    def setUpPaddle(self):
        PS1 = testSensorNew.addPhaseSpaceMulti()
        PS1.addMarkers(0, 1, 2, 3, 4, 5, 6)
        PS1.setPointMarker()
        PS1.setServerAddress('128.174.14.227')
        PS1.setFrequency(240)
        PS1.setScale(0.001, 0.001, 0.001)
        PS1.setSlave()
        #PS1.startStreaming()

        viz.setOption('viz.model.apply_collada_scale', 1)

        ball = viz.add('white_ball.wrl')
        ball.color(viz.WHITE)
        #ball.setScale(0)
        #ojo = viz.addChild('sky_day.osgb')
        print PS1
        viz.link(PS1, ball)

        PS2 = testSensorNew.addPhaseSpaceMulti()
        PS2.addMarkers(7, 8, 9, 10, 11, 12)
        PS2.setPointMarker()

        PS2.setServerAddress('128.174.14.227')
        PS2.setFrequency(240)
        PS2.setScale(0.001, 0.001, 0.001)
        PS2.setSlave()
        PS1.startStreaming()
        PS2.startStreaming()

        ball1 = viz.add('white_ball.wrl')
        ball1.color(viz.WHITE)
        #ball1.alpha = 0
        #ball1.setScale(0)
        #ball1.setPosition(0,2,0)

        print PS2
        viz.link(PS2, ball1)

        water_level = 0

        self.paddle = viz.addChild('paddle/newOar.dae', parent=self.board)
        #self.paddle.collideMesh()
        #self.paddle.disable(viz.DYNAMICS)
        self.paddle.setEuler([90, 0, 0])
        #viz.link(ball, paddle)
        v_x = [1, 0, 0]
        global v_paddle
        v_paddle_last = self.paddle.getEuler()
        Trans = vizmat.Transform()
        '''
        global prev_p0 
        prev_p0 = ball.getPosition()
        global prev_p1
        prev_p1 = ball1.getPosition()
        '''
        self.last_pos_ball = ball.getPosition()

        def TestRecording():
            print ball.getPosition()
            print ball1.getPosition()

        def RotatePaddle():
            p0 = ball.getPosition()
            p1 = ball1.getPosition()
            #camera_pos = self.camera.getPosition()
            board_pos = self.camera.getPosition()
            #camera_rot = self.camera.get()
            board_dir = self.camera.getEuler()
            #print("dir" , board_dir)
            add_x = math.cos(board_dir[2])
            add_z = math.sin(board_dir[2])
            #print("dir", add_x)
            v_true = [p1[0] - p0[0], p1[1] - p0[1], p1[2] - p0[2]]
            position_true = [(p1[0] + p0[0]) / 2 - 0.2,
                             (p1[1] + p0[1]) / 2 - 1,
                             (p1[2] + p0[2]) / 2 + 1.5]

            position_true[1] -= 2
            Trans.makeVecRotVec(v_x, v_true)
            euler = Trans.getEuler()
            #for data in euler:
            #    data = -data
            #qut =
            self.paddle.setEuler(euler)
            #self.paddle.setPosition(self.view.getPosition())
            #self.paddle.setEuler(self.view.getEuler())
            #self.paddle.setPosition([1,0,0], viz.REL_LOCAL)
            self.paddle.setPosition(position_true)

        def updateSpeed():
            p0 = ball.getPosition()
            p1 = ball1.getPosition()
            mid = (p0[0] + p0[1]) / 2
            camera_pos = self.camera.getPosition()
            print("paddle height = ", p0[1])
            move_amount = 1
            turn_amount = 0
            if (self.last_pos_ball[1] > p0[1] + 0.05
                    and p0[1] <= self.water_level):
                message_panel.setText('Let\'s explore the islands!')
                self.move_speed = min(self.move_speed + 2, self.max_speed)
                print("speed up", self.move_speed)
            elif (p0[1] <= self.water_level
                  and abs(self.last_pos_ball[1] - p0[1]) < 1):
                self.move_speed = max(self.move_speed - 0.1, 2)
                print("slow down", self.move_speed)
            else:
                self.move_speed = max(self.move_speed - 0.01, 2)
                print("no action", self.move_speed)
            self.last_pos_ball[1] = p0[1]
            self.transform(move_amount, turn_amount)
            #print(Trans.getForward(self.camera.getEuler()))
            #print(self.camera.getEuler().getForward())
            #print("ball pos", self.ball_board.getPosition)
            #print("board pos", self.board.getPosition())

        def updateDirection():
            p0 = ball.getPosition()
            p1 = ball1.getPosition()
            mid = (p0[0] + p0[1]) / 2
            camera_pos = self.camera.getPosition()
            move_amount = 0
            turn_amount = 0
            print("mid", mid)
            print("p0[0]", p0[0])
            if (self.last_pos_ball[1] > p0[1] + 0.05
                    and p0[1] <= self.water_level):
                if (p0[0] > mid):
                    #turn right
                    print("turn right")
                    turn_amount = 10
                else:
                    print("turn left")
                    turn_amount = -10
            '''
            elif(p0[1] <= self.water_level and abs(self.last_pos_ball[1] - p0[1]) < 0.05):
                if(p0[0] < mid):
                    #turn left   
                    print("turn left")
                    turn_amount = -1
                else:
                    print("turn right")
                    turn_amount = 1
            '''
            self.transform(move_amount, turn_amount)

        def updatePos():
            move_amount = 1
            turn_amount = 0
            self.transform(move_amount, turn_amount)

        vizact.onkeydown(' ', TestRecording)
        vizact.ontimer(0.0, RotatePaddle)
        vizact.ontimer(0.0, updateDirection)
        vizact.ontimer(0.4, updateSpeed)
        vizact.ontimer(0.0, updatePos)
        self.PS1 = PS1
        self.PS2 = PS2
        self.ball1 = ball1
        self.ball = ball
コード例 #43
0
"""

# Import modules.
import random

import viz
import vizfx
import vizact
import vizconnect

import tools

# We're going to add a grabber with highlighting, so we have to update stencil
# settings before calling viz.go
if __name__ == "__main__":
    viz.setOption('viz.display.stencil', 8)

# Add the local events (events specific to this demo)
vizconnect.go('vizconnect_config_local_events.py')

# get the quality setting of the demo if specified
DEMO_QUALITY_SETTING = max(
    0, viz.getOption('DEMO_QUALITY_SETTING', default=4, type=int))

vizfx.addPointLight(pos=(0, 5, 1, 0), euler=(0, 90, 0))

# Load the vizconnect configuration.
if __name__ == "__main__":
    vizconnect.go('./vizconnect_config.py')
    viz.setMultiSample(DEMO_QUALITY_SETTING * 2)
    # disable the head lamps since we're doing lighting ourselves
コード例 #44
0
v_backward = [speed_S[i]+dv_backward for i in range(2)]
print(v_forward)
speed_P = random.sample([v_forward,v_backward]*ptb_total,ptb_total*2)
print(speed_P)
#speed_P = (1520,1500)  # Perturbation speed
elapse_time=0.25

start_L=[]
start_R=[]
SLA =0 # enter value of desired asymmetry. If positive, left leg takes longer step and right takes shorter step to maitain stride legnth constant
print belt_vec
##########################################################################################################################################################

# Vizard window set up
viz.setMultiSample(4)   
viz.setOption('viz.glFinish',1)
viz.MainWindow.fov(100)
viz.go()
viz.addChild('ground_wood.osgb')

################################################################################################################################

# Establish connection with Treadmill Control Panel
HOST = '127.0.0.1' #name of the target computer that runs the treadmill controller
PORT = 4000
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))

# QTM initialization
QUALISYS_IP = '192.168.252.1'
qualisysOn = False
コード例 #45
0
ファイル: OLiVE.py プロジェクト: tokola/GitHub_OLiVE
viz.res.addPublishFilter('*.wav*')
viz.res.addPublishFilter('*.mov*')
viz.res.addPublishFilter('*.xlsx*')
viz.res.addPublishFilter('*.log*')
viz.res.addPublishFileLoader('wav')
viz.res.addPublishFileLoader('jpg')
viz.res.addPublishFileLoader('wrl')
viz.res.addPublishFileLoader('ive')
viz.res.addPublishFileLoader('serializers_osg')
viz.res.addPublishFileLoader('osg')
viz.res.addPublishFileLoader('rgb')
viz.res.addPublishFileLoader('xlsx')
#viz.res.addPublishDirectory('C:/Program Files (x86)/WorldViz/Vizard4/bin/lib/site-packages/xlrd', pattern='*.py')

# Setup persistent published EXE in AppData directory
viz.setOption('viz.publish.persistent',1)
viz.setOption('viz.publish.product','C-OLiVE')
#viz.setOption('viz.publish.company','MyCompany')
viz.setOption('viz.publish.persist_folder','<appdata>/<product>')

##############################################
### MAKE THE INTERFACE AND DIFFERENT VIEWS ###
##############################################

gPlayers = {}		#dictionaty with player, joystick, and avatar classes
gPlayerData = {1: {'name': 'Player 1', 'colors': [[197, 106, 183], [97, 50, 83]], 'pos': [-10,EYEHEIGHT,0]},
               2: {'name': 'Player 2', 'colors': [[83, 171, 224], [36, 70, 90]], 'pos': [-7.5,EYEHEIGHT,0]},
               3: {'name': 'Player 3', 'colors': [[255, 189, 0], [135, 100, 0]], 'pos': [-5,EYEHEIGHT,0]}}
	
def splitViews ():
	global olivePress, floorMap, playerByView
def initTools(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawTool = vizconnect.getRawToolDict()

    #VC: initialize a new tool
    _name = 'grabber'
    if vizconnect.isPendingInit('tool', _name, initFlag, initList):
        #VC: init which needs to happen before viz.go
        if initFlag & vizconnect.INIT_PREVIZGO:
            viz.setOption('viz.display.stencil', 1)

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: initialization code needed by the parameters
            import tools
            from tools import grabber
            from tools import highlighter

            #VC: set some parameters
            usingPhysics = True
            highlightMode = tools.highlighter.MODE_OUTLINE
            placementMode = tools.placer.MODE_MID_AIR

            #VC: create the raw object
            rawTool[_name] = grabber.Grabber(
                usingPhysics=usingPhysics,
                usingSprings=usingPhysics,
                highlightMode=highlightMode,
                placementMode=placementMode,
                updatePriority=vizconnect.PRIORITY_ANIMATOR + 3)

        #VC: init the mappings for the raw object
        if initFlag & vizconnect.INIT_MAPPINGS:
            #VC: per frame mappings
            if initFlag & vizconnect.INIT_MAPPINGS_PER_FRAME:
                #VC: get the raw input dict so we have access to signals
                import vizact
                rawInput = vizconnect.getConfiguration().getRawDict('input')

                #VC: set the update function which checks for input signals
                def update(tool):
                    if rawInput['flystick'].isButtonDown(
                            0
                    ):  # make=ART, model=Flystick, name=flystick, signal=Button 0
                        tool.grabAndHold()

                rawTool[_name].setUpdateFunction(update)

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addTool(rawTool[_name],
                               _name,
                               make='Virtual',
                               model='Grabber')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getTool(_name).setParent(
                vizconnect.getAvatar('head_and_hand').getAttachmentPoint(
                    'r_hand'))

    #VC: initialize a new tool
    _name = 'laser_pointer'
    if vizconnect.isPendingInit('tool', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            displayDistance = True

            #VC: create the raw object
            from tools import laser_pointer
            rawTool[_name] = laser_pointer.LaserPointer(
                displayDistance=displayDistance,
                updatePriority=vizconnect.PRIORITY_ANIMATOR + 3)

        #VC: init the mappings for the raw object
        if initFlag & vizconnect.INIT_MAPPINGS:
            #VC: per frame mappings
            if initFlag & vizconnect.INIT_MAPPINGS_PER_FRAME:
                #VC: get the raw input dict so we have access to signals
                import vizact
                rawInput = vizconnect.getConfiguration().getRawDict('input')

                #VC: set the update function which checks for input signals
                def update(tool):
                    if rawInput['flystick'].isButtonDown(
                            5
                    ):  # make=ART, model=Flystick, name=flystick, signal=Button 5
                        tool.shoot()

                rawTool[_name].setUpdateFunction(update)

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addTool(rawTool[_name],
                               _name,
                               make='Virtual',
                               model='Laser Pointer')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getTool(_name).setParent(
                vizconnect.getAvatar('head_and_hand').getAttachmentPoint(
                    'r_hand'))

    #VC: set the name of the default
    vizconnect.setDefault('tool', 'grabber')

    #VC: return values can be modified here
    return None
コード例 #47
0
	quat = m.getQuat()
	#Apply offset to link
	link.postEuler([-yaw,0,0],target=viz.LINK_ORI_OP,priority=-20)
	link.preQuat(quat,target=viz.LINK_ORI_OP,priority=-20)
	
def resetHand(sensor, yawOffset=90):
	link = get('link2')
	link.reset(viz.RESET_OPERATORS )
	#Get yaw offset for intersense
	yaw = sensor.getEuler()[0]
	yaw -=yawOffset
	m = sensor.getMatrix()
	m.postEuler(-yaw,0,0)
	m.invert()
	quat = m.getQuat()
	#Apply offset to link
	link.postEuler([-yaw,0,0],target=viz.LINK_ORI_OP,priority=-20)
	link.preQuat(quat,target=viz.LINK_ORI_OP,priority=-20)
	
vizact.onkeydown('m',viz.RESET_POS)
# This viztracker file is also able to run itself and show a simple demo when not imported directly
if __name__ == "__main__":
	# Load the 3D world in
	gal =viz.add('ground_grass.osgb')
	viz.setOption('viz.glFinish', 1 )
	go()
	
from viztrackerutils import *


コード例 #48
0
ファイル: Base.py プロジェクト: Andywood10/UI3D_c
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)
コード例 #49
0
def Changescene(i):
    env = viz.addEnvironmentMap(IMAGE_PATH + '/' + env_map_namelist[i])
    sky.visible(viz.ON)
    sky.texture(env)
    viz.setOption('viz.hint', viz.FREE_TEXTURE_MEMORY_HINT)
    global sky