Пример #1
0
	def rotateRigid(self,rotateByDegs_XYZ):

		# create a temp vizard 3d object 
		# rotate, use vertices to redefine rigid object
		
		viz.startLayer(viz.POINTS)
		for idx in range(len(self.markerPos_midx_localXYZ)):
			viz.vertex(self.markerPos_midx_localXYZ[idx][0],self.markerPos_midx_localXYZ[idx][1],self.markerPos_midx_localXYZ[idx][2])
		
		tempRigidObject = viz.endLayer()
		tempRigidObject.visible( viz.OFF ) #Make the object invisible.
		
		# Update rigid body definition on the owl server
		tempRigidObject.setEuler( rotateByDegs_XYZ,viz.RELATIVE)		
		
		owlTracker(self.trackerIdx,OWL_DISABLE)

		count = 0
		for i in xrange(len(self.markerID_midx)):
			owlMarkerfv(markerNumToID(self.trackerIdx, i), OWL_SET_POSITION, tempRigidObject.getVertex(i,viz.RELATIVE))
			self.markerPos_midx_localXYZ[count] = tempRigidObject.getVertex(i,viz.RELATIVE)
			count +=1
			
		owlTracker(self.trackerIdx, OWL_ENABLE);
		
		tempRigidObject.remove() #Remove the object.
Пример #2
0
def addRayPrimitive(origin, direction, length=100, color=viz.RED, 
                    alpha=0.6, linewidth=3, parent=None):
    """ Create a Vizard ray primitive from two vertices. Can be used
    to e.g. indicate a raycast or gaze vector in a VR environment.
    
    Args:
        origin (3-tuple): Ray origin
        direction (3-tuple): Unit direction vector
        length (float): Ray length (set to 1 and use direction=<end>
            to draw point-to-point ray)
        color (3-tuple): Ray color
        alpha (float): Ray alpha value
        linewidth (int): OpenGL line drawing width in pixels
        parent: Vizard node to use as parent
    """
    viz.startLayer(viz.LINES)
    viz.lineWidth(linewidth)
    viz.vertexColor(color)
    viz.vertex(origin)
    viz.vertex([x * length for x in direction])
    ray = viz.endLayer()
    ray.disable([viz.INTERSECTION, viz.SHADOW_CASTING])
    ray.alpha(alpha)
    if parent is not None:
        ray.setParent(parent)
    return ray
Пример #3
0
def addCircle(r, color):
    viz.startLayer(viz.POLYGON)
    viz.vertexColor(color)
    for angle in range(0, 360, 10):
        viz.vertex(r * math.cos(math.radians(angle)),
                   r * math.sin(math.radians(angle)))
    return viz.endLayer()
    def EdgeMaker(self, startpos, bearing, primitive_width):
        """function returns a bend edge"""
        """function returns a bend edge"""
        
        viz.startlayer(self.primitive) 	
        
        for ins, out in zip(inside,outside):

            viz.vertex(ins[0], ABOVEGROUND, ins[1])
            viz.vertexcolor(self.colour)
            viz.vertex(out[0], ABOVEGROUND, out[1])
            viz.vertexcolor(self.colour)

        """
        while i < self.Edge_Pts:			
            x1 = ((bearing - primitive_width)*np.cos(self.RoadArray[i])) + startpos[0]
            z1 = self.Zdirection*((bearing - primitive_width)*np.sin(self.RoadArray[i])) + startpos[2]

            #print (z1[i])			
            viz.vertex(x1, ABOVEGROUND, z1)				
            viz.vertexcolor(self.colour)

            if self.primitive == viz.QUAD_STRIP:
                x2 = ((rads + primitive_width)*np.cos(self.RoadArray[i])) + startpos[0]
                z2 = self.Zdirection*((rads + primitive_width)*np.sin(self.RoadArray[i])) + startpos[2]
                viz.vertex(x2, ABOVEGROUND, z2)				
                viz.vertexcolor(self.colour)

            i += 1

        """

        Bend = viz.endlayer()

        return Bend
Пример #5
0
def room_line(high, wide, dep, pixel):
    room = viz.addGroup()

    pos = np.array([[[wide / 2, 0, 0], [wide / 2, high, 0]],
                    [[-wide / 2, 0, 0], [-wide / 2, high, 0]],
                    [[wide / 2, 0, 0], [-wide / 2, 0, 0]],
                    [[wide / 2, high, 0], [-wide / 2, high, 0]],
                    [[wide / 2, 0, -dep], [wide / 2, high, -dep]],
                    [[-wide / 2, 0, -dep], [-wide / 2, high, -dep]],
                    [[wide / 2, 0, -dep], [-wide / 2, 0, -dep]],
                    [[wide / 2, high, -dep], [-wide / 2, high, -dep]],
                    [[wide / 2, 0, 0], [wide / 2, 0, -dep]],
                    [[wide / 2, high, 0], [wide / 2, high, -dep]],
                    [[-wide / 2, 0, 0], [-wide / 2, 0, -dep]],
                    [[-wide / 2, high, 0], [-wide / 2, high, -dep]]])

    for i in range(12):
        viz.startLayer(viz.LINES)
        viz.lineWidth(pixel)
        viz.vertexColor(1, 0, 0)
        viz.vertex(pos[i, 0, :].tolist())
        viz.vertex(pos[i, 1, :].tolist())
        outline = viz.endLayer()
        outline.setParent(room)

    return room
Пример #6
0
    def rotateRigid(self, rotateByDegs_XYZ):

        # create a temp vizard 3d object
        # rotate, use vertices to redefine rigid object
        # maybe that phasespace coordinate system does not match vizard coordinate system

        viz.startLayer(viz.POINTS)
        for idx in range(len(self.markerPos_midx_localXYZ)):
            viz.vertex(self.markerPos_midx_localXYZ[idx][0],
                       self.markerPos_midx_localXYZ[idx][1],
                       self.markerPos_midx_localXYZ[idx][2])

        tempRigidObject = viz.endLayer()
        tempRigidObject.visible(viz.OFF)  #Make the object invisible.

        # Update rigid body definition on the owl server
        #tempRigidObject.setEuler( rotateByDegs_XYZ,viz.RELATIVE ) #,viz.RELATIVE)

        tempRigidObject.setQuat(rotateByDegs_XYZ, viz.ABS_GLOBAL)

        owlTracker(self.trackerIdx, OWL_DISABLE)

        count = 0
        for i in xrange(len(self.markerID_midx)):
            owlMarkerfv(MARKER(self.trackerIdx, i), OWL_SET_POSITION,
                        tempRigidObject.getVertex(i, viz.RELATIVE))
            self.markerPos_midx_localXYZ[count] = tempRigidObject.getVertex(
                i, viz.RELATIVE)
            count += 1

        owlTracker(self.trackerIdx, OWL_ENABLE)

        tempRigidObject.remove()  #Remove the object.
Пример #7
0
def GenerateStarDome(numStars, pointSize, minRadius, maxRadius, scene=1, yCenter=0):
 #Create a star dome of random points
 viz.startLayer(viz.POINTS)
 viz.pointSize(pointSize)
 for i in range(0, numStars):
  x = random() - 0.5
  y = random() - 0.5
  z = random() - 0.5
  length = math.sqrt(x*x + y*y + z*z)
  rad = vizmat.GetRandom(minRadius,maxRadius)
  x = x / length * rad
  y = y / length * rad
  y += yCenter
  z = z / length * rad
  color = vizmat.GetRandom(0.4,1)
  viz.vertexColor([color,color,color-vizmat.GetRandom(0,0.2)])
  viz.vertex([x, y, z])

 stardome = viz.endLayer()
 stardome.setParent(viz.WORLD, scene=scene)
 stardome.texture( viz.addTexture('particle.rgb') )
 stardome.blendFunc(viz.GL_SRC_ALPHA,viz.GL_DST_ALPHA)
 stardome.enable(viz.POINT_SPRITE)
 stardome.disable(viz.DEPTH_TEST)
 stardome.draworder(-100000)
Пример #8
0
        def motion():
            # Create Fixation Dot
            viz.startLayer(viz.POINTS)
            viz.pointSize(self.POINTSIZE)
            viz.vertexColor(viz.GRAY)
            viz.vertex(0, 1.8, 4)
            points = viz.endLayer()
            points.disable(viz.CULLING)
            # Create the circles
            sphere = self.createCircles(26, 1, 30, -26)
            sphere2 = self.createCircles(22, 0.8, 30, -26)
            sphere3 = self.createCircles(18, 0.6, 30, -26)
            sphere4 = self.createCircles(14, 0.4, 30, -26)
            sphere5 = self.createCircles(10, 0.2, 30, -26)
            viz.MainView.move([0, 0, 3])

            def keydown(key):

                if key == 'f':
                    self.response = 'self motion'
                    self.keyPressTime = viz.tick()  # get time for keypress
                    print(self.response, self.keyPressTime)
                    self.STATE = 'State - self Motion'

                if key == 'j':
                    self.response = 'object motion'
                    self.keyPressTime = viz.tick()  # get time for keypress
                    print(self.response, self.keyPressTime)
                    self.STATE = 'State - Object Motion'

            viz.callback(viz.KEYDOWN_EVENT, keydown)
