コード例 #1
0
ファイル: Maze.py プロジェクト: talathom/GraphicsLab7
 def addCoordinateAxes(self):
     viz.startLayer(viz.LINES)
     viz.linewidth(7)
     viz.vertexColor(viz.RED)
     # positive y axis
     viz.vertex(0, 0, 0)
     viz.vertex(0, 20, 0)
     #positive x axis
     viz.vertex(0, 0, 0)
     viz.vertex(20, 0, 0)
     #positive z axis
     viz.vertex(0, 0, 0)
     viz.vertex(0, 0, 20)
     #y=1 tick mark
     viz.vertex(-0.25, 1, 0)
     viz.vertex(0.25, 1, 0)
     #y=2 tick mark
     viz.vertex(-0.25, 2, 0)
     viz.vertex(0.25, 2, 0)
     #x=1 tick mark
     viz.vertex(1, 0, -.25)
     viz.vertex(1, 0, .25)
     #x=2 tick mark
     viz.vertex(2, 0, -.25)
     viz.vertex(2, 0, +.25)
     #z=1 tick mark
     viz.vertex(-.25, 0, 1)
     viz.vertex(.25, 0, 1)
     #z=2 tick mark
     viz.vertex(-.25, 0, 2)
     viz.vertex(.25, 0, 2)
     viz.endLayer()
コード例 #2
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()
コード例 #3
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()
コード例 #4
0
	def __init__(self, x, y):
		height = 10
		width = 10
		self.x = 0
		self.y = 0
		viz.startLayer(viz.QUADS)
		viz.vertexColor(1,1,0)
		viz.pointSize(1)
		viz.vertex(-5,10)
		viz.vertex(5,10)
		viz.vertex(5,-10)
		viz.vertex(-5,-10)
		viz.endLayer()
コード例 #5
0
ファイル: BallZUtil.py プロジェクト: MSPigl/Computer-Graphics
    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()
コード例 #6
0
    def __init__(self, x, y):
        self.x = x
        self.y = y
        #main ship
        viz.startLayer(viz.QUADS)
        viz.vertexColor(0.27, 0.58, 0.16)
        viz.vertex(-15, -9)
        viz.vertexColor(0.5, 0.4, 0.3)
        viz.vertex(-15, 9)
        viz.vertexColor(0.1, 0, 0.8)
        viz.vertex(15, 9)
        viz.vertexColor(0.5, 0.4, 0.3)
        viz.vertex(15, -9)

        #cannon
        viz.vertexColor(0.27, 0.58, 0.16)
        viz.vertex(4.5, 9)
        viz.vertex(-4.5, 9)
        viz.vertex(-4.5, 14)
        viz.vertexColor(0.2, 0, 0.5)
        viz.vertex(4.5, 14)

        #top
        viz.vertexColor(0.27, 0.58, 0.16)
        viz.vertex(1.5, 14)
        viz.vertex(-1.5, 14)
        viz.vertex(-1.5, 18)
        viz.vertex(1.5, 18)
        self.vertices = viz.endLayer()
コード例 #7
0
    def __init__(self, x, y):
        self.x = x
        self.y = y
        viz.startLayer(viz.QUADS)

        #eye
        viz.vertexColor(1, 0, 0)
        viz.vertex(-5, 0)
        viz.vertex(0, 3)
        viz.vertex(5, 0)
        viz.vertex(0, -3)

        #body
        viz.vertexColor(0, 0.5, 0.5)
        viz.vertex(-10, -10)
        viz.vertex(-6, 6.2)
        viz.vertex(6, 6.2)
        viz.vertex(10, -10)

        #left ear
        viz.vertexColor(1, 0, 0)
        viz.vertex(-5.8, 6)
        viz.vertex(-5.8, 10)
        viz.vertex(-1.9, 10)
        viz.vertex(-1.9, 6)

        #right ear
        viz.vertexColor(1, 0, 0)
        viz.vertex(6, 6)
        viz.vertex(6, 10)
        viz.vertex(2, 10)
        viz.vertex(2, 6)
        self.vertices = viz.endLayer()
