当前位置: 首页>>代码示例>>Python>>正文


Python viz.callback函数代码示例

本文整理汇总了Python中viz.callback函数的典型用法代码示例。如果您正苦于以下问题:Python callback函数的具体用法?Python callback怎么用?Python callback使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了callback函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

	def __init__(self):
		viz.callback(viz.COLLIDE_BEGIN_EVENT, onCollide)

		self.node = vizshape.addCube(TouchCube.DEFAULT_SIZE)
		viz.VizNode.__init__(self,self.node.id)
		self.collideBox()
		self.disable(viz.DYNAMICS)
		self.enable(viz.COLLIDE_NOTIFY)
		#BL:start
		if some_global_variables.PPT1:
			if TouchCube.activateSound == None:
				TouchCube.activateSound = self.playsound(PATH_TO_STUFF + "./Resources/Misc/tcActivate.wav", viz.STOP, volume=0.1)
			if TouchCube.bingSound == None:
				# Bing
				TouchCube.bingSound = self.playsound(PATH_TO_STUFF + "./Resources/Misc/bingCropped.wav", viz.STOP, volume = 0.1)
		else:
			if TouchCube.activateSound == None:
				TouchCube.activateSound = self.playsound(PATH_TO_STUFF + "./Resources/Misc/tcActivate_mono.wav", viz.STOP)
			if TouchCube.bingSound == None:
				# Bing
				TouchCube.bingSound = self.playsound(PATH_TO_STUFF + "./Resources/Misc/bingCropped_mono.wav", viz.STOP)
		#BL:end

		self.color = self._changeColor
		self._dimColor = [1,1,1]

		self._isLit = False

		self.disabledTouchers = []
开发者ID:vhilab,项目名称:fiveArms,代码行数:29,代码来源:touchcube.py

示例2: initializeBoatGrabberAndPhysics

def initializeBoatGrabberAndPhysics():
 global grabberTool, ObjectsToGrab, ALL_GRABBED_EVENT
 
 globals_oa.boat.collideMesh() 
 usingPhysics=False
 
 from tools import grabber
 from tools import highlighter
 
 global rhGrabber, lhGrabber
 if rhGrabber is None:
  rhGrabber = grabber.Grabber(usingPhysics=False, usingSprings=False, highlightMode=highlighter.MODE_BOX)
 if lhGrabber is None:
  lhGrabber = grabber.Grabber(usingPhysics=False, usingSprings=False, highlightMode=highlighter.MODE_BOX)
 rhGrabber.setUpdateFunction(rUpdateGrabberOnBoat)
 if globals_oa.rhModel is not None: rhGrabber.setParent(globals_oa.rhModel)
 lhGrabber.setUpdateFunction(lUpdateGrabberOnBoat)
 if globals_oa.lhModel is not None: lhGrabber.setParent(globals_oa.lhModel) 

 for obj in ObjectsToGrab:
   obj.collideBox()   

 rhGrabber.setItems(ObjectsToGrab)
 lhGrabber.setItems(ObjectsToGrab)
 
 viz.callback(grabber.GRAB_EVENT,grabObject)
 viz.callback(grabber.RELEASE_EVENT, releaseObject)
开发者ID:vhilab,项目名称:Ocean-Acidification,代码行数:27,代码来源:MoleculeGrabbingHandTarget.py

示例3: add_periodic

    def add_periodic(self, period, callback):
        '''Call some code periodically while running a task.

        The given `callback` will be called every `period` seconds between the
        firings of the PRE_RUN and POST_RUN events for this task.

        Parameters
        ----------
        period : float
            Number of seconds between successive calls to the `callback`.
        callback : callable (no arguments)
            Call this function every `period` seconds.

        Returns
        -------
        timer_id :
            The Vizard timer ID. Can be used to kill this periodic event.
        '''
        timer_id = 1 + max(self._timers)
        self._timers.append(timer_id)

        viz.callback(self.POST_RUN_EVENT, lambda me: viz.killtimer(timer_id))
        def start(me):
            def clock(t):
                if t == timer_id: callback()
            viz.callback(viz.TIMER_EVENT, clock)
            viz.starttimer(timer_id, period, viz.FOREVER)
        viz.callback(self.PRE_RUN_EVENT, start)

        return timer_id
开发者ID:EmbodiedCognition,项目名称:cube-experiment,代码行数:30,代码来源:task.py

