def showImageToBothEyes():
	global cam1
	global cam2
	
	video = viz.add('VideoCamera.dle')
	outP = video.getWebcamNames(available = False)
	print(outP)
	
	cam1 = video.addWebcam(id=0, size=(640,480))
	cam2 = video.addWebcam(id=1, size=(640,480))
	
	s = 3000
	focalLen = 0.00081566 * s
	planeHeight = 0.00126 * s
	planeWidth = 0.0022 * s
	camcenter_dX = (640-606.3966)*1.75*(10^-6) * s
	camcenter_dY = (360-310.6875)*1.75*(10^-6) * s

	pl_left = vizshape.addPlane(
		size = [planeWidth,planeHeight],
		axis = vizshape.AXIS_Z,
		cullFace = False
	)
	
	pl_right = vizshape.addPlane(
		size = [planeWidth,planeHeight],
		axis = vizshape.AXIS_Z,
		cullFace = False
	)
		
	pl_left.texture(cam1)
	
	pl_right.texture(cam2)
	
	pl_left.setParent(config.leftEyeNode)
	pl_left.setPosition([0,0,focalLen],viz.ABS_PARENT)	
	
	pl_right.setParent(config.rightEyeNode)
	pl_right.setPosition([0,0,focalLen],viz.ABS_PARENT)
	
	## Add code to update orientation with changes in head orientation
	headEuler_YPR = config.headTracker.getEuler()
	pl_left.setEuler([180+headEuler_YPR[0],0+headEuler_YPR[1],-90+headEuler_YPR[2]])
	pl_right.setEuler([180+headEuler_YPR[0],0+headEuler_YPR[1],-90+headEuler_YPR[2]])
	
	pl_left.renderToEye(viz.LEFT_EYE)
	pl_right.renderToEye(viz.RIGHT_EYE)
	
	# Press 'w' to change camera order
	vizact.onkeydown('w', changeCamID)
Пример #2
0
def placeMirror():
	
	mirrorPos = [0, 1.5, -2];
	
	global wall, mirrorRight, mirrorLeft, mirrorPlane
	wall = viz.addTexQuad()
	wall.setPosition(0, 0, mirrorPos[2] - 0.02)
	wall.setScale(20, 20, 1)
	# Apply nice repeating brick texture
	wallmatrix = vizmat.Transform()
	wallmatrix.setScale(20, 20, 1)
	wall.texmat( wallmatrix )
	bricks = viz.addTexture('brick.jpg')
	bricks.wrap(viz.WRAP_T, viz.REPEAT)
	bricks.wrap(viz.WRAP_S, viz.REPEAT)
	wall.texture(bricks)
	
	mirrorPlane = vizshape.addPlane()
	mirrorPlane.setPosition(mirrorPos, viz.ABS_GLOBAL)
	mirrorPlane.setEuler(0, 90, 0)
	mirrorPlane.setScale(0.09, 1, 0.05)

	windowBox = mirrorPlane.getBoundingBox(mode = viz.ABS_GLOBAL)
	x0 = windowBox.xmin
	x1 = windowBox.xmax
	y0 = windowBox.ymin
	y1 = windowBox.ymax
	z = windowBox.zmax

	viz.startlayer(viz.QUADS)
	viz.texcoord(0,0)
	viz.vertex( x0  , y0 , z )
	viz.texcoord(0,1)
	viz.vertex( x0  , y1, z )
	viz.texcoord(1,1)
	viz.vertex( x1  , y1, z)
	viz.texcoord(1,0)
	viz.vertex( x1  , y0 , z)

	mirrorRight = viz.endlayer( )
	mirrorLeft = mirrorRight.copy()	

	#specify the matrix
	m = viz.Matrix()
	#Try moving the mirror
	#print "z: " + str(z);
	m.setPosition([0, 0, z])
	m.setEuler(0, 0, 0)

	#Apply mirror settings to mirror object
	mirrorPlane.alpha(0.0)
	addMirror(mirrorRight,m,viz.RIGHT_EYE)
	addMirror(mirrorLeft,m,viz.LEFT_EYE)
	
	# Add collision
	mirrorPlane.collideBox()
	
	wall.visible(viz.OFF)
	mirrorRight.visible(viz.OFF)
	mirrorLeft.visible(viz.OFF)
Пример #3
0
    def _setup_clip_plane(self):
        """
		Create a plane with a sissors logo, a grid and a grey back.
		"""
        # Create the white center plane
        self._clip_plane = vizshape.addPlane(size=(.103, .103),
                                             axis=vizshape.AXIS_Y,
                                             cullFace=False,
                                             cornerRadius=0.0025,
                                             lighting=False)
        # Create the back side
        back = vizshape.addPlane(size=(.103, .103),
                                 axis=vizshape.AXIS_Y,
                                 cullFace=False,
                                 cornerRadius=0.0025,
                                 lighting=False,
                                 color=(0.7, 0.7, 0.7),
                                 parent=self._clip_plane)
        back.setPosition([0, 0.002, 0])
        # Create the front side with the sissors logo
        sissors = vizshape.addPlane(size=(.08, .08),
                                    axis=vizshape.AXIS_Y,
                                    cullFace=False,
                                    lighting=False,
                                    parent=self._clip_plane)
        sissors.setPosition([0, -0.002, 0])
        tex = viz.addTexture('assets/sissors.png')
        sissors.texture(tex)
        # Create the grid so the user sees better where the cut goes
        grid = vizshape.addGrid(size=(.5, .5),
                                step=.01,
                                boldStep=0.0,
                                axis=vizshape.AXIS_Y,
                                lighting=False,
                                parent=self._clip_plane)
        # Hide the objects until the clipping function is activated
        self._clip_plane.visible(False)
Пример #4
0
def setStage():

    global groundplane, groundtexture

    #	###should set this hope so it builds new tiles if you are reaching the boundary.
    #	fName = 'textures\strong_edge.bmp'
    #
    #	# add groundplane (wrap mode)
    #	groundtexture = viz.addTexture(fName)
    #	groundtexture.wrap(viz.WRAP_T, viz.REPEAT)
    #	groundtexture.wrap(viz.WRAP_S, viz.REPEAT)
    #
    #	groundplane = viz.addTexQuad() ##ground for right bends (tight)
    #	tilesize = 5000#300 #F***ING MASSIVE
    #	planesize = tilesize/5
    #	groundplane.setScale(tilesize, tilesize, tilesize)
    #	groundplane.setEuler((0, 90, 0),viz.REL_LOCAL)
    #	#groundplane.setPosition((0,0,1000),viz.REL_LOCAL) #move forward 1km so don't need to render as much.
    #	matrix = vizmat.Transform()
    #	matrix.setScale( planesize, planesize, planesize )
    #	groundplane.texmat( matrix )
    #	groundplane.texture(groundtexture)
    #	groundplane.visible(1)

    gsize = [1000, 1000]  #groundplane size, metres
    groundplane = vizshape.addPlane(size=(gsize[0], gsize[1]),
                                    axis=vizshape.AXIS_Y,
                                    cullFace=True)  ##make groundplane
    groundplane.texture(viz.add('black.bmp'))  #make groundplane black

    #Build dot plane to cover black groundplane
    ndots = 200000  #arbitrarily picked. perhaps we could match dot density to K & W, 2013?
    viz.startlayer(viz.POINTS)
    viz.vertexColor(viz.WHITE)
    viz.pointSize(2)
    for i in range(0, ndots):
        x = (random.random() - .5) * gsize[0]
        z = (random.random() - .5) * gsize[1]
        viz.vertex([x, 0, z])

    dots = viz.endLayer()
    dots.setPosition(0, 0, 0)
    dots.visible(1)
    groundplane.visible(1)