コード例 #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 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)
コード例 #10
0
			def createRod():
				viz.startLayer(viz.POINTS)
				viz.pointSize(4)
				viz.vertex(0,1.65,1)
				viz.vertex(0,1.70,1)
				viz.vertex(0,1.75,1)
				viz.vertex(0,1.80,1)
				viz.vertex(0,1.85,1)
				viz.vertex(0,1.90,1)
				viz.vertex(0,1.95,1)
				line = viz.endLayer()
				line.visible(viz.OFF)
				line.center(0,1.8,1)
				initLinePos = 0 + 20 * random.uniform(-1,1)
				line.setEuler([0,0,initLinePos])
				class LineRotation(viz.EventClass):
					def __init__(self):
						viz.EventClass.__init__(self)

						self.callback(viz.KEYDOWN_EVENT, self.keyboardAction)

					def keyboardAction(self,key):
						currentPosition = line.getEuler()
						currentRoll = currentPosition[2]
						if viz.key.isDown(viz.KEY_LEFT):
							line.setEuler([0,0,currentRoll + 1])
						elif viz.key.isDown(viz.KEY_RIGHT): 
							line.setEuler([0,0,currentRoll -1])
				LineRotation()
				return line, initLinePos
コード例 #11
0
ファイル: mocapInterfaceNew.py プロジェクト: vicmcg/CGMaze
    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.
コード例 #12
0
ファイル: Environments.py プロジェクト: dlcen/VizardCode
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
コード例 #13
0
			def createFrame(direction):

				viz.startLayer(viz.LINES)
				viz.vertex(-.2,1.6,1)
				viz.vertex(-.2,2,1)

				viz.vertex(.2,1.6,1)
				viz.vertex(.2,2,1)

				viz.vertex(-.2,1.6,1)
				viz.vertex(.2,1.6,1)

				viz.vertex(-.2,2,1)
				viz.vertex(.2,2,1)

				poly = viz.endLayer()
				poly.visible(viz.OFF)
				poly.center(0,1.8,1)
				if direction == 'left':
					poly.setEuler([0,0,20])
				elif direction == 'right':
					poly.setEuler([0,0,-20])
				elif direction == 'none':
					poly.remove()
				return poly
コード例 #14
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
コード例 #15
0
    def generateLayer(self, terrainData):
        viz.startLayer(viz.TRIANGLES)
        for r in range(0, len(terrainData) - 1):
            for c in range(0, len(terrainData) - 1):
                # each array location generates two triangles

                viz.vertexColor(0.545, .2, 0.074)
                # corners of first triangle, in ccw order when looking down on the surface
                c1 = [c, terrainData[r][c], r]
                c2 = [c + 1, terrainData[r + 1][c + 1], r + 1]
                c3 = [c, terrainData[r + 1][c], r + 1]

                viz.normal(self.normal(c1, c2, c3))
                viz.vertex(c1)
                viz.vertex(c2)
                viz.vertex(c3)

                viz.vertexColor(0.545, .2, 0.074)
                # corners of second triangle, in ccw order when looking down on the surface
                c1 = [c, terrainData[r][c], r]
                c2 = [c + 1, terrainData[r][c + 1], r]
                c3 = [c + 1, terrainData[r + 1][c + 1], r + 1]

                viz.normal(self.normal(c1, c2, c3))
                viz.vertex(c1)
                viz.vertex(c2)
                viz.vertex(c3)

        return viz.endLayer()
コード例 #16
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
コード例 #17
0
ファイル: mocapInterfaceNew.py プロジェクト: vicmcg/CGMaze
	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.