示例4: start

        def start(me):
            def clock(t):
                if t == timer_id:
                    callback()

            viz.callback(viz.TIMER_EVENT, clock)
            viz.starttimer(timer_id, period, viz.FOREVER)
开发者ID:EmbodiedCognition,项目名称:tracing-experiment,代码行数:7,代码来源:task.py

示例5: main

def main():
	global loc_list
	global active_location
	loc_list = []
	
	mainSceneWindow = None
	cameraWindow = None
	cameraWindowView = None
	cam = None
	pause_screen = None
	nunchuck_disconnect_screen = None
	message_screen = None
	wiimote = None
	nunchuck_wiimote = None
	should_it_run = None
	
	mainSceneWindow, cameraWindow, cameraWindowView, cam, pause_screen, nunchuck_disconnect_screen, message_screen, wiimote, nunchuck_wiimote, should_it_run = init_settings(mainSceneWindow, cameraWindow, cameraWindowView, cam, pause_screen, nunchuck_disconnect_screen, message_screen, wiimote, nunchuck_wiimote, should_it_run)
	
	vizact.ontimer(0, moveCamera, nunchuck_wiimote, should_it_run)
	viz.callback(wii.EXT_CONNECT_EVENT,onConnect)
	viz.callback(wii.EXT_DISCONNECT_EVENT,onDisconnect)
	
	initializer(loc_list)
	arMarkerLoader(cam)
	wiimoteInitializer(wiimote, nunchuck_wiimote, should_it_run, message_screen)
	
	viz.go() # Inicia VIZ
	
	for item in loc_list:
		if item.space_name == "piazza.osgb":
			active_location = item
			item.addLocation()
开发者ID:luion,项目名称:virtual-ar-museum,代码行数:32,代码来源:universe.py

示例6: __init__

	def __init__(self):
		viz.callback(viz.COLLIDE_BEGIN_EVENT, onCollide)

		self.node = vizshape.addCube(TouchCube.DEFAULT_SIZE)
		viz.VizNode.__init__(self,self.node.id)
		self.collideBox()
		self.disable(viz.DYNAMICS)
		self.enable(viz.COLLIDE_NOTIFY)
		#BL:start
		if USING_VIZSONIC:
			if TouchCube.activateSound == None:
				TouchCube.activateSound = self.playsound("./Resources/Misc/tcActivate.wav", viz.STOP, volume=0.1)
			if TouchCube.bingSound == None:
				# Bing
				TouchCube.bingSound = self.playsound("./Resources/Misc/bingCropped.wav", viz.STOP, volume = 0.1)
		else:
			print "skipping those errors!"
			if TouchCube.activateSound == None:
				TouchCube.activateSound = self.playsound("./Resources/Misc/tcActivate_mono.wav", viz.STOP)
			if TouchCube.bingSound == None:
				# Bing
				TouchCube.bingSound = self.playsound("./Resources/Misc/bingCropped_mono.wav", viz.STOP)
		#BL:end

		self.color = self._changeColor
		self._dimColor = [1,1,1]

		self._isLit = False

		self.disabledTouchers = []
开发者ID:vhilab,项目名称:thirdArm,代码行数:30,代码来源:touchcube.py

示例7: creepilyMoveCloser

def creepilyMoveCloser(node):
	global introAudio1, introAudio2
	global comeForward, firstSeatPosition, seatQueue
	global PID
	dout = DataOutputHelper(PID)
	comeForward = seatQueue[-2]
	firstSeatPosition = seatQueue[0]
	node.setPosition(firstSeatPosition)
	
	yield viztask.waitMediaEnd(introAudio1)
	
	introAudio2.play()
	
	# We want the participant to have a minute after the audio ends
	viz.callback(viz.MEDIA_EVENT,onAudioEnd)
	dout.timestamp(dout.busFile, 'Initial audio ended')
	
	yield viztask.waitMediaEnd(introAudio2)

	yield viztask.waitTime(.1) # Pause necessary for NodeViewDetection to get necessary info about node
	nvd = DetectWhetherInView.NodeViewDetection(node)
	FadeObject.beginFading()
	
	moveAsUsual = False
	getCloserBeforeBackAway = True
	
	while getCloserBeforeBackAway:
		node.setPosition(firstSeatPosition)
		yield waitTilNodeAndDestOutsideView(nvd, firstSeatPosition)
		yield waitTilNodeInsideView(nvd)
		node.setPosition(comeForward)
		yield creepilyMakeEyeContact(node, comeForward, dout)
		yield moveBackToFirstSeat(node, seatQueue)
		if abs(node.getPosition()[0] - firstSeatPosition[0]) < 0.1:
			getCloserBeforeBackAway = False
			moveAsUsual = True
	
	print 'waiting til node inside view...'
	yield waitTilNodeInsideView(nvd)	
	while moveAsUsual:
		print 'waiting until node and dest outside view...'
		nextPosition = seatQueue[1] # Peek at nextPosition
		yield waitTilNodeAndDestOutsideView(nvd, nextPosition) # Pauses til node and that position are outside of view
		
		# Move to nextPosition
		print 'node and dest are outside view! Moving to next position...'
		node.setPosition(nextPosition)
		seatQueue.rotate(-1) # update seatQueue
		
		print 'waiting til node inside view...'
		yield waitTilNodeInsideView(nvd)
		
		print 'creepily dodging eye contact...'
		yield creepilyMakeEyeContact(node, seatQueue[0], dout)
		
	
		#if seatQueue[0] is not finalSeatPosition:
		print 'waiting 5 seconds then moving him back if hes in view at the end of the 5 seconds.' # TODO: This is not exactly what we want.
		yield moveBackwardsIfStaredAt(node, nvd) # If the node is not in the last seat position,