Пример #5
0
    def add_wall(name, size_xy, position, orientation, vis, proximity, scale):
        """
        Adds a maze wall object and returns it. Optionally equipped with a bounding proximity sensor.

        Args:
            name: name of the wall object
            size_xy: length of the wall object in x, y direction
            position: x, y, z position of the wall object
            orientation: Orientation values to set "pointing" direction of wall, i.e. vizshape.AXIS_X / Y / Z
            [Euler orientation values to set "pointing" direction of wall]
            vis: viz.ON or viz.OFF
            proximity: if True create PathArea proximity sensor
            [if True create BoundingBoxSensor proximity sensor around the wall]
            scale: scale factor or radius of PathArea sensor
            [scale factor or size of BoundingBoxSensor]

        Returns: a wall 3D object with optional BoundingBoxSensor proximity sensor.

        """

        wall = vizshape.addPlane(size=size_xy, axis=orientation)
        wall.name = name
        wall.setPosition(position)
        wall.visible(vis)
        wall.cullFace(True)

        wall.collideMesh()
        wall.disable(viz.DYNAMICS)

        # works only for 90 degree orientation steps, otherwise rotation of pre-created walls would be necessary
        # (-> programmers can't decide)

        normal_vector = [0, 0, 0]
        normal_vector[abs(orientation) - 1] = orientation / abs(orientation)

        if proximity:
            # wall.sensor = vizproximity.addBoundingBoxSensor(wall, scale=scale)
            wall.sensor = vizproximity.sensor(
                vizproximity.PathArea((wall[0], 0), radius=scale), None)

        return [wall, normal_vector]
def CreateTheRoom():

    """<START OF DEFINING THE WORLD>"""

    #disables the original light
    viz.disable(viz.LIGHT0)

    topLight = viz.addLight() 
    topLight.setPosition(0,4,0)
    topLight.setEuler( 0, 90 ,0 )
    #topLight.direction(0,-1,0) 
    topLight.spread(270) 
    topLight.intensity(2000) 
    #topLight.spotexponent(2)     
    sideLight = viz.addLight()
    sideLight.setPosition(0,5,0)
    sideLight.setEuler(0,0,90)

    #creates the floor plane to be 35x80
    #rotated around the Z axis(perpendicular to Y axis)
    floor = vizshape.addPlane(size=(35.0,80.0), axis=vizshape.AXIS_Y, cullFace=False)
    #makes the floor look like wood
    floor.texture(viz.addTexture('images/tile_wood.jpg'))
    #moves the floor +20 meters in the z direction
    floor.setPosition(0,0,20)

    """
    Could use Gabe's mocap interaface here to create a room easily
    and play with textures. 

    If performance is an issue, set cullFace to True.
    """
    #adds the wall(plane) farthest from the hand/person
    #35x10 meters**2
    #rotated around the X axis (perpendicular to Z axis)
    frontWall = vizshape.addPlane(size=(35,10), axis=vizshape.AXIS_Z, cullFace = False)
    #moves the wall to match the edge of the 
    frontWall.setPosition(0,5,60)
    #makes the wall appear white
    frontWall.color(viz.WHITE)

    #adds the wall(plane) that when facing the frontWall, is to the camera's left
    #wall is 80x10 meters**2
    #wall is rotated about the Y axis(perpendicular to X axis)
    leftWall = vizshape.addPlane(size=(80,10), axis=vizshape.AXIS_X, cullFace = False)
    #shifts the wall to match the edge of the floor
    leftWall.setPosition(-17.5,5,20)
    #makes the wall appear white
    leftWall.color(viz.WHITE)

    #adds a wall(plane) that when facing the frontWall is to the camera's right
    #wall is 80x10 meters**2
    #wall is rotated about the Y axis(perpendicular to X axis)
    rightWall = vizshape.addPlane(size=(80,10), axis=vizshape.AXIS_X, cullFace = False)
    #shifts the wall to match the edge of the floor
    rightWall.setPosition(17.5,5,20)
    #makes the wall appear white
    rightWall.color(viz.WHITE)

    #adds a wall(plane) that when facing the frontWall is to the camera's back
    #wall is 35x10 meters**2
    #wall is rotated about the X axis(perpendicular to Z axis)
    backWall = vizshape.addPlane(size=(35,10), axis=vizshape.AXIS_Z, cullFace = False)
    #shifts the wall to match the edge of the floor
    backWall.setPosition(0,5,-20)
    #makes the wall appear white
    backWall.color(viz.WHITE)

    #adds a ceiling(plane) that when facing the frontWall is to the camera's topside
    #wall is 35x80 meters**2
    #wall is rotated about the Z axis(perpendicular to Y axis)
    ceiling = vizshape.addPlane(size=(35.0,80.0), axis=vizshape.AXIS_Y, cullFace=False)
    #makes the ceiling appear Skyblue in color
    ceiling.color(viz.SKYBLUE)
    #shifts the ceiling to rest on top of the four walls
    ceiling.setPosition(0,10,20)

    #add a meter marker at 0 meters along the z axis of the room
    #meter0 = vizshape.addPlane(size = (5,.3), axis = vizshape.AXIS_Y, cullFace = False)
    #meter0.setPosition(0,.3, 0)
    #makes the meter marker appear yellow
    #meter0.color(viz.WHITE)


    """</END OF DEFINING THE WORLD>"""