Пример #9
0
def flashingCloud(height, width, depth, offset, number, node):

	positions = np.random.uniform(low = -width/2, high = width/2, size = (number, 3))
	positions[:, 1] = positions[:, 1]/(width/height) 

	# Save the location of each dots into a .csv file
	record = open('Cloud_positions_' + str(number) + '.csv', 'a' ) 	

	for n in range(number):
		record.write(str(positions[n, 0]) + ',' + str(positions[n, 1]) + ',' + str(positions[n, 2]) + '\n')

	positions[:, 2] = positions[:, 2] - (depth/2 - offset) 

	clouds = []
	
	viz.startLayer(viz.POINTS)
	viz.pointSize(2)  # Set the size of the dots on the display

	# Draw each dot
	for i in range(number):
		viz.vertex(positions[i, 0], positions[i, 1], positions[i, 2])

	cloud = viz.endLayer()

	# Set a parent object for the cloud.
	# Therefore, once the location of the parent is determined, the location of the cloud as a whole is also determined.
	cloud.setParent(node) 

	return cloud
Пример #10
0
	def rotateRigid(self,rotateByDegs_XYZ):

		# create a temp vizard 3d object 
		# rotate, use vertices to redefine rigid object
		# maybe that phasespace coordinate system does not match vizard coordinate system
		
		viz.startLayer(viz.POINTS)
		for idx in range(len(self.markerPos_midx_localXYZ)):
			viz.vertex(self.markerPos_midx_localXYZ[idx][0],self.markerPos_midx_localXYZ[idx][1],self.markerPos_midx_localXYZ[idx][2])
		
		tempRigidObject = viz.endLayer()
		tempRigidObject.visible( viz.OFF ) #Make the object invisible.
		
		# Update rigid body definition on the owl server
		#tempRigidObject.setEuler( rotateByDegs_XYZ,viz.RELATIVE ) #,viz.RELATIVE)		
		
		tempRigidObject.setQuat(rotateByDegs_XYZ,viz.ABS_GLOBAL)
		
		owlTracker(self.trackerIdx,OWL_DISABLE)

		count = 0
		for i in xrange(len(self.markerID_midx)):
			owlMarkerfv(MARKER(self.trackerIdx, i), OWL_SET_POSITION, tempRigidObject.getVertex(i,viz.RELATIVE))
			self.markerPos_midx_localXYZ[count] = tempRigidObject.getVertex(i,viz.RELATIVE)
			count +=1
			
		owlTracker(self.trackerIdx, OWL_ENABLE);
		
		tempRigidObject.remove() #Remove the object.
Пример #11
0
	def __init__(self, angle):
		
		# Initialize Ball Instance Variables
		# radius 
		self.radius = 3
		# number of sides of regular polygon representing the ball
		self.sides = 50
		# velocity vector describing its direction and speed
		self.angle = angle

		self.vy = math.sin(math.radians(angle)) * 2
		self.vx = math.cos(math.radians(angle)) * 2

		# center location 
		self.x = 0
		self.y = 0
		
		# create layer for a circle, centered at (0,0)
		viz.startLayer(viz.POLYGON)
		viz.vertexColor(1,1,0)
		for i in range(0, 360, 360/self.sides):
			x = math.cos( math.radians(i) ) * self.radius
			y = math.sin( math.radians(i) ) * self.radius
			viz.vertex(x, y)
		# saves layer of vertices in instance variable called vertices
		self.vertices = viz.endLayer()
Пример #12
0
 def getViewXYZ(self, dist="far", reFrame=viz.ABS_GLOBAL):
     
     # temporarily add vertex to track parcel pos in abs coords
     viz.startLayer(viz.POINTS)
     viz.vertexColor(1,0,0)
     viz.pointSize(30)
     viz.vertex(0,0,0)
     cV = viz.endLayer()
     cV.setParent(self.bNodeOp)
             
     if dist == "far":
         cV.setPosition(self.viewLocFar, mode=viz.ABS_LOCAL)
         zoneXYZ = cV.getPosition(mode=reFrame)
     elif dist == "near":
         cV.setPosition(self.viewLocNear, mode=viz.ABS_LOCAL)
         zoneXYZ = cV.getPosition(mode=reFrame)
     elif dist == 'center':
         zoneXYZ = self.bNodeOp.getPosition(mode=reFrame)
         
     cV.visible(viz.OFF)        
     cV.remove()
     
     # set y to eye height
     zoneXYZ[1] = ct.EYE_HEIGHT
     
     return zoneXYZ
    def BendMaker(self, t, yawrate, transition_duration, rw, speed, sp, x_dir):
        """function returns a bend edge"""
        """function returns a bend edge"""

        x, y, bearing = cc.clothoid_curve(t, speed, yawrate,
                                          transition_duration)

        if x_dir < 0:
            bearing[:] = [(2 * (np.pi) - b) for b in bearing[:]]

        midline = np.array([((x * x_dir) + sp[0]), (y + sp[1])]).T

        outside = np.array(cc.add_edge((x * x_dir), y, (rw / 2), sp)).T
        inside = np.array(cc.add_edge((x * x_dir), y, -(rw / 2), sp)).T

        #print(outside.shape)
        #print(inside.shape)

        viz.startlayer(self.Primitive)

        for ins, out in zip(inside, outside):

            #print(ins)
            #print(ins.shape)
            viz.vertex(ins[0], ABOVEGROUND, ins[1])
            viz.vertexcolor(self.Colour)
            #print(ins[0], ins[1])
            viz.vertex(out[0], ABOVEGROUND, out[1])
            viz.vertexcolor(self.Colour)
            #print(out[0], out[1])

        Bend = viz.endlayer()

        return ([Bend, midline, inside, outside, bearing])
Пример #14
0
 def getCornerCoords(cNode, quSpace):
 
     nBox = cNode.getBoundingBox(viz.ABS_LOCAL)
     
     cCrns      = [ (nBox.xmin, 0, nBox.zmin), (nBox.xmin, 0, nBox.zmax), (nBox.xmax, 0, nBox.zmax), (nBox.xmax, 0, nBox.zmin) ]
     globalCrns = []
     singleVertChildren = []
     
     for c in cNode.getChildren():
         if c.__class__ == viz.VizPrimitive:
             singleVertChildren.append( c )
     
     #print "nChildren: ", singleVertChildren
     i = 0
     for cC in cCrns:
         
         # add helper vertices if this node does not contain
         # four children -> heuristic
         if not len(singleVertChildren) == 4:
             # create vertex
             viz.startLayer(viz.POINTS)
             viz.vertexColor(1,0,0)
             viz.pointSize(30)
             viz.vertex(0,0,0)
             cV = viz.endLayer()
             
             # set obst as parent
             cV.setParent(cNode)
             
             # move to parent's corner
             x,y,z = cC
             cV.setPosition(x, y, z, viz.ABS_PARENT)
             
         else:
             cV = singleVertChildren[i]
                                    
         # set obst as parent
         cV.setParent(cNode)
         
         # move to parent's corner
         x,y,z = cC
         cV.setPosition(x, y, z, viz.ABS_PARENT)
         
         # get global coords
         x,y,z = cV.getPosition(viz.ABS_GLOBAL)
         
         # flip z axis to get from world to pedSim space
         if quSpace == 'ped':
             z=-z
             
         globalCrns.append( (x,y,z) )
                         
         # remove this vertex
         #cV.remove()
         
         i = i+1
         
     return globalCrns
