def main():
    global co2models, moleculeManager, lhandSensor, rhandSensor, bigCO2, bigH2O, init_pos
    # viz.MainView.setPosition(0,.5, 3)
    loadBoatScene()
    hideScene()
    globals_oa.user.setPosition(init_pos)
    # terrain_LW = vizfx.addChild(('./art/ENV_Island_Main.osgb').getChild('Ocean001'))
    setUpMolecAnimation()
    bigCO2 = co2molecule.copy()
    bigCO2.setScale(3, 3, 3)
    bigCO2.setPosition(0, 1.5, -1.7)
    bigH2O = h2omolecule.copy()
    bigH2O.setScale(3, 3, 3)
    bigH2O.setPosition(3.75, 0.5, 0)
    co2Target = vizproximity.Target(bigCO2)
    moleculeManager.addTarget(co2Target)
    viz.MainScene.enable(viz.FOG, op=viz.OP_ROOT)
    # vizact.ontimer(0, masterTimer)
    if globals_oa.lhModel != None:
        lhandSensor = vizproximity.addBoundingSphereSensor(globals_oa.lhModel, scale=0.9)
    else:
        print "lhModel not set up"
    if globals_oa.rhModel != None:
        rhandSensor = vizproximity.addBoundingSphereSensor(globals_oa.rhModel, scale=0.9)
    else:
        print "rhModel not set up"
    # overOceanSensor = vizproximity.addBoundingBoxSensor(globals_oa.boat, scale = [.8,.8,.65])
    moleculeManager.addSensor(lhandSensor)
    moleculeManager.addSensor(rhandSensor)
    moleculeManager.onEnter(None, EnterProximity)
    revealScene()
Beispiel #2
0
 def addSensor(self):
     """Add a sensor to a proximity manager"""
     if self.metaData['volume'] < 12:
         SF = 2 * (12 - self.metaData['volume']) / 12
         self._sensor = vizproximity.addBoundingSphereSensor(self,
                                                             scale=(1 +
                                                                    1 * SF))
     else:
         self._sensor = vizproximity.addBoundingSphereSensor(self)
     model.proxManager.addSensor(self._sensor)
    def add_sphere(name, rad, col, position, vis, proximity, scale):
        """
        Adds a sphere object and returns it. Optionally adds a proximity sensor around the sphere.

        Args:
            name: name of the sphere object
            rad: radius of the sphere, e.g. 1.0
            col: color of the sphere, e.g. "viz.RED"
            position: specified position by [x, y, z]
            vis: visibility of the sphere, i.e. "viz.ON" or "viz.OFF"
            proximity: if True create a BoundingSphereSensor proximity sensor around the sphere
            scale: scale factor or size of BoundingSphereSensor

        Returns: A Vizard sphere object with the optionality of creating a proximity sensor around the sphere.

        """

        sphere = vizshape.addSphere(radius=rad, color=col)
        sphere.name = name
        sphere.setPosition(position)
        sphere.visible(vis)

        if proximity:
            sphere.sensor = vizproximity.addBoundingSphereSensor(sphere,
                                                                 scale=scale)

        return sphere
 def __init__(self, index, x, y, z):
     self.index = index
     self.center = x, y, z
     self.sphere = vizshape.addSphere(0.1)
     self.sphere.setPosition(self.center)
     self.sphere.color(viz.WHITE)
     self.sensor = vizproximity.addBoundingSphereSensor(self.sphere, scale=1)
     self.signal = viztask.Signal()
     self.sound = viz.addAudio('{:02d}.wav'.format(index))
 def __init__(self, index, x, y, z):
     self.index = index
     self.center = x, y, z
     self.sphere = vizshape.addSphere(0.1)
     self.sphere.setPosition(self.center)
     self.sphere.color(viz.WHITE)
     self.sensor = vizproximity.addBoundingSphereSensor(self.sphere,
                                                        scale=1)
     self.signal = viztask.Signal()
     self.sound = viz.addAudio('{:02d}.wav'.format(index))
Beispiel #6
0
def AddSphere(name, position):

    sphere = vizshape.addSphere(radius=0.2)
    sphere.setPosition(position)

    sensor = vizproximity.addBoundingSphereSensor(sphere,scale=5)
    sensor.name = name
    sphereSensors.append(sensor)
    manager.addSensor(sensor)

    manager.onEnter(sensor, EnterSphere, sphere)
    manager.onExit(sensor, ExitSphere, sphere)
    def setup_proximity(self):
        sensor = vizproximity.addBoundingSphereSensor(self.target, scale=0.7)

        prox = vizproximity.Manager()
        #prox.setDebug(viz.ON)

        prox.addSensor(sensor)
        prox.addTarget(self.left_finger)
        prox.addTarget(self.right_finger)

        prox.onEnter(sensor, lambda e: vrlab.sounds.drip.play())
        prox.onEnter(sensor, lambda e: self.target.color(viz.BLUE))
        if self.target_signal:
            prox.onEnter(sensor, self.target_signal.send)

        prox.onExit(sensor, lambda e: self.target.color(viz.WHITE))