Пример #7
0
world_axes = vizshape.addAxes()
X = viz.addText3D('X',pos=[1.1,0,0],color=viz.RED,scale=[0.3,0.3,0.3],parent=world_axes)
Y = viz.addText3D('Y',pos=[0,1.1,0],color=viz.GREEN,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
Z = viz.addText3D('Z',pos=[0,0,1.1],color=viz.BLUE,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)


#grids are good
grid = vizshape.addGrid(color=[0.2]*3)
viz.clearcolor(viz.GRAY)

#Establish and translate our first cylinder
cylinder1= vizshape.addCylinder(height=1.0,radius=0.5,topRadius=None,bottomRadius=None,axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)
cylinder1= cylinder1.translate(2,2,5)

#create our first plane
plane1= vizshape.addPlane(size=(20.0,20.0),axis=vizshape.AXIS_X, cullFace=False)

#Establish and translate our second cylinder

cylinder2= vizshape.addCylinder(height=1.0,radius=0.5,topRadius=None,bottomRadius=None,axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)
cylinder2= cylinder2.translate(-2,2,5)
#Create proximity manager
manager = vizproximity.Manager()
manager.setDebug(viz.ON)
#create sensors
cylinder1_sensor= vizproximity.Sensor(vizproximity.Box([2,2,2],center=[2,2,5]),source = cylinder1)
manager.addSensor(cylinder1_sensor)

cylinder2_sensor= vizproximity.Sensor(vizproximity.Box([2,2,2],center=[-2,2,5]),source = cylinder2)
manager.addSensor(cylinder2_sensor)
plane1_sensor= vizproximity.Sensor(vizproximity.Box([1,20,20],center=[0,0,0]),source = cylinder2)
Пример #8
0
	def __init__(self):
		"""sets up viewcube and principle planes"""
		#Should appear ontop of podium
		
		self.modeCounter = 0 #Will be used to determine mode
		SF = 1 #Scale box
		
		#------------(AP/RL/SI) + cube mode setup-------------
		
		#add text objects set positions
		self.anterior = viz.addText('Anterior',pos = [0 ,SF*.5 ,SF*.5])
		self.posterior = viz.addText('Posterior',pos = [0, SF*.5 ,SF*-.5])
		self.left = viz.addText('Left', pos = [SF*-.5 ,SF*.5 ,0])
		self.right = viz.addText('Right', pos = [SF*.5 ,SF*.5 ,0])
		self.superior = viz.addText('Superior', pos = [0 ,SF*1.0 ,0])
		self.inferior = viz.addText('Inferior', pos = [0 ,SF*.01 ,0])
		
		#set orientation
		self.anterior.setEuler([180,0,0])
		self.posterior.setEuler([0,0,0])
		self.left.setEuler([90,0,0])
		self.right.setEuler([-90,0,0])
		self.superior.setEuler([0,90,0])
		self.inferior.setEuler([0,90,0])
		
		#set scale
		self.anterior.setScale([.1,.1,.1])
		self.posterior.setScale([.1,.1,.1])
		self.left.setScale([.1,.1,.1])
		self.right.setScale([.1,.1,.1])
		self.superior.setScale([.1,.1,.1])
		self.inferior.setScale([.1,.1,.1])
		
		#set each text object to be centered
		self.anterior.alignment(viz.ALIGN_CENTER_CENTER)
		self.posterior.alignment(viz.ALIGN_CENTER_CENTER)
		self.left.alignment(viz.ALIGN_CENTER_CENTER)
		self.right.alignment(viz.ALIGN_CENTER_CENTER)
		self.superior.alignment(viz.ALIGN_CENTER_CENTER)
		self.inferior.alignment(viz.ALIGN_CENTER_CENTER)
	
		#turn off rendering
		self.anterior.disable([viz.RENDERING])
		self.posterior.disable([viz.RENDERING])
		self.left.disable([viz.RENDERING])
		self.right.disable([viz.RENDERING])
		self.superior.disable([viz.RENDERING])
		self.inferior.disable([viz.RENDERING])

		#consider changing size, font, shading etc.
		
		#add cube
		RADIUS = .5 *SF
		self.cube = wireframeCube([RADIUS,RADIUS,RADIUS])
		self.cube.setPosition([0,RADIUS, 0] , viz.ABS_PARENT)
		
		#turn off visability
		self.cube.visible(viz.OFF) 
		
		#---------------principle plane setup------------------------
		self.frontalPlane    = vizshape.addPlane(size = [1*SF ,1*SF] , axis = vizshape.AXIS_Z ,cullFace = False)
		self.transversePlane = vizshape.addPlane(size = [1*SF ,1*SF] , axis = vizshape.AXIS_Y ,cullFace = False)
		self.sagittalPlane   = vizshape.addPlane(size = [1*SF ,1*SF] , axis = vizshape.AXIS_X , cullFace = False)
		
		#setPosition(up in y so that origin is at bottom)
		self.frontalPlane.setPosition([0,SF*.5,0])
		self.transversePlane.setPosition([0,SF*.5,0])
		self.sagittalPlane.setPosition([0,SF*.5,0])
	
		#set alpha
		self.frontalPlane.alpha(.5)
		self.transversePlane.alpha(.5)
		self.sagittalPlane.alpha(.5)
		
		#set color
		self.frontalPlane.color([1,1,.5])
		self.transversePlane.color([1,1,.5])
		self.sagittalPlane.color([1,1,.5])
		
		#add text labels to upper corners of planes
		self.frontalLabel  = viz.addText('Frontal Plane',pos = [.5*SF ,SF*.5 , .01*SF]) #.01 prevents overlap with plane
		self.transverseLabel  = viz.addText('Transverse Plane',pos = [-.5*SF , .01*SF ,SF*.5]) 
		self.sagittalLabel = viz.addText('Sagittal Plane',pos = [.01*SF ,SF*.5 ,SF*-.5])
		
		#scale text labels
		self.frontalLabel.setScale([.1,.1,.1])
		self.transverseLabel.setScale([.1,.1,.1])
		self.sagittalLabel.setScale([.1,.1,.1])
		
		#set planes to be parents of labels
		self.frontalLabel.setParent(self.frontalPlane)
		self.transverseLabel.setParent(self.transversePlane)
		self.sagittalLabel.setParent(self.sagittalPlane)

		#orient text labels
		self.frontalLabel.setEuler([180,0,0])
		self.transverseLabel.setEuler([0,90,0])
		self.sagittalLabel.setEuler([-90,0,0])
		
		#set alignment of Text labels
		self.frontalLabel.alignment(viz.ALIGN_LEFT_TOP)
		self.transverseLabel.alignment(viz.ALIGN_LEFT_TOP)
		self.sagittalLabel.alignment(viz.ALIGN_LEFT_TOP)
		
		#disable rendering on planes
		self.frontalPlane.disable([viz.RENDERING])
		self.transversePlane.disable([viz.RENDERING])
		self.sagittalPlane.disable([viz.RENDERING])
		
		#disable rendering of Text labels
		self.frontalLabel.disable([viz.RENDERING])
		self.transverseLabel.disable([viz.RENDERING])
		self.sagittalLabel.disable([viz.RENDERING])
world_axes = vizshape.addAxes()
X = viz.addText3D('X',pos=[1.1,0,0],color=viz.RED,scale=[0.3,0.3,0.3],parent=world_axes)
Y = viz.addText3D('Y',pos=[0,1.1,0],color=viz.GREEN,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
Z = viz.addText3D('Z',pos=[0,0,1.1],color=viz.BLUE,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
#grids are good
grid = vizshape.addGrid(color=[0.2]*3)
viz.clearcolor(viz.GRAY)

#Create proximity manager
manager = vizproximity.Manager()
manager.setDebug(viz.ON)



#create our bisecting plane
mid_plane= vizshape.addPlane(size=(.00001,.00001),axis=vizshape.AXIS_X, cullFace=False)

start_node= vizshape.addCylinder(height1, radius=.00000000005,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)
end_node= vizshape.addCylinder(height1, radius=.00000001,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)
left_node1=vizshape.addCylinder(height1, radius= .000001,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)        
left_node2=vizshape.addCylinder(height1, radius= .000001,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)        
left_node3=vizshape.addCylinder(height1, radius= .000001,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)        


right_node1=vizshape.addCylinder(height1, radius=.00000001,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)
right_node2=vizshape.addCylinder(height1, radius=.00000001,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)
right_node3=vizshape.addCylinder(height1, radius=.00000001,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)


left_plane1= vizshape.addPlane(size=(1*scale_x1,1*scale_x1,),axis=vizshape.AXIS_Y, cullFace=False)
right_plane1= vizshape.addPlane(size=(1*scale_x1,1*scale_x1,),axis=vizshape.AXIS_Y, cullFace=False)
Пример #10
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)
viz.clearcolor(viz.SKYBLUE)

viz.MainView.getHeadLight().enable()

viz.MainView.setPosition([5.12,-2.56,-1]) # Set the camera center based on the image resolution, 
											# y is negative so that pixel cordinates match vizard coordinates

viz.phys.enable()

img = cv2.imread('LineImage.jpg')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

wallUpZ = vizshape.addPlane(
	size = [10.24,5.12],	# Set the image plane to match the exact resolution of image in metres
	axis = -vizshape.AXIS_Z,
	cullFace = False
)
wallUpZ.setPosition(5.12,-2.56,6.0)	# Set the imaple plane center based on the image resolution

pic = viz.addTexture('LineImage.jpg')
wallUpZ.texture(pic)

midX = 512 # Based on horizontal image size

def createPhysicalObjects():
	global midX
	minLineLength = 3
	maxLineGap = 0.5
	
	edge = cv2.Canny(gray,100,200)
Пример #12
0
                   (-10, 0.05, -5)]]
scaleFactors = [0.15, 1.8, 1.25, 1.8]

#trials per object
trials_per_object = 4
initial_collect_per_object = 2

#timing
ITI = 2  #intertrial interval, in seconds

##env shape
global radius
radius = 14.5  #in meters, made global for convenience so be careful