Пример #15
0
    def generate_surface(self, data, color_array_name):
        """
		Render the vtk data as a surface, centered at origin and return the Vizard object.
		color_array_name defines the name of the CellData array (for example: "equivalent_stress" or "material")
		"""
        # Start creating the model
        viz.startLayer(viz.TRIANGLES)
        # Use the range of the complete data set to ensure consitency
        minimum, maximum = self.vtk_data_local.GetCellData().GetArray(
            color_array_name).GetRange()

        # Generate surface model by iterating over every polygon
        polys = data.GetPolys()
        polys.InitTraversal()
        id_list = vtk.vtkIdList()
        cell = polys.GetNextCell(id_list)
        while not cell == 0:
            # Get the value of the cell for color calculation
            value = data.GetCellData().GetArray(color_array_name).GetValue(
                polys.GetTraversalLocation() / 4)
            color = Simulation_Data._get_color(minimum, maximum, value)
            viz.vertexColor(color[0], color[1], color[2])

            # Read the points (po) of the polygon
            po = []
            for j in range(id_list.GetNumberOfIds()):
                po.append(data.GetPoints().GetPoint(id_list.GetId(j)))

            # Calculate the normal vector of the polygon
            # Normal vector is needed for better lighting
            # Calculate the coss product of vectors from point 0 to 1 and 0 to 2
            ab = (po[1][0] - po[0][0], po[1][1] - po[0][1],
                  po[1][2] - po[0][2])
            ac = (po[2][0] - po[0][0], po[2][1] - po[0][1],
                  po[2][2] - po[0][2])
            normal = numpy.cross(ab, ac)
            # Set the magnitude of the normal vector to 1
            normal = normal / numpy.linalg.norm(normal)
            # Create the polygon with the normal vector and the points
            viz.normal(normal[0], normal[1], normal[2])
            for position in po:
                viz.vertex(position[0], position[1], position[2])
            cell = polys.GetNextCell(id_list)

        # Finish the model
        model = viz.endLayer()
        # Enable lighting for the model (Shadows aren't needed)
        model.enable(viz.LIGHTING)
        model.disable(viz.SHADOW_CASTING)
        model.disable(viz.SHADOWS)
        # Set the center of the model to (0, 0, 0)
        model.setPosition(-(self._original_center[0]),
                          -(self._original_center[1]),
                          -(self._original_center[2]))
        # Create group to get a centered model with coordinates (0, 0, 0)
        group = viz.addGroup()
        model.setParent(group)
        return group
Пример #16
0
 def drawContextBorders(bbCtx):
     crns = bbCtx.getCorners('world')
     viz.startLayer(viz.LINE_STRIP)
     viz.lineWidth(10)
     viz.vertexColor(1,0,0)
     
     for c in crns:
         viz.vertex(c[0], 1, c[1])            
     viz.endLayer()
Пример #17
0
def groundCreator():
	viz.startLayer(viz.QUADS)
	viz.texCoord(0,0) 
	viz.vertex(100, 0, -100)
	viz.texCoord(1,0) 
	viz.vertex(100, 0, 100)
	viz.texCoord(1,1) 
	viz.vertex(-100, 0, 100)
	viz.texCoord(0,1)  
	viz.vertex(-100, 0, -100)
	ground = viz.endLayer()

	AreaScale_f = [16, 16 ,1]

	matrix_area_f = vizmat.Transform()
	matrix_area_f.setScale(AreaScale_f)
	
	ground.texmat(matrix_area_f)

	wallTex = viz.addTexture('wallTex.jpg')
	wallTex.wrap(viz.WRAP_T,viz.REPEAT)
	wallTex.wrap(viz.WRAP_S,viz.REPEAT)

	ground.texture(wallTex)

	return ground
Пример #18
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)
Пример #19
0
def make_kinect_mesh(depthMap):
	#Build cube
	RADIUS = 1
	
	depthArray = depthMap.get_array()
	
	viz.startLayer(viz.QUADS)
	
	for y in range(0,depthMap.height-1,DOWNSAMPLE):
		for x in range(0,depthMap.width-1,DOWNSAMPLE):
			
			depth_val = depthMap[x,y]/(4*1000.0);

			viz.vertex([x*1.0/depthMap.width, 1 - y*1.0/depthMap.height, depth_val])
			viz.vertex([x*1.0/depthMap.width, 1 - (y+DOWNSAMPLE)*1.0/depthMap.height, depth_val])
			viz.vertex([(x+DOWNSAMPLE)*1.0/depthMap.width, 1 - (y+DOWNSAMPLE)*1.0/depthMap.height, depth_val])
			viz.vertex([(x+DOWNSAMPLE)*1.0/depthMap.width, 1 - (y)*1.0/depthMap.height, depth_val])
			
			pixel_colour = 1 - depthMap[x,y]/(1000.0 * 3.0)
			viz.vertexColor([ pixel_colour, 1, 1, MESH_VISIBLE ])

	kinect_mesh = viz.endLayer()
	kinect_mesh.setPosition([0,0.5,3])
	
	return kinect_mesh
Пример #20
0
def setARfov( val ):
	global node, ARfov_vert, hmdview	
	ARfov_vert = val
	#ARfov_vert = HMDfov_vert
	#ARfov_vert = 20
	ARheight = (int) (HMDheight / HMDfov_vert * ARfov_vert)
	ARwidth = ARheight * HMDaspect
	
	#recalculate ARfov_vert
	#ARfov_vert = (ARheight / HMDheight) * HMDfov_vert
	
	ARx = (HMDwidth - ARwidth)/2
	ARy = (HMDheight - ARheight)/2
	#print "AR view dimensions:",ARwidth,ARheight,ARx,ARy,ARfov_vert
	node.setSize( ARwidth,ARheight,ARx,ARy )
	node.setFov( ARfov_vert, HMDaspect, HMDnear, HMDfar )
	#return
	
	if(hmdview != 0):
		hmdview.remove()
	viz.startlayer(viz.QUADS)
	viz.vertex([ARx,ARy,0])
	viz.vertex([ARx + ARwidth, ARy,0])
	viz.vertex([ARx + ARwidth,ARy + ARheight,0])
	viz.vertex([ARx,ARy + ARheight,0])
	hmdview = viz.endlayer(viz.WORLD,viz.Scene3)
	hmdview.alpha(0.15)
Пример #21
0
def StraightMaker(x,
                  start_z,
                  end_z,
                  colour=[.8, .8, .8],
                  primitive=viz.QUAD_STRIP,
                  width=None):
    """returns a straight, given some starting coords and length"""
    viz.startlayer(primitive)
    if width is None:
        if primitive == viz.QUAD_STRIP:
            width = .05
        elif primitive == viz.LINE_STRIP:
            width = 2
            viz.linewidth(width)
            width = 0

    viz.vertex(x - width, .1, start_z)
    viz.vertexcolor(colour)
    viz.vertex(x + width, .1, start_z)
    viz.vertexcolor(colour)
    viz.vertex(x - width, .1, end_z)
    viz.vertexcolor(colour)
    viz.vertex(x + width, .1, end_z)

    straightedge = viz.endlayer()

    return straightedge
Пример #22
0
	def __init__(self, row, col):
		# Length of each block
		self.length = 20
		
		# Instance variables
		self.x = (row * self.length) - 100
		self.y = 100 - (col * self.length)
		self.row = col
		self.col = row
		
		viz.startLayer(viz.POLYGON)
		
		# Assign vertices a random color
		viz.vertexColor(random.uniform(.2, 1),random.uniform(.2, 1), random.uniform(.2, 1))
		
		# Define vertices
		viz.vertex(0, 0)
		viz.vertex(self.length, 0)
		viz.vertex(self.length, -self.length)
		viz.vertex(0, -self.length)
		
		# Capture layer and set its transformation matrix
		self.vertices = viz.endLayer()
		m = viz.Matrix()
		m.postTrans(self.x, self.y)
		self.vertices.setMatrix(m)
Пример #23
0
def door_line(high, wide, pixel):
    door = viz.addGroup()

    pos = np.array([[-wide / 2, 0, 0], [wide / 2, 0, 0], [wide / 2, high, 0],
                    [-wide / 2, high, 0]])

    viz.startLayer(viz.LINE_LOOP)
    viz.lineWidth(pixel)
    for i in range(4):
        viz.vertex(pos[i, :].tolist())

    line = viz.endLayer()
    line.setParent(door)

    return door
Пример #24
0
    def __init__(self, radius, x, y):
        self.radius = radius
        self.x = x
        self.y = y

        viz.startLayer(viz.POLYGON)
        viz.vertexColor(1, 1, 1)

        for i in range(0, 360):
            temp = i * math.pi / 180
            viz.vertex(
                math.cos(temp) * self.radius,
                math.sin(temp) * self.radius)

        viz.endLayer()
Пример #25
0
def wireframeCube(dimensions):
	"""
	Draw a wireframe rectangle. Currently comes in green only.
	"""
	edges = [[x,y,z] for x in [-1,0,1] for y in [-1,0,1] for z in [-1,0,1] if abs(x)+abs(y)+abs(z) == 2]
	for edge in edges:
		viz.startLayer(viz.LINES)
		viz.vertexColor(0,1,0)
		i = edge.index(0)
		edge[i] = 1
		viz.vertex(map(lambda a,b:a*b,edge,dimensions))
		edge[i] = -1
		viz.vertex(map(lambda a,b:a*b,edge,dimensions))
	cube = viz.endLayer()
	return cube
Пример #26
0
def createQuad(left_bot, left_top, right_bot, right_top):
    viz.startlayer(viz.QUADS)
    viz.vertexcolor(0, 0, 0)
    viz.vertex(left_bot)
    viz.vertex(left_top)
    viz.vertex(right_top)
    viz.vertex(right_bot)
    return viz.endlayer()
