当前位置: 首页>>代码示例>>Python>>正文


Python LineSegs.draw_to方法代码示例

本文整理汇总了Python中panda3d.core.LineSegs.draw_to方法的典型用法代码示例。如果您正苦于以下问题:Python LineSegs.draw_to方法的具体用法?Python LineSegs.draw_to怎么用?Python LineSegs.draw_to使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在panda3d.core.LineSegs的用法示例。


在下文中一共展示了LineSegs.draw_to方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: move_map_avatar

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import draw_to [as 别名]
 def move_map_avatar(self, move, stop):
     # print move
     # avatar is mapped assuming c_range of 0.5. What do I need to
     # change to use a different c_range? c_range of one is twice
     # the
     if move:
         avt = LineSegs()
         avt.setThickness(1)
         avt.setColor(1, 1, 1)
         # print 'last', self.last_avt
         avt.move_to(self.last_avt[0], -5, self.last_avt[1])
         # print 'move', move
         new_move = [i + (j * self.avt_factor) for i, j in zip(self.last_avt, move)]
         # new_move = [i + j for i, j in zip(self.last_avt, move)]
         # would it be better to have a local stop condition?
         if stop[0]:
             new_move[0] = self.last_avt[0]
             # print 'stop x', self.last_avt[0]
         if stop[1]:
             new_move[1] = self.last_avt[1]
             # print 'stop y', self.last_avt[1]
         # print 'new', new_move
         self.last_avt = [new_move[0], new_move[1]]
         avt.draw_to(new_move[0], -5, new_move[1])
         self.map_avt_node.append(self.render2d.attach_new_node(avt.create()))
         # print self.map_avt_node[-1]
         # can't let too many nodes pile up
         if len(self.map_avt_node) > 299:
             # removing the node does not remove the object from the list
             for i, j in enumerate(self.map_avt_node):
                 j.removeNode()
                 if i > 49:
                     break
             del self.map_avt_node[0:50]
开发者ID:codedragon,项目名称:color_world,代码行数:36,代码来源:color_world.py

示例2: plot_match_square

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import draw_to [as 别名]
 def plot_match_square(self, corners):
     print 'plot match square'
     print corners
     match = LineSegs()
     match.setThickness(1.5)
     match.setColor(0, 0, 0)
     match.move_to(corners[0][0], -5, corners[1][0])
     match.draw_to(corners[0][1], -5, corners[1][0])
     match.draw_to(corners[0][1], -5, corners[1][1])
     match.draw_to(corners[0][0], -5, corners[1][1])
     match.draw_to(corners[0][0], -5, corners[1][0])
     # print self.render2d
     self.match_square = self.render2d.attach_new_node(match.create())
开发者ID:codedragon,项目名称:color_world,代码行数:15,代码来源:color_world.py

示例3: plot_border

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import draw_to [as 别名]
 def plot_border(self):
     border = LineSegs()
     border.setThickness(2.0)
     corner = self.win_size/100 * 5/6
     #print('corner', corner)
     border.move_to(corner, 25, corner)
     border.draw_to(corner, 25, -corner)
     border.draw_to(-corner, 25, -corner)
     border.draw_to(-corner, 25, corner)
     border.draw_to(corner, 25, corner)
     self.base.render.attach_new_node(border.create(True))
开发者ID:codedragon,项目名称:play,代码行数:13,代码来源:show_banana_dist.py

示例4: draw_path

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import draw_to [as 别名]
    def draw_path(self, current_position, path):
        from panda3d.core import LineSegs, Vec4, Vec3
        path = [Vec3(*v) for v in path]

        segments = LineSegs()
        segments.set_thickness(2.0)
        segments.set_color((1, 1, 0, 1))
        segments.move_to(current_position)

        for point in path:
            segments.draw_to(point)

        if self._path_node:
            self._path_node.remove_node()

        node = segments.create()
        self._path_node = render.attach_new_node(node)
        self._replan_timer = Timer(1.5)
        self._replan_timer.on_target = self._replan
开发者ID:TurBoss,项目名称:PyAuthServer,代码行数:21,代码来源:controllers.py

示例5: task_mouse_place

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import draw_to [as 别名]
 def task_mouse_place(self,task):
     if base.mouseWatcherNode.isButtonDown(MouseButton.one()):
         self.placing_object = True
         self.place_pos = (self.anchor_x,self.anchor_y)
         self.line_dir.remove()
         ls = LineSegs()
         ls.move_to(self.anchor_x,self.anchor_y,1)
         ls.draw_to(self.model.getX(),self.model.getY(),1)
         node = ls.create()
         angle1 = math.atan2(self.anchor_y - self.anchor_y,self.anchor_x - self.anchor_x+50)
         angle2 = math.atan2(self.anchor_y - self.model.getY(),self.anchor_x - self.model.getY());
         final_angle = angle1-angle2;
         self.model.setHpr(final_angle,0,0)
         self.line_dir = NodePath(node)
         self.line_dir.reparentTo(render)
         return task.again
     else:
         self.line_dir.hide()
         taskMgr.add(self.task_mouse_press_check, "checkMousePress")
         return task.done
开发者ID:HepcatNZ,项目名称:EmpiresOfSuburbia,代码行数:22,代码来源:EditorCol.py

示例6: WartsApp

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import draw_to [as 别名]

#.........这里部分代码省略.........
            entity.setIndicator(self.loader.loadModel(
                getModelPath("unit-indicator-selected.egg")
            ))
        else:
            # You can't currently select others' units, so if a unit is being
            # deselected it must be mine.
            entity.setIndicator(self.loader.loadModel(
                getModelPath("unit-indicator-mine.egg")
            ))

    def displayResources(self, resourceAmt):
        self.resourceDisplay.setText("Resource: {}".format(resourceAmt))

    def createSelectionBox(self, corner1, corner2):
        """
        Create a selection "box" given the coordinates of two opposite corners.
        The corners are given in world coordinates (well, 3d graphics
        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.
        """
开发者ID:CheeseLord,项目名称:warts,代码行数:70,代码来源:graphics.py

示例7: WartsApp

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import draw_to [as 别名]

#.........这里部分代码省略.........
        pass

        # Create unit/model/node as we used to.
        # Also add it to our uid->unit mapping.

    def removeUnit(self, uid, pos):

        # TODO: Actually write this.
        pass

        # Remove+cleanup unit/model/node as we used to.
        # Also remove it from our uid->unit mapping.

    def createSelectionBox(self, corner1, corner2):
        """
        Create a selection "box" given the coordinates of two opposite corners.
        The corners are given in world coordinates (well, 3d graphics
        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.
        """
开发者ID:CheeseLord,项目名称:warts,代码行数:70,代码来源:newgraphics.py


注:本文中的panda3d.core.LineSegs.draw_to方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。