##ground
ground = vizshape.addPlane(size=(40.0, 40.0), axis=vizshape.AXIS_Y)
ground.setPosition(0, 0, 0)
t1 = viz.addTexture('tex2.jpg', wrap=viz.REPEAT)
ground.texture(t1)
ground.texmat(viz.Matrix.scale(20, 20, 1))

##sky color
viz.clearcolor(0.1, 0.1, 0.2)

###CONTEXT GEN FUNCTION####


def ContextGen(runNum):

    if runNum % 2 == 0:
        if subject % 2 == 0:
Пример #13
0
#world_axes = vizshape.addAxes()
#X = viz.addText3D('X',pos=[1.1,0,0],color=viz.RED,scale=[0.3,0.3,0.3],parent=world_axes)
#Y = viz.addText3D('Y',pos=[0,1.1,0],color=viz.GREEN,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
#Z = viz.addText3D('Z',pos=[0,0,1.1],color=viz.BLUE,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
#grids are good
grid = vizshape.addGrid(color=[0.2]*3)
viz.clearcolor(viz.GRAY)

#Create proximity manager
manager = vizproximity.Manager()
manager.setDebug(viz.ON)



#create our bisecting plane
mid_plane= vizshape.addPlane(size=(.00001,.00001),axis=vizshape.AXIS_X, cullFace=False)

start_node= vizshape.addCylinder(height1, radius=.00000000005,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)
end_node= vizshape.addCylinder(height1, radius=.00000001,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)
end_box=(vizshape.addBox([.06,.06,.06],right=True,left=True,top=True,bottom=True, front=True,back=True, splitFaces=False, color=viz.RED))
left_node1=vizshape.addCylinder(height1, radius= .000001,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)        
#left_node2=vizshape.addCylinder(height1, radius= .000001,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)        
#left_node3=vizshape.addCylinder(height1, radius= .000001,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)        


right_node1=vizshape.addCylinder(height1, radius=.00000001,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)
#right_node2=vizshape.addCylinder(height1, radius=.00000001,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)
#right_node3=vizshape.addCylinder(height1, radius=.00000001,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)
#CHANGE: changed start_box's dimensions to max_size from .06 did the same w/ the start_sensor
table= vizshape.addBox([50,.775,50],right=True,left=True,top=True,bottom=True, front=True,back=True, splitFaces=False, color= viz.PURPLE)
start_node= vizshape.addBox([.00001, .000001, .0000001],right=True,left=True,top=True,bottom=True, front=True,back=True, splitFaces=False, color=viz.BLUE)
def CreateTheRoom(room):

    viz.disable(viz.LIGHT0)

    room.topLight = viz.addLight()
    room.topLight.setPosition(0, 4, 0)
    room.topLight.setEuler(-45, 90, 0)

    room.topLight.spread(270)
    room.topLight.intensity(2)

    room.sideLight = viz.addLight()
    room.sideLight.setPosition(0, 1, 0)
    room.sideLight.setEuler(45, 0, -90)
    #see if needs to be put to 360 -room.sideLight.spread(270)
    room.sideLight.intensity(1.2)

    #room.backLight = viz.addLight()
    #room.backLight.setPosition(0,1,0)
    #room.backLight.setEuler(180,0,0)
    #room.backLight.spread(270)
    #room.backLight.intensity(2)

    #creates the floor plane to be 35x80
    #rotated around the Z axis(perpendicular to Y axis)
    room.floor = vizshape.addPlane(size=(35.0, 80.0),
                                   axis=vizshape.AXIS_Y,
                                   cullFace=False)
    #makes the floor look like wood
    room.floor.texture(viz.addTexture('images/tile_wood.jpg'))
    #moves the floor +20 meters in the z direction
    room.floor.setPosition(0, 0, 20)

    #adds the wall(plane) farthest from the hand/person
    #35x10 meters**2
    #rotated around the X axis (perpendicular to Z axis)
    room.frontWall = vizshape.addPlane(size=(35, 10),
                                       axis=-vizshape.AXIS_Z,
                                       cullFace=False)
    #makes the front wall look like wall
    #room.frontWall.texture(viz.addTexture('images/tile_gray.jpg'))
    #moves the wall to match the edge of the
    room.frontWall.setPosition(0, 5, 25)
    #makes the wall appear white
    room.frontWall.color(viz.GRAY)

    #adds the wall(plane) that when facing the frontWall, is to the camera's left
    #wall is 80x10 meters**2
    #wall is rotated about the Y axis(perpendicular to X axis)
    room.leftWall = vizshape.addPlane(size=(80, 10),
                                      axis=-vizshape.AXIS_X,
                                      cullFace=False)
    #makes the left wall look like wall
    room.leftWall.texture(viz.addTexture('images/tile_gray.jpg'))
    #shifts the wall to match the edge of the floor
    room.leftWall.setPosition(-17.5, 5, 20)
    #makes the wall appear white
    room.leftWall.color(viz.GRAY)

    #adds a wall(plane) that when facing the frontWall is to the camera's right
    #wall is 80x10 meters**2
    #wall is rotated about the Y axis(perpendicular to X axis)
    room.rightWall = vizshape.addPlane(size=(80, 10),
                                       axis=-vizshape.AXIS_X,
                                       cullFace=False)
    #makes the right wall look like wall
    room.rightWall.texture(viz.addTexture('images/tile_gray.jpg'))
    #shifts the wall to match the edge of the floor
    room.rightWall.setPosition(17.5, 5, 20)
    #makes the wall appear white
    room.rightWall.color(viz.GRAY)

    #adds a wall(plane) that when facing the frontWall is to the camera's back
    #wall is 35x10 meters**2
    #wall is rotated about the X axis(perpendicular to Z axis)
    room.backWall = vizshape.addPlane(size=(35, 10),
                                      axis=vizshape.AXIS_Z,
                                      cullFace=False)
    #shifts the wall to match the edge of the floor
    room.backWall.setPosition(0, 5, -20)
    room.backWall.color(viz.GRAY)
    #adds texture to backWall
    #room.backWall.texture(viz.addTexture('images/tile_slate.jpg'))
    #makes the wall appear white
    room.backWall.color(viz.GRAY)

    #adds a ceiling(plane) that when facing the frontWall is to the camera's topside
    #wall is 35x80 meters**2
    #wall is rotated about the Z axis(perpendicular to Y axis)
    room.ceiling = vizshape.addPlane(size=(35.0, 80.0),
                                     axis=vizshape.AXIS_Y,
                                     cullFace=False)
    #makes the ceiling appear Skyblue in color
    room.ceiling.color(viz.SKYBLUE)
    #shifts the ceiling to rest on top of the four walls
    room.ceiling.setPosition(0, 10, 20)

    #add a meter marker at 0 meters along the z axis of the room
    #meter0 = vizshape.addPlane(size = (5,.3), axis = vizshape.AXIS_Y, cullFace = False)
    #meter0.setPosition(0,.3, 0)
    #makes the meter marker appear yellow
    #meter0.color(viz.WHITE)

    #adds a wall(plane) that when facing the frontWall is to the camera's back
    #wall is 35x10 meters**2
    #wall is rotated about the X axis(perpendicular to Z axis)
    room.ballPlane = vizshape.addPlane(size=(2, 2),
                                       axis=vizshape.AXIS_Z,
                                       cullFace=False)
    #shifts the wall to match the edge of the floor
    room.ballPlane.setPosition(0, 5, -20)
    #makes the wall appear white
    room.ballPlane.color(viz.WHITE)
    room.ballPlane.alpha(0.0)

    room.ball = vizshape.addSphere(radius=0.04, color=viz.RED)
    room.paddle = vizshape.addCylinder(height=0.03,
                                       radius=0.15,
                                       color=viz.RED,
                                       axis=vizshape.AXIS_Z)
    room.paddle.alpha(1)
    room.cycEyeNode = vizshape.addCone(radius=0.05,
                                       height=0.17,
                                       color=viz.PURPLE,
                                       axis=vizshape.AXIS_Z)
    room.cycEyeNode.alpha(1)
    if (room.visualizeModelOutput == True):
        room.paddleCloneA = vizshape.addCylinder(height=0.05,
                                                 radius=0.15,
                                                 color=viz.ORANGE,
                                                 axis=vizshape.AXIS_Z)
        room.paddleCloneA.alpha(.80)
        room.paddleCloneB = vizshape.addCylinder(height=0.05,
                                                 radius=0.15,
                                                 color=viz.ORANGE,
                                                 axis=vizshape.AXIS_Z)
        room.paddleCloneB.alpha(.70)
        room.paddleCloneC = vizshape.addCylinder(height=0.05,
                                                 radius=0.15,
                                                 color=viz.ORANGE,
                                                 axis=vizshape.AXIS_Z)
        room.paddleCloneC.alpha(.60)
        room.paddleCloneD = vizshape.addCylinder(height=0.05,
                                                 radius=0.15,
                                                 color=viz.ORANGE,
                                                 axis=vizshape.AXIS_Z)
        room.paddleCloneD.alpha(.50)
        room.paddleCloneE = vizshape.addCylinder(height=0.05,
                                                 radius=0.15,
                                                 color=viz.ORANGE,
                                                 axis=vizshape.AXIS_Z)
        room.paddleCloneE.alpha(.40)
        room.paddleCloneF = vizshape.addCylinder(height=0.05,
                                                 radius=0.15,
                                                 color=viz.ORANGE,
                                                 axis=vizshape.AXIS_Z)
        room.paddleCloneF.alpha(.30)
        room.paddleCloneG = vizshape.addCylinder(height=0.05,
                                                 radius=0.15,
                                                 color=viz.ORANGE,
                                                 axis=vizshape.AXIS_Z)
        room.paddleCloneG.alpha(.20)
    if (room.renderGaze == True):
        room.gazePoint = vizshape.addSphere(radius=0.0005, color=viz.GREEN)
        room.gazePoint.setParent(room.cycEyeNode)

    room.male = viz.add('vcc_male.cfg')
    room.male.alpha(0.0)
    armBone = room.male.getBone('Bip01 R UpperArm')
    armBone.lock()
    #armBone.setEuler(0, 0, 0)

    armBone = room.male.getBone('Bip01 L UpperArm')
    armBone.lock()
    armBone.setEuler(-70, 0, 0)
    ForearmBone = room.male.getBone('Bip01 R Forearm')
    ForearmBone.lock()
    ForearmBone.setEuler(100, -90, 155)

    hand = room.male.getBone('Bip01 R Hand')
    hand.lock()
    hand.setEuler(0, -90, 0.0)

    room.squash = viz.addChild('Squash_Racquet.3ds')
    room.squash.scale(0.01, 0.01, 0.01)
    room.squash.setPosition(*hand.getPosition(mode=viz.ABS_GLOBAL) -
                            np.array([.55, -0.2, -0.2]),
                            mode=viz.ABS_GLOBAL)
    room.squash.setEuler([0, 0, 15])

    #room.squash.setQuat(hand.getQuat())
    return room
