當前位置: 首頁>>代碼示例>>Python>>正文


Python LineSegs.drawTo方法代碼示例

本文整理匯總了Python中pandac.PandaModules.LineSegs.drawTo方法的典型用法代碼示例。如果您正苦於以下問題:Python LineSegs.drawTo方法的具體用法?Python LineSegs.drawTo怎麽用?Python LineSegs.drawTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pandac.PandaModules.LineSegs的用法示例。


在下文中一共展示了LineSegs.drawTo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: draw

# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import drawTo [as 別名]
	def draw(self):
		# Draw attack radius
		attackRadLine = LineSegs()
		attackRadLine.setThickness(1)
		attackRadLine.setColor(self._color)
		attackRadLine.moveTo(self.attackRad, 0, 0)
		for i in range(self._EDGES + 1):
			newX = (self.attackRad * math.cos((2*math.pi/self._EDGES)*i))
			newY = (self.attackRad * math.sin((2*math.pi/self._EDGES)*i))
			attackRadLine.drawTo(newX, newY, 0)
		attackRadGeom = attackRadLine.create()
		self._attackRadCircleNP = NodePath(attackRadGeom)
		self._attackRadCircleNP.reparentTo(self._np)
		
		# Draw foot circle
		self._footCircle.setThickness(1)
		self._footCircle.setColor(self._color)
		self._footCircle.moveTo(self.footRad, 0, 0)
		for i in range(self._EDGES):
			newX = (self.footRad * math.cos((2*math.pi/self._EDGES)*i))
			newY = (self.footRad * math.sin((2*math.pi/self._EDGES)*i))
			self._footCircle.drawTo(newX, newY, 0)
		self._footCircle.drawTo(self.footRad, 0, 0)
		footCircleGeom = self._footCircle.create()
		self._footCircleNP = NodePath(footCircleGeom)
		self._footCircleNP.reparentTo(self._np)
開發者ID:crempp,項目名稱:psg,代碼行數:28,代碼來源:GeomObjects.py

示例2: SelectionBox

# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import drawTo [as 別名]
class SelectionBox(NodePath):
    def __init__(self, width=1, depth=1, height=1, thickness=1.0, origin=Point3(0, 0, 0)):
        def __Get3dPoint(pt, origin, axis):
            p = Point3(pt.x, pt.y, 0) - origin
            return RotatePoint3(p, Vec3(0, 0, 1), axis)

        # Create line segments
        self.ls = LineSegs()
        self.ls.setThickness(thickness)

        # axes = [Vec3(1, 0, 0), Vec3(0, 1, 0), Vec3(0, 0, 1), Vec3(1, 0, 0), Vec3(0, 1, 0), Vec3(0, 0, 1)]
        # origins = [origin, origin, origin, origin + Point3(0, 0, -1), origin + Point3(0, 0, -1), origin + Point3(0, 0, 1)]
        axes = [Vec3(1, 0, 0), Vec3(0, 1, 0), Vec3(-1, 0, 0), Vec3(0, -1, 0)]
        origins = [origin, origin, origin, origin]
        for m in range(len(axes)):

            # Get the points for square, append the first one to the end to
            # complete the square
            pts = GetPointsForSquare2(width, height)
            pts.append(pts[0])
            for i in range(len(pts) - 1):

                # Get the distance a third of the way along the edge
                dist = (pts[i + 1] - pts[i]) / 3

                # Draw one square
                self.ls.moveTo(__Get3dPoint(pts[i], origins[m], axes[m]))
                self.ls.drawTo(__Get3dPoint(pts[i] + dist, origins[m], axes[m]))
                self.ls.moveTo(__Get3dPoint(pts[i] + dist + dist, origins[m], axes[m]))
                self.ls.drawTo(__Get3dPoint(pts[i + 1], origins[m], axes[m]))

        # Init the node path, wrapping the lines
        node = self.ls.create()
        NodePath.__init__(self, node)