def init(flagPile):
    global lhandtar, rhandtar, placeFlagSound, pickupFlagSound
    # viz.playSound(globals_oa.AUDIO_DIRECTORY + 'bell.wav', viz.SOUND_PRELOAD)
    placeFlagSound = viz.addAudio(globals_oa.AUDIO_DIRECTORY + "flag_in_ground.mp3")
    placeFlagSound.play()
    placeFlagSound.stop()
    pickupFlagSound = viz.addAudio(globals_oa.AUDIO_DIRECTORY + "flag_in_hand.mp3")
    pickupFlagSound.play()
    pickupFlagSound.stop()
    # adding a manager for touching the snails
    global snailTouchManager
    snailTouchManager = vizproximity.Manager()
    # 	snailTouchManager.setDebug(viz.ON)
    vizact.onkeydown("k", snailTouchManager.setDebug, viz.TOGGLE)

    # adding sensor for the flag pile
    flagPileSensor = vizproximity.Sensor(vizproximity.Sphere(0.3, center=(-0.8, -1, -1.8)), source=flagPile)
    flagPileManager = vizproximity.Manager()
    flagPileManager.addSensor(flagPileSensor)
    vizact.onkeydown(",", flagPileManager.setDebug, viz.TOGGLE)
    flagPileManager.onEnter(flagPileSensor, EnterProximity)

    global rhandtar, lhandtar
    if globals_oa.rhModel is not None:
        rhsphere = vizshape.addSphere(radius=0.06)
        rhsphere.setParent(globals_oa.rhModel)
        rhsphere.setPosition([0, 0, 0.55])
        rhsphere.disable(viz.RENDERING)
        rhandtar = vizproximity.Target(rhsphere)  # globals_oa.rhModel)
        snailTouchManager.addTarget(rhandtar)
        flagPileManager.addTarget(rhandtar)
    if globals_oa.lhModel is not None:
        lhsphere = vizshape.addSphere(radius=0.06)
        lhsphere.setParent(globals_oa.lhModel)
        lhsphere.setPosition([0, 0, 0.55])
        lhsphere.disable(viz.RENDERING)
        lhandtar = vizproximity.Target(lhsphere)  # globals_oa.lhModel)
        snailTouchManager.addTarget(lhandtar)
        flagPileManager.addTarget(lhandtar)

        # adding the sensors around the snails
    for snailAndFlagItem in globals_oa.snailAndFlagItemsInZone1:
        snailSensor = vizproximity.addBoundingSphereSensor(snailAndFlagItem.snailItemFromZoneModel, scale=(3.0))
        snailTouchManager.addSensor(snailSensor)

    snailTouchManager.onEnter(None, ShowFlagAtSnail)
Beispiel #9
0
 def __init__(self):
     self.zombies = {}
     self.sensors = []
     self.zombiesCount = 0
     for roomName, location, name, power, toughness, hitpoints, model in zombies:
         zombietmp = Zombie(name=name,
                            location=location,
                            power=power,
                            toughness=toughness,
                            min=0,
                            max=hitpoints,
                            model=model)
         a = zombietmp.model
         self.zombies[a] = zombietmp
         mysensor = vizproximity.addBoundingSphereSensor(zombietmp.model)
         self.sensors.append(mysensor)
         self.zombiesCount = self.zombiesCount + 1
Beispiel #10
0
def initSteering():
	global wheel
	wheel = globals_oa.boat.getChild('steeringWheel')
	
	steeringManager = vizproximity.Manager()
	steeringManager.setDebug(False)
	
	target = vizproximity.Target(globals_oa.rhModel)
	steeringManager.addTarget(target)
	
	steeringWheelSensor = vizproximity.addBoundingSphereSensor(wheel, scale = .75)
	steeringManager.addSensor(steeringWheelSensor)
	
#	rHandSensor = vizproximity.addBoundingSphereSensor(globals_oa.rhModel, scale = 2.0)
#	steeringManager.addSensor(rHandSensor)
	
	steeringManager.onEnter(None,EnterProximity)
	steeringManager.onExit(None,ExitProximity)
    def baseline(self):
        # set num_sphere positions of spheres randomly, spheres have to be touched then next sphere appears
        # baselines:
        # 1. spectrum (averaging 90% best 1s windows of the baseline period, has touches and walking but no 'task')
        # 2. ersp/connectivity: reaches without meaning but different visual feedback

        # set height of spheres to head - 20cm
        z_range = 3  # lab restrictions
        x_range = 2  # lab restrictions
        height = self.subject.head_sphere.getPosition()[1] - .2

        # number of spheres to touch
        num_sphere = 7

        self.log_exp_progress('type:baseline_start;')
        self.scene.poi_manager.addTarget(self.subject.right_hand_sphere_target)

        # spawn num_sphere balls and touch them consecutively
        for i in range(num_sphere):

            z_pos = random.randrange(0, 2 * z_range + 1) - z_range
            x_pos = random.randrange(0, 2 * x_range + 1) - x_range
            pos = [x_pos, height, z_pos]

            # make a sphere at a random position in the plusminus z and x range
            sphere = vizshape.addSphere(.1)
            sphere.color(viz.YELLOW)
            sphere.setPosition(pos)
            sphere_sensor = vizproximity.addBoundingSphereSensor(sphere)
            self.scene.poi_manager.addSensor(sphere_sensor)

            # yield wait enter hand sphere
            yield vizproximity.waitEnter(sphere_sensor)
            self.log_exp_progress('type:baseline_touch;number:' + str(i + 1) +
                                  ';')
            self.scene.poi_manager.removeSensor(sphere_sensor)
            sphere.remove()

        self.scene.poi_manager.removeTarget(
            self.subject.right_hand_sphere_target)
        self.log_exp_progress('type:baseline_end;')