Пример #27
0
    def generate_cloud(self, data, color_array_name):
        """
		Render the vtk data as a cloud, centered at origin and return the Vizard object.
		color_array_name defines the name of the CellData array (for example: "equivalent_stress" or "material")
		"""
        # Start creating the model
        viz.startLayer(viz.POINTS)
        viz.pointSize(self.cloud_point_size)
        # Use the range of the complete data set to ensure consitency
        minimum, maximum = self.vtk_data_local.GetCellData().GetArray(
            color_array_name).GetRange()

        # Generate cloud model by iterating over every cell
        num_of_cells = data.GetNumberOfCells()
        for i in range(num_of_cells):
            cell = data.GetCell(i)

            # Calculate the center of the cell
            x = 0.0
            y = 0.0
            z = 0.0
            num_of_points = cell.GetNumberOfPoints()
            for j in range(num_of_points):
                point = cell.GetPoints().GetPoint(j)
                x += point[0]
                y += point[1]
                z += point[2]
            x /= num_of_points
            y /= num_of_points
            z /= num_of_points

            # Get the value of the cell for color calculation
            value = data.GetCellData().GetArray(color_array_name).GetValue(i)
            color = Simulation_Data._get_color(minimum, maximum, value)
            viz.vertexColor(color[0], color[1], color[2])
            # Draw the point
            viz.vertex(x, y, z)

        # Finish the model
        model = viz.endLayer()
        # Set the center of the model to (0, 0, 0)
        model.setPosition(-(self._original_center[0]),
                          -(self._original_center[1]),
                          -(self._original_center[2]))
        # Create group to get a centered model with coordinates (0, 0, 0)
        group = viz.addGroup()
        model.setParent(group)
        return group
Пример #28
0
def wireframeCube(dimensions):
    """
	Draw a wireframe rectangle. Currently comes in green only.
	"""
    edges = [[x, y, z] for x in [-1, 0, 1] for y in [-1, 0, 1]
             for z in [-1, 0, 1] if abs(x) + abs(y) + abs(z) == 2]
    for edge in edges:
        viz.startLayer(viz.LINES)
        viz.vertexColor(0, 1, 0)
        i = edge.index(0)
        edge[i] = 1
        viz.vertex(map(lambda a, b: a * b, edge, dimensions))
        edge[i] = -1
        viz.vertex(map(lambda a, b: a * b, edge, dimensions))
    cube = viz.endLayer()
    return cube
Пример #29
0
    def createCircles(self, NUM_DOTS, RADIUS, POINTSIZE, VELOCITYDIRECTION):

        #Build sphere
        viz.startLayer(viz.POINTS)
        viz.vertexColor(viz.WHITE)
        viz.pointSize(self.POINTSIZE)

        for i in range(0, NUM_DOTS):
            x = RADIUS * math.cos((i * 2 * math.pi) / NUM_DOTS)
            y = RADIUS * math.sin((i * 2 * math.pi) / NUM_DOTS)
            viz.vertex([x, y, 0])

        sphere = viz.endLayer()
        sphere.setPosition([0, 1.8, 4])
        sphere.addAction(vizact.spin(0, 0, 1, VELOCITYDIRECTION))
        return sphere
Пример #30
0
def cross(eyeHeight):
    viz.startLayer(viz.LINES)
    viz.lineWidth(2)
    viz.vertex(-0.25, 0 + eyeHeight, 5)  #Vertices are split into pairs.
    viz.vertex(0.25, 0 + eyeHeight, 5)
    viz.vertex(0, -0.25 + eyeHeight, 5)
    viz.vertex(0, 0.25 + eyeHeight, 5)
    myCross = viz.endLayer()
    return myCross
Пример #31
0
def refreshing(clouds):
    index = 0
    while True:
        clouds[index].remove()
        pos = np.random.uniform(low=-6, high=6, size=(cloudFreq / freq, 3))
        pos[:, 1] = pos[:, 1] / 2
        pos[:, 2] = pos[:, 2] - 5
        viz.startLayer(viz.POINTS)
        viz.pointSize(2)
        for n in range(cloudFreq / freq):
            viz.vertex(pos[n, 0], pos[n, 1], pos[n, 2])
        single_cloud = viz.endLayer()
        single_cloud.disable(viz.CULLING)
        single_cloud.setParent(Target)
        clouds.append(single_cloud)
        index += 1
        yield viztask.waitDraw()
Пример #32
0
 def __init__(self, x, y):
     self.x = x
     self.y = y
     viz.startLayer(viz.QUADS)
     viz.vertexColor(1, 0, 1)
     viz.vertex(-1, -2)
     viz.vertex(-1, 2)
     viz.vertex(1, 2)
     viz.vertex(1, -2)
     self.vertices = viz.endLayer()
Пример #33
0
	def __init__(self, dimensions, center = [0,0,0], corner = False):
		edges = [[x,y,z] for x in [-1,0,1] for y in [-1,0,1] for z in [-1,0,1] if abs(x)+abs(y)+abs(z) == 2]
		for edge in edges:
			viz.startLayer(viz.LINES)
			viz.vertexColor(0,1,0)
			i = edge.index(0)
			edge[i] = 1
			viz.vertex(map(lambda a,b:a*b/2, edge, dimensions))
			edge[i] = -1
			viz.vertex(map(lambda a,b:a*b/2, edge, dimensions))
		self.cube = viz.endLayer()
		if corner:
			corner = [float(p[0])/2 + p[1] for p in zip(dimensions,center)]
			self.cube.setPosition(corner, viz.ABS_GLOBAL)
		else:
			self.cube.setPosition(center, viz.ABS_GLOBAL)
			
		super(WireFrameCube, self).__init__(self.cube.id)
Пример #34
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)
Пример #35
0
	def __init__(self, eyeTracker, eye, parentNode, renderToWindows = None,gazeVectorColor=viz.RED):
		
		self.eye = eye
		self.eyeTracker = eyeTracker
		self.renderToWindows = renderToWindows
		
		#Creating a line
		viz.startLayer(viz.LINES)
		viz.lineWidth(4)#Set the size of the lines. 
		viz.vertex(0,0,0)
		viz.vertex(0,0,3)
		viz.vertexColor(gazeVectorColor)
		self.gazeLine = viz.endLayer()
		self.gazeLine.visible(True)
		#self.gazeLine.setScale(1,1,1)

		if( self.renderToWindows ):
			self.gazeLine.renderOnlyToWindows(self.renderToWindows)
		self.gazeLine.setParent(parentNode)
Пример #36
0
	def __init__(self, eyeTracker, eye, parentNode, renderToWindows = None,gazeVectorColor=viz.RED):
		
		self.eye = eye
		self.eyeTracker = eyeTracker
		self.renderToWindows = renderToWindows
		
		#Creating a line
		viz.startLayer(viz.LINES)
		viz.lineWidth(4)#Set the size of the lines. 
		viz.vertex(0,0,0)
		viz.vertex(0,0,3)
		viz.vertexColor(gazeVectorColor)
		self.gazeLine = viz.endLayer()
		self.gazeLine.visible(True)
		#self.gazeLine.setScale(1,1,1)

		if( self.renderToWindows ):
			self.gazeLine.renderOnlyToWindows(self.renderToWindows)
		self.gazeLine.setParent(parentNode)
Пример #37
0
    def __init__(self, x=0, y=0):
        self.x = x
        self.y = y

        viz.startLayer(viz.QUADS)
        #bullet
        viz.vertexColor(1, 1, 1)
        viz.vertex(.5, 0, 0)
        viz.vertex(-.5, 0, 0)
        viz.vertex(-.5, 2.9, 0)
        viz.vertex(.5, 2.9, 0)
        self.quad = viz.endLayer()
Пример #38
0
    def __init__(self, x, y):
        self.x = x
        self.y = y

        viz.startLayer(viz.QUADS)
        viz.vertexColor(0, 0, 0)
        viz.pointSize(100)
        viz.vertex(-1, 0)
        viz.vertex(+1, 0)
        viz.vertex(+1, 2)
        viz.vertex(-1, 2)
        viz.endLayer()
