def __setupWorld__(self):
		
		#Initialize cave and load the powerwall#
		self.cave = vizcave.Cave()		
		#This line of code opens the file if a filename is provided and loads the corner co-ordinates from it, else uses the default co-ordinates#
		self.cave.load(self.caveWallFileName) if None is not self.caveWallFileName else self.cave.addWall(self.powerwall)
		
		# TODO: Pair every obstacle with an invisible "hat" object to detect when the obstacle was avoided.
		# Create a seperate module that does this automatically for each object added.
		# Like from a config file.
		self.crate = viz.addChild( 'crate.osgb' )
		self.crate.setScale([.2,.2,.2])
		self.crate.setPosition([-.45, 0, -.10])
		
		self.cratePole = vizshape.addCylinder(height = .5, radius = 0.025)
		self.cratePole.setPosition( [-.45, .3, -.10] )
		self.cratePole.alpha(0.5)

		self.avatar = viz.addAvatar('duck.cfg')
		self.avatar.setScale(.2, .2, .2)
		self.avatar.setPosition([-1, .1, -.10])		
		
		#self.floor = viz.addChild('lab.osgb')
		self.floor = viz.addChild('piazza.osgb')
seesaw.setScale([10,0.3,1])
seesaw.collideBox() #Make object collide as if a bounding box surrounded the object

#Create balance point of seesaw
fulcrum = viz.addChild('tut_cone.wrl')
fulcrum.setScale([0.5,0.5,0.5])
fulcrum.setPosition([0,.01,1])
fulcrum.collideMesh() #Make object collide if its actual geometry intersects another object
fulcrum.disable(viz.DYNAMICS) #Disables dynamic physics forces from acting on the object

#Create weight on right side of seesaw
load = viz.addChild('duck.wrl')
load.collideBox()

#Create weight on left side of seesaw
counterWeight = viz.addAvatar('duck.cfg')
counterWeight.collideBox(density=5) #The high density parameter makes the object heavier

#Move the viewpoint so that it can see the show
viz.MainView.setPosition([0,2,-15])

#Puts the moving objects in their original state
def reset():    
    seesaw.reset() #Zeros out all forces
    seesaw.setPosition([0,3,5])
    seesaw.setEuler([0,0,0]) #Puts object upright

    load.reset()
    load.setPosition([4,5,5])
    load.setEuler([0,0,0])
Example #3
0
import viz
import vizact

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

female = viz.addAvatar('vcc_female.cfg')
female.setPosition([0,0,3])
female.setEuler([180,0,0])
female.state(12)

#Get a handle to the Neck bone 
neck = female.getBone('Bip01 Neck')
neck.lock() #Disable automatic animation so that we can manually animate it

#Lock the head bone so that manual movement of the neck bone also moves the child head bone
female.getBone('Bip01 Head').lock() 

#Used to rotate the torso when the viewpoint moves to the side of the avatar
torso = female.getBone('Bip01 Spine1')
torso.lock()

def faceView():
    #Make head look at viewpoint
    viewPOS = viz.MainView.getPosition()
    neck.lookAt( viewPOS, mode=viz.AVATAR_WORLD ) #points the head and neck at the viewpoint

    #Get neck orientation to see if we need to translate torso
    neckOrientation = neck.getEuler( viz.AVATAR_LOCAL )
import vizinput

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

#Prompt for the participant's identification number.
subject = vizinput.input('What is the participant number?')

viz.move([0,0,2])

#Add the environment
piazza = viz.addChild('piazza.osgb')

#Add the pigeon.
pigeon = viz.addAvatar('pigeon.cfg',pos=[-0.9, 2.88, 11.3],euler=[100,0,0])
pigeon.state(1)

#ask the question we will record data for
critical_question = viz.addText('Do you see a pigeon?',viz.SCREEN)

yes = viz.addText('Yes!',viz.SCREEN)
no = viz.addText('No!',viz.SCREEN)

critical_question.alignment(viz.ALIGN_CENTER_TOP)
critical_question.setPosition(.5,.9)

yes.alignment(viz.ALIGN_LEFT_TOP)
yes.setPosition(.25,.75)

no.alignment(viz.ALIGN_LEFT_TOP)
Example #5
0
import viz
import vizact

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

female = viz.addAvatar("vcc_female.cfg")
female.setPosition([0, 0, 3])
female.setEuler([180, 0, 0])
female.state(12)

# Get a handle to the Neck bone
neck = female.getBone("Bip01 Neck")
neck.lock()  # Disable automatic animation so that we can manually animate it

# Lock the head bone so that manual movement of the neck bone also moves the child head bone
female.getBone("Bip01 Head").lock()

# Used to rotate the torso when the viewpoint moves to the side of the avatar
torso = female.getBone("Bip01 Spine1")
torso.lock()


def faceView():
    # Make head look at viewpoint
    viewPOS = viz.MainView.getPosition()
    neck.lookAt(viewPOS, mode=viz.AVATAR_WORLD)  # points the head and neck at the viewpoint

    # Get neck orientation to see if we need to translate torso
    neckOrientation = neck.getEuler(viz.AVATAR_LOCAL)
Example #6
0
import viz
import vizact
import viztask

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

viz.MainView.move([0,-1,-3])

dojo = viz.addChild('dojo.osgb')
pigeon = viz.addAvatar('pigeon.cfg')
pigeon.setEuler([180,0,0])
#text = viz.addText('Press "k" to KILL the pigeon', viz.SCREEN)
#text.setPosition([.05,.75,0])
#text.setScale(.8,.8,.8)