コード例 #18
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()
コード例 #19
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)
コード例 #20
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.
コード例 #21
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()
コード例 #22
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
コード例 #23
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
コード例 #24
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
コード例 #25
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
コード例 #26
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
コード例 #27
0
ファイル: Experiment.py プロジェクト: dlcen/VizardCode
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
コード例 #28
0
ファイル: BallZUtil.py プロジェクト: MSPigl/Computer-Graphics
    def __init__(self, length, colors, x, y):
        self.length = length
        self.colors = colors
        self.x = x
        self.y = y

        viz.startLayer(viz.POLYGON)

        viz.vertexColor(colors[0], colors[1], colors[2])
        viz.pointSize(1)

        viz.vertex(0, 0)
        viz.vertex(length, 0)
        viz.vertex(length, length)

        viz.vertex(0, length)

        viz.endLayer()
コード例 #29
0
    def __init__(self):
        # must call constructor of EventClass first!!
        viz.EventClass.__init__(self)
        self.x = 20
        self.z = 20
        self.y = 0
        self.theta = 0
        self.angl = 0
        self.callback(viz.KEYDOWN_EVENT, self.onKeyDown)
        self.avatar = viz.add('vcc_female.cfg')
        self.avatar.disable(viz.INTERSECTION)

        print "Reading file greysriver.asc..."
        f = open('greysriver.asc', 'r')
        # first two lines are number of cols and rows
        cols = int(str.split(f.readline())[1])
        rows = int(str.split(f.readline())[1])

        # discard next 4 lines in file
        f.readline(), f.readline(), f.readline(), f.readline()

        # create 2D array of empty lists, one empty list for each row of data
        self.elevation = [[] for x in range(0, rows)]
        maxElevation = -50000
        minElevation = 50000
        # read in elevation data and keep track of max and min elevations
        for r in range(0, rows):
            for n in str.split(f.readline()):
                self.elevation[r].append(float(n))
                if (float(n) > maxElevation):
                    maxElevation = float(n)
                if (float(n) < minElevation):
                    minElevation = float(n)

        # create triangle mesh
        viz.startLayer(viz.TRIANGLES)
        for r in range(rows - 1):
            for c in range(cols - 1):
                # create first triangle
                color = self.getColor(self.elevation[r][c], maxElevation,
                                      minElevation)
                viz.vertexColor(color)
                viz.vertex(c, self.elevation[r][c], r)
                viz.vertex(c + 1, self.elevation[r + 1][c + 1], r + 1)
                viz.vertex(c, self.elevation[r + 1][c], r + 1)

                # create second triangle
                color = self.getColor(self.elevation[r][c + 1], maxElevation,
                                      minElevation)
                viz.vertexColor(color)
                viz.vertex(c, self.elevation[r][c], r)
                viz.vertex(c + 1, self.elevation[r][c + 1], r)
                viz.vertex(c + 1, self.elevation[r + 1][c + 1], r + 1)
        self.t = viz.endLayer()
        self.y = self.elevation[20][20] + 1
        self.transform()
コード例 #30
0
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)
コード例 #31
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()
コード例 #32
0
ファイル: Arm.py プロジェクト: MSPigl/Computer-Graphics
    def __init__(self):
        viz.EventClass.__init__(self)

        # create 3 layers here for base, upper arm, and lower arm
        # Base
        viz.startLayer(viz.POLYGON)
        viz.vertexColor(viz.RED)
        viz.vertex(-25, 10)
        viz.vertex(25, 10)
        viz.vertex(25, 0)
        viz.vertex(-25, 0)
        self.base = viz.endLayer()

        # UA
        viz.startLayer(viz.POLYGON)
        viz.vertexColor(viz.BLUE)
        viz.vertex(0, 5)
        viz.vertex(40, 5)
        viz.vertex(40, 0)
        viz.vertex(0, 0)
        self.upperArm = viz.endLayer()

        # LA
        viz.startLayer(viz.POLYGON)
        viz.vertexColor(viz.WHITE)
        viz.vertex(0, 5)
        viz.vertex(20, 5)
        viz.vertex(20, 0)
        viz.vertex(0, 0)
        self.lowerArm = viz.endLayer()

        # starting configuration
        self.ua = 120
        self.la = 85
        self.baseX = 0
        self.baseY = 0

        self.upperArm.setParent(self.base)
        self.lowerArm.setParent(self.upperArm)

        self.setTransformations()

        self.callback(viz.KEYDOWN_EVENT, self.onKeyDown)