Пример #39
0
    def __init__(self, bldList):
        
        self.info       = PointInfo()
        self.buildings  = bldList
        self.trials     = []        
        self.cTrial     = None
        self.trialCtr   = -1         
        self.trgAngle   = None
        self.hideBuildings()
        self.trialData  = {}

        # add vertex to measure true target angel
        viz.startLayer(viz.POINTS)
        viz.vertexColor(1,0,0)
        viz.pointSize(30)
        viz.vertex(0,0,0)
        self.refVert = viz.endLayer()
        self.refVert.disable(viz.RENDERING)


        # add grid to orient subject during
        # pointing
        viz.startLayer(viz.LINES)
        viz.lineWidth(6)
        viz.vertexColor(0,0.6,0)
        viz.vertex(-100, 0.01,  0)
        viz.vertex( 100, 0.01,  0)
        viz.vertex(  0, 0.01,-100)
        viz.vertex(  0, 0.01, 100)
        self.cross90 = viz.endLayer()         
        self.cross90.visible(viz.OFF)        

        self.grid = vizshape.addGrid(size=[200,200], step=10.0, boldStep=None)
        self.grid.color([0,.6,0])
        self.grid.visible(viz.OFF)

        # add logger
        self.fields2log = {'trialNr' : 'i8', 'srcBuilding' : 'S10', 'trgBuilding' : 'S10', 'refAngle' : 'f4', 'measAngle' : 'f4', 'trueAngle' : 'f4', 'trialOnset' : 'f8', 'tChoiceMade' : 'f8', 'srcXZ' : [('x', 'f4'), ('z', 'f4')], 'trgXZ' : [('x', 'f4'), ('z', 'f4')], 'srcCtxt' : 'S1', 'trgCtxt' :'S1'}
        self.logHdl     = lg.LogData(self.fields2log)

        # handle exit
        vizact.onexit( self.saveOnExit )
	def __init__(self,**kw):
		group = viz.addGroup(**kw)
		viz.VizNode.__init__(self,group.id)

		self._quad = vizshape.addQuad([1,1],parent=self)
		self._quad.color(viz.RED)
		self._quad.polyMode(viz.POLY_WIRE)

		viz.startLayer(viz.LINES)
		viz.vertexColor(viz.RED)
		for x in range(8):
			viz.vertex([0,0,0])
		self._lines = viz.endLayer(parent=self)
		self._lines.dynamic()

		self.zoffset(-2)
		self.lineWidth(2)
		self.disable(viz.LIGHTING)

		self._wall = None
		self._tracker = None

		vizact.onupdate(viz.PRIORITY_LAST_UPDATE,self.updateFrustum)
def CreateVisualObjects():

    global ball, Head, Hand, GazeLine, EyeBallLine;
    #creats a sphere(the ball) with radius of 5cm
    ball = vizshape.addSphere(radius = .05)
    #colors the ball red
    ball.color(viz.YELLOW)
    ball.visible(True)

    Origin = vizshape.addAxes()
    Origin.setPosition(0,0,0)
    #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
    Hand = vizshape.addCylinder( height = 0.02, radius = 0.2)
    #colors the hand red
    Hand.color(viz.RED)
    Hand.visible(True)

    # Creating a Line to represent Gaze Vector
    viz.startLayer(viz.LINES)
    viz.vertex(0,0,0)
    viz.vertex(0,0,3)
    viz.vertexColor(viz.GREEN)
    GazeLine = viz.endLayer() # Object will contain both points and lines
    GazeLine.visible(True)
    GazeLine.setScale(5,5,5)


    # 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)
    EyeBallLine = viz.endLayer() # Object will contain both points and lines
    EyeBallLine.visible(True)
    EyeBallLine.setScale(5,5,5)
def setARfov( val ):
	global HMDheight, HMDwidth, HMDfov_vert, HMDaspect, HMDnear, HMDfar
	global node, ARfov_vert, ARgraybox
	
	print "********* val is ",val
	ARfov_vert = val
	ARheight = (int) (HMDheight / HMDfov_vert * ARfov_vert)
	ARwidth = ARheight * HMDaspect
	
	ARx = (HMDwidth - ARwidth)/2
	ARy = (HMDheight - ARheight)/2
	node.setSize( ARwidth,ARheight,ARx,ARy )
	node.setFov( ARfov_vert, HMDaspect, HMDnear, HMDfar )
	
	if(ARgraybox != 0):
		ARgraybox.remove()
	viz.startlayer(viz.QUADS)
	viz.vertex([ARx,ARy,0])
	viz.vertex([ARx + ARwidth, ARy,0])
	viz.vertex([ARx + ARwidth,ARy + ARheight,0])
	viz.vertex([ARx,ARy + ARheight,0])
	ARgraybox = viz.endlayer(viz.WORLD,viz.Scene3)
	ARgraybox.alpha(0.15)
Пример #43
0
def placeMirror():
	global m
	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
	#m.setPosition([ 0.5*(x0+x1), 0.5*(y0+y1), z])
	m.setPosition([0,0,z])
	m.setEuler(180, 0, 0)
	
	# Adjust these! #
	#m.setPosition([0,0,z-1.50]) #this makes the mirror not reflect the space of the 4th row
	#m.setScale(2, 2, 2)

	#Apply mirror settings to mirror object
	mirrorPlane.alpha(0.0)
	addMirror(mirrorRight,m,viz.RIGHT_EYE)
	addMirror(mirrorLeft,m,viz.LEFT_EYE)
	def __init__(self,use_keyboard = True, desktop_mode = False):
		"""Initialization function."""
		
		caveapp.CaveApplication.__init__(self,desktop_mode) #call constructor of super class, you have to do this explicitly in Python		
		viz.phys.enable()
		
		self.view = viz.MainView;
		
		self.backGroundMusic = viz.addAudio('Windmill hut.wav')
		self.backGroundMusic.volume(0.5)
		self.backGroundMusic.loop(viz.ON)
		self.backGroundMusic.play()
		self.gameMusic = viz.addAudio('Battle.wav')
		self.gameMusic.volume(0.7)
		
		headLight = viz.MainView.getHeadLight()
		headLight.intensity(100)
		headLight.disable()
		
		for i in range(3):
			light = viz.addLight()
			light.setPosition(0, 2, (i*10))
			light.position(0,0,0,1)
				
		self.use_keyboard = use_keyboard #store if we want to use the keyboard
		self.scaleValue = 0.03
		
		self.shootingRange = viz.addChild('ShootingRange.FBX')
		self.shootingRange.setScale(self.scaleValue, self.scaleValue,self.scaleValue )
		self.shootingRange.name = 'shootingRange'
		self.shootingRange.collideMesh()
		self.shootingRange.disable(viz.DYNAMICS)		
		
		self.target = viz.addChild('target.FBX')
		self.target.name = 'target'
		self.target.setScale(0.9, 0.9, 0.9)
		self.target.collideBox(density = 100)
		self.target.enable(viz.COLLIDE_NOTIFY)
		self.target.setPosition(0,0, 15)
				
		self.enemyGun = viz.addChild('Gun.FBX')
		self.enemyGun.name = 'enemyGun'
		self.enemyGun.setScale(self.scaleValue, self.scaleValue, self.scaleValue)
		self.enemyGun.setPosition(0, 1.8, 14)
		self.enemyGun.setEuler(180,0,0)						
				
		self.bullet = viz.add('Bullet.FBX')
		self.bullet.setPosition(0,1,2)
		self.bullet.setScale(self.scaleValue, self.scaleValue,self.scaleValue)
		self.bullet.name = 'bullet'
		self.bullet.collideCapsule(0.2, 0.1, density = 1, hardness = 1)
		self.bullet.enable(viz.COLLIDE_NOTIFY)
		self.nextShot = True
		
		self.enemyBullet = viz.add('Bullet.FBX')
		self.enemyBullet.setPosition(0,1,10)
		self.enemyBullet.setScale(0.05, 0.05, 0.05)
		self.enemyBullet.name = 'enemyBullet'
		
		self.enemyShot = False
		
		self.enemyShootTimer = vizact.ontimer(3, self.repositionEnemyGun)
		self.moveEnemyBulletTimer = vizact.ontimer(0, self.moveEnemyBullet)
		
		self.moveEnemyBulletTimer.setEnabled(False)
		self.enemyShootTimer.setEnabled(False)
		
		self.shootTimer = vizact.ontimer(1, self.schootClick)
		self.shootTimer.setEnabled(False)	
		
		self.rings = ['Ring10', 'Ring20', 'Ring30', 'Ring40', 'Ring50'] 
									
		self.currentScore = 0		
		self.scoreBaseText = 'Score: '
		self.firstLabelText = self.scoreBaseText + str(self.currentScore)
		self.scoreLabel = viz.addText3D(self.firstLabelText)
		self.scoreLabel.setBackdrop(viz.BACKDROP_RIGHT_BOTTOM)
		self.scoreLabel.setPosition(-1.7, 1, 0)
		self.scoreLabel.setEuler(-90,0,0)
		self.scoreLabel.color(viz.SKYBLUE)
		self.scoreLabel.setScale(0.3, 0.3, 0.3)
		self.scoreLabel.alignment(viz.ALIGN_CENTER_BOTTOM)
		
		self.currentHighScore = 0		
		self.highScoreBaseText = 'Highscore: '
		self.firstHighScoreLabelText = self.highScoreBaseText + str(self.currentHighScore)
		self.highScoreLabel = viz.addText3D(self.firstHighScoreLabelText)
		self.highScoreLabel.setPosition(-1.7, 1.5, 0)
		self.highScoreLabel.setEuler(-90,0,0)
		self.highScoreLabel.color(viz.BLUE)
		self.highScoreLabel.setScale(0.3, 0.3, 0.3)
		self.highScoreLabel.alignment(viz.ALIGN_CENTER_BOTTOM)
		
		self.newPointLabel = viz.addText3D('')
		self.newPointLabel.color(viz.GREEN)
		self.newPointLabel.setPosition(self.target.getPosition()[0], self.target.getPosition()[1] + 2, self.target.getPosition()[2])
		self.newPointLabel.alignment(viz.ALIGN_CENTER_BOTTOM)
		self.maxTimeNewPointVisible = 1
		
		self.newHitLabel = viz.addText3D('')
		self.newHitLabel.color(viz.RED)
		self.newHitLabel.setPosition(self.target.getPosition()[0], self.target.getPosition()[1] + 2.5, self.target.getPosition()[2])
		self.newHitLabel.alignment(viz.ALIGN_CENTER_BOTTOM)
		self.maxTimeHitVisible = 1
		
		self.newPointTimer = vizact.ontimer(self.maxTimeNewPointVisible, self.makeNewPointLabelInvisible)
		self.newPointTimer.setEnabled(False)	
		
		self.newHitPointTimer = vizact.ontimer(self.maxTimeHitVisible, self.makeNewHitLabelInvisible)
		self.newHitPointTimer.setEnabled(False)	
									
		self.goodSound = viz.addAudio('good.mp3')
		self.coinSound = viz.addAudio('coin.wav')	
		self.hitSound = viz.addAudio('hit.mp3')
			
		self.playTimer = vizact.ontimer(1, self.timerClick)
		self.playTimer.setEnabled(False)
		self.playTime = 35		
		self.currentTime = 0
		self.isPlaying = False
		
		self.timeBaseText = 'Time: '
		self.timeLabel = viz.addText3D(self.timeBaseText)
		self.timeLabel.setPosition(1.1, 1.3, 3)
		self.timeLabel.setEuler(50,0,0)
		self.timeLabel.setScale(0.3, 0.3, 0.3)
		self.timeLabel.alignment(viz.ALIGN_CENTER_BOTTOM)
		self.timeLabel.visible(False)
				
		self.scope = viz.addChild('Scope.FBX')
		
		viz.startLayer(viz.LINES)
		viz.vertexColor(viz.RED)
		viz.vertex(-0.2, 0,0)
		viz.vertex(0.2, 0, 0)
		self.topLine = viz.endLayer()
		
		viz.startLayer(viz.LINES)
		viz.vertexColor(viz.RED)
		viz.vertex(0, 0,0)
		viz.vertex(0, -0.3, 0)
		self.leftLine = viz.endLayer()
		
		viz.startLayer(viz.LINES)
		viz.vertexColor(viz.RED)
		viz.vertex(0, 0,0)
		viz.vertex(0, -0.3, 0)
		self.rightLine = viz.endLayer()
		
		self.time = 0.0 