#my custom event
class PigeonGreeting(viz.EventClass): 
    def __init__(self): 
        viz.EventClass.__init__(self) 
        
        self.callback(viz.KEYDOWN_EVENT,self.onKeyDown) 
        
    def onKeyDown(self,key): 
		if key == ' ':
			text2 = viz.addText('"Hello"',parent=viz.SCREEN,pos=(0.5,0.5,0),align=viz.ALIGN_CENTER_CENTER)
			text2.color(viz.RED)
		pass 

PigeonGreeting()
Example #7
0
#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)
MLK.state(11)
speech = vizact.speak('MLKDream.wav', threshold = 0, scale = 0.006, sync = True)
MLK.addAction(speech)

#update view (pos) according to arrow keys
MOVE_SPEED = 2.0
def UpdateView():
	if (RIFT):
		yaw,pitch,roll = viewLink.getEuler()
		m = viz.Matrix.euler(yaw,0,0)
Example #8
0
RIFT = True
PPT1 = True
vhilGo(RIFT, PPT1) 

view = viz.MainView
view.setPosition(0, .5, -10)
viz.setMultiSample(4)
viz.fov(60)
#viz.go(viz.FULLSCREEN)

room = viz.addChild('MeghaRoom2.osgb')
room.setEuler(-88, 0, 0)
room.setScale(.08, .08, .08)
instructions = vizinfo.InfoPanel(icon=False,text=None)

cat = viz.addAvatar('cat_tabby_med2.cfg')
girl = viz.addAvatar('CC2_f006_hipoly_A2_v2.cfg')
girl.state(34)
girl.setEuler(180, 0, 0)
cat.setPosition(-2.8, 0, -3)
girl.setPosition(-2.8, 0, 2)
cat.setScale(1.5, 1.5, 1.5)
girl.setScale(1.5, 1.5, 1.5)
cat.lookAt([2.8, 0, -3])

ball = viz.add('ball.wrl')
ball.disable(viz.RENDERING)
ball.setPosition(1.2, 0, -1.8)
sensorCat = vizproximity.Sensor(vizproximity.Box([.4,.4,.4],center=[0,0.25,0]),source=cat)
sensorTeapot = vizproximity.Sensor(vizproximity.Box([.4,.6,.4],center=[0,0.3,0]),source=ball)
target = vizproximity.Target(viz.MainView)
Example #9
0
	def stageAxes(self, NAxes, relSpeed, holes):
		# Function for swinging the axes
		def swing(object, t, startAngle, endAngle):
			d = (math.sin(t[0]) + 1.0) / 2.0
			angle = startAngle + d * (endAngle - startAngle)
			object.setEuler([90,0,angle])
			t[0] += 0.03 * relSpeed
		
		# Add axes
		beginPosition = 400
		endPosition = 6600
		nrAxes = NAxes
		self.axes = []
		self.axest = []
		self.swoosh = []
		for i in range(nrAxes):
			self.axes.append(viz.addChild('axe.OSGB', cache=viz.CACHE_CLONE))
			self.axes[i].setPosition([beginPosition+i*(endPosition/nrAxes),750,0], viz.REL_LOCAL)
			self.axest.append([float(i)])
			
			sound_node = viz.addGroup(pos=[beginPosition+i*(endPosition/nrAxes),75,0])
			self.swoosh.append(sound_node.playsound('swoosh.wav'))
			self.swoosh[i].minmax(0, 20)
			vizact.ontimer(3.14/relSpeed, self.swoosh[i].play)
			
			vizact.ontimer(0.03, swing, self.axes[i], self.axest[i], 120, 240)
		
		# Add ducky
		self.newduck = viz.addAvatar('duck.cfg')
		self.newduck.setScale([170,170,170])
		self.newduck.setPosition([7200,0,0],viz.REL_LOCAL)
		self.newduck.setEuler([-90,0,0])

		# Add proximity sensors
		manager = vizproximity.Manager()
		target = vizproximity.Target(viz.MainView)
		manager.addTarget(target)
		self.axesensors = []
		for i in range(nrAxes):
			self.axesensors.append(vizproximity.addBoundingBoxSensor(self.axes[i]))
			manager.addSensor(self.axesensors[i])
		duckSensor = vizproximity.addBoundingBoxSensor(self.newduck,scale=(2.5,2.5,3))
		manager.addSensor(duckSensor)
		
		# Boolean variables to store trial results
		self.axesHit = []
		for i in range(nrAxes):
			self.axesHit.append(0)
			