Пример #15
0
# globalAudio()


#===========================
#Enable full screnn anti-aliasing (FSAA) to smooth out edges
viz.setMultiSample(4)
viz.fov(60) #***How do we lock fov?

global_sphere = vizshape.addSphere(radius=128, slices=256)
global_sphere.setPosition([0,0,0])
global_sphere.setEuler(180,0,0) #rotating
#Setting hints for Vizard renderer
global_sphere.disable(viz.CULL_FACE) #Render interior, not exterior of sphere
global_sphere.disable(viz.LIGHTING) #Show full brightness of image, ignoring shading

global_plane = vizshape.addPlane(size=(5,5), axis=vizshape.AXIS_Z, cullFace = True)
global_plane.setEuler(-180,0,0)
global_plane.setPosition(5,0,10)
global_plane.disable(viz.LIGHTING)
global_plane.visible(viz.OFF)


#===========================

def define_scene_tree():

	#==================================================================
    #level1
    this_node = Node()
    this_node.image =  "elephantMerc/1start.jpg"
    this_node.info_image = "textboxes/1. welcome screen_1024x1024.png"
Пример #16
0
    def createVisualObjects(self):

        self.IOD = 0.06
        
        # create a node3D leftEyeNode
        self.cyclopEyeNode = vizshape.addSphere(0.015, color = viz.GREEN)
        self.cyclopEyeNode.alpha(0.3)
        #cyclopEyeNode.visible(viz.OFF)
        self.cyclopEyeNode.setPosition(*self.rawDataStruct['view_Pos_XYZ'][:,0])
        self.cyclopEyeNode.setQuat(*self.rawDataStruct['view_Quat_WXYZ'][:,0])

        # create a node3D rightEyeNode
        self.rightEyeNode = vizshape.addSphere(0.015, color = viz.RED)
        #rightEyeNode.visible(viz.OFF)
        self.rightEyeNode.setParent(self.cyclopEyeNode)
        self.rightEyeNode.setPosition(self.IOD/2, 0, 0.0,viz.ABS_PARENT)
        self.rightEyeNode.alpha(0.3)
    #    right_sphere = gazeSphere(eyeTracker,viz.RIGHT_EYE,rightEyeNode,[clientWindowID],sphereColor=viz.ORANGE)
    #    rightGazeVector = gazeVector(eyeTracker,viz.RIGHT_EYE,rightEyeNode,[clientWindowID],gazeVectorColor=viz.ORANGE)
    #    right_sphere.toggleUpdate()
    #    rightGazeVector.toggleUpdate()
    #    right_sphere.node3D.alpha(0.7)    


        # create a node3D leftEyeNode
        self.leftEyeNode = vizshape.addSphere(0.015, color = viz.BLUE)
        #leftEyeNode.visible(viz.OFF)
        self.leftEyeNode.setParent(self.cyclopEyeNode)
        self.leftEyeNode.setPosition(-self.IOD/2, 0, 0.0,viz.ABS_PARENT)
        self.leftEyeNode.alpha(0.3)
    #    left_sphere = gazeSphere(eyeTracker,viz.LEFT_EYE,leftEyeNode,[clientWindowID],sphereColor=viz.YELLOW)
    #    leftGazeVector = gazeVector(eyeTracker,viz.LEFT_EYE,leftEyeNode,[clientWindowID],gazeVectorColor=viz.YELLOW)
    #    left_sphere.toggleUpdate()
    #    leftGazeVector.toggleUpdate()
    #    left_sphere.node3D.alpha(0.7)
        self.hmdDisplay = vizshape.addPlane([0.126, 0.071], axis = -vizshape.AXIS_Z, color = viz.GRAY)
        self.hmdDisplay.alpha(0.3)
        self.hmdDisplay.setParent(self.cyclopEyeNode)
        self.hmdDisplay.setPosition([0,0,0.0725], viz.ABS_PARENT) # 0.0725

        self.pixelatedBall = vizshape.addCircle(0.001, axis = -vizshape.AXIS_Z, color = viz.WHITE)
        self.pixelatedBall.setParent(self.hmdDisplay)
        self.pixelatedBall.setPosition([0,0,0])
        self.pixelatedBall.alpha(1)
        
        self.eyePOR = vizshape.addCircle(0.001, axis = -vizshape.AXIS_Z, color = viz.GREEN)
        self.eyePOR.setParent(self.hmdDisplay)
        self.eyePOR.setPosition([0,0,0])
        self.eyePOR.alpha(1)

        self.rightPOR = vizshape.addCircle(0.001, axis = -vizshape.AXIS_Z, color = viz.RED)
        self.rightPOR.setParent(self.hmdDisplay)
        self.rightPOR.setPosition([0,0,0])
        self.rightPOR.alpha(1)

        self.leftPOR = vizshape.addCircle(0.001, axis = -vizshape.AXIS_Z, color = viz.BLUE)
        self.leftPOR.setParent(self.hmdDisplay)
        self.leftPOR.setPosition([0,0,0])
        self.leftPOR.alpha(1)



        #creats a sphere(the ball) with radius of 5cm
        self.ball = vizshape.addSphere(radius = .08)
        #colors the ball red
        self.ball.color(viz.YELLOW)
        self.ball.visible(True)
        self.ball.setParent(self.cyclopEyeNode)

        self.Origin = vizshape.addAxes()
        self.Origin.setPosition(-5.5,0.1,8)
    #    #creats a sphere(the ball) with radius of 5cm
    #    #Head = vizshape.addCone( radius = 0.5, height = 0.8)
    #    Head = vizshape.addArrow(1, color = viz.YELLOW_ORANGE)
    #    #colors the ball red
    #    Head.color(viz.PURPLE)
    #    Head.visible(True)
    #    Head.setScale(.2,.2,.3)

        #creats a sphere(the hand) with radius of 10cm
        self.Hand = vizshape.addCylinder( height = 0.02, radius = 0.2, axis = vizshape.AXIS_Z)
        #colors the hand red
        self.Hand.color(viz.RED)
        self.Hand.visible(True)

        # Creating a Line to represent Cyclopean Eye Gaze Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.GREEN)
        self.eyeGazeVector = viz.endLayer() # Object will contain both points and lines
        self.eyeGazeVector.visible(True)
        self.eyeGazeVector.setParent(self.cyclopEyeNode)
        self.eyeGazeVector.pointSize(10)
        #rightGazeVector.setScale(5,5,5)
        self.eyeGazeSphere = vizshape.addSphere(0.02, color = viz.GREEN)
        self.eyeGazeSphere.setParent(self.cyclopEyeNode)


        # Creating a Line to represent Right Eye Gaze Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.RED)
        self.rightGazeVector = viz.endLayer() # Object will contain both points and lines
        self.rightGazeVector.visible(True)
        #rightGazeVector.setParent(rightEyeNode)
        self.rightGazeVector.pointSize(10)
        #rightGazeVector.setScale(5,5,5)
        self.rightGazeSphere = vizshape.addSphere(0.02, color = viz.RED)
        self.rightGazeSphere.setParent(self.rightEyeNode)
        self.rightGazeSphere.visible(False)

        # Creating a Line to represent Left Eye Gaze Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.BLUE)
        self.leftGazeVector = viz.endLayer() # Object will contain both points and lines
        self.leftGazeVector.visible(True)
        #leftGazeVector.setParent(leftEyeNode)
        #leftGazeVector.setScale(5,5,5)
        self.leftGazeSphere = vizshape.addSphere(0.02, color = viz.BLUE)
        self.leftGazeSphere.setParent(self.leftEyeNode)
        self.leftGazeSphere.visible(False)


        # Creating a Line to represent Eye-Ball Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.YELLOW)
        self.EyeBallLine = viz.endLayer() # Object will contain both points and lines
        self.EyeBallLine.visible(False)
        #EyeBallLine.setScale(5,5,5)

        self.male = viz.add('ktex.obj') 
        #male.state(1) #looping idle animation
        #self.headBone = self.male.getBone('Bip01 Head')
        #self.headBone.lock()
        self.male.setParent(self.cyclopEyeNode)
