本文整理汇总了Python中panda3d.core.LineSegs.moveTo方法的典型用法代码示例。如果您正苦于以下问题:Python LineSegs.moveTo方法的具体用法?Python LineSegs.moveTo怎么用?Python LineSegs.moveTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.LineSegs
的用法示例。
在下文中一共展示了LineSegs.moveTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_xy
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import moveTo [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
示例2: plot_xy_vs_t
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import moveTo [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()
示例3: update_LFP
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import moveTo [as 别名]
def update_LFP(self, dt, last_lfp, lfp_trace, offset, gen_lfp):
# lfp data is taken at 1000Hz, and dt is the number of seconds since
# the last frame was flipped, so plot number of points = dt * 1000
lfp = LineSegs()
lfp.setThickness(1.0)
#print('points to plot', int(dt * 1000))
#self.lfp_test += int(dt * 1000)
#print('points so far', self.lfp_test)
for i in range(int(dt * 1000)):
try:
last_lfp.append((next(gen_lfp) * self.lfp_gain) + offset)
#last_lfp_x += 0.05
# only plotting 200 data points at a time
while len(last_lfp) > 3500:
last_lfp.pop(0)
except StopIteration:
#print('done with lfp')
break
if lfp_trace:
lfp_trace[0].removeNode()
lfp_trace.pop(0)
lfp.moveTo(self.start_x_trace, 55, last_lfp[0])
x = self.start_x_trace
for i in last_lfp:
x += .1
lfp.drawTo(x, 55, i)
node = self.base.pixel2d.attachNewNode(lfp.create())
lfp_trace.append(node)
示例4: create
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import moveTo [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( )
示例5: draw_line
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import moveTo [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)
示例6: plot_zero_lines
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import moveTo [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))
示例7: draw_edge
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import moveTo [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
示例8: drawLineSeg
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import moveTo [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)
示例9: create_lines
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import moveTo [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)
示例10: draw_cross
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import moveTo [as 别名]
def draw_cross(self, deg_per_pixel):
cross = LineSegs()
cross.setThickness(2.0)
# cross hair is 1/2 degree visual angle,
# so go 1/4 on each side
dist_from_center = 0.25 / deg_per_pixel
cross.moveTo(0 + dist_from_center, 55, 0)
cross.drawTo(0 - dist_from_center, 55, 0)
cross.moveTo(0, 55, 0 - dist_from_center)
cross.drawTo(0, 55, 0 + dist_from_center)
self.x_node = self.base.render.attachNewNode(cross.create(True))
self.x_node.hide()
示例11: __make_border__
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import moveTo [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'])
示例12: line_small_lakes
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import moveTo [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)
示例13: line_border
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import moveTo [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)
示例14: _createDebugLine
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import moveTo [as 别名]
def _createDebugLine(self, points, connectToEnd=False):
""" Helper for visualizing the light bounds.
Draws a line trough all points. When connectToEnd is true,
the last point will get connected to the first point. """
segs = LineSegs()
segs.setThickness(1.0)
segs.setColor(Vec4(1, 1, 0, 1))
segs.moveTo(points[0])
for point in points[1:]:
segs.drawTo(point)
if connectToEnd:
segs.drawTo(points[0])
return NodePath(segs.create())
示例15: draw_floor_plane
# 需要导入模块: from panda3d.core import LineSegs [as 别名]
# 或者: from panda3d.core.LineSegs import moveTo [as 别名]
def draw_floor_plane(self,size,granularity):
line_drawer = LineSegs('grid_line_drawer')
line_drawer.setColor(0.0,0.0,0.0,1.0)
line_drawer.setThickness(1.0)
for i in range(-size,size+1,granularity):
line_drawer.moveTo(Vec3(float(i),float(-size),0.0))
line_drawer.drawTo(Vec3(float(i),float(size),0.0))
for i in range(-size,size+1,granularity):
line_drawer.moveTo(Vec3(float(-size),float(i),0.0))
line_drawer.drawTo(Vec3(float(size),float(i),0.0))
edge_node = line_drawer.create()
rendered_edges = render.attachNewNode(edge_node)
rendered_edges.setTransparency(TransparencyAttrib.MAlpha)
rendered_edges.setAlphaScale(0.5)
return 0