def addDirectionalLights(scale, scene=viz.MainScene): global light, light2 light = vizfx.addDirectionalLight(pos=[-35*scale,43*scale,-40*scale], scene=scene) light.intensity(1) Color(light,230,140,30) light2 = vizfx.addDirectionalLight(euler=(135,-1,0), scene=scene) light2.intensity(1) Color(light2,230,140,30)
def addOutsideLighting(model=MODEL, scene=viz.MainScene): scenery = vizshape.addBox([2.8, 2.8, 2.8]) scenery.emissive(viz.SLATE) scenery.setPosition([1.15, 2.34, 4.73]) tex = viz.addTexture("resources/images/sfview.png") scenery.texture(tex) scenery.disable(viz.SHADOW_CASTING) light = vizfx.addDirectionalLight(scene=SCENE) light.quadraticattenuation(1) light.intensity(0.2) light.setPosition([0.24, 2, 3.73]) light.setEuler(144, 0, 0)
def setupLighting(self): viz.MainView.getHeadLight().remove() # Create Sky viz.clearcolor(viz.SKYBLUE) sky = viz.add('sky_day.osgb') sky.setScale(2, 2, 2) sky.setPosition(0, 0, 0) lightColor = [0.8, 0.7, 0.6] # Create directional lights sun = vizfx.addDirectionalLight(euler=([-120.00000, 24.50000, 0.00000]), color=lightColor) # Adjust ambient color vizfx.setAmbientColor([0.95, 0.95, 0.95])
female.setPosition([4,0,3]) female.setEuler(180,0,0) female.state(4) def react(): male.state(2) wait = vizact.waittime(3) scratchAndShrug = vizact.sequence(wait, vizact.animation(5),vizact.animation(7)) male.add(scratchAndShrug) def makeMove(): walk_over = vizact.walkTo([-.5,0,-2.2]) yield viztask.addAction( female, walk_over ) female.addAction(vizact.animation(2)) wait = vizact.waittime(3) yield male.addAction(wait) react() vizact.onkeydown(' ', viztask.schedule, makeMove) viz.MainView.setPosition([0,2,-5.5]) #viz.MainView.setEuler([0, 50, 0]) teapot = model.getChild('Teapot001') person = model.getChild('person') spinAction = vizact.spin(0,1,0,90,viz.FOREVER) slowSpinAction = vizact.spin(0,1,0,45,viz.FOREVER) light1 = vizfx.addDirectionalLight(euler=(0,90,0), color=viz.WHITE) light2 = vizfx.addSpotLight(euler=(0,90,0), color = viz.BLUE, spread=45, pos = [0,4,0])
print(tracker) # get the quality setting of the demo if specified DEMO_QUALITY_SETTING = max( 0, viz.getOption('DEMO_QUALITY_SETTING', default=4, type=int)) viz.setMultiSample(DEMO_QUALITY_SETTING * 2) # disable the head lamps since we're doing lighting ourselves for window in viz.getWindowList(): window.getView().getHeadLight().disable() else: vizconnect.go('./multiscript_vizconnect_config.py') # Add the local events (events specific to this demo) #vizconnect.go('vizconnect_config_local_events.py') # Load the vizconnect configuration. File: base_vizconnect_config2016.py vizfx.addDirectionalLight(euler=(0, 90, 0)) # Add a viewpoint so the user starts at [0,0,0]. vp = vizconnect.addViewpoint(pos=[0, 0, 0], posMode=vizconnect.VIEWPOINT_MATCH_BASE) # Enable physics so that objects may collide together. viz.phys.enable() # Add an environment model with collision mesh. env = vizfx.addChild('dojo.osgb') env.disable(viz.SHADOW_CASTING) env.collideMesh() # Add directional shadow light pointing down. light1 = vizfx.addDirectionalLight(shadow=viz.SHADOW_DEPTH_MAP,
def __init__(self, participant): self.visual_maze_instruktionen = { 'baseline_start': 'Zu Beginn wird eine Zusatzmessung aufgenommen.\n' 'Es geht gleich automatisch weiter...', 'baseline_standing': 'Halten Sie Ihre Augen offen und\n' 'entspannen sich.\n' 'Mit einem Klick,\n' 'beginnt die Messung', 'baseline_thrusting': 'Halten Sie Ihre Augen offen und\n' 'tasten wiederholt nach vorne.\n' 'Mit einem Klick,\n' 'beginnt die Messung.', 'baseline_end': 'Bitte beim Versuchsleiter melden.' } # call constructor of superclass super(VisualMaze, self).__init__(participant) #ground = viz.add('tut_ground.wrl') # Add ground # create scene of the experiment self.subject_id = participant.id self.scene = VisualMazeScene(participant.maze_config, self.subject) self.maze = None self.light = vizfx.addDirectionalLight(euler=(0, 90, 0), color=viz.WHITE) self.hand_tracker_id = None self.arm_tracker_id = None self.torso_tracker_id = None # permuted list of all 4 trial mazes L Z U S, with 24 subjects 1 permutation cycle is complete self.trial_list_all = [['Z', 'L', 'U', 'S'], ['L', 'Z', 'U', 'S'], ['U', 'L', 'Z', 'S'], ['L', 'U', 'Z', 'S'], ['Z', 'U', 'L', 'S'], ['U', 'Z', 'L', 'S'], ['U', 'Z', 'S', 'L'], ['Z', 'U', 'S', 'L'], ['S', 'U', 'Z', 'L'], ['U', 'S', 'Z', 'L'], ['Z', 'S', 'U', 'L'], ['S', 'Z', 'U', 'L'], ['S', 'L', 'U', 'Z'], ['L', 'S', 'U', 'Z'], ['U', 'S', 'L', 'Z'], ['S', 'U', 'L', 'Z'], ['L', 'U', 'S', 'Z'], ['U', 'L', 'S', 'Z'], ['Z', 'L', 'S', 'U'], ['L', 'Z', 'S', 'U'], ['S', 'Z', 'L', 'U'], ['Z', 'S', 'L', 'U'], ['L', 'S', 'Z', 'U'], ['S', 'L', 'Z', 'U']] # permuted list of all 3 objects to test in rvd task (G = Global Landmark, L = Local, S = Start) with 24 subjects 4 permutation cycles are complete self.rvd_list_all = [['G', 'L', 'S'], ['L', 'G', 'S'], ['S', 'G', 'L'], ['G', 'S', 'L'], ['L', 'S', 'G'], ['S', 'L', 'G'], ['G', 'L', 'S'], ['L', 'G', 'S'], ['S', 'G', 'L'], ['G', 'S', 'L'], ['L', 'S', 'G'], ['S', 'L', 'G'], ['G', 'L', 'S'], ['L', 'G', 'S'], ['S', 'G', 'L'], ['G', 'S', 'L'], ['L', 'S', 'G'], ['S', 'L', 'G'], ['G', 'L', 'S'], ['L', 'G', 'S'], ['S', 'G', 'L'], ['G', 'S', 'L'], ['L', 'S', 'G'], ['S', 'L', 'G']] # # keys for video recording # vidname = str(participant.id) + '_' + str(participant.control_style) + '.avi' # viz.setOption('viz.AVIRecorder.fps','25') # viz.setOption('viz.AVIRecorder.maxWidth','1280') # viz.setOption('viz.AVIRecorder.maxHeight', '720') # vizact.onkeydown('b', viz.window.startRecording, vidname) # vizact.onkeydown('e', viz.window.stopRecording) # ---- collision event params ---- # # objects handling current state of visual maze experiment # wall enter and exit collision event callbacks self.hand_in_wall = False self.head_in_wall = False # placeholders for visual feedback functions self.feedback_hand = None self.feedback_start_time = 0 self.feedback_duration = 0 self.new_touch_allowed = True self.feedback = vizact.sequence(vizact.waittime(0.5), vizact.fadeTo( 0, time=.2)) # event is 700 ms self.help_sphere = vizshape.addSphere(.1) self.help_sphere.color(viz.GREEN) self.help_sphere.visible(viz.OFF) # ---- Bookkeeping variables for behavioral data collection ---- # self.current_maze = None self.current_trial_run = None # ---- Reward tracking variables ---- # self.hand_hits = 0 self.head_hits = 0 self.local_landmark_hits = 0 self.duration = 0 self.start_return = 0 # pointing task self.pointing_task_on = False # RVD task objects self.rvd_task_on = False self.in_rvd_table = False self.rvd_table = vizshape.addCube(1) self.rvd_table.alpha(0.3) # make surface barely visible self.rvd_table.visible(viz.OFF) self.start_sign = viz.add('resources/start.dae') self.start_sign.setScale(.02, .02, .02) self.start_sign.visible(viz.OFF)
'press <b> to start the game\npress <k> to toggle the sensors\npress 1-5 for change different view point\npress <p> for to see particular landmarks', viz.SCREEN) screen_text.setScale(0.25, 0.25, 0.25) screen_text.setPosition(0, 0.6, 0) viz.setMultiSample(10) #vizconnect.go('vizconnect_config.py') viz.go() ground = viz.addChild('ground.osgb') ground.setPosition([00, -0.1, 0]) ground.setScale([40, 40, 40]) ########add sun and sky############################## sky = viz.addChild('sky_day.osgb') sun = vizfx.addDirectionalLight() sun.setScale(500, 500, 500) sun.color(5.0, 5.0, 5) sun.setEuler(90, 0, 0) sky.setPosition(500, 0, 500) sky.setScale(10, 10, 10) ###########main view position############################ viz.MainView.move([-100, 20, 140]) viz.MainView.setEuler([90, 0, 0]) viz.MainView.gravity(0.0) ####################sun_light##################################################### mylight = viz.addLight() mylight.position(0, 15, 0) mylight.direction(10, -10, -10)
viz.setMultiSample(4) viz.fov(60) vizconnect.go('vizconnect_config_htcvive.py') #run htc vive config script viz.go() viz.phys.enable() #set lab environment and light viz.clearcolor(0.7,0.7,0.8) viz.MainView.setPosition([9,3,15]) viz.MainView.setEuler(180, 0, 0) lab = viz.addChild('lab.osgb') lab.setPosition([0,0,0]) vizfx.addDirectionalLight(euler=(0,45,0)) env = viz.add(viz.ENVIRONMENT_MAP,'sky.jpg') dome = viz.add('skydome.dlc') dome.texture(env) #set up collider and avatar ground = lab.getChild('ground') # get ground ground.collidePlane(bounce = 0, friction = 0.01) # Make collideable plane #get table for experiment table = viz.addChild( 'table.wrl' ) table.setPosition([9,0.5,15]) table.collideBox( node='Leg1', bounce = 0, friction = 1 ) table.collideBox( node='Leg2', bounce = 0, friction = 1 ) table.collideBox( node='Leg3', bounce = 0, friction = 1 )
ori[1], ori[0], ori[2])) self.trackers[t]['values'][0].message(VAL_FMT.format('X', pos[0], ori[1])) self.trackers[t]['values'][1].message(VAL_FMT.format('Y', pos[1], ori[0])) self.trackers[t]['values'][2].message(VAL_FMT.format('Z', pos[2], ori[2])) for n in self.nodes.keys(): pos = self.nodes[n]['model'].getPosition(viz.ABS_GLOBAL) ori = self.nodes[n]['model'].getEuler(viz.ABS_GLOBAL) self.nodes[n]['ui'].message(FMT.format(pos[0], pos[1], pos[2], ori[1], ori[0], ori[2])) if __name__ == '__main__': """ If module is called directly, just display the debug view """ viz.setMultiSample(4) viz.go() hmd = steamvr.HMD() navigationNode = viz.addGroup() viewLink = viz.link(navigationNode, viz.MainView) viewLink.preMultLinkable(hmd.getSensor()) vizshape.addPlane(size=(100,100), color=(0.4, 0.4, 0.4)) headlight = viz.MainView.getHeadLight() headlight.disable() main_light = vizfx.addDirectionalLight(euler=(0,90,0), color=viz.WHITE) origin_light = vizfx.addPointLight(color=viz.WHITE, pos=(0,0,0)) debugger = SteamVRDebugOverlay(enable=True)
def __init__(self): # base class constructor viz.EventClass.__init__(self) self.desk = Model('finished_alley.dae') self.pin1 = Model('pin.dae') self.pin2 = Model('pin.dae') self.pin3 = Model('pin.dae') self.pin4 = Model('pin.dae') self.pin5 = Model('pin.dae') self.pin6 = Model('pin.dae') self.pin7 = Model('pin.dae') self.pin8 = Model('pin.dae') self.pin9 = Model('pin.dae') self.pin10 = Model('pin.dae') self.pins = {self.pin1,self.pin2,self.pin3,self.pin4,self.pin5,self.pin6,self.pin7,self.pin8,self.pin9,self.pin10} self.pinDist = 0.07 self.desk.setOrientation(self.desk.getX() + 1, self.desk.getY(), self.desk.getZ() + 4, .3, 0) self.pin1.setOrientation(1.05, self.desk.getY()-0.05, 2.85, .3, 0) self.pin2.setOrientation(1.05 - self.pinDist, self.desk.getY()-0.05, 2.85 - 0.5*self.pinDist, .3, 0) self.pin3.setOrientation(1.05 - self.pinDist, self.desk.getY()-0.05, 2.85 + 0.5*self.pinDist, .3, 0) self.pin4.setOrientation(1.05 - 2*self.pinDist, self.desk.getY()-0.05, 2.85, .3, 0) self.pin5.setOrientation(1.05 - 2*self.pinDist, self.desk.getY()-0.05, 2.85 + self.pinDist, .3, 0) self.pin6.setOrientation(1.05 - 2*self.pinDist, self.desk.getY()-0.05, 2.85 - self.pinDist, .3, 0) self.pin7.setOrientation(1.05 - 3*self.pinDist, self.desk.getY()-0.05, 2.85 + 0.5*self.pinDist, .3, 0) self.pin8.setOrientation(1.05 - 3*self.pinDist, self.desk.getY()-0.05, 2.85 - 0.5*self.pinDist, .3, 0) self.pin9.setOrientation(1.05 - 3*self.pinDist, self.desk.getY()-0.05, 2.85 - 1.5*self.pinDist, .3, 0) self.pin10.setOrientation(1.05 - 3*self.pinDist, self.desk.getY()-0.05, 2.85 + 1.5*self.pinDist, .3, 0) #self.desk.setPosition([0,.1,0]) # set up keyboard and timer callback methods self.callback(viz.KEYDOWN_EVENT,self.onKeyDown) self.callback(viz.MOUSEDOWN_EVENT,self.onMouseDown) self.callback(viz.TIMER_EVENT,self.onTimer) self.callback(viz.COLLIDE_BEGIN_EVENT,self.onCollideBegin) self.starttimer(1,.1,viz.FOREVER) #avatar's postion and rotation angle self.x = 7.5 self.z = 2.5 self.theta = 270 self.value = 0 self.ballMove = 0 self.bx = 7.5 self.bz = 2.85 self.picked = False self.thrown = False self.ball = Model('ball.dae') self.ball.setOrientation(self.x,.09,self.z, .1, 0) self.avatar = viz.add('vcc_female.cfg') mat = viz.Matrix() mat.postScale(.3,.3,.3) mat.postAxisAngle(0,1,0,self.theta) mat.postTrans(self.x,.1,self.z) self.avatar.setMatrix(mat) self.mode = "firstperson" self.spectator1 = viz.add('vcc_male.cfg') spec1x = 3.5 spec1z = .9 spec1theta = 0 spec1value = 0 mat = viz.Matrix() mat.postScale(.3,.3,.3) mat.postAxisAngle(0,1,0,spec1theta) mat.postTrans(spec1x,.1,spec1z) self.spectator1.setMatrix(mat) self.spectator1.state(3) self.spectator2 = viz.add('vcc_male2.cfg') spec2x = 4.5 spec2z = .9 spec2theta = 0 spec2value = 0 mat = viz.Matrix() mat.postScale(.3,.3,.3) mat.postAxisAngle(0,1,0,spec2theta) mat.postTrans(spec2x,.1,spec2z) self.spectator2.setMatrix(mat) self.spectator2.state(4) #lighting vizfx.addDirectionalLight(color = viz.WHITE, euler = (0,90,0)) self.pin1.node.collideBox() self.pin2.node.collideBox() self.pin3.node.collideBox() self.pin4.node.collideBox() self.pin5.node.collideBox() self.pin6.node.collideBox() self.pin7.node.collideBox() self.pin8.node.collideBox() self.pin9.node.collideBox() self.pin10.node.collideBox() self.desk.node.collideMesh() self.ball.node.collideSphere(bounce = 0) self.ball.node.enable(viz.COLLIDE_NOTIFY) for pin in self.pins: pin.node.enable(viz.COLLIDE_NOTIFY) self.ball.node.disable(viz.DYNAMICS) self.pin1.node.disable(viz.DYNAMICS) self.pin2.node.disable(viz.DYNAMICS) self.pin3.node.disable(viz.DYNAMICS) self.pin4.node.disable(viz.DYNAMICS) self.pin5.node.disable(viz.DYNAMICS) self.pin6.node.disable(viz.DYNAMICS) self.pin7.node.disable(viz.DYNAMICS) self.pin8.node.disable(viz.DYNAMICS) self.pin9.node.disable(viz.DYNAMICS) self.pin10.node.disable(viz.DYNAMICS)
randomization(pr, log_pr) hmd = steamvr.HMD() viz.link(hmd.getSensor(), viz.MainView, offset=[0, 0, .392]) set_graphics_quality() viz.go() ### SETUP ENVIRONMENT ### ######################### # set viewpoint (and shapes) #viz.MainView.setPosition([0,0,1.4]) # Create directional lights light1 = vizfx.addDirectionalLight(euler=(40, 20, 0), color=[0.9, 0.9, 0.9]) light2 = vizfx.addDirectionalLight(euler=(-65, 15, 0), color=[0.9, 0.9, 0.9]) # more lights mylight = viz.addLight() mylight.enable() mylight.position(0, 1, 0) mylight.spread(180) mylight.intensity(0.5) # disable headlight headLight = viz.MainView.getHeadLight() headLight.disable() # environment #