Beispiel #12
0
	def addSensor(self):
		"""Add a sensor to a proximity manager"""
		self._sensor = vizproximity.addBoundingSphereSensor(self)
		proxManager.addSensor(self._sensor)
def initialize(zonePointer, fileWithListOfObjects):

	global species, nodesToHuntForEachSpecies, nodeNamesToHuntForEachSpecies, numObjectsToFind, displayObjects, dictionaryMappingHuntItemsToNamesFromZoneModel, flagPileSensor

	vizact.onkeydown('-', endHunt)
	
	if globals_oa.scavengerHuntInProgress:
		print "Please finish the previous species search first!"
		return

	#format of the input files:
	# each line has one species, and the nodes of that species from the zone model, which are to be hunted
	# the first name in each line is the name of the species and the following names are the names of the nodes
	# there should be no spaces before or after the commas separating the names
#	speciesWithNodeNamesToHunt = createListFromInputFile(fileWithListOfObjects, False)
	createListFromInputFile(fileWithListOfObjects)
	
#	for s in speciesWithNodeNamesToHunt:
#		species.append(s[0])
#		numObjectsToFind.append(0)
#		nodesToHuntForEachSpecies[s[0]] = []
#		speciesRegex[s[0]] = re.compile(s[1] + '[ ]*\d*$') #Assuming node names are of the form 'species + maybe a space + number'
	hud = None
	if globals_oa.hmdUsed == globals_oa.HMD_TYPE['RIFT']: hud = globals_oa.rift.getHUD()
	displayPos = [0, 0.05, 1]

	print "TO FIND:"
#	for zone in [zonePointer]:#, terrainZone2, terrainZone3]:
	
	for name in zonePointer.getNodeNames():
#			nameBlocks = name.split(' ')
#			if 'Ocinebrina' in nameBlocks:
#				print name
		item = None
		speciesIndexCounter = 0
		for s in species:
#				if speciesRegex[s].match(name):#s in name:
			if name in nodeNamesToHuntForEachSpecies[s]:
				item = zonePointer.getChild(name)
				if item:
					nodesToHuntForEachSpecies[s].append(item)
					dictionaryMappingHuntItemsToNamesFromZoneModel[item] = []
					dictionaryMappingHuntItemsToNamesFromZoneModel[item].append(name)
					numObjectsToFind[speciesIndexCounter] += 1
					if 'octopus' in name.lower():
						Octopus.append(item)
					if 'eel' in name.lower():
						Eel.append(item)
					if 'grass' in name.lower():
						Grass.append(item)
				else:
					print name + ' cannot be located'
				break
			else:
				speciesIndexCounter += 1

#	if globals_oa.currentZoneNumber == 3:
#		addHiddenSnailInZone3()
	
	#adding the display objects for each species for the current zone
#	for s in species:
#		displaySpeciesLoc = globals_oa.DISPLAY_OBJECT_DIRECTORY + str(globals_oa.currentZoneNumber) + '/' + str(s).lower()+ '.osgb'
#		print "loading display object from " + displaySpeciesLoc
#		if hud is not None:
#			displaySpeciesNode = vizfx.addChild(displaySpeciesLoc, pos=displayPos, parent=hud)
#	#		displayEdwardsii = vizfx.addChild(FAUNA_DIRECTORY + globals_oa.SNAIL, pos=displayPos, parent=hud)
#			displaySpeciesNode.visible(False)
#			displayObjects.append(displaySpeciesNode)

	print "SPECIES:"
	print str(len(species))
#	print species
	print nodesToHuntForEachSpecies
	print numObjectsToFind
	
	#set up display objects (all invisible)
#	hud = transport_vhil.rift.getHUD()
#	displayEdwardsii = vizfx.addChild(FAUNA_DIRECTORY + globals_oa.SNAIL, pos=displayPos, parent=hud)
#	displayEdwardsii.visible(False)
#	displayObjects.append(displayEdwardsii)
#	displayOctopus = vizfx.addChild(FAUNA_DIRECTORY + 'octopus_vulgaris/octopus vulgaris.osgb', pos=displayPos, parent=hud)
#	displayOctopus.visible(False)
#	displayObjects.append(displayOctopus)
	
#	global slate
	if globals_oa.slate is not None:
#		slate = vizfx.addChild(EQUIPMENT_DIRECTORY + 'Slate_New.osgb')
#		slateLink = viz.link(viz.MainView, globals_oa.slate, offset = (0, -0.75, 0.0))
#		slateLink.setEuler([None,0,0], 1)
#		slateLink.preTrans(globals_oa.INITIAL_POSITIONAL_OFFSET_FOR_SLATE, 0)
#		slateLink.preEuler(globals_oa.INITIAL_ROTATIONAL_OFFSET_FOR_SLATE)
#		slateLink.clampPosY([-1.25, -0.75])
#	else:
		globals_oa.slate.visible(True)
