コード例 #1
0
	def __init__(self,use_keyboard = True, desktop_mode = False):
		
		caveapp.CaveApplication.__init__(self,desktop_mode) #call constructor of super class, you have to do this explicitly in Python		
		#self.wand = vizshape.addAxes() #load axis model to represent the wand (WALL FFS!)
		
		# Add skybox
		sky = viz.add(viz.ENVIRONMENT_MAP,'alien/jajalien1.jpg')
		skybox = viz.add('skydome.dlc')
		skybox.texture(sky)
		
		# First light added seems to be ignored....
		# Add lighting
		dummy = viz.addLight()
		light = viz.addLight()
		light.position(0, 0, 0)
		light.color([0.8, 1, 0.8])
		
		self.use_keyboard = use_keyboard #store if we want to use the keyboard
		#self.time = 0.0 #note that to 0.0 is important because it is a double precision floating point number
		
		self.speed = 400.0 #--four-- meters per second
		originTracker = self.cavelib.getOriginTracker()
		#originTracker.setPosition([-100,100,0],viz.REL_LOCAL)
		self.returnToStart()
		self.yaw = 90
		self.startSet=0
		self.joystickpressed=0
		
		vizact.onkeydown(' ', viz.setDebugSound3D, viz.TOGGLE)
コード例 #2
0
ファイル: labtracker.py プロジェクト: howonlee/boulder
	def __init__(self):
		viz.mouse.setVisible(viz.OFF)
		#Activate NVIS HMD
		nvis.nvisorSX111()
		#nvis.nvisorSX60()
		viz.cursor(viz.OFF)
		#isense = viz.add('intersense.dls')
		vrpn = viz.add('vrpn7.dle')
		view = viz.MainView

		self.markers = []

		headMarker = vrpn.addTracker('PPT0@' + PPT_HOSTNAME, 0)
		self.markers.append(headMarker)
		self.markers.append( vrpn.addTracker('PPT0@' + PPT_HOSTNAME, 1) )
		self.markers.append( vrpn.addTracker('PPT0@' + PPT_HOSTNAME, 2) )
		self.markers.append( vrpn.addTracker('PPT0@' + PPT_HOSTNAME, 3) )
		self.markers.append( vrpn.addTracker('PPT0@' + PPT_HOSTNAME, 4) )

		filter = viz.add("filter.dle")
		headMarker_filter = filter.average(headMarker, samples = 7)

		headPos = viz.link(headMarker_filter, view, priority = 0)
		headPos.setOffset(DEFAULT_OFFSET)
		self.posLink = headPos
		#self.posLink.postScale(DEFAULT_SCALE)
		self.headMarker = headMarker
コード例 #3
0
ファイル: Window.py プロジェクト: tokola/GitHub_OLiVE
	def GameFinish (self, delay):
		self.info = vizinfo.add(self.tooltips['congrats'])
		self.info.visible(0)
		self.info.icon(viz.add('textures/c-olive_icon.png'))
		self.info.add(viz.TEXT3D, self.tooltips['finish']+'\n'+self.tooltips['produce'] % self._oil.getMessage())
		self.info.add(viz.TEXT3D, self.tooltips['stats'])
		self.info.translate(0.1,0.95)
		self.info.alignment(vizinfo.UPPER_LEFT)
		self.info.scale(2.4,2.6)
		self.info.messagecolor(100,100,0)
		self.info.bgcolor(viz.BLACK, 0.8)
		self.info.bordercolor([100,100,0], .9)
		points = self.info.add(viz.TEXQUAD, self.tooltips['score']+': %s' % self._total.getMessage())
		points.texture(viz.add('textures/total_icon.png'))
		time = self.info.add(viz.TEXQUAD, self.tooltips['time']+': %s' % self.ConvertTime(viz.tick()))
		time.texture(viz.add('textures/time_icon.png'))
		self.info.shrink()
		#hide all other panels
		self._scorePanel.visible(0)
		self._infoPanel.visible(0)
		self._alertPanel.visible(0)
		for p in self.PLAYERS.values():
			p._infoPanel.visible(0)
			p._alertPanel.visible(0)
			p._hud.visible(0)
		time.addAction(vizact.waittime(delay))
		time.addAction(vizact.call(self.info.visible, 1))
		time.addAction(vizact.waittime(.1))
		time.addAction(vizact.call(self.PlayVictory))
		time.addAction(vizact.call(self.info.expand))
コード例 #4
0
ファイル: universe.py プロジェクト: luion/virtual-ar-museum
def init_settings(mainSceneWindow, cameraWindow, cameraWindowView, cam, pause_screen, nunchuck_disconnect_screen, message_screen, wiimote, nunchuck_wiimote, should_it_run):
	viz.MainWindow.visible(viz.OFF) #Hago invisible la main window
	viz.setMultiSample(8) # FSAA de 8
	viz.fogcolor = viz.BLACK # Color de sombra = negro
	viz.fog(0.15) # Agrega sombra de tipo exponencial
	viz.collision(viz.ON) # Habilita colisiones en el mundo
	viz.phys.enable() # Habilita la fisica

	#Desabilita mouse
	viz.mouse.setOverride(viz.ON)

	#Mouse invisible
	viz.mouse.setVisible(viz.OFF)

	#Subventana que renderea viz.MainWindow
	mainSceneWindow = viz.addWindow()
	mainSceneWindow.setSize(0.7,1)
	mainSceneWindow.setPosition(0,1)
	mainSceneWindow.fov(40, 1.3) # Coloca el FOV de la ventana principal en la actual con los valores de default (40 grados verticales, 1.3 aspect ratio)

	#Creando una ventana y un punto de vista para la camara
	cameraWindow = viz.addWindow(pos =[.7,1],size=(0.4,1)) #Creando la ventana
	cameraWindowView = viz.addView() #Creando un viewpoint
	cameraWindowView.setScene(2) #Poniendo la nueva ventana en la escena 2
	cameraWindow.setView(cameraWindowView) #Ligando el viewpoint con la nueva ventana

	#Vincular camara web a plugin de AR
	cam = ar.addWebCamera(window=cameraWindow) #Agregando una camara en la ventada nueva

	# Configuracion de mensajes de la pantalla
	message_screen = viz.addTexQuad(parent=viz.SCREEN, pos=[0.5,0.5,1], scale=[12.80,10.24,1]) 
	pause_screen = viz.add("PAUSA.png")
	nunchuck_disconnect_screen = viz.add("NUNCHUCK_DISCONNECTED.png")
	message_screen.texture(pause_screen)
	message_screen.visible(viz.OFF) #Cuando should_it_run sea False, viz.ON es el valor a usar.

	# Conecta al primer wiimote disponible
	wiimote = wii.addWiimote()
	# Prende el LED 1 del wiimote
	wiimote.led = wii.LED_1
	# Obten el nunchuck del wiimote
	nunchuck_wiimote = wiimote.nunchuk 

	#Determines wheter the program should run or not.
	#It will run if the Nunchuck is connected; otherwise, it won't.
	should_it_run = True

	#Ensures that the program won't run without the NUNCHUCK plug'd in.
	if(wiimote.getExtension() == wii.EXT_NUNCHUK):
		should_it_run = True
	else:
		print "Please plug-in the Wii NUNCHUCK."
		message_screen.texture(nunchuck_disconnect_screen)
		message_screen.visible(viz.ON)
		should_it_run = False
	
	return mainSceneWindow, cameraWindow, cameraWindowView, cam, pause_screen, nunchuck_disconnect_screen, message_screen, wiimote, nunchuck_wiimote, should_it_run
コード例 #5
0
def addfix():
	global fixation 
	
	##add fixation
	fixName = 'textures/fix_trans.gif'
	fixation = viz.add(viz.TEXQUAD)
	ttsize = .4
	fixation.scale(ttsize, ttsize, ttsize)
	fixation.texture(viz.add(fixName))
	fixation.visible(1)