#		for i in range(nrAxes):
#			sensors.append(vizproximity.addBoundingBoxSensor(self.axes[i]))
#			manager.addSensor(sensors[i])
		
		holeCoordinates = [
		[755,0,95],
		[755,0,-98],
		[1391,0,-1.5],
		[2017,0,98],
		[2503,0,-5],
		[2987,0,-108],
		[3776,0,-55],
		[4726,0,49],
		[5525,0,95],
		[5525,0,-104],
		[6011,0,-7]]
		
		self.holesensor = []
		k=-1
		for hole in holeCoordinates:
			k+=1
			self.holesensor.append(vizproximity.Sensor(vizproximity.Box([50,300,100],center=hole),source=viz.Matrix.translate(0,0,0)))
			manager.addSensor(self.holesensor[k])
			
		
		self.holesHit = []
		for i in range(len(self.holesensor)):
			self.holesHit.append(0)
		
		# Called when we enter a proximity
		def EnterProximity(e):
			for i in range(nrAxes):
				if e.sensor == self.axesensors[i]:
					self.axesHit[i] += 1
					print "Hit axe #" + str(i) + " " + str(self.axesHit[i]) + " times!"
			
			if holes:
				for i in range(len(self.holesensor)):
					if e.sensor == self.holesensor[i]:
						self.holesHit[i] += 1
						print "Hit hole #" + str(i) + " " + str(self.holesHit[i]) + " times!"
		
		manager.onEnter(None,EnterProximity)
		
		#Add info panel to display messages to participant
		self.instructions = vizinfo.InfoPanel(icon=False,key=None)
		
		vizact.onkeydown('g',manager.setDebug,viz.TOGGLE)  
		
		# Action for hiding/showing text
		DelayHide = vizact.sequence( vizact.waittime(8), vizact.method.visible(False) )
		Show = vizact.method.visible(True)
		
		#instructions.setText("Reach the duck."+str(self.time))
		self.startTime = viz.tick()
		
		
		print "done with scene, awaiting duck"
		print "----------Begin stage "+str(self.stage)+"----------"
		# When finished
		yield vizproximity.waitEnter(duckSensor)
		
		self.elapsedTime = viz.tick() - self.startTime
		self.elapsedTime = str(round(self.elapsedTime,2))
		yayString = "Total number of axes hit: "
		if NAxes>0: yayString += str(self.axesHit[0])
		for i in range(1, nrAxes):
			yayString += ", " + str(self.axesHit[i])
		if holes:
			yayString += ".\nTotal number of holes hit: "
			for i in range(len(self.holesensor)):
				yayString += ", " + str(self.holesHit[i])
		
		yayString += ".\nTime is: " + str(self.elapsedTime)	
		print yayString
		self.tracking_data.write(yayString)
		print "----------End stage----------"
import viz
from vhil_devkit import *
import keyboardcontrol
keyboardcontrol.control(mainview)

vhilGo()

avatar = viz.addAvatar('Homeless Avatars/CC2_m006_hipoly_A2_v2.cfg')
avatar.setPosition([0,.5,2])
avatar.setEuler([180,0,0])

avatar.state(1)
import vizact
vizact.onkeydown(' ', avatar.setAnimationSpeed, 0, 3)
# Create clones of the master ball
for y in range(NUM_BALLS):
    ball = ballMaster.clone()
    ball.setPosition([0, y, 0])
    ball.setScale([BUMPER_WIDTH * 1.5] * 3)
    ball.collideCopy(ballMaster)  # Enable collisions with the ball based on a sphere shape
    balls.append(ball)  # Add the ball to the ball list

ballMaster.remove()

# Create cycle for balls
nextBall = viz.cycle(balls)

# Create object that drops the ball
ballDropper = viz.addAvatar("duck.cfg")
ballDropper.setPosition([0, 1.9, 0.2])
ballDropper.setScale([0.2, 0.2, 0.2])
ballDropper.setEuler([180, 0, 0])
ballDropper.state(1)

# Drop ball when spacebar is pressed
def dropBall():
    ball = nextBall.next()  # get the next ball to drop
    ball.reset()  # zero out physics forces
    ball.setPosition(ballDropper.getPosition())  # drop ball at ballDropper's position
    ballDropper.execute(2)


vizact.onkeydown(" ", dropBall)
Example #12
0
import viz

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

body = viz.addAvatar('vcc_male.cfg')
head = viz.addFace( 'kanye_3.vzf' )

body.setPosition(0,0,5)
body.setEuler(180,0,0)

# body.setFace( head )
body.setFace( head, 'Bip01 Head', 'Bip01 Neck' )
Example #13
0
sky_light.position(0,0,-1,0)
sky_light.color(viz.WHITE)
sky_light.ambient([0.9,0.9,1])

# add the gallery model
gallery = viz.addChild('gallery.osgb')

# add audio and video
music = viz.addAudio('bach_air.mid',loop=1)
video = viz.addVideo('vizard.mpg',play=1,loop=1)

# get a handle to Starry Night texture
painting = gallery.getTexture('painting_starry-night')

# add an avatar
avatar = viz.addAvatar('vcc_male2.cfg',pos=[0,0,1])
avatar.state(1)

# create static drop shadow to avatar
shadow_texture = viz.addTexture('shadow.png')
shadow = vizshape.addQuad(parent=avatar,axis=vizshape.AXIS_Y)
shadow.texture(shadow_texture)
shadow.zoffset()

# move avatar around the room with a sequence of walk, turn, and wait actions

# create action to wait 5-10 seconds
RandomWait = vizact.waittime(vizact.randfloat(5,10))

# list of painting locations
avatarMove = [[-3.7,2.2,300],[-3.7,6.5,270],[0,8,0],[3.7,6.5,90],[3.7,2.6,90],[3.7,1,130]]
Example #14
0
        else:
            vizfx.postprocess.addEffect(effect)


# puts the function on a different thread to allow the while loop to run as the scene keeps going
viz.director(pause)

# load and play the binaural recording
sound = viz.addAudio('resources/barber.mp3')
sound.play()

# load guitar model
guitar = viz.addChild('resources/guitar.osgb')

# load the avatars and set starting position
manuel = viz.addAvatar('vcc_male.cfg')
manuel.setPosition(-0.3, 0, -2.82)

luigi = viz.addChild('vcc_male2.cfg')
luigi.setPosition([-2, 0, 6])

# link the guitar to the back model
back = manuel.getBone('Bip01 Neck')
link = viz.link(back, guitar)

# manuel walking in, closing the door, and 'talking' to the user
manuel.addAction(vizact.walkTo([-0.48, 0, -1.15234], walkSpeed=2.0))
manuel.addAction(vizact.turn(160, 220))
manuel.addAction(vizact.animation(15, speed=2.2))
manuel.addAction(vizact.turn(0, 220))
manuel.addAction(vizact.walkTo([-0.5, 0.0, 2], walkSpeed=1.2))
Example #15
0
            roll += self.inc
            object.setEuler(yaw, pitch, roll)

    def end(self, object):
        self.text.message("The pigeon is kil")
        self.text.setPosition([0.15, 0.75, 0])
        viz.ActionClass.end(self, object)