#	if globals_oa.lhModel is not None: globals_oa.slate.setParent(globals_oa.lhModel)
#	globals_oa.slate.setPosition([0.01, 0, -0.5])
#	globals_oa.slate.setEuler([-90,0,0])
#	globals_oa.slate.setScale([0.8,0.8,0.8])
		
		
#	global basket
#	basket = vizfx.addChild(EQUIPMENT_DIRECTORY + 'diveBasket.osgb')
#	basket.setScale([0.75, 0.85, 0.75])
	globals_oa.basket.visible(True)
	if globals_oa.currentZoneNumber == 1:
		#globals_oa.basket.setPosition([0,-1.74,0]) old basket position
		#globals_oa.basket.setPosition([2,-.2,0])
#		globals_oa.basket.setPosition([2,-1.3,2])
		globals_oa.basket.setPosition(globals_oa.basketPosInCGscene1)
	elif globals_oa.currentZoneNumber == 3:
		globals_oa.basket.setPosition([58.8, -1.78, 0.281726598739624])#947296142578125
#		basketLink = viz.link(viz.MainView, basket, offset = (0, -0.75, 0.0))
#		basketLink.setEuler([None,0,0], 1)
#		basketLink.preTrans([.5, 0, 0.70], 0)
#		basketLink.preEuler([50,0,0])
#		basketLink.clampPosY([-1.25, -0.75])

	
	global basketManager
	basketManager = vizproximity.Manager()
	basketSensor = vizproximity.addBoundingBoxSensor(globals_oa.basket, scale = (1.5, 2, 1.5))
	basketManager.addSensor(basketSensor)
#	basketManager.onEnter(None, selectObject)
	
#	vizact.onkeydown('f',basketManager.setDebug,viz.TOGGLE)
	
	
#	global slateFadingManager
#	slateFadingManager = vizproximity.Manager()
#
#
##	slateFadingManager.addSensor(globals_oa.oceanFloorCollisionSensor)
##	slateFadingManager.addSensor(globals_oa.rockChunkCollisionSensor1)
##	slateFadingManager.addSensor(globals_oa.rockChunkCollisionSensor2)
##	slateFadingManager.addSensor(globals_oa.rockChunkCollisionSensor3)
#	
#	target = vizproximity.Target(globals_oa.slate)
#	slateFadingManager.addTarget(target)
#	
#	slateFadingManager.onEnter(None,EnterProximity)
#	slateFadingManager.onExit(None,ExitProximity)
#	
#	vizact.onkeydown('0',slateFadingManager.setDebug,viz.TOGGLE)

	textScale = 0.05
	
	slateEuler = [0,0,0]
	averageInitPos = [0.0, 1.5, -0.15]
	# Create time limit text
	global time_text
#	if time_text is None:
		
#		time_text_link.setEuler([None,90,0], 2)
#		time_text_link.preTrans([0.0, 0.01, 0.1], 1)
#	else:
	if time_text is not None:
		time_text.visible(True)
#	time_text = viz.addText3D('', pos = [0, 0, 0])
	time_text.alignment(viz.ALIGN_CENTER_TOP)
	time_text.setParent(globals_oa.slate)
#	time_text.setPosition([0,0.01,0.25])
	time_text.setPosition(averageInitPos[0], averageInitPos[1] + 0.5, averageInitPos[2])
	time_text.setEuler(slateEuler)
#		time_text_link = viz.link(globals_oa.slate, time_text)#, offset = (0, 0.01,0.05))
	time_text.setScale(textScale, textScale, textScale)
		
	# Create score text
#	global score_text
#	if score_text is None:
#		#score_text = viz.addText3D('',pos = [-0.4, 0.3, 1], parent=hud)
#		score_text = viz.addText('',pos = [0, 0.01, -0.05])
#		score_text.setScale(textScale, textScale, textScale)
#		score_text.alignment(viz.ALIGN_CENTER_TOP)
#		score_text.setParent(globals_oa.slate)
#		score_text.setPosition([0,0.01,-0.05])
#		score_text.setEuler([180,-90,0])
##		score_text_link = viz.link(globals_oa.slate, score_text)
##		#score_text_link.setMask(viz.LINK_POS)
##		#score_text.setEuler([0, 90, 0], mode = viz.REL_LOCAL)
##		score_text_link.setEuler([None,90,0], 2)
###		score_text_link.preTrans([0.0, 0.01, -0.05], 1)
##		score_text_link.preTrans([0.05, 0.01, 0.0], 1)
##	
#		score_text.color(viz.BLACK)
#		#score_text.alignment(viz.ALIGN_LEFT_TOP)
#		#score_text.setBackdrop(viz.BACKDROP_OUTLINE)
#		#viz.link(viz.MainWindow.LeftTop,score_text,offset=[20,-20,0])
#	else:
#		score_text.visible(True)
#	
	global pics
#	pics = []
#	pics.append( viz.addTexture('resources/Ocinebrina Edwardsii_Zone' + str(globals_oa.currentZoneNumber) + '.png') )
#	pics.append( viz.addTexture('resources/Octopus_2D.png') )
#	pics.append( viz.addTexture('resources/Eel_2D.png') )
#	pics.append( viz.addTexture('resources/seagrass.jpg') ) # Get picture of seagrass
	
	global count_text1
	global count_text2
	global count_text3
	global quad1
	global quad2
	global quad3
	
	if quad1 is not None:
		quad1.visible(True)
		quad2.visible(True)
		quad3.visible(True)
		count_text1.visible(True)
		count_text2.visible(True)
		count_text3.visible(True)
	
