def makeSelectRect(): ctup = (1,1,1,1) fmt = GeomVertexFormat.getV3c4() vertexData = GeomVertexData('points', fmt, Geom.UHDynamic) points = ( #makes nice for Tristrips (0,0,0), (0,0,1), (1,0,0), (1,0,1), ) verts = GeomVertexWriter(vertexData, 'vertex') color = GeomVertexWriter(vertexData, 'color') for point in points: verts.addData3f(*point) color.addData4f(*ctup) boxLines = GeomLinestrips(Geom.UHDynamic) boxLines.addVertices(0,1,3,2) boxLines.addVertex(0) boxLines.closePrimitive() boxTris = GeomTristrips(Geom.UHDynamic) boxTris.addConsecutiveVertices(0,3) boxTris.closePrimitive() box = Geom(vertexData) box.addPrimitive(boxLines) #box.addPrimitive(boxTris) return box
def makeSelectRect(): ctup = (1, 1, 1, 1) fmt = GeomVertexFormat.getV3c4() vertexData = GeomVertexData('points', fmt, Geom.UHDynamic) points = ( #makes nice for Tristrips (0, 0, 0), (0, 0, 1), (1, 0, 0), (1, 0, 1), ) verts = GeomVertexWriter(vertexData, 'vertex') color = GeomVertexWriter(vertexData, 'color') for point in points: verts.addData3f(*point) color.addData4f(*ctup) boxLines = GeomLinestrips(Geom.UHDynamic) boxLines.addVertices(0, 1, 3, 2) boxLines.addVertex(0) boxLines.closePrimitive() boxTris = GeomTristrips(Geom.UHDynamic) boxTris.addConsecutiveVertices(0, 3) boxTris.closePrimitive() box = Geom(vertexData) box.addPrimitive(boxLines) #box.addPrimitive(boxTris) return box
def draw(self): self.clearMesh() #print "vertices : %s" % (self.vertices) for p in self.vertices: self.vWriter.addData3f(p[0], p[1], p[2]) self.cWriter.addData4f(self.color) lines = GeomLinestrips (Geom.UHStatic) for line in self.lines: lines.addVertices(line[0], line[1]) lines.closePrimitive() self.geom.addPrimitive (lines)
def draw(self): self.clearMesh() #print "vertices : %s" % (self.vertices) for p in self.vertices: self.vWriter.addData3f(p[0], p[1], p[2]) self.cWriter.addData4f(self.color) lines = GeomLinestrips(Geom.UHStatic) for line in self.lines: lines.addVertices(line[0], line[1]) lines.closePrimitive() self.geom.addPrimitive(lines)
def primitives_lines(self, vdata): vertex = GeomVertexWriter(vdata, 'vertex') color = GeomVertexWriter(vdata, 'color') n = len(self.points) # Points for p in self.points: vertex.addData3f(p.x, p.y, p.z) color.addData4f(0.2, 0.2, 0.2, 0.0) # Triangles for a, b, c in self.vertices: lines = GeomLinestrips(Geom.UHStatic) lines.addVertices(a, b, c, a) lines.closePrimitive() yield lines
def _get_primitive() -> GeomLines: """Generate GeomLines primitive for bounding box lines.""" primitive = GeomLinestrips(Geom.UHStatic) # 0, 1, 2, 3, 4, 5, 6, 7 - bounding box grey vertices # Bounding box for i in [0, 4]: for j in [0, 1, 2, 3, 0]: primitive.addVertex(i + j) primitive.closePrimitive() for i in range(4): primitive.addVertices(i, i + 4) primitive.closePrimitive() return primitive
def _get_primitive_linestrips(line_count: int) -> GeomPrimitive: """Generate GeomLinestrips primitive for build plate grid. Parameters ---------- line_count : int Line count for the generated GeomLinestrips primitive. Returns ------- GeomLinestrips Generated primitive. """ primitive = GeomLinestrips(Geom.UHStatic) for i in range(line_count): primitive.addVertices(2 * i, 2 * i + 1) primitive.closePrimitive() return primitive
def line (self, start, end): # since we're doing line segments, just vertices in our geom format = GeomVertexFormat.getV3() # build our data structure and get a handle to the vertex column vdata = GeomVertexData ('', format, Geom.UHStatic) vertices = GeomVertexWriter (vdata, 'vertex') # build a linestrip vertex buffer lines = GeomLinestrips (Geom.UHStatic) vertices.addData3f (start[0], start[1], start[2]) vertices.addData3f (end[0], end[1], end[2]) lines.addVertices (0, 1) lines.closePrimitive() geom = Geom (vdata) geom.addPrimitive (lines) # Add our primitive to the geomnode #self.gnode.addGeom (geom) return geom
def makeAxis(): #FIXME make this scale based on zoom??? """ x y z r g b """ colors = ( (1,0,0,1), (0,1,0,1), (0,0,1,1), (1,0,0,1), (0,1,0,1), (0,0,1,1), ) points = ( (0,0,0), (0,0,0), (0,0,0), (1,0,0), (0,1,0), (0,0,1), ) fmt = GeomVertexFormat.getV3c4() #3 component vertex, w/ 4 comp color #fmt = GeomVertexFormat.getV3() #3 component vertex, w/ 4 comp color vertexData = GeomVertexData('points', fmt, Geom.UHStatic) verts = GeomVertexWriter(vertexData, 'vertex') color = GeomVertexWriter(vertexData, 'color') for p,c in zip(points,colors): verts.addData3f(*p) color.addData4f(*c) axisX = GeomLinestrips(Geom.UHStatic) axisX.addVertices(0,3) axisX.closePrimitive() axisY = GeomLinestrips(Geom.UHStatic) axisY.addVertices(1,4) axisY.closePrimitive() axisZ = GeomLinestrips(Geom.UHStatic) axisZ.addVertices(2,5) axisZ.closePrimitive() axis = Geom(vertexData) axis.addPrimitive(axisX) axis.addPrimitive(axisY) axis.addPrimitive(axisZ) return axis
def makeAxis(): #FIXME make this scale based on zoom??? """ x y z r g b """ colors = ( (1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1), (1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1), ) points = ( (0, 0, 0), (0, 0, 0), (0, 0, 0), (1, 0, 0), (0, 1, 0), (0, 0, 1), ) fmt = GeomVertexFormat.getV3c4() #3 component vertex, w/ 4 comp color #fmt = GeomVertexFormat.getV3() #3 component vertex, w/ 4 comp color vertexData = GeomVertexData('points', fmt, Geom.UHStatic) verts = GeomVertexWriter(vertexData, 'vertex') color = GeomVertexWriter(vertexData, 'color') for p, c in zip(points, colors): verts.addData3f(*p) color.addData4f(*c) axisX = GeomLinestrips(Geom.UHStatic) axisX.addVertices(0, 3) axisX.closePrimitive() axisY = GeomLinestrips(Geom.UHStatic) axisY.addVertices(1, 4) axisY.closePrimitive() axisZ = GeomLinestrips(Geom.UHStatic) axisZ.addVertices(2, 5) axisZ.closePrimitive() axis = Geom(vertexData) axis.addPrimitive(axisX) axis.addPrimitive(axisY) axis.addPrimitive(axisZ) return axis