def dead(text):
    action = viz.ActionData()
    action.data = [text]
    action.actionclass = VizDeadAction
    return action


dojo = viz.addChild("dojo.osgb")
pigeon = viz.addAvatar("pigeon.cfg")
pigeon.setEuler([180, 0, 0])
text = viz.addText('Press "k" to KILL the pigeon', viz.SCREEN)
text.setPosition([0.05, 0.75, 0])
text.setScale(0.8, 0.8, 0.8)


def myTask(text):
    yield viztask.waitKeyDown("k")
    pigeon.addAction(dead(text))


viztask.schedule(myTask(text))
viz.fov(50)
viz.go(viz.FULLSCREEN)
#viz.collision(viz.ON)

# Simulate head tracker using keyboard/mouse navigator
head_tracker = vizcam.addWalkNavigate()
head_tracker.setPosition([0,1.5,0])

viz.mouse.setVisible(False)

# Add pit model
model = viz.add('pit.osgb')
model.hint(viz.OPTIMIZE_INTERSECT_HINT)

for x in [-4,-2,2,4]:
	male = viz.addAvatar('vcc_male2.cfg',pos=(x,0.05,0),euler=(0,0,0))
	male.state(6)
	Chair=viz.addChild('chair.ive')
	Chair.setScale([.01,.01,.01])
	Chair.setEuler([180,0,0])
	Chair.setPosition([x,0.05,-.1])
for i in range(-4,5):
	Table=viz.addChild('table.wrl')
	Table.setPosition([i,0.3,1])
	
for i in range(-4,5,3):
	phone=viz.addChild('phone.ive')
	phone.setPosition([i,1,1])
	cup=viz.addChild('F:\cup.obj')
	cup.setScale([.05,.05,.05])
	cup.setPosition([i+1,1,1+.25])
Example #17
0
def trial_down ():
	global k
	k = 0
	global x
	x = 0
	for i in range (100):
		yield viztask.waitTime(.5)
		ready_text = viz.addText3D('Get ready!',pos = [-2,1.7,20])	
		ready_text.color(0,0,0)
		yield viztask.waitTime(1)
		ready_text.remove ()
		yield viztask.waitTime(2)	
		yield room ()
		doors = []
		D1 = random.choice([-4.25,-3.25,-2.25,-1.25])
		D2 = random.choice([4.75,5.75,6.75,7.75])
		D3 = random.choice([13.75,14.75,15.75,16.75])
		D4 = random.choice([22.75,23.75,24.75,25.75])
		D5 = random.choice([31.75,32.75,33.75,34.75])
		L_doors = []
		L_doors.append(D1)
		L_doors.append(D2)
		L_doors.append(D3)
		L_doors.append(D4)
		L_doors.append(D5)
		D7 = random.choice([-4.25,-3.25,-2.25,-1.25])
		D8 = random.choice([4.75,5.75,6.75,7.75])
		D9 = random.choice([13.75,14.75,15.75,16.75])
		D10 = random.choice([22.75,23.75,24.75,25.75])
		D11 = random.choice([31.75,32.75,33.75,34.75])
		R_doors = []
		R_doors.append(D7)
		R_doors.append(D8)
		R_doors.append(D9)
		R_doors.append(D10)
		R_doors.append(D11)
		people = []
		P1 = random.choice([9.25,10.25,11.25,12.25,18.25,19.25,20.25,21.25])
		P2 = random.choice([27.25,28.25,29.25,30.25,36.25,37.25,38.25,39.25])
		L_people = []
		L_people.append(P1)
		L_people.append(P2)
		P3 = random.choice([9.25,10.25,11.25,12.25,18.25,19.25,20.25,21.25])
		P4 = random.choice([27.25,28.25,29.25,30.25,36.25,37.25,38.25,39.25])
		R_people = []
		R_people.append(P3)
		R_people.append(P4)
		targ = random.choice(targets)
		if targ == 2.5:
			size = .051006
		if targ == 3.5:
			size = .071409	
		if targ == 4.8:
			size = .097932
		if targ == 6.2:
			size = .126495
		if targ == 7.6:
			size = .155059
		if targ == 9:
			size = .183622
		if targ == 10.4:
			size = .212186
		if targ == 11.8:
			size = .240749
		if targ == 13.2:
			size = .269313
		if targ == 14.6:
			size = .297876
		if targ == 17.4:
			size = .355003
		if targ == 20.2:
			size = .41213
		if targ == 23:
			size = .469257
		if targ == 25.8:
			size = .526384
		if targ == 30:
			size = .612075
		if targ == 38:
			size = .775295
		print targ
		sphere = vizshape.addSphere((size),20,20)
		sphere.color(1.02,.444,0)
		sphere.setPosition([0,(size),(targ)])
		shadow = vizshape.addCircle((size),20)
		shadow.color([.05,.05,.05]) #proportion of 1 for amount of each color (red, green, blue). 0,0,0 = black, 1,1,1 = white.
		shadow.setEuler([0,90,0])
		shadow.setPosition([0,.001,(targ)])
		for z in np.asarray(L_doors):
			door = vizshape.addBox(size=[.04445,2.13,.91])  
			door.texture(wood)
			door.setPosition([-4.9733,1.065,float(z)])
			doors.append(door)
			doorknob = vizshape.addSphere(radius=.045,axis=vizshape.AXIS_X)
			doorknob.color(viz.YELLOW)
			doorknob.setPosition(-4.9396,1,(float(z)-.3364))
			doors.append(doorknob)
		for z in np.asarray(R_doors):
			door = vizshape.addBox(size=[.04445,2.13,.91])  
			door.texture(wood)
			door.setPosition([4.9683,1.065,float(z)])
			doors.append(door)
			doorknob = vizshape.addSphere(radius=.045,axis=vizshape.AXIS_X)
			doorknob.color(viz.YELLOW)
			doorknob.setPosition(4.9396,1,(float(z)-.3364))
			doors.append(doorknob)	
		for z in np.asarray(L_people):
			o = random.choice([0,90,180])
			person = viz.addAvatar('vcc_female.cfg',euler=(float(o),0,0))
			person.setPosition([-4.25,0,float(z)])
			person.state(1)
			people.append(person)
		for z in np.asarray(R_people):
			o = random.choice([0,180,270])
			person = viz.addAvatar('vcc_female.cfg',euler=(float(o),0,0))
			person.setPosition([4.5,0,float(z)])
			person.state(1)
			people.append(person)	
		en_env()
		tic = time.time()
		yield viztask.waitTime(.01) 
		time.sleep(.09+x)
		toc = time.time ()
		mask.enable(viz.RENDERING)
		dis_env()
		sphere.remove ()
		shadow.remove ()
		for door in np.asarray(doors):
			door.remove()
		for person in np.asarray(people):
			person.remove()
		yield viztask.waitTime(1)
		mask.disable(viz.RENDERING)
		print toc - tic
		viz.callback(viz.KEYDOWN_EVENT,KeyEvents)
		yield viztask.waitKeyDown(viz.KEY_KP_ENTER) 
		if k == 1:
			break
	times.append((toc - tic)+.01)		
	print times