#	if quad1 is None: #need to be initialized
#		quad1 = viz.addTexQuad(size = 0.15)
#		quad2 = viz.addTexQuad(size = 0.15)
#		quad3 = viz.addTexQuad(size = 0.15)
#		count_text1 = viz.addText('count: 0')
#		count_text2 = viz.addText('count: 0')
#		count_text3 = viz.addText('count: 0')
		
	#the following should be read from a file carrying textures names for species to be hunted, specific to each zone
	horizontalShift = 0.1
	if globals_oa.currentZoneNumber == 1:
		quad1.setTexQuadDisplayMode(viz.TEXQUAD_FIT)
		quad1.setParent(globals_oa.slate)
#		quad1.setPosition([-.1,0.01,0.1])
		quad1.setPosition(averageInitPos[0] - horizontalShift, averageInitPos[1] + 0.25, averageInitPos[2])
		quad1.setEuler(slateEuler)
		#quad1.setScale([0.75,0.75,0.75])
		quad1.texture(pics[0])
		pics[0].hint(viz.PRELOAD_HINT)
		
		count_text1.setScale(textScale, textScale, textScale)
		count_text1.alignment(viz.ALIGN_CENTER_TOP)
		count_text1.setParent(globals_oa.slate)
		count_text1.setPosition(averageInitPos[0] + horizontalShift, averageInitPos[1] + 0.25, averageInitPos[2])#[0.1,0.01,0.15])
		count_text1.setEuler(slateEuler)
		count_text1.color(viz.BLACK)
		
		
#		quad2.setTexQuadDisplayMode(viz.TEXQUAD_FIT)
#		quad2.setParent(globals_oa.slate)
##		quad2.setPosition([-.1,0.01,-0.1])
#		quad2.setPosition(averageInitPos[0] - horizontalShift, averageInitPos[1] + 0.2, averageInitPos[2])
#		quad2.setEuler(slateEuler)
#		#quad2.setScale([0.75,0.75,0.75])
#		quad2.texture(pics[1])
#		pics[1].hint(viz.PRELOAD_HINT)
#		
#		count_text2.setScale(textScale, textScale, textScale)
#		count_text2.alignment(viz.ALIGN_CENTER_TOP)
#		count_text2.setParent(globals_oa.slate)
##		count_text2.setPosition([0.1,0.01,-0.05])
#		count_text2.setPosition(averageInitPos[0] + horizontalShift, averageInitPos[1] + 0.2, averageInitPos[2])
#		count_text2.setEuler(slateEuler)
#		count_text2.color(viz.BLACK)
		
		quad2.visible(False)
		count_text2.visible(False)
		
#		quad3.setTexQuadDisplayMode(viz.TEXQUAD_FIT)
#		quad3.setParent(globals_oa.slate)
##		quad3.setPosition([-0.1,0.01,-0.3])
#		quad3.setPosition(averageInitPos[0] - horizontalShift, averageInitPos[1] + 0.05, averageInitPos[2])
#		quad3.setEuler(slateEuler)
#		#quad3.setScale([0.75,0.75,0.75])
#		quad3.texture(pics[2])
#		pics[2].hint(viz.PRELOAD_HINT)
#		
#		count_text3.setScale(textScale, textScale, textScale)
#		count_text3.alignment(viz.ALIGN_CENTER_TOP)
#		count_text3.setParent(globals_oa.slate)
##		count_text3.setPosition([0.1,0.01,-0.25])
#		count_text3.setPosition(averageInitPos[0] + horizontalShift, averageInitPos[1] + 0.05, averageInitPos[2])
#		count_text3.setEuler(slateEuler)
#		count_text3.color(viz.BLACK)
		
		quad3.visible(False)
		count_text3.visible(False)
		
	elif globals_oa.currentZoneNumber == 3:
		quad1.setTexQuadDisplayMode(viz.TEXQUAD_FIT)
		quad1.setParent(globals_oa.slate)
#		quad1.setPosition([-0.1,0.01,0.1])
		quad1.setPosition(averageInitPos[0] - horizontalShift, averageInitPos[1] + 0.3, averageInitPos[2])
		quad1.setEuler(slateEuler)
		quad1.texture(pics[0])
		pics[0].hint(viz.PRELOAD_HINT)
		
		count_text1.setScale(textScale, textScale, textScale)
		count_text1.alignment(viz.ALIGN_CENTER_TOP)
		count_text1.setParent(globals_oa.slate)
#		count_text1.setPosition([0.1,0.01,0.15])
		count_text1.setPosition(averageInitPos[0] + horizontalShift, averageInitPos[1] + 0.3, averageInitPos[2])
		count_text1.setEuler(slateEuler)
		count_text1.color(viz.BLACK)
		count_text1.message('found: 0')
		
		quad2.setTexQuadDisplayMode(viz.TEXQUAD_FIT)
		quad2.setParent(globals_oa.slate)
