def init(): vhilGo(rift = RIFT)#, mode=viz.FULLSCREEN) # viz.window.setFullscreenMonitor(1) # For Lucas's computer - comment out if you want keyboardcontrol.control(viz.MainView) for Scene in SCENE_REFS: Scene.load(sceneRef=SCENE_REFS[Scene]) vizact.onkeydown(SCENE_KEYCHAR[Scene], scheduleSwitchScene, Scene)
def addFlickeringLight(model=MODEL, scene=viz.MainScene): global flickerOff fanLight = model.getChild("Sphere001") if flickerOff: vizfx.setAmbientColor(viz.BLACK) fanLight.emissive(viz.BLACK) else: vizfx.setAmbientColor(viz.SLATE) fanLight.emissive(viz.WHITE) flickerOff = not flickerOff flickering = fanLight.playsound("Audio/Apartment Scene/light_flicker.wav") flickering.play() if __name__ == "__main__": vhilGo(rift=False) SCENE = viz.Scene1 MODEL = "Apartment_Final.OSGB" apartment = vizfx.addChild(MODEL, scene=SCENE) control.control(viz.MainView) apartment.setPosition([0, 0.17, 0]) apartment.setScale([30, 30, 30]) vizfx.setAmbientColor([0.1, 0.1, 0.1]) viz.MainView.setPosition([-2.2, 1.6, -1.2]) viz.MainView.setEuler([90, 0, 0]) viz.MainView.setEuler([90, 0, 0]) viz.MainView.getHeadLight().disable() rotateFan(model=apartment, scene=SCENE) addOutsideLighting(apartment, SCENE) vizact.ontimer2(0.1, 10, addFlickeringLight, apartment, SCENE)
# hfov: horizontal # The vfov must be supplied; the # hfov is optional. def init(vfov=None, hfov=None): global VFOV global HFOV VFOV = vfov print 'VFOV:',VFOV if hfov is None: ar = viz.MainWindow.getAspectRatio() print 'aspect ratio:',ar HFOV = vizmat.getHorizontalFOV(vertical=VFOV, aspectRatio=ar) else: HFOV = hfov print 'HFOV:',HFOV # computeFrustumPyramid(VFOV*vizmat.DEG_TO_RAD, HFOV*vizmat.DEG_TO_RAD) VFOV_DEFAULT = 40 # Vertical field of view in degrees of default-sized window if __name__ == '__main__': from vhil_devkit import * import keyboardcontrol init(vfov=VFOV_DEFAULT) vhilGo() keyboardcontrol.control(viz.MainView)
viz.phys.enable() viz.phys.setGravity(0,-.21,0) #Half Gravity ground = viz.add('tut_ground.wrl') # Add ground ground.collidePlane() # Make collideable plane logo = viz.add('logo.wrl',pos=[0,1,6]) # Add logo logo.collideMesh(bounce=1.5) # Collide and make it bounce a bit for x in range(10): for z in range(10): ball = viz.add('white_ball.wrl',pos=[-.5+.1*x,2.5+.1*z,6],scale=[.5,.5,.5]) ball.collideSphere() import keyboardcontrol keyboardcontrol.control(logo) logo.enable(viz.COLLIDE_NOTIFY) def onCollide(e): print 'colliding:',e.obj1.id, e.obj2.id viz.callback(viz.COLLIDE_BEGIN_EVENT, onCollide) # #""" #The bumpers are reacting to a collision event #with the balls by changing color. #Arrow keys: Move ball dropper #Spacebar: drops a ball. #""" #import viz #import vizact #import random
import viz from vhil_devkit import * import keyboardcontrol vhilGo() keyboardcontrol.control(MainView) ball = viz.add('ball.wrl') ball.setPosition([0,1.82,5]) box = ball.getBoundingBox() boxSize = box.size print str(boxSize) print 'center:',box.center import vizshape #sphere = vizshape.addSphere(1, flipFaces=True) prism = vizshape.addBox(size=boxSize, flipFaces=True) prism.setPosition(box.center) #import vizproximity #sensor = vizproximity.addBoundingBoxSensor(ball)
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)