本文整理汇总了Python中UM.Mesh.MeshBuilder.MeshBuilder.addVertex方法的典型用法代码示例。如果您正苦于以下问题:Python MeshBuilder.addVertex方法的具体用法?Python MeshBuilder.addVertex怎么用?Python MeshBuilder.addVertex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UM.Mesh.MeshBuilder.MeshBuilder
的用法示例。
在下文中一共展示了MeshBuilder.addVertex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rebuild
# 需要导入模块: from UM.Mesh.MeshBuilder import MeshBuilder [as 别名]
# 或者: from UM.Mesh.MeshBuilder.MeshBuilder import addVertex [as 别名]
def rebuild(self):
if not self._width or not self._height or not self._depth:
return
min_w = -self._width / 2
max_w = self._width / 2
min_h = 0.0
max_h = self._height
min_d = -self._depth / 2
max_d = self._depth / 2
z_fight_distance = 0.2 # Distance between buildplate and disallowed area meshes to prevent z-fighting
if self._shape != "elliptic":
# Outline 'cube' of the build volume
mb = MeshBuilder()
mb.addLine(Vector(min_w, min_h, min_d), Vector(max_w, min_h, min_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(min_w, min_h, min_d), Vector(min_w, max_h, min_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(min_w, max_h, min_d), Vector(max_w, max_h, min_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(max_w, min_h, min_d), Vector(max_w, max_h, min_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(min_w, min_h, max_d), Vector(max_w, min_h, max_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(min_w, min_h, max_d), Vector(min_w, max_h, max_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(min_w, max_h, max_d), Vector(max_w, max_h, max_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(max_w, min_h, max_d), Vector(max_w, max_h, max_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(min_w, min_h, min_d), Vector(min_w, min_h, max_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(max_w, min_h, min_d), Vector(max_w, min_h, max_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(min_w, max_h, min_d), Vector(min_w, max_h, max_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(max_w, max_h, min_d), Vector(max_w, max_h, max_d), color = self.VolumeOutlineColor)
self.setMeshData(mb.build())
# Build plate grid mesh
mb = MeshBuilder()
mb.addQuad(
Vector(min_w, min_h - z_fight_distance, min_d),
Vector(max_w, min_h - z_fight_distance, min_d),
Vector(max_w, min_h - z_fight_distance, max_d),
Vector(min_w, min_h - z_fight_distance, max_d)
)
for n in range(0, 6):
v = mb.getVertex(n)
mb.setVertexUVCoordinates(n, v[0], v[2])
self._grid_mesh = mb.build()
else:
# Bottom and top 'ellipse' of the build volume
aspect = 1.0
scale_matrix = Matrix()
if self._width != 0:
# Scale circular meshes by aspect ratio if width != height
aspect = self._height / self._width
scale_matrix.compose(scale = Vector(1, 1, aspect))
mb = MeshBuilder()
mb.addArc(max_w, Vector.Unit_Y, center = (0, min_h - z_fight_distance, 0), color = self.VolumeOutlineColor)
mb.addArc(max_w, Vector.Unit_Y, center = (0, max_h, 0), color = self.VolumeOutlineColor)
self.setMeshData(mb.build().getTransformed(scale_matrix))
# Build plate grid mesh
mb = MeshBuilder()
mb.addVertex(0, min_h - z_fight_distance, 0)
mb.addArc(max_w, Vector.Unit_Y, center = Vector(0, min_h - z_fight_distance, 0))
sections = mb.getVertexCount() - 1 # Center point is not an arc section
indices = []
for n in range(0, sections - 1):
indices.append([0, n + 2, n + 1])
mb.addIndices(numpy.asarray(indices, dtype = numpy.int32))
mb.calculateNormals()
for n in range(0, mb.getVertexCount()):
v = mb.getVertex(n)
mb.setVertexUVCoordinates(n, v[0], v[2] * aspect)
self._grid_mesh = mb.build().getTransformed(scale_matrix)
# Indication of the machine origin
if self._global_container_stack.getProperty("machine_center_is_zero", "value"):
origin = (Vector(min_w, min_h, min_d) + Vector(max_w, min_h, max_d)) / 2
else:
origin = Vector(min_w, min_h, max_d)
mb = MeshBuilder()
mb.addCube(
width = self._origin_line_length,
height = self._origin_line_width,
depth = self._origin_line_width,
center = origin + Vector(self._origin_line_length / 2, 0, 0),
color = self.XAxisColor
)
mb.addCube(
width = self._origin_line_width,
height = self._origin_line_length,
depth = self._origin_line_width,
center = origin + Vector(0, self._origin_line_length / 2, 0),
color = self.YAxisColor
)
mb.addCube(
width = self._origin_line_width,
height = self._origin_line_width,
#.........这里部分代码省略.........
示例2: calculateBoundingBoxMesh
# 需要导入模块: from UM.Mesh.MeshBuilder import MeshBuilder [as 别名]
# 或者: from UM.Mesh.MeshBuilder.MeshBuilder import addVertex [as 别名]
def calculateBoundingBoxMesh(self):
aabb = self.getBoundingBox()
if aabb:
bounding_box_mesh = MeshBuilder()
rtf = aabb.maximum
lbb = aabb.minimum
bounding_box_mesh.addVertex(rtf.x, rtf.y, rtf.z) # Right - Top - Front
bounding_box_mesh.addVertex(lbb.x, rtf.y, rtf.z) # Left - Top - Front
bounding_box_mesh.addVertex(lbb.x, rtf.y, rtf.z) # Left - Top - Front
bounding_box_mesh.addVertex(lbb.x, lbb.y, rtf.z) # Left - Bottom - Front
bounding_box_mesh.addVertex(lbb.x, lbb.y, rtf.z) # Left - Bottom - Front
bounding_box_mesh.addVertex(rtf.x, lbb.y, rtf.z) # Right - Bottom - Front
bounding_box_mesh.addVertex(rtf.x, lbb.y, rtf.z) # Right - Bottom - Front
bounding_box_mesh.addVertex(rtf.x, rtf.y, rtf.z) # Right - Top - Front
bounding_box_mesh.addVertex(rtf.x, rtf.y, lbb.z) # Right - Top - Back
bounding_box_mesh.addVertex(lbb.x, rtf.y, lbb.z) # Left - Top - Back
bounding_box_mesh.addVertex(lbb.x, rtf.y, lbb.z) # Left - Top - Back
bounding_box_mesh.addVertex(lbb.x, lbb.y, lbb.z) # Left - Bottom - Back
bounding_box_mesh.addVertex(lbb.x, lbb.y, lbb.z) # Left - Bottom - Back
bounding_box_mesh.addVertex(rtf.x, lbb.y, lbb.z) # Right - Bottom - Back
bounding_box_mesh.addVertex(rtf.x, lbb.y, lbb.z) # Right - Bottom - Back
bounding_box_mesh.addVertex(rtf.x, rtf.y, lbb.z) # Right - Top - Back
bounding_box_mesh.addVertex(rtf.x, rtf.y, rtf.z) # Right - Top - Front
bounding_box_mesh.addVertex(rtf.x, rtf.y, lbb.z) # Right - Top - Back
bounding_box_mesh.addVertex(lbb.x, rtf.y, rtf.z) # Left - Top - Front
bounding_box_mesh.addVertex(lbb.x, rtf.y, lbb.z) # Left - Top - Back
bounding_box_mesh.addVertex(lbb.x, lbb.y, rtf.z) # Left - Bottom - Front
bounding_box_mesh.addVertex(lbb.x, lbb.y, lbb.z) # Left - Bottom - Back
bounding_box_mesh.addVertex(rtf.x, lbb.y, rtf.z) # Right - Bottom - Front
bounding_box_mesh.addVertex(rtf.x, lbb.y, lbb.z) # Right - Bottom - Back
self._bounding_box_mesh = bounding_box_mesh.build()