本文整理汇总了Python中panda3d.core.LineSegs.setVertex方法的典型用法代码示例。如果您正苦于以下问题:Python LineSegs.setVertex方法的具体用法?Python LineSegs.setVertex怎么用?Python LineSegs.setVertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.LineSegs
的用法示例。
在下文中一共展示了LineSegs.setVertex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WartsApp
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setVertex [as 别名]
#.........这里部分代码省略.........
coordinates).
"""
assert self.selectionBox is None
p1, p2, p3, p4 = self.convert3dBoxToScreen(corner1, corner2)
x1, y1 = p1
x2, y2 = p2
x3, y3 = p3
x4, y4 = p4
# TODO[#3]: Magic numbers bad.
self.selectionBox = LineSegs("SelectionBox")
self.selectionBox.setThickness(3.0)
self.selectionBox.setColor(0.0, 1.0, 0.25, 1.0)
self.selectionBox.move_to(x1, 0, y1)
self.selectionBox.draw_to(x2, 0, y2)
self.selectionBox.draw_to(x3, 0, y3)
self.selectionBox.draw_to(x4, 0, y4)
self.selectionBox.draw_to(x1, 0, y1)
self.selectionBoxNode = self.render2d.attachNewNode(
self.selectionBox.create())
def moveSelectionBox(self, corner1, corner2):
assert self.selectionBox is not None
p1, p2, p3, p4 = self.convert3dBoxToScreen(corner1, corner2)
x1, y1 = p1
x2, y2 = p2
x3, y3 = p3
x4, y4 = p4
self.selectionBox.setVertex(0, x1, 0, y1)
self.selectionBox.setVertex(1, x2, 0, y2)
self.selectionBox.setVertex(2, x3, 0, y3)
self.selectionBox.setVertex(3, x4, 0, y4)
self.selectionBox.setVertex(4, x1, 0, y1)
def removeSelectionBox(self):
self.selectionBoxNode.removeNode()
self.selectionBox = None
self.selectionBoxNode = None
def convert3dBoxToScreen(self, corner1, corner3):
"""
Return screen coordinates of the 4 corners of a box, given in 3d
coordinates. The box is specified using 2 opposite corners.
"""
wx1, wy1, wz1 = corner1
wx3, wy3, wz3 = corner3
wx2, wy2 = (wx1, wy3)
wx4, wy4 = (wx3, wy1)
# Note: corner1 and corner2 could have nonzero z because floating-point
# calculations, but they should at least be close. We'll just average
# their z and not worry about it.
wz2 = wz4 = 0.5 * (wz1 + wz3)
p1 = self.coord3dToScreen((wx1, wy1, wz1))
p2 = self.coord3dToScreen((wx2, wy2, wz2))
p3 = self.coord3dToScreen((wx3, wy3, wz3))
p4 = self.coord3dToScreen((wx4, wy4, wz4))
示例2: WartsApp
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setVertex [as 别名]
#.........这里部分代码省略.........
coordinates).
"""
assert self.selectionBox is None
p1, p2, p3, p4 = self.convert3dBoxToScreen(corner1, corner2)
x1, y1 = p1
x2, y2 = p2
x3, y3 = p3
x4, y4 = p4
# TODO[#3]: Magic numbers bad.
self.selectionBox = LineSegs("SelectionBox")
self.selectionBox.setThickness(3.0)
self.selectionBox.setColor(0.0, 1.0, 0.25, 1.0)
self.selectionBox.move_to(x1, 0, y1)
self.selectionBox.draw_to(x2, 0, y2)
self.selectionBox.draw_to(x3, 0, y3)
self.selectionBox.draw_to(x4, 0, y4)
self.selectionBox.draw_to(x1, 0, y1)
self.selectionBoxNode = self.render2d.attachNewNode(
self.selectionBox.create())
def moveSelectionBox(self, corner1, corner2):
assert self.selectionBox is not None
p1, p2, p3, p4 = self.convert3dBoxToScreen(corner1, corner2)
x1, y1 = p1
x2, y2 = p2
x3, y3 = p3
x4, y4 = p4
self.selectionBox.setVertex(0, x1, 0, y1)
self.selectionBox.setVertex(1, x2, 0, y2)
self.selectionBox.setVertex(2, x3, 0, y3)
self.selectionBox.setVertex(3, x4, 0, y4)
self.selectionBox.setVertex(4, x1, 0, y1)
def removeSelectionBox(self):
self.selectionBoxNode.removeNode()
self.selectionBox = None
self.selectionBoxNode = None
def convert3dBoxToScreen(self, corner1, corner3):
"""
Return screen coordinates of the 4 corners of a box, given in 3d
coordinates. The box is specified using 2 opposite corners.
"""
wx1, wy1, wz1 = corner1
wx3, wy3, wz3 = corner3
wx2, wy2 = (wx1, wy3)
wx4, wy4 = (wx3, wy1)
# Note: corner1 and corner2 could have nonzero z because floating-point
# calculations, but they should at least be close. We'll just average
# their z and not worry about it.
wz2 = wz4 = 0.5 * (wz1 + wz3)
p1 = self.coord3dToScreen((wx1, wy1, wz1))
p2 = self.coord3dToScreen((wx2, wy2, wz2))
p3 = self.coord3dToScreen((wx3, wy3, wz3))
p4 = self.coord3dToScreen((wx4, wy4, wz4))