Пример #17
0
    def createTheRoom(self):

        """<START OF DEFINING THE WORLD>"""
        self.setLighting()


        #creates the floor plane to be 35x80
        #rotated around the Z axis(perpendicular to Y axis)
        self.floor = vizshape.addPlane(size=(self.roomWidth, self.roomLength), axis=vizshape.AXIS_Y, cullFace=False)
        #makes the floor look like wood
        self.floor.texture(viz.addTexture('images/tile_wood.jpg'))
        #moves the floor +20 meters in the z direction
        self.floor.setPosition(0,0,0)
        #floor.alpha(0.8)

        #adds a ceiling(plane) that when facing the frontWall is to the camera's topside
        #wall is 35x80 meters**2
        #wall is rotated about the Z axis(perpendicular to Y axis)
        self.ceiling = vizshape.addPlane(size=(self.roomWidth, self.roomLength), axis=-vizshape.AXIS_Y, cullFace=False)
        #makes the ceiling appear Skyblue in color
        self.ceiling.color(viz.CYAN)
        #shifts the ceiling to rest on top of the four walls
        self.ceiling.setPosition(0,self.roomHeight,0)


        #If performance is an issue, set cullFace to True.

        #adds the wall(plane) farthest from the hand/person
        #35x10 meters**2
        #rotated around the X axis (perpendicular to Z axis)
        self.frontWall = vizshape.addPlane(size=(self.roomWidth, self.roomHeight), axis=-vizshape.AXIS_Z, cullFace = False)
        #moves the wall to match the edge of the 
        self.frontWall.setPosition(0,self.roomHeight/2,self.roomLength/2)
        #makes the wall appear white
        self.frontWall.color([0.6,0.6,0.6])
        self.wall_text_object = viz.addText3D( 'PerForM Lab',parent=self.frontWall,pos=[-3,1,-0.2])

        #adds a wall(plane) that when facing the frontWall is to the camera's back
        #wall is 35x10 meters**2
        #wall is rotated about the X axis(perpendicular to Z axis)
        self.backWall = vizshape.addPlane(size=(self.roomWidth, self.roomHeight), axis=vizshape.AXIS_Z, cullFace = False)
        #shifts the wall to match the edge of the floor
        self.backWall.setPosition(0,self.roomHeight/2,-self.roomLength/2)
        #makes the wall appear white
        self.backWall.color(viz.WHITE)

        #adds the wall(plane) that when facing the frontWall, is to the camera's left
        #wall is 80x10 meters**2
        #wall is rotated about the Y axis(perpendicular to X axis)
        self.leftWall = vizshape.addPlane(size=(self.roomLength, self.roomHeight), axis=-vizshape.AXIS_X, cullFace = False)
        #shifts the wall to match the edge of the floor
        self.leftWall.setPosition(self.roomWidth/2,self.roomHeight/2,0)
        #makes the wall appear white
        self.leftWall.color(viz.GRAY)

        #adds a wall(plane) that when facing the frontWall is to the camera's right
        #wall is 80x10 meters**2
        #wall is rotated about the Y axis(perpendicular to X axis)
        self.rightWall = vizshape.addPlane(size=(self.roomLength, self.roomHeight), axis=vizshape.AXIS_X, cullFace = False)
        #shifts the wall to match the edge of the floor
        self.rightWall.setPosition(-self.roomWidth/2,self.roomHeight/2,0)
        #makes the wall appear white
        self.rightWall.color(viz.GRAY)


        #add a meter marker at 0 meters along the z axis of the room
        #meter0 = vizshape.addPlane(size = (5,.3), axis = vizshape.AXIS_Y, cullFace = False)
        #meter0.setPosition(0,.3, 0)
        #makes the meter marker appear yellow
        #meter0.color(viz.WHITE)

        #adds a wall(plane) that when facing the frontWall is to the camera's back
        #wall is 35x10 meters**2
        #wall is rotated about the X axis(perpendicular to Z axis)
        self.ballPlane = vizshape.addPlane(size=(2,2), axis=vizshape.AXIS_Z, cullFace = False)
        #shifts the wall to match the edge of the floor
        self.ballPlane.setPosition(0,5,-20)
        #makes the wall appear white
        self.ballPlane.color(viz.WHITE)
        self.ballPlane.alpha(0.0)
        self.text_object = viz.addText3D( '',parent=self.ballPlane,pos=[-0.4,0.6,0])
        self.text_object.setScale(0.2,0.2,0.2)


        """</END OF DEFINING THE WORLD>"""
