本文整理匯總了Python中pandac.PandaModules.LineSegs.create方法的典型用法代碼示例。如果您正苦於以下問題:Python LineSegs.create方法的具體用法?Python LineSegs.create怎麽用?Python LineSegs.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pandac.PandaModules.LineSegs
的用法示例。
在下文中一共展示了LineSegs.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: draw
# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import create [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)
示例2: SelectionBox
# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import create [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)
示例3: __init__
# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import create [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() )
示例4: add_line
# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import create [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)
示例5: drawLineToNeighbors
# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import create [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)
示例6: __createLine
# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import create [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
示例7: drawLine
# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import create [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)
示例8: AttackCursor
# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import create [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()
示例9: xBox
# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import create [as 別名]
def xBox(frame, lineThick=2, color=(1,1,1,1), brdrColor=(1,1,1,1), BGColor = None):
w = frame[1]-frame[0]
h = frame[3]-frame[2]
bx = LineSegs('xbox')
rect(bx, (frame[1]-h/4,frame[1]-3*h/4,frame[2]+h/4,frame[3]-h/4))
ex(bx, (frame[1]-h/4,frame[1]-3*h/4,frame[2]+h/4,frame[3]-h/4))
box = bx.create()
if BGColor:
fill(rectangleLine, frame, BGColor, lineThick).reparentTo(NodePath(box))
return box
示例10: drawBestPath
# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import create [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)
示例11: __init__
# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import create [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())
示例12: sepLine
# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import create [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()
示例13: bevelArrow
# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import create [as 別名]
def bevelArrow(frame, bevel=.35, arrowhead=.4, lineThick=2, color=(1,1,1,1), brdrColor=(1,1,1,1), BGColor = None):
ls = LineSegs()
ls.setThickness(lineThick)
if brdrColor != 'transparent':
ls.setColor(brdrColor)
bevelArrowLine(ls, frame, bevel, arrowhead)
else:
ls.setColor(color)
a = ls.create()
if BGColor:
fill(bevelArrowLine, frame, BGColor, lineThick, bevel, arrowhead).reparentTo(NodePath(a))
return a
示例14: rectangle
# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import create [as 別名]
def rectangle(frame, lineThick=2, color=(1,1,1,1), brdrColor=(1,1,1,1), BGColor = None):
ls = LineSegs()
ls.setThickness(lineThick)
if brdrColor != 'transparent':
ls.setColor(brdrColor)
rectangleLine(ls, frame)
else:
ls.setColor(color)
a = ls.create()
if BGColor:
fill(rectangleLine, frame, BGColor, lineThick).reparentTo(NodePath(a))
return a
示例15: makeArc
# 需要導入模塊: from pandac.PandaModules import LineSegs [as 別名]
# 或者: from pandac.PandaModules.LineSegs import create [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)