コード例 #6
0
def init(qHaveSimultaneous):
    if qHaveSimultaneous:
        vizconnect.go('vizconnectSetups/vive_ppt_intersense.py')
    else:
        vizconnect.go('vizconnectSetups/viveLighthouse.py')
    piazza = viz.add('piazza.osgb')
    piazza2 = viz.add('piazza_animations.osgb')

    vive = vizconnect.getRawTracker('head_tracker')
    if qHaveSimultaneous:
        optHead = vizconnect.getRawTracker('optical_heading')
        PPT1 = vizconnect.getRawTracker('ppt_1')
        PPT2 = vizconnect.getRawTracker('ppt_2')
        PPT3 = vizconnect.getRawTracker('ppt_3')
        PPT4 = vizconnect.getRawTracker('ppt_4')
        inertiacube = vizconnect.getRawTracker('inertiacube')

    # check controller is on
    steamvr.getControllerList()[0].isButtonDown(2)

    def getTrackInfo():
        if 1:
            if qHaveSimultaneous:
                return {
                    'vive': vive.getPosition() + vive.getEuler(),
                    'optical_heading':
                    optHead.getPosition() + optHead.getEuler(),
                    'PPT1': PPT1.getPosition(),
                    'PPT2': PPT2.getPosition(),
                    'PPT3': PPT3.getPosition(),
                    'PPT4': PPT4.getPosition(),
                    'inertiacube': inertiacube.getEuler()
                }
            else:
                return {'vive': vive.getPosition() + vive.getEuler()}
        else:
            return {
                'viveController':
                steamvr.getControllerList()[0].getPosition() +
                steamvr.getControllerList()[0].getEuler()
            }

    trialStartSound = viz.addAudio('sounds/quack.wav', play=0, volume=2.)
    trialCompletedSound = viz.addAudio('sounds/pop.wav', play=0, volume=2.)
    alarmSound = viz.addAudio('alarm.wav', play=0, volume=2.)

    # make return values
    Sounds = namedtuple('Sounds', 'trialStart trialCompleted alarm')
    InitReturn = namedtuple('initReturn', 'visuals sounds trackerDataFun')
    return InitReturn(visuals=[piazza, piazza2],
                      sounds=Sounds(trialStart=trialStartSound,
                                    trialCompleted=trialCompletedSound,
                                    alarm=alarmSound),
                      trackerDataFun=getTrackInfo)
コード例 #7
0
ファイル: SP_Orca18_Main.py プロジェクト: callummole/SP_18-19
        def loadimage(fn):
            """Loads a and scales a texture from a given image path"""
            defaultscale = 800.0 / 600.0
            aspect = 1920.0 / 1080.0
            scale = aspect / defaultscale
            ttsize = 1
            pt = viz.add(viz.TEXQUAD, viz.SCREEN)
            pt.scale(ttsize, ttsize * scale, ttsize)
            pt.texture(viz.add(fn))

            pt.visible(0)
            return (pt)
コード例 #8
0
	def loadimage(fn):
		"""Loads a and scales a texture from a given image path""" 
		defaultscale = 800.0/600.0
		aspect = 1920.0 / 1080.0		
		scale = aspect/defaultscale
		ttsize = 1
		pt = viz.add(viz.TEXQUAD, viz.SCREEN)
		pt.scale(ttsize, ttsize*scale, ttsize)
		pt.texture(viz.add(fn))
		pt.translate(Grid[0][0],Grid[0][1]) # Now you can specify screen coordinates, so the visual angle is OK (i.e. no depth)
		pt.visible(0)
		return (pt)
コード例 #9
0
    def start(self):
        viz.add(self.resource)
        self.visible(viz.OFF)
        self.setScale(self.scale[0], self.scale[1], self.scale[2])

        if self.scope == 'global':
            self.setPosition(self.position, viz.ABS_GLOBAL)
        elif self.scope == 'local':
            self.setPosition(self.position, viz.ABS_LOCAL)
        else:
            print(
                "ERROR: Could not set position of landmark object because of undefined scope '"
                + str(scope) + "'. Scope must be 'local' or 'global'.")
コード例 #10
0
 def drawCorners(sD):
     # buildings
     tmpObst = sD.obstacles
     for cObst in tmpObst:
         for cP in cObst.getCorners('world'):
             cornerBalls.append(viz.add('ball.wrl'))
             cornerBalls[-1].setPosition(cP[0],0,cP[1])
     # show bounding box corners using balls
     for cP in sD.bbCtx1.getCorners('world'):
         cornerBalls.append(viz.add('ball.wrl'))
         cornerBalls[-1].setPosition(cP[0],0,cP[1])
     # show bounding box corners using balls
     for cP in sD.bbCtx2.getCorners('world'):
         cornerBalls.append(viz.add('ball.wrl'))
         cornerBalls[-1].setPosition(cP[0],0,cP[1])
コード例 #11
0
	def setStage(self,stage,NAxes,relSpeed,holes,waittime):
		self.stage = stage
		if holes == True:
			self.bridge = viz.add('bridgeHoles.OSGB')
		else:
			self.bridge = viz.add('bridge.OSGB')
		
		self.tracking_data.write("Stage "+str(stage)+"\n")
		yield self.activateHeadTracking(True)
		yield self.stageAxes(NAxes,relSpeed,holes)
		yield self.activateHeadTracking(False)
		
		yield self.deleteScene()
		yield viztask.waitTime(waittime)
		yield self.returnToStart()