コード例 #33
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 )
コード例 #34
0
ファイル: BallZUtil.py プロジェクト: MSPigl/Computer-Graphics
    def __init__(self, angle, length):
        self.angle = angle
        self.length = length

        self.angle *= math.pi / 180

        self.x = math.cos(angle) * length
        self.y = math.sin(angle) * length

        print("({}, {})".format(self.x, self.y))

        viz.startLayer(viz.LINES)

        viz.vertexColor(1, 0, 0)
        viz.lineWidth(10)

        viz.vertex(0, 0)
        viz.vertex(self.x, self.y)

        viz.endLayer()
コード例 #35
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()
コード例 #36
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
コード例 #37
0
ファイル: view.py プロジェクト: erikmessier/anatomy-puzzle
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
コード例 #38
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)
コード例 #39
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)
コード例 #40
0
	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)
コード例 #41
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)
コード例 #42
0
	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 
コード例 #43
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)
コード例 #44
0
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) 
myLines3 = viz.endLayer()
myLines3.color(0,0,1)
コード例 #45
0
					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]
panel = vizinfo.InfoPanel(instructions, title='Instructions', key=None, icon=False, align=viz.ALIGN_CENTER, parent=canvas)
#textButton = viz.addButtonLabel('next')
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
global targetto2
targetto2 = 0.0375
コード例 #47
0
 def draw(self, vertices):
     viz.startLayer(viz.LINE_LOOP)
     viz.lineWidth(10)
     for v in vertices:
         viz.vertex(*v)
     return viz.endLayer()
コード例 #48
0
ファイル: Flying_Demo_2015.py プロジェクト: vhilab/Demos
#Sounds to play on building collisions
CRASH_SOUND = viz.playSound('BuildingCrashSound.wav', viz.SOUND_PRELOAD)

BirdEyeWindow = viz.addWindow()
BirdEyeWindow.fov(60)
BirdEyeWindow.visible(0,viz.SCREEN)
BirdEyeView = viz.addView()
BirdEyeWindow.setView(BirdEyeView)
BirdEyeWindow.setPosition([0,25,0])
BirdEyeView.setEuler([0,90,0])

###User tracking with lines###
viz.startLayer(viz.LINE_STRIP)
viz.vertexColor(viz.YELLOW)
lines = viz.endLayer(parent=viz.ORTHO,scene=BirdEyeWindow)

lines.dynamic()

def UpdatePath():

    # Get main view position in bird eye window pixel coordinates
    x,y,z = BirdEyeWindow.worldToScreen(viz.MainView.getPosition(),mode=viz.WINDOW_PIXELS)

    # Get position of last line vertex
    lx,ly,lz = lines.getVertex(-1)

    # Add new vertex if current position is different from last position
    if x != lx or y != ly:
        lines.addVertex([x,y,0.0])
コード例 #49
0
ファイル: otfTest.py プロジェクト: vhilab/homelessness-study
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 ) 
コード例 #50
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)
コード例 #51
0
ファイル: somewhere.py プロジェクト: Dethro16/NFI
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:
	y=z+1
	fpl = masterpointlist[z]
	while y <= zcount:
		spl = masterpointlist[y]
		for i in fpl:
			for j in spl:
				dist = math.sqrt(pow((i[0]-j[0]),2) + pow((i[1]-j[1]),2) + pow((i[2]-j[2]),2))
				if dist <0.1:
					if area.count(i) == 0:
						area += [i]