#		quad2.setPosition([-0.1,0.01,-0.1])
		quad2.setPosition(averageInitPos[0] - horizontalShift, averageInitPos[1] + 0.1, averageInitPos[2])
		quad2.setEuler(slateEuler)
		quad2.texture(pics[3])
		pics[3].hint(viz.PRELOAD_HINT)
		
		count_text2.setScale(textScale, textScale, textScale)
		count_text2.alignment(viz.ALIGN_CENTER_TOP)
		count_text2.setParent(globals_oa.slate)
#		count_text2.setPosition([0.1,0.01,-0.05])
		count_text2.setPosition(averageInitPos[0] + horizontalShift, averageInitPos[1] + 0.1, averageInitPos[2])
		count_text2.setEuler(slateEuler)
		count_text2.color(viz.BLACK)
		count_text2.message('found: 0')
		
		quad3.visible(False)
		count_text3.visible(False)


	# Create surface to wrap the texture on 
#	global quad
#	if quad is None:
#		quad = viz.addTexQuad(size = 0.25) 
#		quad.setTexQuadDisplayMode(viz.TEXQUAD_FIT)
#		quad.setParent(globals_oa.slate)
#		quad.setPosition([0,0.01,0])
#		quad.setEuler([180,-90,0])
#		quad.setScale([0.5,0.5,0.5])
#		# Wrap texture on quad 
#		display_image_link = viz.link(globals_oa.slate, quad)# offset = (0.0, 0.01, 0.25))
#		#display_image_link = viz.addTexQuad(texture=viz.add('resources/Ocinebrina Edwardsii.tif'), size=0.1)
#		#display_image_link.setMask(viz.LINK_POS)
#		display_image_link.setEuler([None,90,0], 1)
#		display_image_link.preTrans([0.0, 0.01, 0.25], 0)
#		#quad.setEuler([0, 90, 0], mode = viz.REL_LOCAL)
#		quad.disable(viz.INTERSECTION)
#		quad.disable(viz.LIGHTING)
#		quad.disable(viz.FOG)
	else:
		quad.visible(True)

	
	
	textPos = [0, -0.05, 1]
	speciesTextScale = 0.05
	global speciesText
	if speciesText is None:
		if hud is not None:
			speciesText = viz.addText("", pos=textPos, parent=hud)
			speciesText.alignment(viz.ALIGN_CENTER_TOP)
			speciesText.setScale(speciesTextScale, speciesTextScale, speciesTextScale)
			speciesText.color(viz.BLACK)
			speciesText.visible(False)

	#viz.callback(viz.TIMER_EVENT,onTimer) 

	if (((globals_oa.currentZoneNumber == 0) and globals_oa.scavengerHuntCompleteInTestZone) or ((globals_oa.currentZoneNumber == 1) and globals_oa.scavengerHuntCompleteInZone1) or 
	((globals_oa.currentZoneNumber == 2) and globals_oa.scavengerHuntCompleteInZone2) or ((globals_oa.currentZoneNumber == 3) and globals_oa.scavengerHuntCompleteInZone3)):
		print "This scavenger hunt is already completed! Please try the hunt in a different zone."
		return

	print 'Scavenger Hunt started'
	global scavengerHuntStartSound
	if scavengerHuntStartSound is None:
		scavengerHuntStartSound = loadAudioFile(AUDIO_DIRECTORY + 'bell.wav')
	
	#adding a manager for touching the snails
	global snailTouchManager
	snailTouchManager = vizproximity.Manager()
#	snailTouchManager.setDebug(viz.ON)
	vizact.onkeydown('k',snailTouchManager.setDebug,viz.TOGGLE)
	
	#adding sensor for the flag pile
	global flagPileManager
	flagPileSensor = vizproximity.Sensor(vizproximity.Sphere(.3,center=[1.3, -1.23484, 0.8]), source=flagPile)
	flagPileManager = vizproximity.Manager()
	flagPileManager.addSensor(flagPileSensor)
	vizact.onkeydown(';', flagPileManager.setDebug, viz.TOGGLE)

	
	#scavengerHuntStartSound.play()
	#vizact.onsensordown(globals_oa.wiimote, globals_oa.wii.BUTTON_B,selectObject)
	if (globals_oa.hmdUsed == globals_oa.HMD_TYPE['VIVE']) and (globals_oa.rhViveTracker is not None):
		print "USING VIVE"
		#vizact.onsensordown(globals_oa.rhViveTracker, steamvr.BUTTON_TRIGGER,selectObject)
#		if globals_oa.rhViveTracker:
#			handModel1 = globals_oa.rhViveTracker.addModel()
#			link1 = viz.link(globals_oa.rightHandLink, handModel1)
#		if globals_oa.lhViveTracker:
#			handModel2 = globals_oa.lhViveTracker.addModel()
#			link2 = viz.link(globals_oa.leftHandLink, handModel2)
			
#		from tools import grabber
#		from tools import highlighter
#		global rhtool, lhtool
#		
#		if rhtool is None:
#			rhtool = grabber.Grabber(usingPhysics=False, usingSprings=False, highlightMode=highlighter.MODE_BOX)
#		if lhtool is None:
#			lhtool = grabber.Grabber(usingPhysics=False, usingSprings=False, highlightMode=highlighter.MODE_BOX)
		