Example #18
0
sky.texture(env)

#def path_func(complexity):
#   W = [random.random() for i in range(int(complexity))]
#  print(W)
# def f(x):
#    y = sum([math.sin(w*x/5) for w in W])
#   return y / complexity
# return f

#f = path_func(50.0)

land = viz.addChild('Land/model.osgb')
land.setPosition([0, 1, 0])

male = viz.addAvatar('vcc_male.cfg', pos=(-38, 5, 40), euler=(90, 0, 0))
male.setScale(1, 1, 1)
male.state(5)

female = viz.addAvatar('vcc_female.cfg',
                       pos=(-35, 4.75, 40),
                       euler=(270, 0, 0))
female.setScale(1, 1, 1)
female.state(5)

basket = viz.addChild('basketball.osgb')
basket.setPosition([-140, 2.8, 130])

male1 = viz.addAvatar('vcc_male.cfg', pos=(-140, 2.8, 130), euler=(90, 0, 0))
male1.setScale(2, 2, 2)
male1.state(5)
Example #19
0
choices = ['Hostile Agent','Non-Hostile Agent','Selfish-Agent','Goal-Following Agent','Leader Following Agent','Fuzzy-Behaviour Agent']
dialog = vizdlg.ChooseDialog(prompt='Select The Agent Type:', choices=choices)
dialog.setScreenAlignment(viz.ALIGN_CENTER)

Numbers = ['1','2','3','4','5','6','7','8','9','10']
how_many = vizdlg.ChooseDialog(prompt='Select The Number of Agents', choices=Numbers)
how_many.setScreenAlignment(viz.ALIGN_CENTER)






############################add avatars####################################

male11=viz.addAvatar('vcc_male2.cfg', pos=(50,0,56), euler=(270,0,0) )
male11.setScale(2,1.8,2)
male11.state(2)

#in the corner where there is no signal light
male1=viz.addAvatar('vcc_male2.cfg', pos=(5.5,0,115), euler=(270,0,0) )
male1.setScale(2,1.8,2)
male1.state(4)

male2=viz.addAvatar('vcc_male_blue.osgb', pos=(4,0,113), euler=(0,0,0) )
male2.setScale(2,1.8,2)
male2.state(4)


#NEAR THE TRASHCANE three people
female1=viz.addAvatar('vcc_female_white.osgb', pos=(4,0,76), euler=(90,0,0) )
Example #20
0
piazza = viz.addChild('piazza.osgb')
viz.addChild('piazza_animations.osgb')

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

# Swap out sky with animated sky dome
piazza.getChild('pz_skydome').remove()
day = viz.add('sky_day.osgb')

ground = viz.add('tut_ground.wrl')
ground.setPosition(0,-.05, 0)
ground.collidePlane()

# Add avatar sitting on a bench
male = viz.addAvatar('vcc_male2.cfg',pos=(-6.5,0,13.5),euler=(90,0,0))
male.state(6)

male2 = viz.addAvatar('vcc_male.cfg',pos=(2.5,0,7.5),euler=(160,0,0))
male2.state(9)

# Create pigeon
pigeon = viz.addAvatar('pigeon.cfg')
pigeon.visible(False)

#Create white ball
ball_root = viz.addGroup()
ball_root.visible(True)
ball = viz.add('white_ball.wrl', parent=ball_root)
ball.setPosition([2.5,2,7])
ball.collideSphere(bounce = 1)
Example #21
0
import vizproximity
import viztask

#Enable physics
viz.phys.enable()

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

view = viz.MainView
view.move([0,0,-7])

ground = viz.addChild('ground.osgb')
male = viz.addChild('vcc_male.cfg', pos=[-4, 0, 0], euler=[90,0,0])
female = viz.addAvatar('vcc_female.cfg', pos=[4,0,0], euler=[-90,0,0])


maleSensor = vizproximity.Sensor(vizproximity.Box([2,2,2],center=[0,1,0]),source=male)
femaleSensor = vizproximity.Sensor(vizproximity.Box([2,2,2],center=[0,1,0]),source=female)

