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


Python LineSegs.setColor方法代码示例

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


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

示例1: move_map_avatar

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setColor [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_xy

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setColor [as 别名]
 def plot_xy(self):
     joy_in = self.js.getEvents()
     if joy_in:
         #print type(joy_in)
         for event_name in joy_in:
             #print event_name
             event = joy_in[event_name]
             #print event
             #print type(event)
             #print inspect.getmembers(event, predicate=inspect.ismethod)
             event_mag = event.getMagnitude()
             if event_name == 'moveForward':
                 self.y_mag = event_mag
                 print('forward', self.y_mag)
             elif event_name == 'moveBackward':
                 self.y_mag = -event_mag
                 print('backward', self.y_mag)
             elif event_name == 'turnRight':
                 self.x_mag = event_mag
                 print('right', self.x_mag)
             elif event_name == 'turnLeft':
                 self.x_mag = -event_mag
                 print('left', self.x_mag)
         plot_xy = LineSegs()
         plot_xy.setThickness(2.0)
         plot_xy.setColor(Vec4(1, 1, 0, 1))
         plot_xy.moveTo(self.old_x, 0, self.old_y)
         plot_xy.drawTo(self.x_mag, 0, self.y_mag)
         base.render2d.attach_new_node(plot_xy.create(True))
         self.old_x = self.x_mag
         self.old_y = self.y_mag
开发者ID:codedragon,项目名称:play,代码行数:33,代码来源:test_js_pandaepl.py

示例3: plot_xy_vs_t

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setColor [as 别名]
    def plot_xy_vs_t(self):
        then = self.now
        if self.now == 0:
            then = time.time()
        self.now = time.time()
        #print self.now
        dt = (self.now - then) / 10
        joy_in = self.js.getEvents()
        if joy_in:
            #print type(joy_in)
            for event_name in joy_in:
                #print event_name
                event = joy_in[event_name]
                #print event
                #print type(event)
                #print inspect.getmembers(event, predicate=inspect.ismethod)
                event_mag = event.getMagnitude()
                if event_name == 'moveForward':
                    y_mag = event_mag
                    #print('forward', y_mag)
                    self.y_mag = (y_mag * self.gain) - self.offset
                    #print('forward', self.y_mag)
                elif event_name == 'moveBackward':
                    y_mag = -event_mag
                    #print('backward', y_mag)
                    self.y_mag = (y_mag * self.gain) - self.offset
                    #print('backward', self.y_mag)
                elif event_name == 'turnRight':
                    x_mag = event_mag
                    #print('right', x_mag)
                    self.x_mag = (x_mag * self.gain) + self.offset
                    #print('right', self.x_mag)
                elif event_name == 'turnLeft':
                    x_mag = -event_mag
                    #print('left', x_mag)
                    self.x_mag = (x_mag * self.gain) + self.offset
                    #print('left', self.x_mag)
        plot_x = LineSegs()
        plot_x.setThickness(2.0)
        plot_x.setColor(Vec4(1, 1, 0, 1))
        plot_x.moveTo(self.time, 0, self.old_x)

        plot_y = LineSegs()
        plot_y.setThickness(2.0)
        plot_y.setColor(Vec4(1, 0, 0, 1))
        plot_y.moveTo(self.time, 0, self.old_y)

        self.time += dt
        #print('dt', dt)
        #print('time', self.time)
        plot_x.drawTo(self.time, 0, self.x_mag)
        node = base.render2d.attach_new_node(plot_x.create(True))
        self.plot.append(node)
        plot_y.drawTo(self.time, 0, self.y_mag)
        node = base.render2d.attach_new_node(plot_y.create(True))
        self.plot.append(node)
        self.old_x = self.x_mag
        self.old_y = self.y_mag
        if self.time > 1:
            self.clear_plot()
开发者ID:codedragon,项目名称:play,代码行数:62,代码来源:test_js_pandaepl.py

示例4: create

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setColor [as 别名]
 def create(self, s):
     segs = LineSegs( )
     segs.setThickness( 2.0 )
     segs.setColor( Vec4(1,0,0,1) )
     segs.moveTo( s.points[0] )
     for p in s.points[1:]:
         segs.drawTo( p )
     return segs.create( )
开发者ID:solarii,项目名称:kosminenSimulaattori,代码行数:10,代码来源:simulaattori.py

示例5: plot_zero_lines

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setColor [as 别名]
 def plot_zero_lines(self):
     plot_zero = LineSegs()
     plot_zero.setThickness(2.0)
     plot_zero.setColor(Vec4(1, 0, 1, 1))
     plot_zero.moveTo(-1, 0, self.x_mag)
     plot_zero.drawTo(1, 0, self.x_mag)
     plot_zero.moveTo(-1, 0, self.y_mag)
     plot_zero.drawTo(1, 0, self.y_mag)
     base.render2d.attach_new_node(plot_zero.create(True))
开发者ID:codedragon,项目名称:play,代码行数:11,代码来源:test_js_pandaepl.py

示例6: draw_line

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setColor [as 别名]
 def draw_line(self,p,col):
     line = LineSegs()
     line.setColor(col[0],col[1],col[2], 1)
     line.setThickness(2)
     line.moveTo(p[0],p[1],0)
     line.drawTo(p[2],p[3],0)
     line_node = line.create()
     node_path = NodePath(line_node)
     node_path.reparentTo(render)
开发者ID:HepcatNZ,项目名称:VoronoiMap,代码行数:11,代码来源:VoronoiMap.py

示例7: draw_edge

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setColor [as 别名]
	def draw_edge(self,e,e_color):
		line_drawer = LineSegs('line_drawer')
		line_drawer.setColor(e_color)
		line_drawer.setThickness(1.5)
		line_drawer.moveTo(e.v1.pos)
		line_drawer.drawTo(e.v2.pos)
		edge_node = line_drawer.create()
		rendered_edge = self.render_root.attachNewNode(edge_node)
		self.render_nodes['edge_'+str(e.ID)] = rendered_edge
开发者ID:nkolkin13,项目名称:ProcEdit,代码行数:11,代码来源:mesh_selection.py

示例8: drawLineSeg

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setColor [as 别名]
    def drawLineSeg(self, loader, parent, start, end):
        lines = LineSegs()
        lines.setThickness(5.0)
        lines.setColor(VBase4(1, 0.5, 0.5, 1.0))
        lines.moveTo(start)
        lines.drawTo(end)

        np = parent.attachNewNode(lines.create())
        np.setDepthWrite(True)
        np.setDepthTest(True)
开发者ID:BarkingMouseStudio,项目名称:python-experiments,代码行数:12,代码来源:muscle.py

示例9: fire_laser

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setColor [as 别名]
    def fire_laser(self, panda3dworld, entity_id):
        now = globalClock.getRealTime()
        if now - self.last_time_laser_fired < self.laser_reload_time:
            if defines.ENTITIES[entity_id]["CATEGORY"] == "ship":
                panda3dworld.keys["fire"] = 0
            elif defines.ENTITIES[entity_id]["CATEGORY"] == "ship2":
                panda3dworld.keys["p2fire"] = 0
        else:
            self.last_time_laser_fired = now

            pos = defines.ENTITIES[entity_id]["NODE"].getPos()
            angle = 360 - defines.ENTITIES[entity_id]["NODE"].getR()
            # print angle
            start_pos_x = pos.x + 0.5 * cos(angle * pi / 180)
            start_pos_y = pos.z + 0.5 * sin(angle * pi / 180)
            pos_x = pos.x + 10 * cos(angle * pi / 180)
            pos_y = pos.z + 10 * sin(angle * pi / 180)

            callback = test_laser_collision(start_pos_x, start_pos_y, pos_x, pos_y)
            if callback.hit:
                pos_x = callback.point.x
                pos_y = callback.point.y
                for contact_id, entity in defines.ENTITIES.items():
                    if entity["BODY"].fixtures[0] == callback.fixture:
                        if (
                            entity["CATEGORY"] == "ship"
                            or entity["CATEGORY"] == "ship2"
                            or entity["CATEGORY"] == "asteroid"
                        ):
                            entity["SHIELD"] -= 10
                        elif entity["CATEGORY"] == "bullet":
                            defines.ENTITIES[contact_id]["NODE"].removeNode()
                            defines.ENTITIES[contact_id]["PHYSIC_NODE"].removeNode()
                            defines.world.DestroyBody(defines.ENTITIES[contact_id]["BODY"])
                            del defines.ENTITIES[contact_id]
            ls = LineSegs("lines")
            ls.setColor(1, 1, 1, 1)
            ls.drawTo(start_pos_x, 55, start_pos_y)
            ls.drawTo(pos_x, 55, pos_y)
            laser = ls.create(False)
            laserPath = render.attachNewNode(laser)
            laserPath.setBin("unsorted", 0)
            laserPath.setDepthTest(False)

            sound = base.loader.loadSfx("sounds/laser.ogg")
            sound.setVolume(0.2)
            sound.play()

            taskMgr.doMethodLater(0.05, remove_laser_task, "remove laser", extraArgs=[laserPath], appendTask=True)

            defines.ENTITIES[entity_id]["ENERGY"] -= 5
            if defines.ENTITIES[entity_id]["CATEGORY"] == "ship":
                panda3dworld.keys["fire"] = 0
            elif defines.ENTITIES[entity_id]["CATEGORY"] == "ship2":
                panda3dworld.keys["p2fire"] = 0
开发者ID:martinrioux,项目名称:Panda3D-Space-Wars,代码行数:57,代码来源:weapons.py

示例10: create_lines

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setColor [as 别名]
def create_lines(joints, color, thickness=5.0):
    for node, parent in joints:
        if parent is not None:
            lines = LineSegs()
            lines.setThickness(thickness)
            lines.setColor(color)
            lines.moveTo(0, 0, 0)
            lines.drawTo(node.getPos(parent))

            np = parent.attachNewNode(lines.create())
            np.setDepthWrite(True)
            np.setDepthTest(True)
开发者ID:BarkingMouseStudio,项目名称:python-experiments,代码行数:14,代码来源:actor_utils.py

示例11: plot_match_square

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setColor [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

示例12: __init__

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setColor [as 别名]
    def __init__(self):
        BareBonesEditor.__init__(self)
        camera.setPos( 0.0, 0.0, 50.0)
        camera.lookAt(0)

        # hole1 = HorseShoeCentered()
        # hole2 = SquareOffCenter()
        # holes = []
        # holes.append(hole1)
        # holes.append(hole2)
        #
        # map10 = SquareMap10x10()
        # mapWholes = []
        # mapWholes.append(map10)
        # mapWholes.append(holes)
        # for i in mapWholes:
        #     print "mapWholes", i
        #
        # mesh_trilator = makeTriMesh(mapWholes[0], mapWholes[1])  # , holes) ############
        mapThrs = TheirMap()
        # for i in mapThrs:
        #     print "mapThrs", i
        mesh_trilator = makeTriMesh(mapThrs[0], mapThrs[1])  # , holes) ###########

        aLst = AdjacencyList(mesh_trilator[1])
        # for i in aLst.aLst:
        #     print i
        indsNP = drawInds(aLst.adjLst)  # put text on each triangle
        indsNP.setPos(0, 0, .2)
        indsNP.setColor(0, 1, 1, 1)
        mapNP = render.attachNewNode(mesh_trilator[0])
        wireNP = render.attachNewNode('wire')
        wireNP.setPos(0, 0, .1)
        wireNP.setColor(1, 0, 0, 1)
        wireNP.setRenderMode(RenderModeAttrib.MWireframe, .5, 0)
        mapNP.instanceTo(wireNP)

        # aStar = TriangulationAStar(aLst.adjLst, Point3(-11, -11, 0), Point3(11, 11, 0))aLst.adjLst[11].getCenter()
        aStar = TriangulationAStarR(aLst.adjLst, Point3(-11, 11, 0), aLst.adjLst[17].getCenter(), radius=.55)
        path = aStar.AStar()
        print "\n\nEND PATH\n", path
        # https://www.panda3d.org/manual/index.php?title=Putting_your_new_geometry_in_the_scene_graph&diff=prev&oldid=6303
        linesegs = LineSegs("lines")
        linesegs.setColor(0, 0, 1, 1)
        linesegs.setThickness(5)
        for p in path:
            linesegs.drawTo(p)
        node = linesegs.create(False)
        nodePath = render.attachNewNode(node)
        nodePath.setZ(.15)
开发者ID:jkcavin1,项目名称:barebones,代码行数:52,代码来源:Pathfinding.py

示例13: line_small_lakes

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setColor [as 别名]
 def line_small_lakes(self):
     for l in range(len(small_lake_lines)):
         line = LineSegs()
         line.setColor(0,0,0, 1)
         line.setThickness(2)
         for n in range(len(small_lake_lines[l])):
             x = (small_lake_nodes[small_lake_lines[l][n]]["x"]-map_center[0])*amplification
             y = (small_lake_nodes[small_lake_lines[l][n]]["y"]-map_center[1])*amplification
             if n == 0:
                 line.moveTo(x,y,0)
             else:
                 line.drawTo(x,y,0)
         line_node = line.create()
         node_path = NodePath(line_node)
         node_path.reparentTo(render)
开发者ID:HepcatNZ,项目名称:OSMGameMapper,代码行数:17,代码来源:osm_mapdata.py

示例14: __make_border__

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setColor [as 别名]
 def __make_border__(cls, parent, thickness, color, l, r , b, t):
     moveto_drawto = (
        ((l,0,t), (l,0,b)),
        ((r,0,t), (r,0,b)),
        ((l,0,b), (r,0,b)),
        ((l,0,t), (r,0,t)),
     )
     for moveto, drawto in moveto_drawto:
         Border = LineSegs()
         Border.setThickness(thickness)
         Border.setColor(*color)
         Border.moveTo(*moveto)
         Border.drawTo(*drawto)
         b = parent.attachNewNode(Border.create())
         b.setBin(*cls.DRAW_ORDER['border'])
开发者ID:tgbugs,项目名称:desc,代码行数:17,代码来源:ui.py

示例15: line_border

# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import setColor [as 别名]
 def line_border(self):
     line = LineSegs()
     line.setColor(0,0,0, 1)
     line.setThickness(5)
     x1 = (175.152-map_center[0])*amplification
     x2 = (177.358-map_center[0])*amplification
     y1 = (-38.808-map_center[1])*amplification
     y2 = (-37.462-map_center[1])*amplification
     line.moveTo(x1,y1,0)
     line.drawTo(x1,y2,0)
     line.drawTo(x2,y2,0)
     line.drawTo(x2,y1,0)
     line.drawTo(x1,y1,0)
     line_node = line.create()
     node_path = NodePath(line_node)
     node_path.reparentTo(render)
开发者ID:HepcatNZ,项目名称:OSMGameMapper,代码行数:18,代码来源:osm_mapdata.py


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