示例#1
0
文件: Test.py 项目: kevinsp/DvB
def pigeonsFeed():

    random_speed = vizact.method.setAnimationSpeed(0,vizact.randfloat(0.7,1.5))
    random_walk = vizact.walkTo(pos=[vizact.randfloat(-4,4),0,vizact.randfloat(3,7)])
    random_animation = vizact.method.state(vizact.choice([1,3],vizact.RANDOM))
    random_wait = vizact.waittime(vizact.randfloat(5.0,10.0))
    pigeon_idle = vizact.sequence( random_speed, random_walk, random_animation, random_wait, viz.FOREVER)

    for pigeon in pigeons:
        pigeon.addAction(pigeon_idle)
示例#2
0
文件: D2C3.py 项目: vhilab/VRITS-2015
# 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
hooting = pigeon.playsound('birds.wav',viz.LOOP)
hooting.pause()

# Create flash screen quad
flash_quad = viz.addTexQuad(parent=viz.ORTHO)
flash_quad.color(viz.WHITE)
flash_quad.alignment(viz.ALIGN_LEFT_BOTTOM)
flash_quad.drawOrder(-10)
flash_quad.blendFunc(viz.GL_ONE,viz.GL_ONE)
flash_quad.visible(False)
示例#3
0
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)

viz.move([0, 0, -8])

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

plants = []
for x in [-3, -1, 1, 3]:
    for z in [4, 2, 0, -2, -4]:
        plant = viz.addChild('plant.osgb', cache=viz.CACHE_CLONE)
        plant.setPosition([x, 0, z])
        plants.append(plant)

spin = vizact.spin(0, 1, 0, 15)

spinPlant = lambda plant: plant.addAction(spin)
vizact.ontimer2(0.5, 19, spinPlant, vizact.choice(plants))
示例#4
0
#applyTorque
"""
ball = viz.add('ball.wrl',pos=[0,.2,6]) # Add a ball 
ballPhys = ball.collideSphere() # Enable physics on ball 

ball.applyTorque([0,1,0],0) # Apply small torque for 1 second
"""

#addThruster

person = viz.add('vcc_female.cfg',pos=[0,1.6,10]) 
person.collideBox() 
thrust = person.addThruster(mode=viz.ABS_LOCAL,force=[0,6,0]) 
# Press space to enable/disable thruster 
vizact.onkeydown(' ',vizact.choice([thrust.disable,thrust.enable]))