#maleSensor = vizproximity.Sensor( vizproximity.RectangleArea([2,2]), source=male )
#femaleSensor = vizproximity.Sensor( vizproximity.RectangleArea([2,2]), source=female )

#Add main viewpoint as proximity target 
target = vizproximity.Target(viz.MainView)
maleTarget = vizproximity.Target(male.getBone('Bip01 R Hand'))
femaleTarget = vizproximity.Target(female.getBone('Bip01 R Hand'))
print femaleTarget.getSourceObject()

Example #22
0
viz.link(tracker,viz.MainView)
viz.mouse.setVisible(False)

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

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

# Swap out sky with animated sky dome
piazza.getChild('pz_skydome').remove()
day = viz.add('sky_day.osgb')
day.renderToBackground()

male = viz.addAvatar('resources/CC2_m001_hipoly_A1_v2.cfg',pos=(-6.5,0,8),euler=(180,0,0))
male.state(3)

startedWalking = False

female = viz.addAvatar('resources/CC2_f020_hipoly_A1_v2.cfg',pos=FEMALE_POSITION,euler=(-90,0,0))
female.state(3)

pigeon = viz.addAvatar('pigeon.cfg', pos=PIGEON_POSITION)
pigeon.setScale(2,2,2)
pigeon.setEuler(random.randint(120, 180))
randomAnimation = vizact.method.state(vizact.choice([1,3], vizact.RANDOM))
randomWait = vizact.waittime(vizact.randfloat(2,3))
pigeon_idle = vizact.sequence(randomAnimation, randomWait, viz.FOREVER)
pigeon.runAction(pigeon_idle)
Example #23
0
import viz

room = viz.add('MeghaRoom.osgb')

girl = viz.addAvatar('Models/CC2_f001_hipoly_A0_v2.cfg')

view = viz.MainView
view.setPosition(10, 20, 10)

room.setScale(.25, .5, .25)

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

def walk():
	girl.move([1, 0 , 1])

vizact.onkeydown(' ', walk)
Example #24
0
import viz
import vizact
import vizproximity
import viztask
import vizinfo

viz.setMultiSample(4)
viz.fov(60)
viz.go()
#Add info panel to display messages to participant
instructions = vizinfo.InfoPanel(icon=False,text=None)


ground = viz.addChild('ground.osgb')
avatar = viz.addAvatar('CC2_f002_hipoly_A2_v2.cfg')
cat = viz.addAvatar('cat_tabby_med.cfg')
cat.setPosition(2, 0, 2)
avatar.enable(viz.SAMPLE_ALPHA_TO_COVERAGE)
avatar.disable(viz.BLEND)
cat.enable(viz.SAMPLE_ALPHA_TO_COVERAGE)
cat.disable(viz.BLEND)


def startWalking() :
	avatar.state(139)

def talk() :
	while True:
		yield viztask.waitKeyDown('1')
		yield viztask.addAction(avatar, vizact.animation(65))
		yield viztask.addAction(cat, vizact.animation(3))
Example #25
0
if TYPICAL_GUI_CANVAS:
	# Create canvas for displaying GUI objects
	canvas = viz.addGUICanvas()
	canvas.alignment(viz.ALIGN_CENTER)

	# Set canvas as default so all GUI objects are automatically added to it
	viz.MainWindow.setDefaultGUICanvas(canvas)

	controlPanel = vizinfo.InfoPanel(text='Navigate with WASD', title='Canvas Example')

	controlPanel.addSection('Render Mode')
	radio_world_overlay = controlPanel.addLabelItem('World Overlay', viz.addRadioButton('RenderMode'))
	radio_world = controlPanel.addLabelItem('World', viz.addRadioButton('RenderMode'))
	radio_screen_ortho = controlPanel.addLabelItem('Screen Ortho', viz.addRadioButton('RenderMode'))
	radio_world_overlay.set(1)

	controlPanel.addSeparator()
	manual_cursor = controlPanel.addLabelItem('Manual Cursor',viz.addCheckbox())
	select_world = controlPanel.addItem(viz.addButtonLabel('Select World'))


	canvas.setRenderWorldOverlay([800,600],40,3)

if NODE3D_CANVAS:
	pigeon = viz.addAvatar('pigeon.cfg',scale=[200]*3)
	pigeon.addAction(vizact.spin(0,1,0,45))
	pigeon.enable(viz.DEPTH_TEST,op=viz.OP_ROOT)

	#Add the pigeon to the panel
	panel = vizinfo.InfoPanel('Find the pigeons before they fly away',align=viz.ALIGN_CENTER,fontSize=22,icon=False)
	panel.addItem(pigeon,align=viz.ALIGN_CENTER)
Example #26
0
import viz

#Enable full screen anti-aliasing (FSAA) to smooth edges
viz.setMultiSample(4)

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

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

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

male = viz.addAvatar('vcc_male.cfg')
male.setPosition([4.5, 0, 7])
male.setEuler([0, 0, 0])

female = viz.addAvatar('vcc_female.cfg')
female.setPosition([4.5, 0, 9])
female.setEuler([180, 0, 0])

#Set the male and female to the talking state
male.state(11)
female.state(11)

import random

pigeons = []
for i in range(100):

    #Generate random values for position and orientation
Example #27
0
import viztask
import random

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

# Setup keyboard/mouse tracker
tracker = vizcam.addWalkNavigate()
tracker.setPosition([0,1.8,-10])
viz.link(tracker,viz.MainView)

room = viz.addChild('room.osgb')
room.setScale(.025, .025, .025)

man = viz.addAvatar('CC2_m004_hipoly_A3_v2.cfg')
men = []
for x in range(0, 6):
  men.append(viz.addAvatar('CC2_m004_hipoly_A3_v2.cfg'))