开发者ID:vhilab,项目名称:homelessness-study,代码行数:59,代码来源:CreepySeatChanging.py

示例8: setAsMain

	def setAsMain(self):
		viz.logStatus('Setting Joyculus as main')

		val = mathlite.getNewRange(self.joy.getSlider(),1,-1,self.MIN_SPEED,self.MAX_SPEED)
		self.MOVE_SPEED = val
		
		vizact.onsensordown(self.joy,self.KEYS['reset'],self.reset)
		vizact.ontimer(0,self.updateView)
		viz.callback(getExtension().SLIDER_EVENT,self.onSliderChange)
开发者ID:justlim77,项目名称:TrussBridgeBuilder,代码行数:9,代码来源:navigation.py

示例9: enable

def enable():
	global car, call_screen, SCENE
	viz.MainWindow.setScene(SCENE)
	reset()
	vizact.onkeydown('r', reset)
	#PhoneRadio.test(SCENE, car, call_screen)
	PhoneRadio.enable(SCENE, car, call_screen)
	
	#wait for keypress 1 to start object finding portion
	viz.callback(PhoneRadio.INTRO_OVER_EVENT, PosessionHunting.enable)
	
	#waits for last object to be found, and then schedules police narrative
	viz.callback(PosessionHunting.FINDING_TASK_OVER_EVENT, police.enable)
开发者ID:vhilab,项目名称:homelessness-study,代码行数:13,代码来源:CarScene.py

示例10: __init__

 def __init__(self, scene=viz.Scene1, avatar=None):
   self.scene = scene
   self.avatar = avatar
   self.subwindow = None
   self.subview = None
   self.scale = 0.4
   
   self.initScreen()
   
   if self.avatar is not None:
     self.initAvatar()
     
   vizact.onkeydown(' ',self.toggleVisibility)
   viz.callback(viz.MOUSEWHEEL_EVENT,self.rescale)
开发者ID:vhilab,项目名称:homelessness-study,代码行数:14,代码来源:StoryScreen.py

示例11: main

def main():

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

    viz.go(viz.FULLSCREEN)

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

    mocap = phasespace.Phasespace()

    head = mocap.get_rigidTracker("hmd")

    # DOES NOT ACCOUNT FOR RIGID BODY OFFSET DURING RESET

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

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

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

    mocap.start_thread()
    # mocap.start_timer()

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

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

    def keydown(key):

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

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

    viz.callback(viz.KEYDOWN_EVENT, keydown)
开发者ID:YanjieGao,项目名称:ExperimentBase,代码行数:50,代码来源:phasespace_newTest.py

示例12: __init__

	def __init__(self, handTracker = None):
		
		# These two lines are weird necessities to subclass the VizNode class (which most Vizard objects are?)
		self.node = viz.addChild(Dart._MODEL_FILE)
		viz.VizNode.__init__(self,self.node.id)
		
		self.setScale(Dart._SCALE, Dart._SCALE, Dart._SCALE)
		self.color(1, 0, 0)
		
		self.collideBox()
		self.enable(viz.COLLIDE_NOTIFY)
		viz.callback(viz.COLLIDE_BEGIN_EVENT, onCollide)
		self.initVelocity()
		self.initEuler()
		self.setVelocity([0, 0, 0])
		if handTracker != None: self.attachToHand(handTracker)