#		rhtool.setUpdateFunction(rUpdateGrabber)
#		if globals_oa.rhModel is not None:rhtool.setParent(globals_oa.rhModel)
#		
#		lhtool.setUpdateFunction(lUpdateGrabber)
#		if globals_oa.lhModel is not None: lhtool.setParent(globals_oa.lhModel) 
		#sphere = vizshape.addSphere(radius = 0.3)
		
		#sphere.setParent(globals_oa.rhModel)
		
		global rhandtar, lhandtar
		if globals_oa.rhModel is not None:
			rhsphere = vizshape.addSphere(radius = 0.05) 
			rhsphere.setParent(globals_oa.rhModel)
			rhsphere.setPosition([0,0,.55])
			rhsphere.disable(viz.RENDERING)
			rhandtar = vizproximity.Target(rhsphere)#globals_oa.rhModel)
			snailTouchManager.addTarget(rhandtar)
			flagPileManager.addTarget(rhandtar)
		if globals_oa.lhModel is not None:
			lhsphere = vizshape.addSphere(radius = 0.05) 
			lhsphere.setParent(globals_oa.lhModel)
			lhsphere.setPosition([0,0,.55])
			lhsphere.disable(viz.RENDERING)
			lhandtar = vizproximity.Target(lhsphere)#globals_oa.lhModel)
			snailTouchManager.addTarget(lhandtar)
			flagPileManager.addTarget(lhandtar)
#		basketManager.addTarget(rhandtar)
#		basketManager.addTarget(lhandtar)

	#adding the sensors around the snails
	for snailAndFlagItem in globals_oa.snailAndFlagItemsInZone1:
		snailSensor = vizproximity.addBoundingSphereSensor(snailAndFlagItem.snailItemFromZoneModel, scale = (1.0))
		snailTouchManager.addSensor(snailSensor)
	
	def EnterProximity(e):
		global snapFlagLeftHand, snapFlagRightHand
		if e.target == lhandtar:
			snapFlagLeftHand()
		elif e.target ==rhandtar:
			snapFlagRightHand()
	flagPileManager.onEnter(flagPileSensor, EnterProximity)

		#viz.link(globals_oa.rhModel, tool)
#		viz.callback(grabber.GRAB_EVENT,grabObject)
#		viz.callback(grabber.RELEASE_EVENT, releaseObject)
	
	snailTouchManager.onEnter(None, ShowFlagAtSnail)
	
	if globals_oa.currentZoneNumber == 1: globals_oa.MOVEMENT_DATA_RECORDING_TAG = globals_oa.TAG_SCAVENGER_HUNT_START_ZONE_1
	else: globals_oa.MOVEMENT_DATA_RECORDING_TAG = globals_oa.TAG_SCAVENGER_HUNT_START_ZONE_3
	
	global speciesIndex, numFound
	speciesIndex = 0
	numFound = 0
	viztask.schedule( findObject() )
Beispiel #14
0
manager.addTarget(target)

#create scene and set up collisions
gallery = viz.addChild('gallery.OSGB')

#add wooden platform
platform = viz.addChild('platform_wood.OSGB')
platform.setScale(.05,.05,.05)
platform.setEuler(-41,0,0)
platform.setPosition(-.5,0,5.8)

#add orb for video
ball = viz.addChild('white_ball.wrl')
ball.setPosition(0,1,5)
ball.setScale(3,3,3)
sensor = vizproximity.addBoundingSphereSensor(ball,scale=2)
manager.addSensor(sensor)

#add spherical video player
sphere = spherical_player.Player(videoFile='Take8_OvalRunning.mp4', audioFile=None, PPT1=False, radius=250, loop=True)
sphere.video.volume(0)
sphere.setScreenPosition([0,10,5])
sphere.play()

