本文整理汇总了Python中pyglet.gl.glRotatef函数的典型用法代码示例。如果您正苦于以下问题:Python glRotatef函数的具体用法?Python glRotatef怎么用?Python glRotatef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了glRotatef函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transform
def transform(self):
"""
Apply ModelView transformations.
You will most likely want to wrap calls to this function with
``glPushMatrix()``/``glPopMatrix()``
"""
x, y = director.get_window_size()
if not(self.grid and self.grid.active):
# only apply the camera if the grid is not active
# otherwise, the camera will be applied inside the grid
self.camera.locate()
gl.glTranslatef(self.position[0], self.position[1], 0)
gl.glTranslatef(self.transform_anchor_x, self.transform_anchor_y, 0)
if self.rotation != 0.0:
gl.glRotatef(-self._rotation, 0, 0, 1)
if self.scale != 1.0 or self.scale_x != 1.0 or self.scale_y != 1.0:
gl.glScalef(self._scale * self._scale_x, self._scale * self._scale_y, 1)
if self.transform_anchor != (0, 0):
gl.glTranslatef(
-self.transform_anchor_x,
-self.transform_anchor_y,
0)
示例2: paint
def paint(self, peg):
batch = self.get_batch()
glPushMatrix()
glTranslatef(peg.x, peg.y, 0)
glRotatef(peg.angle, 0, 0, 1)
batch.draw()
glPopMatrix()
示例3: draw
def draw(self):
self.loadStartPosition()
gl.glRotatef(90.0, 0.0, 0.0, 1.0)
gl.glBegin(gl.GL_QUADS)
gl.glColor3f(1.0, 1.0, 0.0)
tenth = math.pi * 2.0 / 10.0
for z in [-0.1, 0.1]:
for i in xrange(5):
a = float(i) * tenth * 2.0
gl.glVertex3f(0.0, 0.0, z)
gl.glVertex3f(0.4 * math.cos(a - tenth), 0.4 * math.sin(a - tenth), z)
gl.glVertex3f(math.cos(a), math.sin(a), z)
gl.glVertex3f(0.4 * math.cos(a + tenth), 0.4 * math.sin(a + tenth), z)
for i in xrange(5):
a = float(i) * tenth * 2.0
gl.glVertex3f(0.4 * math.cos(a - tenth), 0.4 * math.sin(a - tenth), 0.1)
gl.glVertex3f(math.cos(a), math.sin(a), 0.1)
gl.glVertex3f(math.cos(a), math.sin(a), -0.1)
gl.glVertex3f(0.4 * math.cos(a - tenth), 0.4 * math.sin(a - tenth), -0.1)
gl.glVertex3f(0.4 * math.cos(a + tenth), 0.4 * math.sin(a + tenth), 0.1)
gl.glVertex3f(math.cos(a), math.sin(a), 0.1)
gl.glVertex3f(math.cos(a), math.sin(a), -0.1)
gl.glVertex3f(0.4 * math.cos(a + tenth), 0.4 * math.sin(a + tenth), -0.1)
gl.glEnd()
self.loadStartPosition()
gl.glTranslatef(0.0, 0.0, 0.1)
gl.glScalef(0.01, 0.01, 0.0)
self.label.draw()
gl.glLoadIdentity()
示例4: rotate
def rotate(p, state, kwargs):
x, y = p.x, p.y
xp = x + (p.width / 2)
yp = y + (p.height / 2)
gl.glTranslatef(xp, yp, 0)
gl.glRotatef(kwargs['angle'], 0.0, 0.0, 1.0)
gl.glTranslatef(-xp, -yp, 0)
示例5: render_cylinder
def render_cylinder(self, base_radius, height, slices, stacks,
top_radius=None):
""" Generate the polygons for a cylinder
:param base_radius: The radius of the bottom of the cylinder.
:type base_radius: float
:param height: The cylinder's height
:type height: float
:param slices: The number of longitudinal lines
:type slices: int
:param stacks: The number of latitudinal lines
:type stacks: int
:param top_radius: The radius of the top of the cylinder. If undefined,
the top radius will be the same as the base radius
:type top_radius: float
"""
# rotate the cylinder so that it is drawn along the VPython axis
# convention
gl.glRotatef(90, 0, 1, 0)
if top_radius is None:
gl.glu.gluCylinder(self.quadric, base_radius, base_radius,
height, slices, stacks)
else:
gl.glu.gluCylinder(self.quadric, base_radius, top_radius,
height, slices, stacks)
gl.glRotatef(-90, 0, 1, 0)
示例6: draw_objects
def draw_objects(self):
'''called in the middle of ondraw after the buffer has been cleared'''
self.create_objects()
glPushMatrix()
if self.orthographic:
glTranslatef(0, 0, -3 * self.dist) # Move back
else:
glTranslatef(0, 0, -self.dist) # Move back
# Rotate according to trackball
glMultMatrixd(build_rotmatrix(self.basequat))
# Move origin to bottom left of platform
platformx0 = -self.build_dimensions[3] - self.parent.platform.width / 2
platformy0 = -self.build_dimensions[4] - self.parent.platform.depth / 2
glTranslatef(platformx0, platformy0, 0)
for obj in self.parent.objects:
if not obj.model \
or not obj.model.loaded \
or not obj.model.initialized:
continue
glPushMatrix()
glTranslatef(*(obj.offsets))
glTranslatef(*(obj.centeroffset))
glRotatef(obj.rot, 0.0, 0.0, 1.0)
glScalef(*obj.scale)
obj.model.display()
glPopMatrix()
glPopMatrix()
示例7: draw_ents
def draw_ents(self, ents):
for ent in ents:
glPushMatrix()
glTranslatef(ent.body.position.x, ent.body.position.y, 0)
glRotatef(ent.body.angle * 180 / pi, 0, 0, 1)
ent.batch.draw()
glPopMatrix()
示例8: draw_objects
def draw_objects(self):
'''called in the middle of ondraw after the buffer has been cleared'''
self.create_objects()
glPushMatrix()
# Rotate according to trackball
glMultMatrixd(build_rotmatrix(self.basequat))
# Move origin to bottom left of platform
platformx0 = -self.build_dimensions[3] - self.parent.platform.width / 2
platformy0 = -self.build_dimensions[4] - self.parent.platform.depth / 2
glTranslatef(platformx0, platformy0, 0)
light_z = max(self.parent.platform.width, self.parent.platform.depth)
glLightfv(GL_LIGHT0, GL_POSITION, vec(0,
self.parent.platform.depth / 2,
light_z, 0))
glLightfv(GL_LIGHT1, GL_POSITION, vec(self.parent.platform.width,
self.parent.platform.depth / 2,
light_z, 0))
for obj in self.parent.objects:
if not obj.model \
or not obj.model.loaded \
or not obj.model.initialized:
continue
glPushMatrix()
glTranslatef(*(obj.offsets))
glTranslatef(*(obj.centeroffset))
glRotatef(obj.rot, 0.0, 0.0, 1.0)
glScalef(*obj.scale)
obj.model.display()
glPopMatrix()
glPopMatrix()
示例9: render
def render(self):
gl.glPushMatrix()
gl.glTranslatef(self.x + self.width / 2, self.y + self.height / 2, 0)
gl.glRotatef(self.angle, 0, 0, 1)
gl.glTranslatef(-self.x - self.width / 2, -self.y - self.height / 2, 0)
self.batch.draw()
gl.glPopMatrix()
gl.glPushMatrix()
cx, cy, cw, ch = cannon_rects[0]
gl.glTranslatef(self.x + cx + cw / 2, self.y + cy + ch / 2, 0)
gl.glRotatef(self.cannon_angle - 90, 0, 0, 1)
gl.glTranslatef(-self.x - cx - cw / 2, -self.y - cy, 0)
self.cannon_batch.draw()
gl.glPopMatrix()
self.batch = pyglet.graphics.Batch()
self.cannon_batch = pyglet.graphics.Batch()
示例10: rotate
def rotate(self,ang,rx,ry,rz):
glPushMatrix()
glLoadIdentity()
glRotatef(ang,rx,ry,rz)
glMultMatrixf(self.matrix)
self.matrix=get_model_matrix()
glPopMatrix()
示例11: set_3d
def set_3d(self):
""" Configure OpenGL to draw in 3d.
"""
width, height = self.get_size()
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glViewport(0, 0, width, height)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.gluPerspective(65.0, width / float(height), 0.1, DIST)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
x, y = self.rotation
gl.glRotatef(x, 0, 1, 0)
gl.glRotatef(-y, math.cos(math.radians(x)), 0, math.sin(math.radians(x)))
x, y, z = self.position
gl.glTranslatef(-x, -y, -z)
gl.glEnable(gl.GL_LIGHTING)
gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, GLfloat4(0.05,0.05,0.05,1.0))
gl.glEnable(gl.GL_COLOR_MATERIAL)
gl.glColorMaterial(gl.GL_FRONT, gl.GL_AMBIENT_AND_DIFFUSE)
#gl.glLightfv(gl.GL_LIGHT1,gl.GL_SPOT_DIRECTION, GLfloat3(0,0,-1))
gl.glLightfv(gl.GL_LIGHT1, gl.GL_AMBIENT, GLfloat4(0.5,0.5,0.5,1.0))
gl.glLightfv(gl.GL_LIGHT1, gl.GL_DIFFUSE, GLfloat4(1.0,1.0,1.0,1.0))
gl.glLightfv(gl.GL_LIGHT1, gl.GL_POSITION, GLfloat4(0.35,1.0,0.65,0.0))
#gl.glLightfv(gl.GL_LIGHT0,gl.GL_SPECULAR, GLfloat4(1,1,1,1))
gl.glDisable(gl.GL_LIGHT0)
gl.glEnable(gl.GL_LIGHT1)
示例12: drawSpace
def drawSpace(self, window):
gl.glPushMatrix()
# GL matrices are applied last-added-first, so this *is* the right
# order for pushing them.
gl.glTranslatef(-self.viewportOrigin[0], -self.viewportOrigin[1], 0.0)
if self.shake is not None:
# We want to rotate around the center of the current viewport
# vpc = view port center
vpc_x = self.viewportOrigin[0] + self.windowProps.windowWidth//2
vpc_y = self.viewportOrigin[1] + self.windowProps.windowHeight//2
gl.glTranslatef(vpc_x, vpc_y, 0.0)
gl.glRotatef(self.shake.getAngle(), 0, 0, 1)
gl.glTranslatef(-vpc_x, -vpc_y, 0.0)
ge = self.gameElements
ge.starField.draw()
ge.swarm.draw()
if not self.explodedMarker.done():
ge.ship.draw()
if self.endGame and not self.drawFrameMarker.done():
self.endGame.draw(window)
for shot in ge.shots:
if shot.alive:
shot.draw()
gl.glPopMatrix()
示例13: rotate
def rotate(f,
angle,
x=0.0, y=0.0, z=1.0):
push()
gl.glRotatef(angle * 180 / pi,
x, y, z)
f()
pop()
示例14: on_draw
def on_draw():
window.clear()
gl.glLoadIdentity()
gl.gluLookAt(0, 8, 8, 0, 0, 0, 0, 1, 0)
gl.glRotatef(rot, 1, 0, 0)
gl.glRotatef(rot/2, 0, 1, 0)
batch.draw()
gl.glFinish()
示例15: draw
def draw(self):
glPushMatrix()
glRotatef(self.angle, 0., 0., 1.)
glScalef(self.scale, 1., 1.)
glTranslatef(0., -common_res.ray.height/2, 0.)
glColor4f(1., 1., 1., self.alpha)
common_res.ray.blit(0, 0)
glPopMatrix()