本文整理汇总了Python中pyglet.gl.glVertex3f函数的典型用法代码示例。如果您正苦于以下问题:Python glVertex3f函数的具体用法?Python glVertex3f怎么用?Python glVertex3f使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了glVertex3f函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_line
def draw_line(self, v, color):
o = self._p._origin
pgl.glBegin(pgl.GL_LINES)
pgl.glColor3f(*color)
pgl.glVertex3f(v[0][0] + o[0], v[0][1] + o[1], v[0][2] + o[2])
pgl.glVertex3f(v[1][0] + o[0], v[1][1] + o[1], v[1][2] + o[2])
pgl.glEnd()
示例2: draw
def draw(self, scale, pos):
LINE_COLOUR = (255, 255, 255)
# gl.glEnable(gl.GL_DEPTH_TEST);
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glEnable(gl.GL_LINE_SMOOTH)
gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_DONT_CARE)
gl.glBegin(gl.GL_LINES)
for link in self.links:
if link.highlight:
gl.glColor3ub(*self.colour)
gl.glColor3ub(*self.colour)
else:
gl.glColor3ub(*LINE_COLOUR)
gl.glColor3ub(*LINE_COLOUR)
if link.highlight:
depth = 0.5
else:
depth = 0.5
gl.glVertex3f(*util.add_tup(pos, util.scale_tup(link.points[0].pos, scale)) + (depth,))
gl.glVertex3f(*util.add_tup(pos, util.scale_tup(link.points[1].pos, scale)) + (depth,))
print util.add_tup(pos, util.scale_tup(link.points[0].pos, scale))
gl.glEnd()
示例3: f
def f():
for u in range(1, len(self.u_set)):
pgl.glBegin(pgl.GL_QUAD_STRIP)
for v in range(len(self.v_set)):
pa = self.verts[u - 1][v]
pb = self.verts[u][v]
if pa is None or pb is None:
pgl.glEnd()
pgl.glBegin(pgl.GL_QUAD_STRIP)
continue
if use_cverts:
ca = self.cverts[u - 1][v]
cb = self.cverts[u][v]
if ca is None:
ca = (0, 0, 0)
if cb is None:
cb = (0, 0, 0)
else:
if use_solid_color:
ca = cb = self.default_solid_color
else:
ca = cb = self.default_wireframe_color
pgl.glColor3f(*ca)
pgl.glVertex3f(*pa)
pgl.glColor3f(*cb)
pgl.glVertex3f(*pb)
pgl.glEnd()
示例4: render1
def render1(self):
if len(self.v) == 4 : gl.glBegin(gl.GL_QUADS)
elif len(self.v) > 4 : gl.glBegin(gl.GL_POLYGON)
else: gl.glBegin(gl.GL_TRIANGLES)
for p in self.v:
gl.glVertex3f(p[0], p[1],0) # draw each vertex
gl.glEnd()
示例5: bounce
def bounce(thing, other, vector=None):
screen = thing.screen
velocity_perpendicular = thing.vel.proj(vector)
velocity_parallel = thing.vel - velocity_perpendicular
if vector * thing.vel > 0:
thing.vel = (
screen.constants["friction"] * velocity_parallel + screen.constants["elasticity"] * velocity_perpendicular
)
else:
thing.vel = (
screen.constants["friction"] * velocity_parallel - screen.constants["elasticity"] * velocity_perpendicular
)
thing.position_component.position += screen.constants["displace"] * vector
if other.immobile:
thing.position_component.position += vector
if screen.draw_debug:
opengl.glBegin(opengl.GL_LINES)
p = thing.position_component.position
opengl.glVertex3f(p.x, p.y, 11)
opengl.glVertex3f(p.x + 5 * vector.x, p.y + 5 * vector.y, 11)
opengl.glEnd()
示例6: draw_arrow
def draw_arrow(p1, p2):
"""
Draw a single vector.
"""
glColor3f(0.4, 0.4, 0.9)
glVertex3f(*p1)
glColor3f(0.9, 0.4, 0.4)
glVertex3f(*p2)
示例7: renderCatalog
def renderCatalog(cat, far):
gl.glDisable(gl.GL_LIGHTING)
for s in cat:
c = s.getRgb()
gl.glPointSize(s.getSize())
gl.glBegin(gl.GL_POINTS)
gl.glColor3f(c[0], c[1], c[2])
gl.glVertex3f(far * cos(s.ra_rad) * cos(s.dec_rad), far * sin(s.ra_rad) * cos(s.dec_rad), far * sin(s.dec_rad))
gl.glEnd()
gl.glEnable(gl.GL_LIGHTING)
示例8: draw_lines
def draw_lines(point_list, color, border_width=1):
"""
Draw a set of lines.
Draw a line between each pair of points specified.
Args:
:point_list: List of points making up the lines. Each point is
in a list. So it is a list of lists.
:color: color, specified in a list of 3 or 4 bytes in RGB or
RGBA format.
:border_width: Width of the line in pixels.
Returns:
None
Raises:
None
Example:
>>> import arcade
>>> arcade.open_window("Drawing Example", 800, 600)
>>> arcade.set_background_color(arcade.color.WHITE)
>>> arcade.start_render()
>>> point_list = ((390, 450), \
(450, 450), \
(390, 480), \
(450, 480), \
(390, 510), \
(450, 510))
>>> arcade.draw_lines(point_list, arcade.color.BLUE, 3)
>>> arcade.finish_render()
>>> arcade.quick_run(0.25)
"""
GL.glEnable(GL.GL_BLEND)
GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
GL.glEnable(GL.GL_LINE_SMOOTH)
GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST)
GL.glHint(GL.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST)
GL.glLoadIdentity()
# Set line width
GL.glLineWidth(border_width)
# Set color
if len(color) == 4:
GL.glColor4ub(color[0], color[1], color[2], color[3])
elif len(color) == 3:
GL.glColor4ub(color[0], color[1], color[2], 255)
GL.glBegin(GL.GL_LINES)
for point in point_list:
GL.glVertex3f(point[0], point[1], 0.5)
GL.glEnd()
示例9: draw_canvas
def draw_canvas():
# Draw full-screen canvas
gl.glDrawBuffer(gl.GL_COLOR_ATTACHMENT0_EXT)
gl.glBegin(gl.GL_QUADS)
for coords in [(-1.0, -1.0),
(1.0, -1.0),
(1.0, 1.0),
(-1.0, 1.0)]:
gl.glVertex3f(coords[0], coords[1], 0.0)
gl.glEnd()
示例10: draw_callback
def draw_callback(self, nx, ny, z):
gl.glLineWidth(self.BOLT_WIDTH)
gl.glBegin(gl.GL_LINES)
gl.glColor4f(self.COLOR[0], self.COLOR[1], self.COLOR[2], 1)
gl.glVertex3f(self.x, self.y, z)
gl.glColor4f(self.COLOR[0] * 0.7, self.COLOR[1] * 0.7,
self.COLOR[2] * 0.7, 0)
gl.glVertex3f(self.x + nx * self.BOLT_LENGTH,
self.y + ny * self.BOLT_LENGTH, z)
gl.glColor3f(1, 1, 1)
gl.glEnd()
示例11: draw
def draw(self):
glPushMatrix()
glBegin(GL_LINES)
glColor4f(*self.color)
for di in [-1, 1]:
for dj in [-1, 1]:
glVertex3f(0, 0, 0)
glVertex3f(self.scale * di, self.scale * dj, self.height)
glEnd()
glPopMatrix()
示例12: draw
def draw(self):
p = adjust_for_cam(self._body.position)
gl.glEnable(pyglet.gl.GL_TEXTURE_2D)
gl.glBindTexture(gl.GL_TEXTURE_2D, BLASTER_IMAGE.id)
gl.glEnable(gl.GL_POINT_SPRITE)
gl.glTexEnvi(gl.GL_POINT_SPRITE, gl.GL_COORD_REPLACE, gl.GL_TRUE)
gl.glPointSize(4 * SPACE.scale)
gl.glBegin(gl.GL_POINTS)
# TODO: more optimized to draw as one large batch
gl.glVertex3f(p.x, p.y, 0)
gl.glEnd();
示例13: draw_line
def draw_line(start_x, start_y, end_x, end_y, color, border_width=1):
"""
Draw a line.
Args:
:start_x: x position of line starting point.
:start_y: y position of line starting point.
:end_x: x position of line ending point.
:end_y: y position of line ending point.
:color: color, specified in a list of 3 or 4 bytes in RGB or
RGBA format.
:border_width: Width of the line in pixels.
Returns:
None
Raises:
None
Example:
>>> import arcade
>>> arcade.open_window("Drawing Example", 800, 600)
>>> arcade.set_background_color(arcade.color.WHITE)
>>> arcade.start_render()
>>> arcade.draw_line(270, 495, 300, 450, arcade.color.WOOD_BROWN, 3)
>>> color = (127, 0, 127, 127)
>>> arcade.draw_line(280, 495, 320, 450, color, 3)
>>> arcade.finish_render()
>>> arcade.quick_run(0.25)
"""
GL.glEnable(GL.GL_BLEND)
GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
GL.glEnable(GL.GL_LINE_SMOOTH)
GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST)
GL.glHint(GL.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST)
GL.glLoadIdentity()
# Set line width
GL.glLineWidth(border_width)
# Set color
if len(color) == 4:
GL.glColor4ub(color[0], color[1], color[2], color[3])
elif len(color) == 3:
GL.glColor4ub(color[0], color[1], color[2], 255)
GL.glBegin(GL.GL_LINES)
GL.glVertex3f(start_x, start_y, 0.5)
GL.glVertex3f(end_x, end_y, 0.5)
GL.glEnd()
示例14: draw_polygon_outline
def draw_polygon_outline(point_list, color, border_width=1):
"""
Draw a polygon outline. Also known as a "line loop."
Args:
:point_list: List of points making up the lines. Each point is
in a list. So it is a list of lists.
:color: color, specified in a list of 3 or 4 bytes in RGB or
RGBA format.
:border_width: Width of the line in pixels.
Returns:
None
Raises:
None
>>> import arcade
>>> arcade.open_window("Drawing Example", 800, 600)
>>> arcade.set_background_color(arcade.color.WHITE)
>>> arcade.start_render()
>>> point_list = ((30, 240), \
(45, 240), \
(60, 255), \
(60, 285), \
(45, 300), \
(30, 300))
>>> arcade.draw_polygon_outline(point_list, arcade.color.SPANISH_VIOLET, 3)
>>> arcade.finish_render()
>>> arcade.quick_run(0.25)
"""
GL.glEnable(GL.GL_BLEND)
GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
GL.glEnable(GL.GL_LINE_SMOOTH)
GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST)
GL.glHint(GL.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST)
# Set line width
GL.glLineWidth(border_width)
GL.glLoadIdentity()
# Set color
if len(color) == 4:
GL.glColor4ub(color[0], color[1], color[2], color[3])
elif len(color) == 3:
GL.glColor4ub(color[0], color[1], color[2], 255)
GL.glBegin(GL.GL_LINE_LOOP)
for point in point_list:
GL.glVertex3f(point[0], point[1], 0.5)
GL.glEnd()
示例15: render_indicators
def render_indicators(self, W, H):
gl.glBegin(gl.GL_QUADS)
s = W/40.0
h = H/40.0
gl.glColor4f(0,0,0,1)
gl.glVertex3f(W, 0, 0)
gl.glVertex3f(W, 5*h, 0)
gl.glVertex3f(0, 5*h, 0)
gl.glVertex3f(0, 0, 0)
def vertical_ind(place, val, color):
gl.glColor4f(color[0], color[1], color[2], 1)
gl.glVertex3f((place+0)*s, h + h*val, 0)
gl.glVertex3f((place+1)*s, h + h*val, 0)
gl.glVertex3f((place+1)*s, h, 0)
gl.glVertex3f((place+0)*s, h, 0)
def horiz_ind(place, val, color):
gl.glColor4f(color[0], color[1], color[2], 1)
gl.glVertex3f((place+0)*s, 4*h , 0)
gl.glVertex3f((place+val)*s, 4*h, 0)
gl.glVertex3f((place+val)*s, 2*h, 0)
gl.glVertex3f((place+0)*s, 2*h, 0)
true_speed = np.sqrt(np.square(self.car.hull.linearVelocity[0]) + np.square(self.car.hull.linearVelocity[1]))
vertical_ind(5, 0.02*true_speed, (1,1,1))
vertical_ind(7, 0.01*self.car.wheels[0].omega, (0.0,0,1)) # ABS sensors
vertical_ind(8, 0.01*self.car.wheels[1].omega, (0.0,0,1))
vertical_ind(9, 0.01*self.car.wheels[2].omega, (0.2,0,1))
vertical_ind(10,0.01*self.car.wheels[3].omega, (0.2,0,1))
horiz_ind(20, -10.0*self.car.wheels[0].joint.angle, (0,1,0))
horiz_ind(30, -0.8*self.car.hull.angularVelocity, (1,0,0))
gl.glEnd()
self.score_label.text = "%04i" % self.reward
self.score_label.draw()