Пример #45
0
	def addCameraBounds(self):
		"""Create node for rendering tracking boundary of HMD camera"""
		if not self._sensor:
			return None

		if (self._sensor.getSrcMask() & viz.LINK_POS) == 0:
			return None

		left,right,bottom,top,near,far = self._sensor.getCameraFrustum()
		s = far / near
		fleft, fright, fbottom, ftop = left*s, right*s, bottom*s, top*s

		viz.startLayer(viz.LINES)

		# Boundary lines
		viz.vertex([0,0,0])
		viz.vertex([fleft,ftop,far])
		viz.vertex([0,0,0])
		viz.vertex([fright,ftop,far])
		viz.vertex([0,0,0])
		viz.vertex([fleft,fbottom,far])
		viz.vertex([0,0,0])
		viz.vertex([fright,fbottom,far])

		# Near plane
		viz.vertex([left,top,near])
		viz.vertex([right,top,near])
		viz.vertex([right,top,near])
		viz.vertex([right,bottom,near])
		viz.vertex([right,bottom,near])
		viz.vertex([left,bottom,near])
		viz.vertex([left,bottom,near])
		viz.vertex([left,top,near])

		# Far plane
		viz.vertex([fleft,ftop,far])
		viz.vertex([fright,ftop,far])
		viz.vertex([fright,ftop,far])
		viz.vertex([fright,fbottom,far])
		viz.vertex([fright,fbottom,far])
		viz.vertex([fleft,fbottom,far])
		viz.vertex([fleft,fbottom,far])
		viz.vertex([fleft,ftop,far])

		lines = viz.endLayer(color=viz.GREEN)
		lines.drawOrder(100)
		lines.disable([viz.LIGHTING,viz.DEPTH_TEST,viz.SHADOW_CASTING,viz.INTERSECTION,viz.PICKING])
		lines.setReferenceFrame(viz.RF_VIEW)
		link = viz.link(self._sensor, lines, srcFlag=ORI_CAMERA)
		link.postMultInverseLinkable(self._sensor)

		return lines
Пример #46
0
#script that starts the vizard enviroment and displays the origin and coordinate axes
#WDA 3/14/2016

import viz
import vizshape

viz.go(

)

origin = vizshape.addSphere(.01,50,50)
origin.color(1,1,0)
origin.setPosition(0,0,0)

viz.startLayer(viz.LINES) 
viz.vertex(0,0,0) #Vertices are split into pairs. 
viz.vertex(1,0,0) 
myLines = viz.endLayer()
myLines.color(1,0,0)
messagewinx = viz.addText('X',pos=[1,0,0],scale=[0.04,0.04,0.04])

viz.startLayer(viz.LINES) 
viz.vertex(0,0,0) #Vertices are split into pairs. 
viz.vertex(0,1,0) 
myLines2 = viz.endLayer()
myLines2.color(0,1,0)
messagewiny = viz.addText('Y',pos=[0,1,0],scale=[0.04,0.04,0.04])

viz.startLayer(viz.LINES) 
viz.vertex(0,0,0) #Vertices are split into pairs. 
viz.vertex(0,0,1) 
import threading
import Queue
import time
import json
import vizact
import math
import cProfile

viz.splashScreen('C:\Users\Gelsey Torres-Oviedo\Desktop\VizardFolderVRServer\Logo_final.jpg')
viz.go(
viz.FULLSCREEN
)
time.sleep(2)#show off a litle bit...

viz.startLayer(viz.LINES) 
viz.vertex(-1,-0.25,-0.0001) #Vertices are split into pairs. 
viz.vertex(1,-0.25,-0.0001) 
myLines = viz.endLayer() 
#indicate flag for post-catch targets, which last for the first 12 steps
global catchflag
catchflag = 1
global stridecounter
stridecounter = 0

#set target tolerance for stride length
global targetL
targetL = 0.25
global targetR
targetR = 0.25
global targettol
targettol = 0.025
Пример #48
0
	def __init__( self , speedMultiplier = 1.0, av_type = 0 ):
		print "Creating a person"
		self.speedMultiplier = speedMultiplier
		self.save_path = path.Path()
		self.in_quad = 0
		if av_type == 0:
			type = random.randrange(0,4)
			if type == 0:
				self.avatar = viz.add('male.cfg',viz.WORLD,scene=viz.MainScene)
			elif type == 1:
				self.avatar = viz.add('vcc_male.cfg',viz.WORLD,scene=viz.MainScene)
			elif type == 2:
				self.avatar = viz.add('female.cfg',viz.WORLD,scene=viz.MainScene)
			else:
				self.avatar = viz.add('vcc_female.cfg',viz.WORLD,scene=viz.MainScene)
		else:
			self.avatar = viz.add('vcc_male.cfg',viz.WORLD,scene=viz.MainScene)
			#Add the hat model
			self.hat = viz.add('tophat.3ds')
			self.hat.setScale([1,5,1])

			#Get the head bone of the avatar
			head = self.avatar.getBone('Bip01 Head')

			#Link the hat to the head
			HatLink = viz.link(head,self.hat)

			#Tweek the hat link so it fits snuggly on the head
			
			HatLink.preTrans( [0,0.1,-0.0] )
			HatLink.preEuler( [0,-10,0] )
			
		self.avatar.setPosition(quadSet.get_random_point())
		#self.save_path.setStart(self.avatar.getPosition())
		self.save_path.addPoint(self.avatar.getPosition(), 0)
		self.next_point = quadSet.get_quadrant(self.avatar.getPosition())[0].get_random_walk()
		self.next_speed = get_next_speed()
		self.save_path.addPoint(self.next_point, self.next_speed)
		self.coll = 0
		self.avatar.collideMesh()
		self.avatar.enable(viz.COLLIDE_NOTIFY)
		
		#setup the AR
		viz.startlayer(viz.QUADS)
		if av_type == 0:
			viz.vertexcolor(1,0,0)
		else:
			viz.vertexcolor(1,0,0)
		viz.linewidth(20)
		pos = self.avatar.getPosition()
		viz.vertex(-0.3,0,0)
		viz.vertex(0.3,0,0)
		viz.vertex(0.3,2,0)
		viz.vertex(-0.3,2,0)
		self.pointAR = viz.endlayer(viz.WORLD, viz.Scene2)
		self.pointAR.alpha(0.3)
		
		self.tracking_error = []
		self.arev = vizact.ontimer(.01,self.move_AR)
		
		self.myquadrants = [False,False,False,False,False,False,False,False]
		self.lastTime = 0
		self.timeNotVisible = 0
    def createVisualObjects(self):

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

        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)

        self.IOD = 0.06
        
        # create a node3D leftEyeNode
        self.cyclopEyeNode = vizshape.addSphere(0.015, color = viz.GREEN)
        #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)
    #    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)
    #    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)

        # Creating a Line to represent 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 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)

        # Creating a Line to represent 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)


        # 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(True)