コード例 #12
0
def initInputs(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawInput = vizconnect.getRawInputDict()

    #VC: initialize a new input
    _name = 'flystick_analog'
    if vizconnect.isPendingInit('input', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            basename = 'DTrack'
            hostname = '192.168.0.10'

            #VC: create the raw object
            vrpn = viz.add('vrpn7.dle')
            sensor = vrpn.addAnalog(basename + '@' + hostname)
            rawInput[_name] = sensor

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addInput(rawInput[_name],
                                _name,
                                make='Generic',
                                model='VRPN Analog')

    #VC: initialize a new input
    _name = 'flystick_buttons'
    if vizconnect.isPendingInit('input', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            basename = 'DTrack'
            hostname = '192.168.0.10'

            #VC: create the raw object
            vrpn = viz.add('vrpn7.dle')
            sensor = vrpn.addButton(basename + '@' + hostname)
            rawInput[_name] = sensor

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addInput(rawInput[_name],
                                _name,
                                make='Generic',
                                model='VRPN Buttons')

    #VC: return values can be modified here
    return None
コード例 #13
0
def initTrackers():
	rawTracker = vizconnect.getRawTrackerDict()
	default = ''

	# initialization code for ppt which is a WorldVizPPT
	pptHostname="localhost"
	vrpn7 = viz.add('vrpn7.dle')
	# initialization for sub object ppt_Rhead
	markerId=1
	rawTracker['ppt_Rhead'] = vrpn7.addTracker('PPT0@'+pptHostname, markerId-1)
	# initialization for sub object ppt_Lhead
	markerId=2
	rawTracker['ppt_Lhead'] = vrpn7.addTracker('PPT0@'+pptHostname, markerId-1)
	# initialization for sub object ppt_hand
	markerId=4
	rawTracker['ppt_hand'] = vrpn7.addTracker('PPT0@'+pptHostname, markerId-1)

	# initialization code for osv3_sensor_bus which is a InertialLabsOSv3SensorBus
	port=11
	sensorIndex=0
	InertialLabs = viz.add('InertialLabs.dle')
	sensors = InertialLabs.addSensorBus(port=port)
	try:
		sensor = sensors[sensorIndex]
	except:
		viz.logWarn("** WARNING: can't connect to InertialLabs OSv3 (Sensor Bus) on port {0} with index {1}. It's likely that not enough sensors are connected.".format(port, sensorIndex))
		sensor = viz.addGroup()
		sensor.invalidTracker = True
	rawTracker['osv3_sensor_bus'] = sensor

	# transformation offset code for osv3_sensor_bus
	link = viz.link(rawTracker['osv3_sensor_bus'], viz.NullLinkable)
	link.setSrcMaskOverride(viz.LINK_ORI|viz.LINK_POS)
	link.preEuler([90, 0, 180])
	rawTracker['osv3_sensor_bus'] = link

	# initialization code for optical_heading which is a VirtualOpticalHeading
	leftPosTracker=vizconnect.getRawTracker('ppt_Lhead')
	rightPosTracker=vizconnect.getRawTracker('ppt_Rhead')
	oriTracker=vizconnect.getRawTracker('osv3_sensor_bus')
	distance=0.37
	from vizconnect.virtual_trackers import OpticalHeading
	rawTracker['optical_heading'] = OpticalHeading(leftPosTracker, rightPosTracker, oriTracker, distance=distance)

	# setting default
	default = 'ppt_Rhead'

	return rawTracker, default
コード例 #14
0
	def __init__(self, offset, particle=None, sensorNum=0, attachTo=viz.MainView, preTrans = [0, 0, 0.1778]) :
		viz.EventClass.__init__(self)

		self.offset 	= offset
		self.particle   = particle
		self.sensorNum = sensorNum
		self.attachTo = attachTo
		self.preTran = preTrans
		
		self.off 			   = True

		self.vrpn = viz.add('vrpn6.dle')
		self.tracker = self.vrpn.addTracker('[email protected]', sensorNum) 
		self.tracker.swapPos([1,3,2]) 
		self.tracker.swapQuat([-1,-3,-2,4])
		
		self.preMat = vizmat.Transform()
		self.preMat.preEuler([-90, 0, 0]);
		self.preMat.preTrans(self.preTran);
		
		self.postMat = vizmat.Transform();
		self.postMat.postTrans(offset);
		
		vizact.ontimer(0, self.updateView)
		self.pos = [0,0,0]
		self.rot = [0, 0, 0, 0]
		self.turnOn()
コード例 #15
0
    def __init__(self,
                 name='None',
                 power=0,
                 toughness=0,
                 pos=[0, 0, 0],
                 model='None'):
        """
        Creates an item. use Item( name,description, power, toughness)
        """

        Entity.Entity.__init__(self, name)  #set name of object
        """
        Sets object Name
        """

        #self.description=description # ? a description of the object
        self.stats = Stats.Stats(
            power, toughness
        )  # ? an instance of stats, holding the power/toughness of the object.

        if model != 'None':
            self.model = viz.add(model, scene=3)

            #self.model.setScale(.1/3,.1/3,.1/3)
            self.model.setPosition(pos)
            print 'Item init, model pos'
            print self.model.getPosition()
コード例 #16
0
def main():
    global marker
    global current
    if marker.getVisible() and current == 1:
        current = 0

        baseValueX1 = marker.getPosition(0)[0]
        #this denotes the X position
        baseValueY1 = marker.getPosition(0)[1]
        #this denotes the Y position
        baseValueZ1 = marker.getPosition(0)[2]
        #this denotes the Z position

        endValueX1 = endMarker.getPosition()[0]
        endValueY1 = endMarker.getPosition()[1]
        endValueZ1 = endMarker.getPosition()[2]

        arrow = viz.add('thesis/greenArrow.dae')
        scaleSize = 0.5
        arrow.setScale(scaleSize, scaleSize, scaleSize)
        #change the size of arrow object
        arrow.setEuler(90)
        arrow.setPosition([baseValueX1, baseValueY1, baseValueZ1])

        positions = [[baseValueX1, baseValueY1, baseValueZ1], [1, 1, 1],
                     [2, 2, 2], [3, 3, 3], [4, 4, 4]]

        for p in range(5):
            pinch = viz.addChild('thesis/niceHand_5.dae')
            scaleSize = 0.5
            pinch.setScale(scaleSize, scaleSize, scaleSize)
            #change the size of arrow object
            pinch.setEuler([90, 0, 0])
            pinch.setPosition(positions[p])
コード例 #17
0
def start_avatar():
	
	avatar = viz.add('vcc_female.cfg', pos = (0,0,4), euler=(180,0,0))
	avatar.state(5)

	#Add avatar as a shadow caster
	shadow.addCaster(avatar)
コード例 #18
0
def createCustomComposite(id=0):
    viz.logNotice('MotionNode Head Tracking')

    # Use general VRPN tracker.
    vrpn = viz.add('vrpn7.dle')
    PPT_VRPN = 'Tracker0@localhost'
    head = vrpn.addTracker(PPT_VRPN)
    # Need to change rotation axes from MotionNode
    # to Vizard conventions.
    head.swapQuat([-3, -2, -1, 4])

    # Or, use the built in MotionNode tracker
    # support.
    #MotionNode = viz.add('MotionNode.dle')
    #head = MotionNode.addSensor()

    headfinal = viz.addGroup()
    headlink = viz.link(head, headfinal, enabled=False)
    import vizact
    vizact.onupdate(viz.PRIORITY_PLUGINS + 1, headlink.update)
    headlink.postTrans([0, 0.1, 0])  # Apply 10 cm translate in Y axis

    import vizuniverse as VU
    comp = VU.VUCompositeTrackers()
    comp.storeTracker(comp.HEAD, headfinal)

    comp.createAvatarNone()
    comp.defineViewpoint()
    comp.finishTrackers()
    return comp
コード例 #19
0
    def __init__(self, room, size, marker_num, hand='left'):

        VisualObject.__init__(self, room=room, shape='sphere', size=size)

        # remove the sphere and add the baseball glove
        self.vis_node.remove()
        model_path = 'res/glove_{}.OSGB'.format(hand)
        try:
            self.vis_node = viz.addChild(model_path)
        except:
            print 'Hand must be left or right.'

        # setup position and orientation tracking
        glove_tracker = ppt.add_tracker(1)
        isense = viz.add('intersense.dle')
        self.ori_tracker = isense.addTracker(port=0)
        self.ori_tracker.setCompass(0)
        self.ori_tracker.setEnhancement(0)
        self.ori_tracker.resetHeading()
        vizact.onkeydown('i', self.ori_tracker.resetHeading)
        if hand == 'left':
            pre_trans = [0.04, -0.02, 0]
        else:
            pre_trans = [-0.04, -0.02, 0]
        link = ppt.link(tracker=glove_tracker, target=self.vis_node, ori=self.ori_tracker, pre_trans=pre_trans)

        # setup physics object
        # TODO: do we really want this?
        self.toggleUpdatePhysWithVis()
コード例 #20
0
def initAvatars(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawAvatar = vizconnect.getRawAvatarDict()

    #VC: initialize a new avatar
    _name = 'male'
    if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: create the raw object
            avatar = viz.add('vcc_male.cfg')
            avatar._bodyPartDict = {}
            avatar._handModelDict = {}
            rawAvatar[_name] = avatar

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addAvatar(rawAvatar[_name],
                                 _name,
                                 make='Complete Characters',
                                 model='Male')

        #VC: init the animator
        if initFlag & vizconnect.INIT_ANIMATOR:
            # need to get the raw tracker dict for animating the avatars
            from vizconnect.util.avatar import animator
            from vizconnect.util.avatar import skeleton

            # get the skeleton from the avatar
            _skeleton = skeleton.CompleteCharacters(rawAvatar[_name])

            #VC: set which trackers animate which body part
            # format is: bone: (tracker, parent, degrees of freedom used)
            _trackerAssignmentDict = {
                vizconnect.AVATAR_HEAD:
                (vizconnect.getTracker('look_at2').getNode3d(), None,
                 vizconnect.DOF_6DOF),
                vizconnect.AVATAR_L_FOREARM:
                (vizconnect.getTracker('marker6').getNode3d(), None,
                 vizconnect.DOF_6DOF),
                vizconnect.AVATAR_L_HAND:
                (vizconnect.getTracker('look_at').getNode3d(), None,
                 vizconnect.DOF_6DOF),
                vizconnect.AVATAR_R_HAND:
                (vizconnect.getTracker('look_at3').getNode3d(), None,
                 vizconnect.DOF_6DOF),
            }

            #VC: create the raw object
            _rawAnimator = animator.InverseKinematics(rawAvatar[_name],
                                                      _skeleton,
                                                      _trackerAssignmentDict)

            #VC: set animator in wrapper (DO NOT EDIT)
            vizconnect.getAvatar(_name).setAnimator(_rawAnimator,
                                                    make='WorldViz',
                                                    model='Inverse Kinematics')

    #VC: return values can be modified here
    return None
コード例 #21
0
def fadeAndAppear(): 
 ball = viz.add('soccerball.ive') 
 ball.setPosition(2,2,0)
 yield viztask.addAction( ball, vizact.fadeTo(0,time=2) ) 
 print 'done fading' 
 yield viztask.addAction( ball, vizact.fadeTo(1,time=2) ) 
 print 'done appearing' 
コード例 #22
0
def loadDisabledOceanScene():
 # Add environments.
 global globeScene, city, skyDome2
 globals_oa.ocean = vizfx.addChild(globals_oa.FILE_PATH_TO_WATER)
 globals_oa.ocean.setAnimationSpeed(0.5)
 globals_oa.terrainZone2 = vizfx.addChild(globals_oa.FILE_PATH_TO_ZONE2)

 globals_oa.currentZoneNumber = 1
 
 #underwater collision
 transport_vhil.initializeOceanFloorCollision()
 transport_vhil.initializeOceanSurfaceCollision()
 
 globals_oa.ocean.disable(viz.RENDERING)
 globals_oa.terrainZone2.disable(viz.RENDERING)


#load globescene assets
 globeScene = vizfx.addChild(globals_oa.FILE_PATH_TO_GLOBE)
 globeScene.setScale([0.2,0.2,0.2])
 globeScene.setPosition([0,0,1])
 globeScene.disable(viz.RENDERING)

#load city scene assets
 city = vizfx.addChild(globals_oa.FILE_PATH_TO_CITY)
 city.setPosition([-8,0,11])
 skyDome2 = viz.add('sky_day.osgb')
 city.disable(viz.RENDERING)
 skyDome2.disable(viz.RENDERING)
コード例 #23
0
ファイル: HiBallCameraMT.py プロジェクト: bmj8778/CatchB
    def __init__(self,
                 offset,
                 particle=None,
                 sensorNum=0,
                 attachTo=viz.MainView,
                 preTrans=[0, 0, 0.1778]):
        viz.EventClass.__init__(self)

        self.offset = offset
        self.particle = particle
        self.sensorNum = sensorNum
        self.attachTo = attachTo
        self.preTran = preTrans

        self.off = True

        self.vrpn = viz.add('vrpn6.dle')
        self.tracker = self.vrpn.addTracker('[email protected]', sensorNum)
        self.tracker.swapPos([1, 3, 2])
        self.tracker.swapQuat([-1, -3, -2, 4])

        self.preMat = vizmat.Transform()
        self.preMat.preEuler([-90, 0, 0])
        self.preMat.preTrans(self.preTran)

        self.postMat = vizmat.Transform()
        self.postMat.postTrans(offset)

        vizact.ontimer(0, self.updateView)
        self.pos = [0, 0, 0]
        self.rot = [0, 0, 0, 0]
        self.turnOn()
コード例 #24
0
def initInputs(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawInput = vizconnect.getRawInputDict()

	#VC: initialize a new input
	_name = 'r_hand_input'
	if vizconnect.isPendingInit('input', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: create the raw object
			rawInput[_name] = viz.mouse
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addInput(rawInput[_name], _name, make='Generic', model='Mouse Buttons')

	#VC: initialize a new input
	_name = 'keyboard'
	if vizconnect.isPendingInit('input', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			index = 0
			
			#VC: create the raw object
			d = viz.add('directinput.dle')
			device = d.getKeyboardDevices()[index]
			rawInput[_name] = d.addKeyboard(device)
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addInput(rawInput[_name], _name, make='Generic', model='Keyboard')

	#VC: return values can be modified here
	return None
コード例 #25
0
def initInputs(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawInput = vizconnect.getRawInputDict()

	#VC: initialize a new input
	_name = 'keyboard'
	if vizconnect.isPendingInit('input', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			index = 0
			
			#VC: create the raw object
			d = viz.add('directinput.dle')
			device = d.getKeyboardDevices()[index]
			rawInput[_name] = d.addKeyboard(device)
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addInput(rawInput[_name], _name, make='Generic', model='Keyboard')

	#VC: initialize a new input
	_name = 'mouse_buttons'
	if vizconnect.isPendingInit('input', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: create the raw object
			rawInput[_name] = viz.mouse
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addInput(rawInput[_name], _name, make='Generic', model='Mouse Buttons')

	#VC: return values can be modified here
	return None
コード例 #26
0
def Pau():
    #Menu principal
    global current_scene
    current_scene = 4
    bgTexture = viz.add(image['pau'])
    quad_bgtexture = viz.addTexQuad(parent=viz.SCREEN, scene=scenePau)
    quad_bgtexture.texture(bgTexture)
    quad_bgtexture.setScale(12.8, 10.24, 0)
    quad_bgtexture.setPosition(0.5, 0.5)
    viz.scene(scenePau)

    #Botones de interaccion
    btn_atras = viz.addButton(scene=scenePau)
    btn_atras.setPosition(0.60, 0.05)
    btn_atras.setScale(7, 1.6)
    btn_atras.downpicture(button['regresar'])
    btn_atras.uppicture(button['regresar'])

    #Botones de interaccion
    btn_sig = viz.addButton(scene=scenePau)
    btn_sig.setPosition(0.87, 0.05)
    btn_sig.setScale(7, 1.6)
    btn_sig.downpicture(button['portada_A'])
    btn_sig.uppicture(button['portada_A'])

    vizact.onbuttonup(btn_atras, Conant)
    vizact.onbuttonup(btn_sig, Diego)
コード例 #27
0
def Instruction(objName, ITI, phase, feedback):

    viz.MainWindow.setScene(2)
    if phase:

        if feedback > 0:
            smile = viz.add('smile' + str(feedback) + '.tif')
            feed = viz.addTexQuad(parent=viz.SCREEN, scene=2, size=[500, 400])
            feed.setPosition([0.5, 0.5, 0])  #put quad in view
            feed.texture(smile)
            yield viztask.waitTime(ITI - 1)
            feed.visible(0)

        Message = 'Collect ' + objName

    else:
        Message = 'Replace ' + objName

    #info
    info = viz.addText(Message, viz.SCREEN, scene=2)
    info.fontSize(36)
    info.color(viz.WHITE)
    info.setPosition([0.4, 0.5, 0])
    info.visible(1)

    #wait for iti
    yield viztask.waitTime(ITI + 1)
    info.visible(0)
コード例 #28
0
ファイル: LogParser.py プロジェクト: tokola/GitHub_OLiVE
def setupPathView ():
	import vizcam
#	viz.MainWindow.ortho(-25,25,-15,20,-1,1)
	viz.MainView.setEuler(0,90,0)
	flmap=viz.add('models/floor_map.IVE')
	flmap.texture(viz.addTexture('textures/map_view.png'),'',0)
	cam = vizcam.PivotNavigate(distance=50)
	cam.centerNode(flmap)
コード例 #29
0
ファイル: MYO2.py プロジェクト: rhodesvr/myo-march
def initializeObjectFiles():
    global objectFiles
    commonAddress='C:\Users\Bryton\Desktop\Terrain Vizard\TerrainStuff\\'
    for i in range(len(objectAddresses)):
        objectFiles.append([])
        for j in range(len(objectAddresses[i])):
            objectFiles[i].append(viz.add(commonAddress + objectAddresses[i][j]))
            objectFiles[i][j].visible(viz.OFF)
コード例 #30
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')
コード例 #31
0
	def __init__(self):
		# base class constructor 
		viz.EventClass.__init__(self)
		self.desk = Model('desk\\model1.dae')
		self.shelf = Model('shelf\\model.dae')
		self.desk.setOrientation(3,0,4,1,90)
		self.shelf.setOrientation(0, .5, 0, 1, 0)
		self.deskPressed = False
		self.shelfPressed = False
		# set up keyboard and timer callback methods
		self.callback(viz.KEYDOWN_EVENT,self.onKeyDown)
		self.callback(viz.MOUSEDOWN_EVENT, self.onMouseDown)
				
		#avatar's postion and rotation angle
		self.x = 0.5
		self.z = 0.5
		self.theta = 0
		
		# The 2D array below stores the representation of a maze.
		# Array entries containing a 2 represent 1 x 2 x 1 wall blocks.
		# Array entries containing a 0 represent 1 x 0.1 x 1 floor blocks.
		self.maze = []
		self.maze = [[2,2,2,2,2,2,2,2,2]] + self.maze # row 8
		self.maze = [[2,0,0,0,0,0,0,0,2]] + self.maze # row 7
		self.maze = [[2,0,0,0,0,0,0,0,2]] + self.maze # row 6
		self.maze = [[2,0,0,0,2,0,0,0,2]] + self.maze # row 5
		self.maze = [[2,0,0,0,0,0,0,0,2]] + self.maze # row 4
		self.maze = [[2,0,0,0,0,0,0,0,2]] + self.maze # row 2
		self.maze = [[0,0,0,0,0,0,0,0,2]] + self.maze # row 0
		self.maze = [[0,0,0,0,0,0,0,0,2]] + self.maze # row 1
		self.maze = [[0,0,0,2,2,2,2,2,2]] + self.maze # row 0
		
		# Add +x,+y,+z coordinate axes to scene to help with placing the blocks correctly
		self.addCoordinateAxes()
		
		# Code to create blocks forming the maze goes here
		for r in range(0,len(self.maze)):
			for c in range(0, len(self.maze[0])):
				if (self.maze[r][c] == 0):
					box = vizshape.addCube( size=1, color=viz.YELLOW )
					mat = viz.Matrix()
					mat.postScale(1,.1,1)
					mat.postTrans(c+.5,0.05,r+.5)
					box.setMatrix( mat )
				elif (self.maze[r][c] == 2):
					box = vizshape.addCube( size=1, color=viz.GREEN )
					mat = viz.Matrix()
					mat.postScale(1,2,1)
					mat.postTrans(c+.5,1,r+.5)
					box.setMatrix( mat )
					
		self.avatar = viz.add('vcc_female.cfg')
		mat = viz.Matrix()
		mat.postAxisAngle(0,1,0,self.theta)
		mat.postTrans(self.x,.1,self.z);
		self.avatar.setMatrix(mat)
		
		self.mode = "thirdperson"
コード例 #32
0
def _setupOtherTrackers(otherTrackerVIDs):
	global vrpn
	if vrpn is None: vrpn = viz.add('vrpn7.dle')

	trackers = []
	for id in otherTrackerVIDs:
		trackers.append(vrpn.addTracker(PPT_ADDRESS, id-1))

	return trackers
コード例 #33
0
ファイル: Window.py プロジェクト: tokola/GitHub_OLiVE
	def AddMap (self):
		self.flmap=viz.add('models/floor_map2.IVE')
#		self.flmap.texture(viz.addTexture('textures/map_view.png'),'',0)
		self.flmap.setPosition(0, .01, 0)
		#self.flmap.setScale(1, 1, 1.1)
		self.flmap.renderOnlyToWindows([self._window])
		self.bg = viz.addTexQuad(parent=viz.ORTHO, scene=self._window)
		self.CreateInfoPanels()
		self.CreateScorePanel()
コード例 #34
0
    def __init__(self):
        # must call constructor of EventClass first!!
        viz.EventClass.__init__(self)
        self.x = 20
        self.z = 20
        self.y = 0
        self.theta = 0
        self.angl = 0
        self.callback(viz.KEYDOWN_EVENT, self.onKeyDown)
        self.avatar = viz.add('vcc_female.cfg')
        self.avatar.disable(viz.INTERSECTION)

        print "Reading file greysriver.asc..."
        f = open('greysriver.asc', 'r')
        # first two lines are number of cols and rows
        cols = int(str.split(f.readline())[1])
        rows = int(str.split(f.readline())[1])

        # discard next 4 lines in file
        f.readline(), f.readline(), f.readline(), f.readline()

        # create 2D array of empty lists, one empty list for each row of data
        self.elevation = [[] for x in range(0, rows)]
        maxElevation = -50000
        minElevation = 50000
        # read in elevation data and keep track of max and min elevations
        for r in range(0, rows):
            for n in str.split(f.readline()):
                self.elevation[r].append(float(n))
                if (float(n) > maxElevation):
                    maxElevation = float(n)
                if (float(n) < minElevation):
                    minElevation = float(n)

        # create triangle mesh
        viz.startLayer(viz.TRIANGLES)
        for r in range(rows - 1):
            for c in range(cols - 1):
                # create first triangle
                color = self.getColor(self.elevation[r][c], maxElevation,
                                      minElevation)
                viz.vertexColor(color)
                viz.vertex(c, self.elevation[r][c], r)
                viz.vertex(c + 1, self.elevation[r + 1][c + 1], r + 1)
                viz.vertex(c, self.elevation[r + 1][c], r + 1)

                # create second triangle
                color = self.getColor(self.elevation[r][c + 1], maxElevation,
                                      minElevation)
                viz.vertexColor(color)
                viz.vertex(c, self.elevation[r][c], r)
                viz.vertex(c + 1, self.elevation[r][c + 1], r)
                viz.vertex(c + 1, self.elevation[r + 1][c + 1], r + 1)
        self.t = viz.endLayer()
        self.y = self.elevation[20][20] + 1
        self.transform()
コード例 #35
0
	def init3dMouse(self):
		connexion = viz.add('3dconnexion.dle')
		device = connexion.addDevice()
		device.setRotateScale([0,1,0])
		device.setTranslateScale([0,0,1])
		
		#link = viz.link(device, self.pointer, viz.REL_PARENT)
		#link.preEuler([0,90,0])

		myTask = viztask.schedule( getCoords(device,self.pointer))
コード例 #36
0
    def init3dMouse(self):
        connexion = viz.add('3dconnexion.dle')
        device = connexion.addDevice()
        device.setRotateScale([0, 1, 0])
        device.setTranslateScale([0, 0, 1])

        #link = viz.link(device, self.pointer, viz.REL_PARENT)
        #link.preEuler([0,90,0])

        myTask = viztask.schedule(getCoords(device, self.pointer))
コード例 #37
0
    def __init__(self,
                 name,
                 wall_length,
                 wall_height,
                 wall_depth,
                 orientation,
                 feedback_dir,
                 position,
                 visible=False):
        """

            Args:
                name:
                wall_length:
                wall_height:
                wall_depth
                position:
                orientation:
                visible:

        """

        # create collision wall object
        self.wall_object = viz.add(
            'box.wrl', scale=[wall_length, wall_height, wall_depth])
        self.wall_object.collideBox()
        self.wall_object.disable(viz.DYNAMICS)
        self.wall_object.enable(viz.COLLIDE_NOTIFY)

        self.wall_object.name = name
        self.wall_object.wall_length = wall_length
        self.wall_object.wall_height = wall_height
        self.wall_object.wall_depth = wall_depth
        self.wall_object.orientation = orientation

        # feedback direction parameter: can be + or - on an axis or 0 if no problem as is
        self.wall_object.feedback_dir = feedback_dir

        self.wall_object.position = position

        # make wall invisible
        if visible:
            self.wall_object.alpha(1)
        else:
            self.wall_object.alpha(0)

        if orientation == 'x':
            ori = [90, 0, 0]
            self.wall_object.color(
                viz.BLUE)  # change color of x walls if visible
        elif orientation == 'z':
            ori = [0, 0, 0]

        self.wall_object.setPosition(position)
        self.wall_object.setEuler(ori)
コード例 #38
0
def onKeyDown(key):
	if key == ' ':
		print 'Space Key Pressed'
		ball1 = viz.add('soccerball.ive') #Add an object.
		ball1.setPosition(1.0,-1,6.0)
		ballPhys1 = ball1.collideSphere(bounce=1.5)   # Define ball's physical properties
		ball1.applyForce([0.01,0,0],1)
		
	if key == 'c':
		print 'Calculating edges and creating physical objects'
		createPhysicalObjects()
コード例 #39
0
def initAvatars(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawAvatar = vizconnect.getRawAvatarDict()

	#VC: initialize a new avatar
	_name = 'female'
	if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: create the raw object
			avatar = viz.add('vcc_female.cfg')
			avatar._bodyPartDict = {}
			avatar._handModelDict = {}
			rawAvatar[_name] = avatar
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addAvatar(rawAvatar[_name], _name, make='Complete Characters', model='Female')
	
		#VC: init the animator
		if initFlag&vizconnect.INIT_ANIMATOR:
			# need to get the raw tracker dict for animating the avatars
			from vizconnect.util.avatar import animator
			from vizconnect.util.avatar import skeleton
			
			# get the skeleton from the avatar
			_skeleton = skeleton.CompleteCharacters(rawAvatar[_name])
			
			#VC: set which trackers animate which body part
			# format is: bone: (tracker, parent, degrees of freedom used)
			_trackerAssignmentDict = {
				vizconnect.AVATAR_HEAD:(vizconnect.getTracker('rift_orientation_tracker').getNode3d(), None, vizconnect.DOF_ORI),
			}
			
			#VC: create the raw object
			_rawAnimator = animator.InverseKinematics(rawAvatar[_name], _skeleton, _trackerAssignmentDict)
			
			#VC: set animator in wrapper (DO NOT EDIT)
			vizconnect.getAvatar(_name).setAnimator(_rawAnimator, make='WorldViz', model='Inverse Kinematics')
	
		#VC: init the mappings for the wrapper
		if initFlag&vizconnect.INIT_WRAPPER_MAPPINGS:
			#VC: on-state mappings
			if initFlag&vizconnect.INIT_MAPPINGS_ON_STATE:
				vizconnect.getAvatar(_name).setOnStateEventList([
						vizconnect.onstate(lambda rawInput: rawInput['joystick'].isButtonDown(3), vizconnect.getAvatar(_name).setVisible),# make=Generic, model=Joystick, name=joystick, signal=Button 3
				])
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getAvatar(_name).setParent(vizconnect.getTransport('walking'))

	#VC: return values can be modified here
	return None
コード例 #40
0
ファイル: roots.py プロジェクト: justlim77/TrussBridgeBuilder
	def __init__(self):
		super(self.__class__, self).__init__()
		
		self._day = viz.add('resources/sky_day.osgb',parent=self._root)
		self._day.renderToBackground(order=8)
		self._environment = vizfx.addChild('resources/environment.osgb',parent=self._root)
#		self._environment.renderToBackground()
		self._waveGroup = viz.addGroup(parent=self._root)
#		self._wave_M = viz.addChild('resources/wave.osgb',cache=viz.CACHE_CLONE,pos=([0,1.5,0]),parent=self._waveGroup)
#		self._wave_B = viz.addChild('resources/wave.osgb',cache=viz.CACHE_CLONE,pos=([0,1.5,-50]),parent=self._waveGroup)
		self._newWalkway = vizfx.addChild('resources/walkway.osgb',pos=[0,0.25,0], parent=self._root)	
コード例 #41
0
def expertise_maze():

    # setup viewpoint and positioning
    yield setup_view()

    # declare globals
    global signal
    global collide_coords
    global movement_time
    global coordinate_array
    global maze

    # clear the coordinate array
    coordinate_array = array([])

    # Setup the objection "collision"
    signal = viztask.Signal()
    collide_coords = end_coords

    # Show instructions and wait for user signal until they are removed
    instructions = viz.addText('Please navigate to the blue wall', viz.SCREEN)
    instructions.fontSize(42)
    instructions.setPosition(.5, .5)
    instructions.alignment(viz.TEXT_CENTER_CENTER)
    yield viztask.waitKeyDown('m')
    instructions.remove()

    # show user fixation cross
    yield display_fix()

    # Load the maze
    maze_name = maze_root + '.IVE'
    maze = viz.add(maze_name)
    maze.visible(viz.OFF)
    yield maze.visible(viz.ON)

    # enable all of the global events
    joy_timer.setEnabled(viz.ON)
    coor_timer.setEnabled(viz.ON)
    write_onkey.setEnabled(viz.ON)
    quit_onkey.setEnabled(viz.ON)
    pos_timer.setEnabled(viz.ON)

    # reset and start the clock
    movement_time = TickTockTimer()
    movement_time.StartTimer()

    # wait for "collision" signal
    yield signal.wait()

    #disable and quit
    disable()
    write_trial_data()
    maze.remove()
コード例 #42
0
    def __init__(self, maze_type, subject, show_avatar_hands=False):

        # call constructor of superclass
        super(VisualMazeScene, self).__init__(background_noise=True)

        if not maze_type == 'baseline':

            # create proximity manager for maze ground units and corner types
            self.poi_manager = super(VisualMazeScene,
                                     self).create_proximity_manager()
            vizact.onkeydown('p', self.poi_manager.setDebug, viz.TOGGLE)

            # init drawing tool
            self.draw_tool = pencil.Pencil()
            self.draw_sphere = VisualMazeScene.add_sphere(
                'draw_sphere', 0.1, viz.RED, [0, 0, 0], viz.OFF, False, None)

            # arrow for warning when head is leaving the maze path
            self.arrow = viz.add('resources/arrow.dae')
            self.arrow.visible(viz.OFF)
            self.arrow.setScale(2, 2, 2)
            self.arrow.color(viz.RED)

            # add draw frame 3D model
            self.drawing_frame = viz.add('resources/frame_model.osgb')
            self.drawing_frame.setScale(1.5, 1.5, 1.5)
            self.drawing_frame.visible(viz.OFF)

            # add local landmark (flash)
            self.flash_quad = screen_flash.Flasher(color=viz.WHITE)

            # reward feedback
            self.coin = viz.add('resources/model2.dae')
            self.coin.setScale(1, 1, 1)
            self.coin.visible(viz.OFF)

            # tracked 3D object for hand collision
            self.feedback_sphere_right = VisualMazeScene.add_sphere(
                'wall_touch', 0.001, viz.WHITE, [0, 0, 0], viz.ON, False, None)
            self.feedback_sphere_right.setScale([0.29 * 350, 0.29 * 350, 0.01])
            self.feedback_sphere_right.alpha(0)
コード例 #43
0
def initializeObjectFiles():
	global objectFiles
	
	for i in range(len(objectAddresses)):
		objectFiles.append([])
		for j in range(len(objectAddresses[i])):
			#account for wheelbarro.ive ending
			tempending = ojbectEnding
			if (i == 2 and j == 5):
				tempending = '.ive'
			objectFiles[i].append(viz.add(commonAddress + objectAddresses[i][j] + tempending))
			objectFiles[i][j].visible(viz.OFF)
コード例 #44
0
ファイル: Machinery.py プロジェクト: tokola/GitHub_OLiVE
	def __init__(self, factory, pos):
		self.object = factory.add('models/boiler.ive')
		self.hatch = (self.object.insertGroupBelow('HatchDoorL'), self.object.insertGroupBelow('HatchDoorR'))
		self.gauge = self.object.insertGroupBelow('velona')
		fire = viz.add('textures/fire.mov', loop=1, play=1)
		self.fire = viz.addTexQuad(texture=fire, pos=[.15,1.2,0], size=1.2, alpha=0)
		self.fire.setParent(self.object)
		self.fire.visible(0)
		self.object.setPosition(pos)
		self.getComponents()
		#this is called by the AddProximitySensors() of the main module
		self.proximityData = (vizproximity.RectangleArea([5,5]), self.object)
コード例 #45
0
ファイル: Window.py プロジェクト: tokola/GitHub_OLiVE
	def ShowTotalScore (self):
		#add third row with the total score if not added already
		try:
			self._total.alignment(viz.ALIGN_RIGHT_BASE)
		except:
			row3text = viz.addText(self.tooltips['score'])
			row3text.font("Segoe UI")
			row3icon = viz.addTexQuad(size=25, texture=viz.add('textures/total_icon.png'))
			self._total= viz.addText('000')
			self._total.font("Segoe UI")
			self._total.alignment(viz.ALIGN_RIGHT_BASE)
			self._scorePanel.addRow([row3icon, row3text, self._total])
コード例 #46
0
def initAvatars():
	avatars = []
	for d in AVATAR_DATA:
		avatar = viz.add(d.file, euler=AVATAR_EULER)
		avatar.setPosition( Seats.getseat(d.seat) )
		avatar.state(d.state)
		avatar.teleSeatIDs = d.teleSeatIDs
		avatar.story = d.story
		avatar.stateNum = d.state
		
		avatars.append(avatar)
	return avatars
コード例 #47
0
 def __init__(self, filename):
     # read model data from file and add to scene graph
     self.node = viz.add(filename)
     # model's location in world
     self.x = 0
     self.y = 0
     self.z = 0
     # model's scale
     self.s = 1
     # model's rotation about the Y axis (in degrees)
     self.yrot = 0
     self.setTransMatrix()
コード例 #48
0
ファイル: Window.py プロジェクト: tokola/GitHub_OLiVE
	def CreateScorePanel(self):
		self._newScore = None	#holds the temp score after each update
		self._scorePanel = vizdlg.GridPanel(window=self._window, skin=vizdlg.ModernSkin, 
					spacing=-10, align=vizdlg.ALIGN_RIGHT_TOP, margin=0)
		row1text = viz.addText(self.tooltips['points'])
		row1text.font("Segoe UI")
		self._scoreIcon = viz.addTexQuad(size=25, texture=viz.add('textures/star_yellow_256.png'))
		self._score= viz.addText('000')
		self._score.font("Segoe UI")
		self._score.alignment(viz.ALIGN_RIGHT_BASE)
		self._scorePanel.addRow([self._scoreIcon, row1text, self._score])
		row2text = viz.addText(self.tooltips['oil'])
		row2text.font("Segoe UI")
		self._oilIcon = viz.addTexQuad(size=25, texture=viz.add('textures/oil_icon.png'))
		self._oil= viz.addText('000')
		self._oil.font("Segoe UI")
		self._oil.alignment(viz.ALIGN_RIGHT_BASE)
		self._scorePanel.addRow([self._oilIcon, row2text, self._oil])
		self._scorePanel.setCellAlignment(vizdlg.ALIGN_RIGHT_TOP)
		#place the score board at the top right corner of the window
		viz.link(self._window.RightTop, self._scorePanel, offset=(-10,-45,0))
コード例 #49
0
def addBusLight(scene=viz.MainScene):
    busLightModel = viz.add("Bus Light.vzf", scene=scene)
    light = viz.addLight(scene=scene, group=1)
    viz.link(busLightModel, light)
    light.position(0, 0, 0, 1)
    busLightModel.emissive(viz.WHITE)
    busLightModel.setEuler([0, 90.0, 0])
    light.color(viz.WHITE)
    intensity = 3
    light.intensity(intensity)
    light.quadraticattenuation(1)
    return busLightModel
コード例 #50
0
ファイル: pptextension.py プロジェクト: vhilab/thirdArm
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('PPT0@' + 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('PPT0@' + PPT_HOSTNAME, 1)
	lhPPT = vrpn.addTracker('PPT0@' + 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;
コード例 #51
0
ファイル: Window.py プロジェクト: tokola/GitHub_OLiVE
	def AddPanel(self, langu):
		self._hud = viz.addGroup(viz.ORTHO, scene=self._window)
		panel = viz.addTexQuad(parent=viz.ORTHO, scene=self._window, size=200)
		panel.texture(viz.addTexture('textures/panel.png', useCache = True))
		panel.setParent(self._hud)
		self.tag = viz.addTexQuad(parent=viz.ORTHO, scene=self._window, size=200)
		self.tag.texture(viz.addTexture('textures/p'+str(self._player)+'_tag.png', useCache = True))
		self.tag.setParent(self._hud)
		#add the player name as a child of the panel
		self._name = viz.addText(self._name, panel)
		self._name.alignment(viz.ALIGN_CENTER_TOP)
		self._name.font("Segoe UI")
		self._name.color(viz.BLACK)
		self._name.fontSize(14)
		self._name.resolution(.5)
		self._name.setScale(1.5,.75,1)
		self._name.setPosition(3,92,0)
		self._name.setParent(self._hud)
		#add the user feedback message
		self._message = viz.addText('', viz.ORTHO, self._window)
		self._message.alignment(viz.ALIGN_LEFT_TOP)
		self._message.font("Segoe UI")
		self._message.color(viz.BLACK)
		self._message.fontSize(13)
		self._message.resolution(.5)
		self._message.setScale(1.5,.75,1)
		self._message.setPosition(-80,32,0)
		self._message.setParent(self._hud)
		#add the collab icon
		self._collabTextures = [viz.add('textures/signs'+langu+'/collab0.png'), viz.add('textures/signs'+langu+'/collab1.png')]
		self._collabIcon = viz.addTexQuad(parent=viz.ORTHO, scene=self._window, size=150)
		self._collabIcon.texture(self._collabTextures[0])
		self._collabIcon.setParent(self._hud)
		self._collabIcon.drawOrder(20)
		self._collabIcon.setPosition(0, -65, 10)
		self._collabIcon.setScale(1,.4,1)
		self._collabIcon.alpha(0)
		self.ResizePanel()
		#add the info panels
		self.CreateInfoPanels()
コード例 #52
0
ファイル: touchcube.py プロジェクト: vhilab/thirdArm
def setupTarget():
	viztask.waitTime(5)
	target = viz.add('arm/all_target.wrl')
	target.setScale(.01, .01, .01)
	target.setEuler(0, 90, 0)
	target.setPosition([-1.35, 1.5, -1.5])
	reportTargetTime()
	
	#Adds invisible cube that launches fire
	global targetcube 
	targetcube = []
	targetcube.append(TouchCube())
	targetcube[0].setPosition([-1.35, 1.5, -1.5])
コード例 #53
0
ファイル: vhil_devkit.py プロジェクト: vhilab/VRITS-2015
def _setupHeadTrackers(hmd, OH):
	global vrpn
	if vrpn is None: vrpn = viz.add('vrpn7.dle')

	POS_TRACKER = vrpn.addTracker(PPT_ADDRESS, 0)
	ORI_TRACKER = hmd.getSensor()

	if OH:
		print 'vhil_devkit: Optical heading setup not yet implemented - set OH to False.'
	else:
		tracker = viz.mergeLinkable(POS_TRACKER, ORI_TRACKER)
		oculusViewLink = viz.link(tracker, MainView)
		oculusViewLink.preTrans(OCULUSVIEWLINK_PRETRANS)
def initInputs(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawInput = vizconnect.getRawInputDict()

    #VC: initialize a new input
    _name = 'flystick'
    if vizconnect.isPendingInit('input', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            hostname = '192.168.5.160'

            #VC: create the raw object
            from vizconnect.util.input import vrpn_joystick
            sensor = vrpn_joystick.VRPNJoystick(basename='DTrack',
                                                hostname=hostname)
            rawInput[_name] = sensor

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addInput(rawInput[_name],
                                _name,
                                make='ART',
                                model='Flystick')

    #VC: initialize a new input
    _name = 'keyboard'
    if vizconnect.isPendingInit('input', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            index = 0

            #VC: create the raw object
            d = viz.add('directinput.dle')
            device = d.getKeyboardDevices()[index]
            rawInput[_name] = d.addKeyboard(device)

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

    #VC: set the name of the default
    vizconnect.setDefault('input', 'flystick')

    #VC: return values can be modified here
    return None
コード例 #55
0
ファイル: Maze.py プロジェクト: talathom/GraphicsLab7
    def __init__(self):
        # base class constructor
        viz.EventClass.__init__(self)

        # set up keyboard and timer callback methods
        self.callback(viz.KEYDOWN_EVENT, self.onKeyDown)

        # avatar's x,z location in maze and its rotation angle
        self.theta = 0
        self.x = 0.5
        self.z = 0.5
        self.fp = False

        # The 2D array below stores the representation of a maze.
        # Array entries containing a 2 represent 1 x 2 x 1 wall blocks.
        # Array entries containing a 0 represent 1 x 0.1 x 1 floor blocks.
        self.maze = []
        self.maze = [[2, 2, 2, 2, 2, 2, 2, 2, 2]] + self.maze  # row 8
        self.maze = [[2, 0, 0, 0, 0, 0, 0, 0, 2]] + self.maze  # row 7
        self.maze = [[2, 0, 0, 0, 0, 0, 0, 0, 2]] + self.maze  # row 6
        self.maze = [[2, 0, 0, 2, 2, 2, 0, 0, 2]] + self.maze  # row 5
        self.maze = [[2, 0, 0, 2, 2, 2, 0, 0, 2]] + self.maze  # row 4
        self.maze = [[2, 0, 0, 2, 2, 2, 0, 0, 2]] + self.maze  # row 2
        self.maze = [[0, 0, 0, 0, 0, 0, 0, 0, 2]] + self.maze  # row 0
        self.maze = [[0, 0, 0, 0, 0, 0, 0, 0, 2]] + self.maze  # row 1
        self.maze = [[0, 0, 0, 2, 2, 2, 2, 2, 2]] + self.maze  # row 0

        # Add +x,+y,+z coordinate axes to scene to help with placing the blocks correctly
        self.addCoordinateAxes()

        # Code to create blocks forming the maze goes here
        for x in range(0, len(self.maze)):
            for z in range(0, len(self.maze[0])):
                if self.maze[x][z] == 0:
                    block = vizshape.addCube(size=1, color=viz.YELLOW)
                    mat = viz.Matrix()
                    mat.postScale(1, 0.1, 1)
                    mat.postTrans(x + .5, .05, z + .5)
                    block.setMatrix(mat)
                elif self.maze[x][z] == 2:
                    block = vizshape.addCube(size=1, color=viz.GREEN)
                    mat = viz.Matrix()
                    mat.postScale(1, 2, 1)
                    mat.postTrans(x + .5, 1, z + .5)
                    block.setMatrix(mat)
        self.avatar = viz.add('vcc_female.cfg')
        mat = viz.Matrix()
        mat.postTrans(self.x, .1, self.z)
        self.avatar.setMatrix(mat)
        self.avatar.state(1)
コード例 #56
0
def practice_maze():

    # declare globals
    global coordinate_array
    global movement_time
    global maze

    # Display instructions until they are removed
    practice_instructions = viz.addText(
        'This practice session is designed to help you get used to\n using the joystick. Navigate through the hallways using\n the joystick until you are comfortable using to move.',
        viz.SCREEN)
    practice_instructions.fontSize(42)
    practice_instructions.setPosition(.5, .5)
    practice_instructions.alignment(viz.TEXT_CENTER_CENTER)
    yield viztask.waitKeyDown('m')
    practice_instructions.remove()

    # show user fixation cross
    yield display_fix()

    # setup viewpoint and positioning
    yield setup_view()

    # load the  maze
    maze_name = maze_root + '.IVE'
    maze = viz.add(maze_name)
    maze.visible(viz.OFF)
    yield maze.visible(viz.ON)

    # load coordinate_array in clear it so that previous trial data is gone
    coordinate_array = array([])

    # enable all of the global events
    joy_timer.setEnabled(viz.ON)
    coor_timer.setEnabled(viz.ON)
    write_onkey.setEnabled(viz.ON)
    quit_onkey.setEnabled(viz.ON)

    # reset and start the clock
    movement_time = TickTockTimer()
    movement_time.StartTimer()

    # stay in maze until experimenter presses a key...
    yield viztask.waitKeyDown('m')

    # disable events and quit maze
    disable()
    write_trial_data()
    maze.remove()
コード例 #57
0
def CreateAvatar(startLocation, avatarScale=0.35, visible=viz.OFF):
    avatar = viz.add('female.cfg')

    avatar.destination = startLocation
    avatar.interrupted = "No"
    avatar.backupMoveProbability = None
    avatar.moveProbability = None

    (position, rotation) = __state2viz(startLocation)
    avatar.visible(visible)
    avatar.translate(position)
    avatar.rotate(rotation)
    avatar.scale(avatarScale, avatarScale, avatarScale)
    avatar.idlepose(12)
    return avatar
コード例 #58
0
    def __init__(self):

        viz.EventClass.__init__(self)

        self.callback(viz.KEYDOWN_EVENT, self.onKeyDown)
        self.callback(viz.TIMER_EVENT, self.onTimer)
        #self.callback(viz.MOUSEDOWN_EVENT, self.onMouse)

        self.x = 0
        self.y = 0
        self.z = 0

        #self.rotate = 0

        self.pitch = 0
        self.roll = 0
        self.yaw = 0

        space = viz.add(viz.ENVIRONMENT_MAP, 'Skybox/stars.jpg')
        skybox = viz.add('skydome.dlc')
        skybox.texture(space)

        self.model = None
        self.xWing = viz.add('x-wing/x-wing.dae')
        self.tie = viz.add('tie/tie.dae')
        self.destroyer = viz.add('destroyer/[.dae]/republic assault ship.dae')
        print("Destroyer is at {}".format(self.destroyer.getCenter()))
        self.destroyer.setScale(15, 15, 15)
        self.destroyer.setPosition(0, -50, 600)

        self.picking = True
        self.pickShip()

        self.starttimer(1, 1 / 20, viz.FOREVER)

        self.callback(viz.MOUSEDOWN_EVENT, self.onClick)
コード例 #59
0
ファイル: vrlabConfig.py プロジェクト: performlabrit/StepOver
    def _connectWiiMote(self):

        wii = viz.add('wiimote.dle')  #Add wiimote extension

        # Replace old wiimote
        if (self.wiimote):
            print 'Wiimote removed.'
            self.wiimote.remove()

        self.wiimote = wii.addWiimote()  # Connect to first available wiimote

        vizact.onexit(
            self.wiimote.remove)  # Make sure it is disconnected on quit

        self.wiimote.led = wii.LED_1 | wii.LED_4  #Turn on leds to show connection
コード例 #60
0
def finalDemo():
    sky.remove()
    Panel.remove()
    piazza = viz.add('gallery.osgb')
    Panel2 = vizinfo.InfoPanel(
        "You may now take off the headset, Thank you for your participation",
        parent=canvas,
        align=viz.ALIGN_CENTER,
        fontSize=22,
        icon=False,
        title="Finished")
    Panel2.alpha(.8)
    navigationNode = viz.addGroup()
    viewLink = viz.link(navigationNode, viz.MainView)
    viewLink.preMultLinkable(hmd.getSensor())
    viewLink.setOffset([0, 1.8, 0])
    viz.link(viz.CenterBottom, Panel2, offset=(400, 230, 0))