woman = viz.addAvatar('CC2_f008_hipoly_A3_v2.cfg')

# woman.setPosition([1.3,0,-1.4])
man.setPosition([2,0, -.4])
man.setEuler([-140,0,0])
men[0].setPosition([1.2,0,0])
men[1].setPosition([-.45,0,0])
men[2].setPosition([-1.7,0,-.3])
men[3].setPosition([-1.7,0,-4.5])
men[4].setPosition([1.2,0,-4.5])
men[5].setPosition([0,0,-2])
Example #28
0
platform = viz.addChild('platform.osg')
platform.setPosition([0, .2, -11])
micStand = viz.addChild('pole.wrl',parent=platform)
micStand.setPosition([0, 0, .5])
micStand.setScale([0.5,0.36,0.5])
micStand.color(1,1,1)

mic = viz.addChild('pole.wrl')
mic.setPosition([0, 1.6, -10.5])
mic.setScale([0.1,0.04,0.15])
mic.setEuler([0,-45,0])
mic.color(1,0,0)

hat = viz.addChild('tophat.3ds')
performer = viz.addAvatar('vcc_male2.cfg')
performer.setPosition([0, .2, -11])
performer.blend(4,0.5)
performer.blend(5,0.5)

head = performer.getBone('Bip01 Head')
HatLink = viz.link(head,hat)
#Tweek the hat link so it fits snuggly on the head
HatLink.preTrans( [0,0.15,-0.0] )
HatLink.preEuler( [0,-10,0] )

	
for x in [-1,0,1]:
	backupDancer = viz.addAvatar('vcc_female.cfg')
	backupDancer.setPosition([x, .2, -13])
	backupDancer.state(5)
Example #29
0
import viz

view = viz.MainView
view.setPosition(0, 1.5, -4)
viz.setMultiSample(4)
viz.go()

dojo = viz.add('dojo.osgb')

girl = viz.addAvatar('CC2_f001_hipoly_A1_v2.cfg', euler = [180, 0, 0])
girl.state(67)
Example #30
0
File: Test.py Project: kevinsp/DvB
import viz
import vizact



#Enable full screen anti-aliasing (FSAA) to smooth edges
viz.setMultiSample(4)

viz.go()

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

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

male = viz.addAvatar('vcc_male.cfg')
male.setPosition([4.5, 0, 7])
male.setEuler([0,0,0])

female = viz.addAvatar('vcc_female.cfg')
female.setPosition([4.5,0,9])
female.setEuler([180,0,0])

#Set the male and female to the talking state
male.state(14)
female.state(14)

import random

pigeons = []
for i in range(10):
Example #31
0
#Add info panel to display messages to participant
instructions = vizinfo.InfoPanel(icon=False,key=None)

#Add ambient sound
piazzaSound = viz.addAudio('piazza.mp3')
piazzaSound.play()
piazzaSound.loop()

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

#Move the viewpoint to the starting location
viz.MainView.move([10.5,0,20.5])
viz.MainView.setEuler([-90,0,0])

#Add male and female avatars in conversation
male = viz.addAvatar('vcc_male.cfg',pos=[-2.6,0,10.4],euler=[-40,0,0])
female = viz.addAvatar('vcc_female.cfg',pos=[-3.4,0,11.2],euler=[140,0,0])
male.state(14)
female.state(14)

#Add pigeon to make copies of
pigeon = viz.addAvatar('pigeon.cfg')
pigeon.visible(0)

#Add plant marker for participant to walk to
plantMarker = viz.addChild('plant.osgb',pos=[-10.3,0,20.6],scale=[0.5,0.5,0.5])

#Add crates marker for participant to walk to
crate1 = viz.addChild('crate.osgb',pos=[-9.9,0.3,5.7],scale=[0.6,0.6,0.6])
crate2 = crate1.clone(pos=[-9.8,0.3,5.05],euler=[5,0,0],scale=[0.6,0.6,0.6])
crate3 = crate1.clone(pos=[-9.8,0.9,5.35],euler=[-5,0,0],scale=[0.6,0.6,0.6])
Example #32
0
#sample function, The function spinPlant will get called every 0.5 seconds for a total of 20 times (1 + 19 repeats). 
#Each time, the spin action is applied to the next plant in the list.
#def spinPlant(plant):		
#    plant.addAction(spin)
#vizact.ontimer2(0.5,19,spinPlant,vizact.choice(plants))
#for indefinite repeats, use ontimer function, has no repeat parameter
num=10
s=3
c=3
species='pigeon.cfg'
while num>0:
	x = random.randint(-4,4)
	z = random.randint(-8,-2)
	yaw = random.randint(0,360)
	animal = viz.addAvatar(species)
	animal.setScale(c,c,c)
	animal.setPosition(x,0,z)
	animal.setEuler(yaw,0,0)
	animal.collideMesh()
	animal.state(s)
	num=num-1
	if num==5:
		s=1
		species='duck.cfg'
		c=.5
		
#def animalMoves():


import viz
import vizact

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

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

male = viz.addAvatar('vcc_male.cfg',pos=[8, 0, 7])
female = viz.addAvatar('vcc_female.cfg',pos=[8,0,9],euler=[180,0,0])
male.state(14)
female.state(14)

bird1 = viz.addAvatar('pigeon.cfg',pos=[-6.5, 0.43, -1.56],euler=[120,0,0])
bird1.state(1)

bird2 = viz.addAvatar('pigeon.cfg',pos=[5.61, 4.5, -9.88],euler=[-90,0,0])
bird2.state(1)

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

conversation_node = viz.addGroup(pos=[8,1.8,8])
conversation_node.playsound('conversation.wav',viz.LOOP)