#addVelocity
"""
ball = viz.add('ball.wrl',pos=[0,1,10]) 
ball.collideSphere() 

vel = ball.addVelocity(velocity=[0,.15,0],maxForce=1) 

slider = viz.addSlider(pos=(0.5,0.1,0)) 
slider.set(0.5) 

def UpdateVelocity(pos): 
    vel.setVelocity([(pos*2.0 - 1.0)*5.0,.18,0]) 
vizact.onslider(slider,UpdateVelocity) 
示例#5
0
viz.fov(60)
viz.go()


#Turn on the physics engine 
viz.phys.enable()


ground = viz.add('ground.osgb')  # Add ground 
ground.collidePlane()   # Make collideable plane 
ball = viz.add('ball.wrl',pos=(0,1.8,6))    # Add a ball 
ballPhys = ball.collideSphere()   # Define ball's physical properties
ballPhys.setDensity(.8) #Heavy node

thrust1 = ball.addThruster(mode=viz.ABS_LOCAL,force=[0,.75,0]) 
thrust1.disable()
thrust2 = ball.addThruster(mode=viz.ABS_LOCAL,force=[.15,0,0])
thrust2.disable()
thrust3 = ball.addThruster(mode=viz.ABS_LOCAL,force=[-.15,0,0]) 
thrust3.disable()

vizact.onkeydown(' ',vizact.choice([thrust1.disable,thrust1.enable]))
vizact.onkeydown(viz.KEY_RIGHT,vizact.choice([thrust2.disable,thrust2.enable]))
vizact.onkeydown(viz.KEY_LEFT,vizact.choice([thrust3.disable,thrust3.enable]))

ironWoman = viz.add('vcc_female.cfg')
ironWoman.setScale([.5,2,.5])

viz.link(ball, ironWoman)

viz.MainView.setPosition([0,5,-20])
示例#6
0
#ground
ground = viz.add('tut_ground.wrl')
#collideable plane
ground.collidePlane()
#sky
sky = viz.add('sky_day.osgb')
sky.collidePlane()

#left thruster
leftGlove = viz.addChild('glove.cfg')
leftGlove.setScale([3,3,3])
leftGlove.setPosition([-0.5,0,0])
leftGlove.collideMesh()
lgThrust = leftGlove.addThruster(mode=viz.ABS_LOCAL,force=[0,6,0])
#lgThrust.disable()
vizact.onkeydown('a',vizact.choice([lgThrust.enable,lgThrust.disable]))

#right thruster
rightGlove = viz.addChild('glove.cfg')
rightGlove.setScale([3,3,3])
rightGlove.setPosition([0.5,0,0])
rightGlove.collideMesh()
rgThrust = rightGlove.addThruster(mode=viz.ABS_LOCAL,force=[0,6,0])
rgThrust.disable()
vizact.onkeydown('b',vizact.choice([rgThrust.enable,rgThrust.disable]))


###create avatar
female = viz.addAvatar('vcc_female.cfg')
female.state(9)
Hand1 = female.getBone('Bip01 L Hand')
示例#7
0
#returns objects to original positions
def reset():    
    leftThruster.reset() #Zeros out all forces
    leftThruster.setPosition([-1,4,0])
    leftThruster.setEuler([0,0,0]) #Puts object upright
    leftThrust.disable() #removes thrust

    rightThruster.reset() 
    rightThruster.setPosition([1,4,0])
    rightThruster.setEuler([0,0,0]) 
    rightThrust.disable()

    center.reset() 
    center.setPosition([0,3,0])
    center.setEuler([0,0,0])



#adds thrust to each thruster	
leftThrust = leftThruster.addThruster(mode=viz.ABS_LOCAL,force=[0,60,0])
leftThrust.disable()
rightThrust = rightThruster.addThruster(mode=viz.ABS_LOCAL,force=[0,60,0])
rightThrust.disable()

reset()
#allows user to control thrusters
vizact.onkeydown('a',vizact.choice([leftThrust.enable,leftThrust.disable]))
vizact.onkeydown('d',vizact.choice([rightThrust.enable,rightThrust.disable]))

vizact.onkeydown(' ', reset )
示例#8
0
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)

viz.move([0,0,-8])

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

plants = []
for x in [-3, -1, 1, 3]:
    for z in [4, 2, 0, -2, -4]:
        plant = viz.addChild('plant.osgb',cache=viz.CACHE_CLONE)
        plant.setPosition([x,0,z])
        plants.append(plant)

spin = vizact.spin(0,1,0,15)

spinPlant = lambda plant: plant.addAction(spin)
vizact.ontimer2(0.5,19,spinPlant,vizact.choice(plants))
示例#9
0
#Enable full screen anti-aliasing (FSAA) to smooth edges
viz.setMultiSample(4)

viz.go()

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

viz.move([0,0,-8])

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

plants = []
for x in [-3, -1, 1, 3]:
    for z in [4, 2, 0, -2, -4]:
        plant = viz.addChild('plant.osgb',cache=viz.CACHE_CLONE)
        plant.setPosition([x,0,z])
        plants.append(plant)

		
import vizact
spin = vizact.spin(0,1,0,15)



def spinPlant(plant):
    plant.addAction(spin)

vizact.ontimer(0.5,spinPlant,vizact.choice(plants)) 
示例#10
0
# Turn on the physics engine
viz.phys.enable()

# Add ground
ground = viz.addChild("ground.osgb")
ground.collidePlane()  # Make ground collide with objects as if it were an infinite plane


ironNode = viz.add("box.wrl", pos=[0, 0.2, 2])
ironNode.setScale([1, 1, 1])
ironNode.collideBox(density=3)

thrust1 = ironNode.addThruster(mode=viz.ABS_LOCAL, force=[0, 25, 0], pos=[-0.2, 0.2, 2])
thrust1.disable()
vizact.onkeydown("j", vizact.choice([thrust1.enable, thrust1.disable]))

thrust2 = ironNode.addThruster(mode=viz.ABS_LOCAL, force=[0, 25, 0], pos=[0.2, 0.2, 2])
thrust2.disable()
vizact.onkeydown("f", vizact.choice([thrust2.enable, thrust2.disable]))

person = viz.add("vcc_female.cfg")
person.setScale([0.5, 2, 0.5])

viz.link(ironNode, person)

# Called every frame, this function does the same thing as the link above
def copyTransform(source, destination):
    S = source.getMatrix()
    destination.setMatrix(S)
示例#11
0
def run():
	vizact.onkeydown(viz.KEY_UP,vizact.choice([thrust1.enable,thrust1.disable]))
	vizact.onkeydown(viz.KEY_LEFT,vizact.choice([thrust2.enable,thrust2.disable]))
plantPositions = [[-3.5, 0, -0.3], [-4, 0, 7.9], [4, 0, 7.9], [3.5, 0, -0.3]]
plants = []
plants_root = viz.addGroup()
plants_root.visible(False)
for position in plantPositions:
    plant = viz.addChild('plant.osgb',
                         parent=plants_root,
                         pos=position,
                         cache=viz.CACHE_CLONE)
    plants.append(plant)
    shadow.clone(parent=plant)

# Ceiling pigeon is watching you admire art
pigeon = viz.addAvatar('pigeon.cfg', pos=(1, 8.1, 5.9), euler=(180, 0, 0))
pigeon.state(1)

#Define callback functions for key events


#Scale the plants
def scalePlants(val):
    for plant in plants:
        plant.setScale([val] * 3)


#Register key events
vizact.onkeydown('p', plants_root.visible, viz.TOGGLE)
vizact.onkeydown('s', scalePlants, vizact.choice([1.2, 0.8, 1]))
vizact.onkeydown('m', vizact.choice([music.play, music.stop]))
vizact.onkeydown('v', gallery.texture, vizact.choice([video, painting]),
                 'painting_starry-night')