开发者ID:vhilab,项目名称:thirdArm,代码行数:16,代码来源:BalloonsClassesOld.py

示例13: __setupTracking__

	def __setupTracking__(self):
		
		#get mocap interface
		self.mocap = Connector.getMocapInterface()

		#Get the shutter-glass rigid body
		self.shutterGlass = self.mocap.returnPointerToRigid(Connector.SHUTTERGLASSES)
		self.head_tracker = viz.link(self.shutterGlass.vizNode,viz.NullLinkable,srcFlag=viz.ABS_PARENT)
		self.cave.setTracker(self.head_tracker)

		# Create cave view
		cave_origin = vizcave.CaveView(self.head_tracker)
		
		#In case you want to override & translate the physical location of cave, uncommnet this
		
		'''
		origin_tracker = viztracker.KeyboardMouse6DOF()
		origin_link = viz.link(origin_tracker, cave_origin)
		origin_link.setMask(viz.LINK_POS)
		'''
		
		#Foot rigidBodies
		leftFootRigid = self.mocap.returnPointerToRigid(Connector.L_FOOT)
		rightFootRigid = self.mocap.returnPointerToRigid(Connector.R_FOOT)
		
		#Foot visuals, make them 100% transparent when not in debug mode
		self.leftFootViz = vizshape.addBox(size=(.2,.2,.2))
		self.rightFootViz = vizshape.addBox(size=(.2,.2,.2))
		
		if(self.debug):
			self.leftFootViz.alpha(0.025)
			self.rightFootViz.alpha(0.025)
		else:
			self.leftFootViz.alpha(0.0075)
			self.rightFootViz.alpha(0.0075)
		
		#Foot class objects
		self.leftFoot = Foot(mocapFootObj = leftFootRigid, name="Left")
		self.rightFoot = Foot(mocapFootObj = rightFootRigid, name="Right")
		
		#setup buffer updates
		vizact.onupdate(0, self.leftFoot.populateNextBufferElement)
		vizact.onupdate(0, self.rightFoot.populateNextBufferElement)
		vizact.onupdate(0, self.updateBooties)
		viz.callback(viz.COLLIDE_BEGIN_EVENT, self.collideDetected)
开发者ID:performlabrit,项目名称:VRWalking-Preliminary,代码行数:45,代码来源:WEnvironment.py

示例14: main

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)
开发者ID:EmbodiedCognition,项目名称:tracing-experiment,代码行数:43,代码来源:phasespace_test.py

示例15: setup

def setup():
	global lhPPT, rhPPT, headPPT, headLink;
	global lhSphere, rhSphere
	
	nvis.nvisorSX111();
	#nvis.nvisorSX60();
	viz.mouse.setVisible(False)
	#viz.cursor(viz.OFF);
	view = viz.MainView
	isense = viz.add('intersense.dle')
	headTracker = isense.addTracker(port=1)
	vizact.onkeydown('r',headTracker.resetHeading)
	vrpn = viz.add('vrpn7.dle');
	PPT_HOSTNAME = '171.64.33.43';
	headPPTorig = vrpn.addTracker('[email protected]' + PPT_HOSTNAME, 0);

	#Merge two links together
	headPPT = viz.mergeLinkable(headPPTorig,headTracker)
	headLink = viz.link(headPPT, viz.MainView);
	headLink.postTrans([EYE_VECTOR[0], EYE_VECTOR[1], EYE_VECTOR[2]]);
	
	#now add the PPT hands tracker
	rhPPT = vrpn.addTracker('[email protected]' + PPT_HOSTNAME, 1)
	lhPPT = vrpn.addTracker('PP[email protected]' + PPT_HOSTNAME, 2)
	
	grid = vizshape.addGrid();
	grid.color([0.5] * 3);
	
	viz.callback(viz.KEYDOWN_EVENT, onKeyDown);
	
	if(DEBUG_MODE):
		print "adding spheres";
		rhSphere = vizshape.addSphere(radius = 0.1, color = viz.WHITE);
		lhSphere = vizshape.addSphere(radius = 0.1, color = viz.WHITE);
		rfSphere = vizshape.addSphere(radius = 0.1, color = viz.WHITE);
		lfSphere = vizshape.addSphere(radius = 0.1, color = viz.WHITE);
		

	
	return;
开发者ID:vhilab,项目名称:thirdArm,代码行数:40,代码来源:pptextension.py


注:本文中的viz.callback函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。