Пример #18
0
n = 720
d = 449
s = 1.75*10**-6
scale = 10000

focalLen = d*s*scale
planeWidth = m*s*scale
planeHeight = n*s*scale
'''
focalLen = 7 #meter
planeWidth = 2*focalLen*math.tan(111.316*3.14/(2*180))
planeHeight = 2*focalLen*math.tan(74.34*3.14/(2*180))

pl_left = vizshape.addPlane(
		size = [planeWidth,planeHeight],
		axis = -vizshape.AXIS_Z,
		cullFace = False
		)

pl_right = vizshape.addPlane(
		size = [planeWidth,planeHeight],
		axis = -vizshape.AXIS_Z,
		cullFace = False
		)

pl_left.setParent(config.leftEyeNode)
pl_left.setPosition([0,0,focalLen],viz.ABS_PARENT)

pl_right.setParent(config.rightEyeNode)
pl_right.setPosition([0,0,focalLen],viz.ABS_PARENT)
Пример #19
0
# setting door center to fix the pivot/rotation point
door.setCenter([-5, 0, 0])
#load the tV model and set its position and rotation
tv = viz.addChild('resources/monitor2.osgb')
tv.setPosition(0, 2.5, -2.2)
tv.setEuler(0, 40, 0)

# video texture
video = viz.addVideo('resources/hale_bopp_1.mpg')
video.play()
video.loop()
#video.volume(1)

#creating a plane that holds the video texture
screen = vizshape.addPlane([0.9, 0.55, 0.9], axis=vizshape.AXIS_Z)
screen.setEuler(45, 0, 0)
screen.texture(video)

#link the plane to the tv model
viz.link(tv, screen, offset=[0, 0.22, 0.24])

# for exporting osgb file into other file formats - useful
# gallery.save('model/shop.fbx')


#this function opens the door
def openDoor(door):
    action1 = vizact.spinTo(axisAngle=[0, 0, -1, 60], speed=120)
    yield door.addAction(action1)
Пример #20
0
    def __init__(self):
        """sets up viewcube and principle planes"""
        #Should appear ontop of podium

        self.modeCounter = 0  #Will be used to determine mode
        SF = 1  #Scale box

        #------------(AP/RL/SI) + cube mode setup-------------

        #add text objects set positions
        self.anterior = viz.addText('Anterior', pos=[0, SF * .5, SF * .5])
        self.posterior = viz.addText('Posterior', pos=[0, SF * .5, SF * -.5])
        self.left = viz.addText('Left', pos=[SF * -.5, SF * .5, 0])
        self.right = viz.addText('Right', pos=[SF * .5, SF * .5, 0])
        self.superior = viz.addText('Superior', pos=[0, SF * 1.0, 0])
        self.inferior = viz.addText('Inferior', pos=[0, SF * .01, 0])

        #set orientation
        self.anterior.setEuler([180, 0, 0])
        self.posterior.setEuler([0, 0, 0])
        self.left.setEuler([90, 0, 0])
        self.right.setEuler([-90, 0, 0])
        self.superior.setEuler([0, 90, 0])
        self.inferior.setEuler([0, 90, 0])

        #set scale
        self.anterior.setScale([.1, .1, .1])
        self.posterior.setScale([.1, .1, .1])
        self.left.setScale([.1, .1, .1])
        self.right.setScale([.1, .1, .1])
        self.superior.setScale([.1, .1, .1])
        self.inferior.setScale([.1, .1, .1])

        #set each text object to be centered
        self.anterior.alignment(viz.ALIGN_CENTER_CENTER)
        self.posterior.alignment(viz.ALIGN_CENTER_CENTER)
        self.left.alignment(viz.ALIGN_CENTER_CENTER)
        self.right.alignment(viz.ALIGN_CENTER_CENTER)
        self.superior.alignment(viz.ALIGN_CENTER_CENTER)
        self.inferior.alignment(viz.ALIGN_CENTER_CENTER)

        #turn off rendering
        self.anterior.disable([viz.RENDERING])
        self.posterior.disable([viz.RENDERING])
        self.left.disable([viz.RENDERING])
        self.right.disable([viz.RENDERING])
        self.superior.disable([viz.RENDERING])
        self.inferior.disable([viz.RENDERING])

        #consider changing size, font, shading etc.

        #add cube
        RADIUS = .5 * SF
        self.cube = wireframeCube([RADIUS, RADIUS, RADIUS])
        self.cube.setPosition([0, RADIUS, 0], viz.ABS_PARENT)

        #turn off visability
        self.cube.visible(viz.OFF)

        #---------------principle plane setup------------------------
        self.frontalPlane = vizshape.addPlane(size=[1 * SF, 1 * SF],
                                              axis=vizshape.AXIS_Z,
                                              cullFace=False)
        self.transversePlane = vizshape.addPlane(size=[1 * SF, 1 * SF],
                                                 axis=vizshape.AXIS_Y,
                                                 cullFace=False)
        self.sagittalPlane = vizshape.addPlane(size=[1 * SF, 1 * SF],
                                               axis=vizshape.AXIS_X,
                                               cullFace=False)

        #setPosition(up in y so that origin is at bottom)
        self.frontalPlane.setPosition([0, SF * .5, 0])
        self.transversePlane.setPosition([0, SF * .5, 0])
        self.sagittalPlane.setPosition([0, SF * .5, 0])

        #set alpha
        self.frontalPlane.alpha(.5)
        self.transversePlane.alpha(.5)
        self.sagittalPlane.alpha(.5)

        #set color
        self.frontalPlane.color([1, 1, .5])
        self.transversePlane.color([1, 1, .5])
        self.sagittalPlane.color([1, 1, .5])

        #add text labels to upper corners of planes
        self.frontalLabel = viz.addText(
            'Frontal Plane', pos=[.5 * SF, SF * .5,
                                  .01 * SF])  #.01 prevents overlap with plane
        self.transverseLabel = viz.addText('Transverse Plane',
                                           pos=[-.5 * SF, .01 * SF, SF * .5])
        self.sagittalLabel = viz.addText('Sagittal Plane',
                                         pos=[.01 * SF, SF * .5, SF * -.5])

        #scale text labels
        self.frontalLabel.setScale([.1, .1, .1])
        self.transverseLabel.setScale([.1, .1, .1])
        self.sagittalLabel.setScale([.1, .1, .1])

        #set planes to be parents of labels
        self.frontalLabel.setParent(self.frontalPlane)
        self.transverseLabel.setParent(self.transversePlane)
        self.sagittalLabel.setParent(self.sagittalPlane)

        #orient text labels
        self.frontalLabel.setEuler([180, 0, 0])
        self.transverseLabel.setEuler([0, 90, 0])
        self.sagittalLabel.setEuler([-90, 0, 0])

        #set alignment of Text labels
        self.frontalLabel.alignment(viz.ALIGN_LEFT_TOP)
        self.transverseLabel.alignment(viz.ALIGN_LEFT_TOP)
        self.sagittalLabel.alignment(viz.ALIGN_LEFT_TOP)

        #disable rendering on planes
        self.frontalPlane.disable([viz.RENDERING])
        self.transversePlane.disable([viz.RENDERING])
        self.sagittalPlane.disable([viz.RENDERING])

        #disable rendering of Text labels
        self.frontalLabel.disable([viz.RENDERING])
        self.transverseLabel.disable([viz.RENDERING])
        self.sagittalLabel.disable([viz.RENDERING])
Пример #21
0
#trials per object
trials_per_context = 20 #just generate a lot, as participants won't get through this many / run

#timing
ITI=2 #intertrial interval, in seconds

##env shape
global radius
radius = 14.5 #in meters, made global for convenience so be careful 

##############################
## ENVIRONMENT AND CONTROLS ##
##############################

##ground
ground = vizshape.addPlane(size=(40.0,40.0),axis=vizshape.AXIS_Y)
ground.setPosition(0,0,0)
t1 = viz.addTexture('tex2.jpg',wrap=viz.REPEAT)
ground.texture(t1)
ground.texmat( viz.Matrix.scale(20,20,1) )

ground2 = vizshape.addPlane(size=(40.0,40.0),axis=vizshape.AXIS_Y,scene=viz.Scene2)
ground2.setPosition(0,0,0)
ground2.texture(t1)
ground2.texmat( viz.Matrix.scale(20,20,1) )

ground3 = vizshape.addPlane(size=(40.0,40.0),axis=vizshape.AXIS_Y,scene=viz.Scene3)
ground3.setPosition(0,0,0)
ground3.texture(t1)
ground3.texmat( viz.Matrix.scale(20,20,1) )
viz.MainView.getHeadLight().enable()

cam = viz.MainView
cam.setPosition([0,1.06,0])

##
s = 1
focalLen = 0.00081566 * s
planeWidth = 0.00126 * s
planeHeight = 0.0022 * s
camcenter_dX = (640-606.3966)*1.75*(10^-6) * s
camcenter_dY = (360-310.6875)*1.75*(10^-6) * s

ImagePlane = vizshape.addPlane(
	size = [planeWidth,planeHeight],
	axis = -vizshape.AXIS_Z,
	cullFace = False
)

ImagePlane.enable(viz.BLEND)
ImagePlane.alpha(0.5)

link = viz.link(cam,ImagePlane)
link.preTrans([0,0,focalLen])

# Load texture 

video = viz.add('VideoCamera.dle')
cam_r = video.addWebcam()

pic = viz.addTexture('imcalib30_corr.jpg')
Пример #23
0
waterSound = viz.addAudio('fountain.wav')
waterSound.volume(0.2)
choirLocation = viz.addGroup(pos=[0.2, 1.8, -53])
choir_sound = choirLocation.playsound('art/scene1 choir.wav')

#scene1 = viz.addChild('art/scene1.osgb')
scene1 = vizfx.addChild('art/scene1.osgb')
viz.MainView.getHeadLight().disable()
# Disable ambient light
vizfx.setAmbientColor(viz.BLACK)

#scene1.disable(viz.LIGHTING)
scene1.hint(viz.ALLOW_NPOT_TEXTURE_HINT)
scene1.disable(0x3000)  #Disable clip plane on model
waterPlane = vizshape.addPlane(size=[400, 400], pos=[0, 0.2, 0])
obj_vis.append(scene1)
obj_vis.append(waterPlane)

sky = viz.addChild('sky_day.osgb')
obj_vis.append(sky)

#bellSensorLocation = viz.addGroup(pos=[0.74121, 0.61385, -74.72057])
#bellSensor = vizproximity.Sensor(vizproximity.Box(size=[6,10,6]),source=bellSensorLocation)
#bellLocation = viz.addGroup(pos=[0.90712, 4.80442, -91.77573])
#bell_sound = bellLocation.playsound('bells.wav',flag=viz.PAUSE)

stoneSensorLocation = viz.addGroup(pos=[0, 3.5, -90])
stoneSensor = vizproximity.Sensor(vizproximity.Box(size=[2, 3, 2]),
                                  source=stoneSensorLocation)
Пример #24
0
                                                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)
Пример #25
0
#Create backlight
back_light = viz.addLight(euler=(0, 215, 0))  #euler = yaw, pitch, roll
back_light.position(-2, 0, 4, 0)
back_light.color(viz.WHITE)
back_light.intensity(.75)

#Create frontlight?
front_light = viz.addLight(euler=(0, 45, 0))  #euler = yaw, pitch, roll
front_light.position(-2, 0, 4, 0)
front_light.color(viz.WHITE)
front_light.intensity(1.5)

#Creating all parts of scene
global ground
ground = vizshape.addPlane(
    size=[10, 45]
)  #set constant size of 10 m wide, 45 m deep. Extra 5m in depth allows for 5m to extend behind participants' view
ground.setPosition(
    0, 0, 17.5
)  #set constant position to begin at viewpoint and set z dimension so 5m is behind participant view and 40m extends in front
ground.texture(carpet)
ground.disable(viz.RENDERING)

global farwall
farwall = vizshape.addPlane(
    size=[10, 2.69], axis=vizshape.AXIS_Z, cullFace=False
)  #set default size to 2.69m tall by 10 m wide, aligned with Z axis
farwall.setPosition(0, 1.345, 40)
farwall.texture(wallpaper)
farwall.disable(viz.RENDERING)
Пример #26
0
vhil2.setPosition(-2,2,3.56)

headLight = viz.MainView.getHeadLight() 
headLight.disable() 

#import vizsonic
#vizsonic.setReverb(6.0, 0.2, 0.5, 0.9, 0.0)
#vizsonic.setSimulatedRoomRadius(6.5,4.5)

BILLBOARD = False

#Reflect mask for the mirror
REFLECT_MASK = viz.addNodeMask()

#Add mirror object
mirrorPlane = vizshape.addPlane()

#set properties of the mirror
mirrorPlane.setScale(.13,0,.03)
mirrorPlane.setPosition(0.15,2,1.45)
mirrorPlane.setEuler(0,-90,0)


### add mirror
def addMirror(mirror,mat=None,eye=viz.BOTH_EYE):

	#If mirror matrix is not specifed, get matrix of mirror object
	if mat is None:
		mat = mirror.getMatrix()

	#Position of mirror
world_axes = vizshape.addAxes()
X = viz.addText3D('X',pos=[1.1,0,0],color=viz.RED,scale=[0.3,0.3,0.3],parent=world_axes)
Y = viz.addText3D('Y',pos=[0,1.1,0],color=viz.GREEN,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
Z = viz.addText3D('Z',pos=[0,0,1.1],color=viz.BLUE,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
#grids are good
grid = vizshape.addGrid(color=[0.2]*3)
viz.clearcolor(viz.GRAY)

#Create proximity manager
manager = vizproximity.Manager()
manager.setDebug(viz.ON)



#create our bisecting plane
mid_plane= vizshape.addPlane(size=(.00001,.00001),axis=vizshape.AXIS_X, cullFace=False)

start_node= right_node=vizshape.addCylinder(height, radius=2,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)
     
left_node=vizshape.addCylinder(height, radius= 3,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)        
right_node=vizshape.addCylinder(height, radius=2,topRadius= None,bottomRadius= None, axis=vizshape.AXIS_Y,slices=20,bottom=True,top=True)
left_plane1= vizshape.addPlane(size=(1*scale_x,1*scale_y,),axis=vizshape.AXIS_Y, cullFace=False)
left_plane2= vizshape.addPlane(size=(1*scale_x,1*scale_y,),axis=vizshape.AXIS_Y, cullFace=False)


box_and_sensor_parameters=[x_translate,y_height,z_depth]
box_and_sensor_parameters2= [-x_translate,y_height,z_depth]
left_plane=left_plane1.translate(x_translate,y_height,z_depth)
left_plane2.translate(-x_translate,y_height,z_depth)

Пример #28
0
import viz
import vizshape
viz.setMultiSample(4)
viz.fov(60)
viz.go()

plane= vizshape.addPlane([2,2], vizshape.AXIS_Z,cullFace = True)