bell_sound = piazza.playsound('bells.wav',node='bell-sound')
bell_sound.minmax(0,3)

vizact.onkeydown('1',bell_sound.play)

def startBird1():
#Create clones of the master ball
for y in range(NUM_BALLS):
	ball = ballMaster.clone()
	ball.setPosition( [0, y, 0] )
	ball.setScale( [BUMPER_WIDTH*1.5]*3 )
	ball.collideCopy( ballMaster ) #Enable collisions with the ball based on a sphere shape
	balls.append( ball ) #Add the ball to the ball list

ballMaster.remove()

#Create cycle for balls
nextBall = viz.cycle( balls )

#Create object that drops the ball
ballDropper = viz.addAvatar( 'duck.cfg' )
ballDropper.setPosition( [0, 1.9, .2] )
ballDropper.setScale( [.2, .2, .2] )
ballDropper.setEuler( [180, 0, 0] )
ballDropper.state( 1 )

#Drop ball when spacebar is pressed
def dropBall():
	ball = nextBall.next() #get the next ball to drop
	ball.reset() #zero out physics forces
	ball.setPosition( ballDropper.getPosition() ) #drop ball at ballDropper's position
	ballDropper.execute( 2 )

vizact.onkeydown(' ',dropBall)

#Move ballDropper
Example #35
0
viz.link(tracker,viz.MainView)
viz.mouse.setVisible(False)

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

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

# Swap out sky with animated sky dome
piazza.getChild('pz_skydome').remove()
day = viz.add('sky_day.osgb')

# Add avatar sitting on a bench
male = viz.addAvatar('vcc_male2.cfg',pos=(-6.5,0,13.5),euler=(90,0,0))
male.state(6)

# Create pigeon
pigeon_root = viz.addGroup()
pigeon_root.visible(False)
pigeon = viz.addAvatar('pigeon.cfg',parent=pigeon_root)

# Add idle animation
random_walk = vizact.walkTo(pos=[vizact.randfloat(-0.5,0.5),0,vizact.randfloat(-0.5,0.5)])
random_animation = vizact.method.state(vizact.choice([1,3],vizact.RANDOM))
random_wait = vizact.waittime(vizact.randfloat(4.0,8.0))
pigeon_idle = vizact.sequence( random_walk, random_animation, random_wait, viz.FOREVER)
pigeon.runAction(pigeon_idle)

# Adding sound to pigeon
Example #36
0
BUS_OBJ_SCALE = .0365
BUS_OSGB_SCALE = 35
curscale = BUS_OSGB_SCALE
bus = viz.add('bus_obj/Bus_Sept3.OSGB')
bus.setScale([curscale]*3)

#adjust to correct main viewpoint
viz.MainView.setPosition(-3, 1.82, 1.5)
viz.MainView.setEuler(105, -0.0, 0.0)

def reset():
  ORI_TRACKER.reset()
vizact.onkeydown('r', reset)

# add homeless avatars
homeless1 = viz.addAvatar('Homeless Avatars/CC2_m006_hipoly_A2_v2.cfg', pos=(-1.8,.45,0), euler=(100, 0, 0))
homeless1.addAction(vizact.animation(68))

#add Bus Lights
busLight = viz.add('Bus Light.vzf')
busLight.setPosition([-6.1, -2.7, 2.9])
busLight.setEuler([180.0, 90.0, 180.0])

bus_light = viz.addLight()
bus_light.position( 0,0,0,1 )
viz.link( busLight, bus_light )
busLight.emissive(viz.WHITE)
bus_light.color(viz.WHITE)
intensity = .15
bus_light.intensity(intensity)
bus_light.linearattenuation( 3 )
import viz
import viztask
import vizact
import vizproximity

dojo = viz.add('dojo.osgb')

male = viz.addAvatar('Models/CC2_m001_hipoly_A1_v2.cfg', pos = [-2, 0, 0], euler = [90, 0, 0])
female = viz.addAvatar('vcc_female.cfg', pos = [2, 0, 0], euler = [-90, 0, 0])
pigeon = viz.addAvatar('pigeon.cfg', pos = [-3,0,0])

view = viz.MainView
view.setPosition(0, 2, -10)

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

female.state(1)
male.state(1)

manager = vizproximity.Manager()

femaleSensor = vizproximity.Sensor(vizproximity.Box([4,5,5], center=[0,0,0]), source = female)
pigeonSensor = vizproximity.Sensor(vizproximity.Box([1,1,1], center =[0,0,0]), source = pigeon)

target = vizproximity.Target(male)

manager.addSensor(femaleSensor)
manager.addSensor(pigeonSensor)
manager.addTarget(target)
sky_light.ambient([0.9, 0.9, 1])

#Add the gallery model
gallery = viz.addChild('gallery.osgb')

#Add audio
music = viz.addAudio('bach_air.mid', loop=1)

#Add video
video = viz.addVideo('vizard.mpg', play=1, loop=1)

#Get a handle to Starry Night texture
painting = gallery.getTexture('painting_starry-night')

#Add an avatar
avatar = viz.addAvatar('vcc_male2.cfg', pos=[0, 0, 1])
avatar.state(1)

#Create static drop shadow to avatar
shadow_texture = viz.addTexture('shadow.png')
shadow = vizshape.addQuad(parent=avatar, axis=vizshape.AXIS_Y)
shadow.texture(shadow_texture)
shadow.zoffset()

#Move avatar around the room with a sequence of walk, turn, and wait actions

#Create action to wait 5-10 seconds
RandomWait = vizact.waittime(vizact.randfloat(5, 10))

#A list of painting locations
avatarMove = [[-3.7, 2.2, 300], [-3.7, 6.5, 270], [0, 8, 0], [3.7, 6.5, 90],