Пример #50
0
 def draw(self, vertices):
     viz.startLayer(viz.LINE_LOOP)
     viz.lineWidth(10)
     for v in vertices:
         viz.vertex(*v)
     return viz.endLayer()
Пример #51
0
			temp +=(s*0.5,)
		part3 = temp
		result = (part1[0]+part2[0]+part3[0],part1[1]+part2[1]+part3[1],part1[2]+part2[2]+part3[2])
		return result

wd = [0,0,0]
wc = 0
grav = [0.0,9.81,0.0]
bl = ([-4.970107078552246, 5.897994518280029, 1.4124407768249512],[-4.973110198974609, 6.1175079345703125, 2.1125693321228027],[-4.975081920623779, 6.5309247970581055, 2.8221869468688965],[-4.975322246551514, 6.759340286254883, 3.1336262226104736],[-4.975906848907471, 7.1793365478515625, 2.779799699783325],[-4.97451114654541, 5.308044910430908, 3.1625561714172363],[-4.973536014556885, 5.8962178230285645, 3.2122514247894287],[-4.9707231521606445, 5.660599231719971, 3.5753281116485596],[-4.966211795806885, 4.887547492980957, 3.882848024368286],[-2.7433903217315674, 5.715956211090088, 5.507270812988281],[-3.2320258617401123, 6.556395053863525, 5.514878273010254],[-3.798262596130371, 5.829957008361816, 5.529846668243408],[-2.0034732818603516, 7.698963642120361, 5.504480361938477],[-4.953855037689209, 6.041557788848877, 5.1223649978637695],[-1.3830612897872925, 5.617004871368408, -4.059776782989502],[-1.6367100477218628, 3.0266971588134766, -4.050085544586182],[-2.242931604385376, 2.975187301635742, -4.043353080749512],[-2.9772372245788574, 2.110835075378418, -4.028698921203613],[-1.6415677070617676, 2.3813564777374268, -4.04733943939209],[-0.3302052915096283, 1.9607874155044556, -4.049890518188477],[-4.9920268058776855, 5.900781631469727, -1.8857085704803467],[-4.989490985870361, 5.56298828125, -1.7206439971923828],[-4.996257305145264, 4.581329345703125, -2.1972899436950684],[-4.994059085845947, 4.407802581787109, -1.6545305252075195],[-4.992647171020508, 4.442633628845215, -1.1358085870742798],[-4.988626480102539, 4.823823928833008, 0.1453738659620285],[-4.988673210144043, 5.07926607131958, -0.048772379755973816],[-4.988332748413086, 5.744387149810791, -0.1320347636938095],[-4.9886860847473145, 6.315260410308838, -0.23182286322116852],[-4.986820697784424, 5.827799320220947, -0.9230077862739563],[-4.991076946258545, 4.644659042358398, -0.8074011206626892],[-4.9762864112854, 4.111218452453613, 3.3881337642669678],[-4.9752607345581055, 7.730223178863525, 2.4686429500579834],[0.26733750104904175, 8.535117149353027, 5.487018585205078],[1.2186188697814941, 7.103093147277832, 5.488711833953857],[-0.5966476202011108, 7.537855625152588, 5.486145973205566],[-0.8177675008773804, 7.79792594909668, 5.4877166748046875],[-1.8698996305465698, 8.362137794494629, 5.504770755767822],[-4.992286205291748, 2.577256441116333, 0.02785523794591427])
al = []
target = [1.1959341764450073, 7.428847789764404, 0.7743394374847412]
masterpointlist = []
for b in bl:
	viz.startLayer(viz.LINE_STRIP)
	viz.vertexcolor(viz.BLUE)
	viz.vertex(b)
	x=0
	al += ([target[0]-b[0],target[1]-b[1],target[2]-b[2]],)
	pointlist = []
	while x <=5:
		point = formula(grav,wd,wc,x,al[bl.index(b)*-1],b)
		viz.vertex(point)
		pointlist += [point]
		x += 0.1
	masterpointlist += [pointlist]
	viz.endLayer()
area = []
z=0
print al
zcount = len(masterpointlist)-1
while z < zcount:
Пример #52
0
import viz
import vizshape

viz.startLayer(viz.LINES)
viz.vertexColor(viz.YELLOW)
viz.vertex(0,0,0)
viz.vertex(1,0,0)
X = viz.endLayer()

viz.startLayer(viz.LINES)
viz.vertex(0,0,0)
viz.vertex(0,1,0)
Y = viz.endLayer()

viz.startLayer(viz.LINES)
viz.vertexColor(viz.BLUE)
viz.vertex(0,0,0)
viz.vertex(0,0,1)
Z = viz.endLayer()

viz.go()

viz.MainView.setPosition(0,0,-1)
Пример #53
0
def createSolidBox(min, max):
    viz.startlayer(viz.QUADS, "top")
    viz.vertexcolor(1.0, 0.5, 0.0)

    # top
    # viz.vertexcolor(0.0,1.0,0.0)
    viz.normal(0, 1, 0)
    viz.vertex(max[0], max[1], min[2])
    viz.vertex(min[0], max[1], min[2])
    viz.vertex(min[0], max[1], max[2])
    viz.vertex(max[0], max[1], max[2])

    viz.startlayer(viz.QUADS, "bottom")
    viz.vertexcolor(0.5, 0.5, 0.0)
    viz.linewidth(2.0)

    # bottom
    # viz.vertexcolor(1.0,0.5,0.0)
    viz.normal(0, -1, 0)
    viz.vertex(max[0], min[1], max[2])
    viz.vertex(min[0], min[1], max[2])
    viz.vertex(min[0], min[1], min[2])
    viz.vertex(max[0], min[1], min[2])

    viz.startlayer(viz.QUADS, "front")
    viz.vertexcolor(0.5, 0.5, 0.0)
    viz.linewidth(2.0)

    # front
    # viz.vertexcolor(1.0,0.0,0.0)
    viz.normal(0, 0, 1)
    viz.vertex(max[0], max[1], max[2])
    viz.vertex(min[0], max[1], max[2])
    viz.vertex(min[0], min[1], max[2])
    viz.vertex(max[0], min[1], max[2])

    viz.startlayer(viz.QUADS, "back")
    viz.vertexcolor(0.5, 0.5, 0.0)
    viz.linewidth(2.0)

    # back
    # viz.vertexcolor(1.0,1.0,0.0)
    viz.normal(0, 0, -1)
    viz.vertex(max[0], min[1], min[2])
    viz.vertex(min[0], min[1], min[2])
    viz.vertex(min[0], max[1], min[2])
    viz.vertex(max[0], max[1], min[2])

    viz.startlayer(viz.QUADS, "left")
    viz.vertexcolor(0.5, 0.5, 0.0)
    viz.linewidth(2.0)

    # left
    # viz.vertexcolor(0.0,0.0,1.0)
    viz.normal(-1, 0, 0)
    viz.vertex(min[0], max[1], max[2])
    viz.vertex(min[0], max[1], min[2])
    viz.vertex(min[0], min[1], min[2])
    viz.vertex(min[0], min[1], max[2])

    viz.startlayer(viz.QUADS, "right")
    viz.vertexcolor(0.5, 0.5, 0.0)
    viz.linewidth(2.0)

    # right
    # viz.vertexcolor(1.0,0.0,1.0)
    viz.normal(1, 0, 0)
    viz.vertex(max[0], max[1], min[2])
    viz.vertex(max[0], max[1], max[2])
    viz.vertex(max[0], min[1], max[2])
    viz.vertex(max[0], min[1], min[2])

    return viz.endlayer()
				panel.setText(test_text[test_num])
				if(test_num == 2):
					background2.visible(viz.ON)

