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
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
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()
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
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
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)
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, 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()
def __init__(self, angle, length): # Instance variables self.angle = angle self.changeInAngle = 0 self.length = length self.x = 0 self.y = -100 viz.startLayer(viz.LINES) viz.vertexColor(1, 0, 0) viz.lineWidth(5) # Define vertices viz.vertex(0, 0) viz.vertex(math.cos(math.radians(self.angle)) * self.length, math.sin(math.radians(self.angle)) * 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)
def addToolTip(self, bb): self.tooltip = viz.addText(self.nameFormatted) self.tooltip.visible(viz.OFF) self.tooltip.color([0.0, 1.0, 0.5]) self.tooltip.setParent(bb) position = list( numpy.add( numpy.subtract(bb.centerPointScaled, bb.cornerPointScaled), bb.axis.getPosition(viz.ABS_GLOBAL)) ) #calculate transformed center of the bounding box position = [[x, y, z - 1] for x, y, z in [position]][0] self.tooltip.billboard(viz.BILLBOARD_VIEW) self.tooltip.setScale(0.1, 0.1, 0.1) #set to prefered scale self.tooltip.setPosition(position) self.tooltip.alignment(viz.TEXT_CENTER_CENTER) #Line between tooltip and mesh centerPoint viz.startLayer(viz.LINES) viz.vertexColor(viz.BLUE) viz.lineWidth(2) self.nameLine = viz.endLayer() self.nameLine.dynamic() self.nameLine.visible(viz.OFF)
def draw(self, vertices): viz.startLayer(viz.LINE_LOOP) viz.lineWidth(10) for v in vertices: viz.vertex(*v) return viz.endLayer()