#add MLK, set up initial animation
MLK = viz.addAvatar('Avatars/MLK/CC2_m005_hipoly_A2_v2.cfg')
head = viz.addFace( 'MLK_head.vzf' )
MLK.setFace(head)
vizact.onupdate(viz.PRIORITY_LINKS+1,head.setPosition,0,-.02,0.03,viz.REL_LOCAL)
MLK.setPosition(0,.8,7.3)
MLK.setEuler(180,0,0)
Beispiel #15
0
    def __init__(self, maze_type, poi_prox_manager):

        if maze_type == 'I' or maze_type == 'training':

            # adapt to lab specifics at BeMoBIL
            x_offset = 1
            z_offset = 5
            y_offset = .5

            self.walls = viz.add('resources/mazes/I.osgb')
            pos = self.walls.getPosition()
            self.walls.setPosition(
                [pos[0] - x_offset, pos[1] + y_offset, pos[2] - z_offset])
            self.start_pos = [1.5 - x_offset, 0, .5 - z_offset]
            self.end_pos = [1.5 - x_offset, 0, 9.5 - z_offset]

        elif maze_type == 'L':

            # adapt to lab specifics at BeMoBIL
            x_offset = 3
            z_offset = 3
            y_offset = .5

            self.walls = viz.add('resources/mazes/L.osgb')
            pos = self.walls.getPosition()
            self.walls.setPosition(
                [pos[0] - x_offset, pos[1] + y_offset, pos[2] - z_offset])
            self.start_pos = [1.5 - x_offset, 0, .5 - z_offset]
            self.end_pos = [6.5 - x_offset, 0, 4.5 - z_offset]

        elif maze_type == 'Z':

            # adapt to lab specifics at BeMoBIL
            x_offset = 3.5
            z_offset = 3
            y_offset = .5

            self.walls = viz.add('resources/mazes/Z.osgb')
            pos = self.walls.getPosition()
            self.walls.setPosition(
                [pos[0] - x_offset, pos[1] + y_offset, pos[2] - z_offset])
            self.start_pos = [4.5 - x_offset, 0, .5 - z_offset]
            self.end_pos = [1.5 - x_offset, 0, 6.5 - z_offset]

        elif maze_type == 'U':

            # adapt to lab specifics at BeMoBIL
            x_offset = 3
            z_offset = 3
            y_offset = .5

            self.walls = viz.add('resources/mazes/U.osgb')
            pos = self.walls.getPosition()
            self.walls.setPosition(
                [pos[0] - x_offset, pos[1] + y_offset, pos[2] - z_offset])
            self.start_pos = [1.5 - x_offset, 0, .5 - z_offset]
            self.end_pos = [4.5 - x_offset, 0, .5 - z_offset]

        elif maze_type == 'S':

            # adapt to lab specifics at BeMoBIL
            x_offset = 2
            z_offset = 3
            y_offset = .5

            self.walls = viz.add('resources/mazes/Z4.osgb')
            pos = self.walls.getPosition()
            self.walls.setPosition(
                [pos[0] - x_offset, pos[1] + y_offset, pos[2] - z_offset])
            self.start_pos = [3.5 - x_offset, 0, .5 - z_offset]
            self.end_pos = [3.5 - x_offset, 0, 5.5 - z_offset]

        # add sensor for start position
        self.maze_start_position = MazeUnit('start_pos',
                                            edge_length=1,
                                            position=self.start_pos,
                                            proximity_manager=poi_prox_manager)
        self.maze_end_position = MazeUnit('end_pos',
                                          edge_length=1,
                                          position=self.end_pos,
                                          proximity_manager=poi_prox_manager)

        self.maze_start_sphere = vizshape.addSphere(.05)
        self.maze_start_sphere.setPosition(
            [self.start_pos[0], 1.5, self.start_pos[2]])
        self.maze_start_sphere.color(viz.YELLOW)
        self.maze_start_sphere.visible(viz.OFF)
        self.maze_start_sphere_sensor = vizproximity.addBoundingSphereSensor(
            self.maze_start_sphere)

        self.maze_start_ground = vizshape.addPlane([1, 1])
        self.maze_start_ground.setPosition(self.start_pos)
        self.maze_start_ground.visible(viz.OFF)

        # start arrow on the ground pointing in direction of start
        self.start_arrow = viz.add('resources/arrow.dae')
        self.start_arrow.visible(viz.OFF)
        self.start_arrow.setScale(2, 2, 2)
        self.start_arrow.color(viz.RED)
        self.start_arrow.setPosition(
            [self.start_pos[0] + .12, 0, self.start_pos[2] + .25])
        self.start_arrow.setEuler([180, 0, 0])

        self.maze_end_ground = vizshape.addPlane([1, 1])
        self.maze_end_ground.setPosition(self.end_pos)
        self.maze_end_ground.visible(viz.OFF)

        # add landmark
        #[BPA 2019-04-29] using the new landmark class now:
        ##### configuration:
        self.landmarkOffsetPosition = 10  #units straight ahead from start position
        self.landmarkResource = 'resources/lighthouse.dae'
        self.landmarkScale = [.03, .03, .03]
        #self.landmarkPosition = [self.start_pos[0], 0, self.start_pos[2]+self.landmarkOffsetPosition]
        self.landmarkPosition = [
            0.5, 0, self.start_pos[2] + self.landmarkOffsetPosition
        ]
        self.global_landmark = viz.add(self.landmarkResource)

        self.global_landmark.visible(viz.OFF)
        self.global_landmark.setScale(self.landmarkScale[0],
                                      self.landmarkScale[1],
                                      self.landmarkScale[2])
        self.global_landmark.setPosition(self.landmarkPosition)
target = vizproximity.Target(item)#PARA CONTROL EN LA COMPU
#target = vizproximity.Target(rightHand) #DESCOMENTAR ESTO PARA LA SALA DE RV
manager.addTarget(target)


#-------------------------------ABRIR Y CERRAR PUERTAS-------------------------------------------------------

#ABRIR Y CERRAR PUERTA SALA DE CONTROL

DoorSC_GEODE = lab.getChild('Door sala control').getChild ('Box010')
Chapa = lab.getChild ('Chapa')
Cilindro = lab.getChild('Cylinder001')
link_DoorSC = viz.link(DoorSC_GEODE, Chapa)
link2_DoorSC = viz.link(DoorSC_GEODE, Cilindro)

sensor_DoorSC = vizproximity.addBoundingSphereSensor(DoorSC_GEODE, scale = .8)
manager.addSensor(sensor_DoorSC)

#def doorSC(e): #SALA RV
def doorSC():
	print 'estoy en doorSC'
	global state_doorSC
	
#	if e.gesture == rightHand.getSensor().returnOpen[0]:
#		print 'nada'
#	else:
	if state_doorSC == 1: #CERRAR
		eule2 = [-90,0,0]
		DoorSC_GEODE.setEuler(eule2, viz.REL_LOCAL)
		state_doorSC = 0
	else: #ABRIR