# Add controllers
for controller in steamvr.getControllerList():

	# Create model for controller
	controller.model = controller.addModel(parent=navigationNode)
	controller.model.disable(viz.INTERSECTION)
	viz.link(controller, controller.model)

	# Create pointer line for controller
	viz.startLayer(viz.LINES)
	viz.vertexColor(viz.WHITE)
	viz.vertex([0,0,0])
	viz.vertex([0,0,100])
	controller.line = viz.endLayer(parent=controller.model)
	controller.line.disable([viz.INTERSECTION, viz.SHADOW_CASTING])
	controller.line.visible(True)

	# Setup task for triggering jumps using controller
	viztask.schedule(JumpTask(controller))

# Add directions to canvas
canvas = viz.addGUICanvas(pos=[0, 3.0, 6.0])
canvas.setMouseStyle(0)
canvas.alignment(viz.ALIGN_CENTER)
canvas.setRenderWorld([400,400], [5.0,5.0])

instructions =test_text[test_num]
Пример #55
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)
Пример #56
0
	def __init__( self ,  av_type = 0):
		self.in_quad = 0
		if av_type == 0:
			type = random.randrange(0,4)
			if type == 0:
				self.avatar = viz.add('male.cfg',viz.WORLD,scene=viz.MainScene)
			elif type == 1:
				self.avatar = viz.add('vcc_male.cfg',viz.WORLD,scene=viz.MainScene)
			elif type == 2:
				self.avatar = viz.add('female.cfg',viz.WORLD,scene=viz.MainScene)
			else:
				self.avatar = viz.add('vcc_female.cfg',viz.WORLD,scene=viz.MainScene)
		else:
			self.avatar = viz.add('vcc_male.cfg',viz.WORLD,scene=viz.MainScene)
			#Add the hat model
			self.hat = viz.add('tophat.3ds')
			self.hat.setScale([1,5,1])

			#Get the head bone of the avatar
			head = self.avatar.getBone('Bip01 Head')

			#Link the hat to the head
			HatLink = viz.link(head,self.hat)

			#Tweek the hat link so it fits snuggly on the head
			
			HatLink.preTrans( [0,0.1,-0.0] )
			HatLink.preEuler( [0,-10,0] )
			#HatLink.([0,5,0])
			
		self.avatar.setPosition(get_random_point())
		self.next_point = get_quadrant(self.avatar.getPosition()).get_random_walk()
		self.coll = 0
		self.avatar.collideMesh()
		self.avatar.enable(viz.COLLIDE_NOTIFY)
		
		#setup the AR
		viz.startlayer(viz.QUADS)
		viz.vertexcolor(1,0,0)
		#viz.pointsize(20)
		viz.linewidth(20)
		pos = self.avatar.getPosition()
		#viz.vertex(pos[0], -20, pos[2])
		#viz.vertex(pos[0], 20, pos[2])
		#rx = 0.5
		#ry = 1
		#viz.vertex(-rx, 0, 0)
		#viz.vertex(-rx, r, 0)
		#viz.vertex(r, r, 0)
		#viz.vertex(r, -r, 0)
		
		#viz.vertex(0,0,0)
		#viz.vertex(0,2,0)
		viz.vertex(-0.3,0,0)
		viz.vertex(0.3,0,0)
		viz.vertex(0.3,2,0)
		viz.vertex(-0.3,2,0)
		self.pointAR = viz.endlayer(viz.WORLD, viz.Scene2)
		self.set_AR(True)
		#self.pointAR.alpha(0.3)
		
		
		self.arev = vizact.ontimer(.01,self.move_AR)
Пример #57
0
def createSolidBox(min,max):
	viz.startlayer(viz.QUADS, 'top') 
	viz.vertexcolor(1.0,0.5,0.0)
	
	#top
	#viz.vertexcolor(0.0,1.0,0.0)
	viz.normal(0,1,0)
	viz.vertex( max[0], max[1], min[2])
	viz.vertex( min[0], max[1], min[2])
	viz.vertex( min[0], max[1], max[2])
	viz.vertex( max[0], max[1], max[2])

	viz.startlayer(viz.QUADS,'bottom') 
	viz.vertexcolor(.5,.5,0.0)
	viz.linewidth(2.0)
	
	#bottom
	#viz.vertexcolor(1.0,0.5,0.0)
	viz.normal(0,-1,0)
	viz.vertex( max[0], min[1], max[2])
	viz.vertex( min[0], min[1], max[2])
	viz.vertex( min[0], min[1], min[2])
	viz.vertex( max[0], min[1], min[2])

	viz.startlayer(viz.QUADS,'front') 
	viz.vertexcolor(.5,.5,0.0)
	viz.linewidth(2.0)
	
	#front
	#viz.vertexcolor(1.0,0.0,0.0)
	viz.normal(0,0,1)
	viz.vertex( max[0], max[1], max[2])
	viz.vertex( min[0], max[1], max[2])
	viz.vertex( min[0], min[1], max[2])
	viz.vertex( max[0], min[1], max[2])

	viz.startlayer(viz.QUADS,'back') 
	viz.vertexcolor(.5,.5,0.0)
	viz.linewidth(2.0)
	
	#back
	#viz.vertexcolor(1.0,1.0,0.0)
	viz.normal(0,0,-1)
	viz.vertex( max[0], min[1], min[2])
	viz.vertex( min[0], min[1], min[2])
	viz.vertex( min[0], max[1], min[2])
	viz.vertex( max[0], max[1], min[2])

	viz.startlayer(viz.QUADS,'left') 
	viz.vertexcolor(.5,.5,0.0)
	viz.linewidth(2.0)
	
	#left
	#viz.vertexcolor(0.0,0.0,1.0)		
	viz.normal(-1,0,0)
	viz.vertex( min[0], max[1], max[2])	
	viz.vertex( min[0], max[1], min[2])	
	viz.vertex( min[0], min[1], min[2])	
	viz.vertex( min[0], min[1], max[2])	

	viz.startlayer(viz.QUADS,'right') 
	viz.vertexcolor(.5,.5,0.0)
	viz.linewidth(2.0)
	
	#right
	#viz.vertexcolor(1.0,0.0,1.0)
	viz.normal(1,0,0)
	viz.vertex( max[0], max[1], min[2])	
	viz.vertex( max[0], max[1], max[2])	
	viz.vertex( max[0], min[1], max[2])	
	viz.vertex( max[0], min[1], min[2])	
	
	return viz.endlayer()
Пример #58
0
node2D.setScene(viz.Scene3)
node2D.setBuffer( viz.RENDER_FRAME_BUFFER )
node2D.setOrder( viz.POST_RENDER )
node2D.setInheritView(0)
node2D.setSize( HMDwidth,HMDheight )
node2D.setProjectionMatrix(viz.Matrix.ortho2D(0,HMDwidth,0,HMDheight))
node2D.setClearMask(0)
node2D.disable(viz.DEPTH_TEST)
#viz.startlayer(viz.LINES)
#viz.vertex([HMDwidth/2,0,0])
#viz.vertex([HMDwidth/2,HMDheight,0])
#viz.endlayer(viz.WORLD,viz.Scene3)

viz.startlayer(viz.LINES)
viz.vertexcolor([1,0,0])
viz.vertex([HMDwidth/2-10,HMDheight/2,0])
viz.vertex([HMDwidth/2+10,HMDheight/2,0])
viz.vertex([HMDwidth/2,HMDheight/2-10,0])
viz.vertex([HMDwidth/2,HMDheight/2+10,0])
viz.vertexcolor([1,1,1])
viz.endlayer(viz.WORLD,viz.Scene3)








ringbuffer_len = 20
yaw_ringbuffer = range(ringbuffer_len)
Пример #59
0
import viz
import vizact
viz.go()

#Example for creating a fan of triangles: 
viz.startLayer(viz.TRIANGLE_FAN)  
viz.vertex(0,1,5) #All the triangles have the first vertex as a point. 
viz.vertex(-1.5,1.35,10) #The other points are taken in pairs. 
viz.vertex(-.25,1.5,10) 
viz.vertex(0,.8,10) 
viz.vertex(.25,1.5,10) 
viz.vertex(1.5,1.35,10) 
myTrianglefan = viz.endLayer()  

#Notify Vizard that the layer will be modified frequently. 
myTrianglefan.dynamic() 

#Grab a vertex. 
tip = myTrianglefan.Vertex( 0 ) 
fadeInAndOut = vizact.sequence( [vizact.fadeTo(viz.RED,time=1),vizact.fadeTo(viz.WHITE,time=1)], viz.PERPETUAL ) 
#Apply an action to the vertex. 
tip.addAction( fadeInAndOut )