開發者ID:LBdN,項目名稱:labs,代碼行數:36,代碼來源:geometry.py

示例3: __init__

# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import drawTo [as 別名]
    def __init__( self, *args, **kwargs ):
        colour = kwargs.pop( 'colour', (1, 1, 1, .2) )
        p3d.SingleTask.__init__( self, *args, **kwargs )

        # Create a card maker
        cm = CardMaker( self.name )
        cm.setFrame( 0, 1, 0, 1 )
        
        # Init the node path, wrapping the card maker to make a rectangle
        NodePath.__init__( self, cm.generate() )
        self.setColor( colour )
        self.setTransparency( 1 )
        self.reparentTo( self.root2d )
        self.hide()
        
        # Create the rectangle border
        ls = LineSegs()
        ls.moveTo( 0, 0, 0 )
        ls.drawTo( 1, 0, 0 )
        ls.drawTo( 1, 0, 1 )
        ls.drawTo( 0, 0, 1 )
        ls.drawTo( 0, 0, 0 )
        
        # Attach border to rectangle
        self.attachNewNode( ls.create() )
開發者ID:Derfies,項目名稱:panda3d-editor,代碼行數:27,代碼來源:marquee.py

示例4: add_line

# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import drawTo [as 別名]
 def add_line(self, rendering_node, color, thickness, start, end):
     linesegs = LineSegs()  
     linesegs.setColor(*color) 
     linesegs.setThickness(thickness)
     linesegs.drawTo((start[0], start[1], start[2])) 
     linesegs.drawTo((end[0], end[1], end[2]))    
     new_node = linesegs.create()
     rendering_node.attachNewNode(new_node)
開發者ID:charles-daumont,項目名稱:PyNetLogo,代碼行數:10,代碼來源:Main.py

示例5: drawLine

# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import drawTo [as 別名]
	def drawLine(self, parent, source, target):
		line = LineSegs()
		line.setThickness(LINETHICKNESS)
		line.reset()
		line.setColor(*GRIDCOLOR)
		line.moveTo(source)
		line.drawTo(target)
		node = line.create()
		lineSegNP = NodePath(node).reparentTo(parent)
開發者ID:crempp,項目名稱:psg,代碼行數:11,代碼來源:Grid.py

示例6: drawLineToNeighbors

# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import drawTo [as 別名]
 def drawLineToNeighbors(self):
     ls = LineSegs()
     ls.setThickness(1.0)
     for neighbor in self.neighbors:
         ls.setColor(1,1,1,1)
         ls.moveTo(self.getPos(render))
         ls.drawTo(neighbor.getPos(render))
     self.np = NodePath(ls.create("Neighbor Line Segment"))
     self.np.reparentTo(render)
開發者ID:Babi-Wan,項目名稱:robotic-agent-path-planning-project,代碼行數:11,代碼來源:waypoint.py

示例7: AttackCursor

# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import drawTo [as 別名]
class AttackCursor(object):
	_EDGES = 40
	_color = Vec4(0.8, 0.3, 0.3, 1)
	
	def __init__(self, parent, entity, foot=1):
		self.entity = entity
		self.pos = entity.pos
		self.attackRad         = entity.attackRad
		self.footRad           = foot
		self._footCircle       = LineSegs()
		self._footCircleNP     = NodePath("Movement Foot Circle Node")
		self._attackRadCircle  = LineSegs()
		self._attackRadCircleNP= NodePath("Attack Radius Node")
		self._np               = NodePath("Movement Node")
		self.attackables       = Entity.EntityManager().getEntitiesWithin(self.pos, self.attackRad)
		
		for e in self.attackables:
			if isinstance(e, Entity.EntityShip) and e != self.entity and e.owner != self.entity.owner: 
				e.representation.setAttackable()
			
	def draw(self):
		# Draw attack radius
		attackRadLine = LineSegs()
		attackRadLine.setThickness(1)
		attackRadLine.setColor(self._color)
		attackRadLine.moveTo(self.attackRad, 0, 0)
		for i in range(self._EDGES + 1):
			newX = (self.attackRad * math.cos((2*math.pi/self._EDGES)*i))
			newY = (self.attackRad * math.sin((2*math.pi/self._EDGES)*i))
			attackRadLine.drawTo(newX, newY, 0)
		attackRadGeom = attackRadLine.create()
		self._attackRadCircleNP = NodePath(attackRadGeom)
		self._attackRadCircleNP.reparentTo(self._np)
		
		# Draw foot circle
		self._footCircle.setThickness(1)
		self._footCircle.setColor(self._color)
		self._footCircle.moveTo(self.footRad, 0, 0)
		for i in range(self._EDGES):
			newX = (self.footRad * math.cos((2*math.pi/self._EDGES)*i))
			newY = (self.footRad * math.sin((2*math.pi/self._EDGES)*i))
			self._footCircle.drawTo(newX, newY, 0)
		self._footCircle.drawTo(self.footRad, 0, 0)
		footCircleGeom = self._footCircle.create()
		self._footCircleNP = NodePath(footCircleGeom)
		self._footCircleNP.reparentTo(self._np)
		
	def removeNode(self):
		for e in self.attackables:
			if isinstance(e, Entity.EntityShip):
				e.representation.unsetAttackable()
		self._footCircleNP.removeNode()
		self._attackRadCircleNP.removeNode()
		self._np.removeNode()

	def __del__(self):
		self.removeNode()
開發者ID:crempp,項目名稱:psg,代碼行數:59,代碼來源:GeomObjects.py

示例8: __createLine

# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import drawTo [as 別名]
 def __createLine(self, length=1, color=(1,1,1,1), endColor=None):
   LS=LineSegs()
   LS.setColor(*color)
   LS.moveTo(0,0,0)
   LS.drawTo(length*1,0,0)
   node=LS.create()
   if endColor:
     LS.setVertexColor(1,*endColor)
   return node
開發者ID:KillerGoldFisch,項目名稱:panda3d-editor,代碼行數:11,代碼來源:pDirectTree.py

示例9: drawBestPath

# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import drawTo [as 別名]
 def drawBestPath(self):
     if self.bestPath != None:
         ls = LineSegs()
         ls.setThickness(10.0)
         for i in range(len(self.bestPath) - 1):
             ls.setColor(0, 0, 1, 1)
             ls.moveTo(self.bestPath[i].getPos())
             ls.drawTo(self.bestPath[i + 1].getPos())
             np = NodePath(ls.create("aoeu"))
             np.reparentTo(render)
開發者ID:Babi-Wan,項目名稱:robotic-agent-path-planning-project,代碼行數:12,代碼來源:npc.py

示例10: sepLine

# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import drawTo [as 別名]
def sepLine(frame, styles):
	style = styles['menu separator']
	ls = LineSegs('sepLine')
	ls.setColor(style['color'])
	ls.setThickness(style['thick'])
	hpad = (frame[1]-frame[0])*.2
	hh = frame[3]+(frame[3]-frame[2])#/2
	ls.moveTo(frame[0]+hpad,0,hh)
	ls.drawTo(frame[1]-hpad,0,hh)
	return ls.create()
開發者ID:rll,項目名稱:labeling_tool,代碼行數:12,代碼來源:buttonjoe.py

示例11: __init__

# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import drawTo [as 別名]
    def __init__(self, start, end, thickness=1.0):

        # Create line segments
        ls = LineSegs()
        ls.setThickness(thickness)
        ls.drawTo(Point3(start))
        ls.drawTo(Point3(end))

        # Init the node path, wrapping the lines
        NodePath.__init__(self, ls.create())
開發者ID:LBdN,項目名稱:labs,代碼行數:12,代碼來源:geometry.py

示例12: makeArc

# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import drawTo [as 別名]
 def makeArc(angleDegrees=360, numSteps=16, color=Vec4(1, 1, 1, 1)):
     ls = LineSegs()
     angleRadians = deg2Rad(angleDegrees)
     for i in range(numSteps + 1):
         a = angleRadians * i / numSteps
         y = math.sin(a)
         x = math.cos(a)
         ls.drawTo(x, y, 0)
     node = ls.create()
     if color != Vec4(1, 1, 1, 1):
         for i in range(numSteps + 1):
             ls.setVertexColor(i, color)
         pass
     return NodePath(node)
開發者ID:Fish4,項目名稱:Atlantis-Warfare,代碼行數:16,代碼來源:__init__.py

示例13: makeArc

# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import drawTo [as 別名]
def makeArc(color, angle_degrees = 360, numsteps = 16, horizon_plane = 0,): 
    ls = LineSegs() 
    ls.setColor(color)
    angleRadians = deg2Rad(angle_degrees) 

    for i in xrange(numsteps + 1): 
        a = angleRadians * i / numsteps 
        y = math.sin(a) 
        x = math.cos(a) 

        ls.drawTo(x, y, horizon_plane)
        ls.setThickness(2.0)
        ls.setColor(color)
    node = ls.create() 
    return NodePath(node)
開發者ID:mcgillcomp361,項目名稱:COMP361Project,代碼行數:17,代碼來源:shapes.py

示例14: makeArc

# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import drawTo [as 別名]
def makeArc(initial_x, initial_y, angleDegrees = 360, numSteps = 16):
    ls = LineSegs()

    angleRadians = deg2Rad(angleDegrees)

    for i in range(numSteps + 1):
        a = angleRadians * i / numSteps
        y = initial_y + 0.01*math.sin(a)
        x = initial_x + 0.01*math.cos(a)
	ls.setThickness(3)
	ls.setColor(0, 0, 0, 1)
        ls.drawTo(x, 0, y)

    node = ls.create()
    return NodePath(node)	
開發者ID:shubhamgoyal,項目名稱:virtual-vision-simulator,代碼行數:17,代碼來源:virtual_world.py

示例15: __init__

# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import drawTo [as 別名]
    def __init__(self,pickableList = []):
        self.pickable = pickableList
        tempCard = CardMaker('')
        tempCard.setFrame(0,1,0,1)

        #Lets render our frame so we can hide / show /resize it as needed        
        self.selectFrame = render2d.attachNewNode(tempCard.generate())
        self.selectFrame.setColor(1,1,0,.2)
        self.selectFrame.setTransparency(1)
        self.selectFrame.hide()
        
        #Set up our line segmants for a border 
        ls = LineSegs()
        ls.moveTo(0,0,0)
        ls.drawTo(1,0,0)
        ls.drawTo(1,0,1)
        ls.drawTo(0,0,1)
        ls.drawTo(0,0,0)
        
        self.selectFrame.attachNewNode(ls.create())
        
        self.selected = []
        self.previousSelect = []
        self.selectable = []
        
        #Init our mouse locations
        self.pt2InitMousePos = (-1,-1)
        self.pt2LastMousePos = (-1,-1)
        self.fFovh , self.fFovv = base.camLens.getFov()
        
        self.fTimeLastUpdateRect = 0
        self.fTimeLastUpdateSelected = 0
        self.UpdateTimeRect = 0.015
        self.UpdateTimeSelected = 0.015
        
        print "Running Select Tools"
        
        self.accept("mouse1",self.OnStartSelect)
        self.accept("control-mouse1",self.OnStartSelect)
        self.accept("mouse1-up",self.OnMouseRelease)
        self.taskUpdateSelectRect = 0
開發者ID:SergeyBurma,項目名稱:panda3d-rts-engine,代碼行數:43,代碼來源:GuiTools.py


注:本文中的pandac.PandaModules.LineSegs.drawTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。