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


Python gl.glPushMatrix方法代碼示例

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


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

示例1: show_velocity

# 需要導入模塊: from pyglet import gl [as 別名]
# 或者: from pyglet.gl import glPushMatrix [as 別名]
def show_velocity(self, position, velocity, expected_velocity=None):
        """
        Show velocity vector as a thin cylinder arrow.
        """
        if not hasattr(self, 'drone_velocity_drawer'):
            return

        transform = self._get_velocity_transform(velocity, position)
        gl.glPushMatrix()
        gl.glMultMatrixf(rendering.matrix_to_gl(transform))

        self.drone_velocity_drawer.draw(mode=self.drone_vertex_list_mode)
        gl.glPopMatrix()

        if expected_velocity is not None and \
           hasattr(self, 'drone_expected_velocity_drawer'):
            transform = self._get_velocity_transform(
                expected_velocity, position)
            gl.glPushMatrix()
            gl.glMultMatrixf(rendering.matrix_to_gl(transform))

            self.drone_expected_velocity_drawer.draw(
                mode=self.drone_vertex_list_mode)
            gl.glPopMatrix() 
開發者ID:PaddlePaddle,項目名稱:RLSchool,代碼行數:26,代碼來源:render.py

示例2: draw_checkerboard

# 需要導入模塊: from pyglet import gl [as 別名]
# 或者: from pyglet.gl import glPushMatrix [as 別名]
def draw_checkerboard(self):
        if self.show_checkerboard:
            gl.glPushMatrix()
            gl.glScalef(self.window.width/float(self.checkerboard.width),
                        self.window.height/float(self.checkerboard.height),
                        1.)
            gl.glMatrixMode(gl.GL_TEXTURE)
            gl.glPushMatrix()
            gl.glScalef(self.window.width/float(self.checkerboard.width),
                        self.window.height/float(self.checkerboard.height),
                        1.)
            gl.glMatrixMode(gl.GL_MODELVIEW)
            self.checkerboard.blit(0, 0, 0)
            gl.glMatrixMode(gl.GL_TEXTURE)
            gl.glPopMatrix()
            gl.glMatrixMode(gl.GL_MODELVIEW)
            gl.glPopMatrix() 
開發者ID:pyglet,項目名稱:pyglet,代碼行數:19,代碼來源:test_image.py

示例3: render_labels

# 需要導入模塊: from pyglet import gl [as 別名]
# 或者: from pyglet.gl import glPushMatrix [as 別名]
def render_labels(self):
        # Render for errors and labels of pins

        if not self.active and not self.hover:
            return

        if self.problem:
            self.er_label.x = self.x - self.cw - self.offset
            self.er_label.y = self.y
            self.er_label.draw()

        if self.hover:
            for label, put in zip(self.in_labels, self.put_pos(self.inputs)):
                gl.glPushMatrix()
                gl.glTranslatef(put['pos'], self.y + self.ch + 15, 0.0)
                gl.glRotatef(45.0, 0.0, 0.0, 1.0)
                label.draw()
                gl.glPopMatrix()

            for label, put in zip(self.out_labels, self.put_pos(self.outputs)):
                gl.glPushMatrix()
                gl.glTranslatef(put['pos'], self.y - self.ch - 20, 0.0)
                gl.glRotatef(45.0, 0.0, 0.0, 1.0)
                label.draw()
                gl.glPopMatrix() 
開發者ID:honix,項目名稱:Pyno,代碼行數:27,代碼來源:element.py

示例4: draw_mouse_cursor

# 需要導入模塊: from pyglet import gl [as 別名]
# 或者: from pyglet.gl import glPushMatrix [as 別名]
def draw_mouse_cursor(self):
        '''Draw the custom mouse cursor.

        If the current mouse cursor has ``drawable`` set, this method
        is called before the buffers are flipped to render it.

        This method always leaves the ``GL_MODELVIEW`` matrix as current,
        regardless of what it was set to previously.  No other GL state
        is affected.

        There is little need to override this method; instead, subclass
        ``MouseCursor`` and provide your own ``draw`` method.
        '''
        # Draw mouse cursor if set and visible.
        # XXX leaves state in modelview regardless of starting state
        if (self._mouse_cursor.drawable and
            self._mouse_visible and
            self._mouse_in_window):
            gl.glMatrixMode(gl.GL_PROJECTION)
            gl.glPushMatrix()
            gl.glLoadIdentity()
            gl.glOrtho(0, self.width, 0, self.height, -1, 1)

            gl.glMatrixMode(gl.GL_MODELVIEW)
            gl.glPushMatrix()
            gl.glLoadIdentity()

            self._mouse_cursor.draw(self._mouse_x, self._mouse_y)

            gl.glMatrixMode(gl.GL_PROJECTION)
            gl.glPopMatrix()

            gl.glMatrixMode(gl.GL_MODELVIEW)
            gl.glPopMatrix()

    # Properties provide read-only access to instance variables.  Use
    # set_* methods to change them if applicable. 
開發者ID:shrimpboyho,項目名稱:flappy-bird-py,代碼行數:39,代碼來源:__init__.py

示例5: on_draw

# 需要導入模塊: from pyglet import gl [as 別名]
# 或者: from pyglet.gl import glPushMatrix [as 別名]
def on_draw(self):
        self.window.clear()
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glPushMatrix()
        gl.glLoadIdentity()
        self.camera()
        gl.glEnable(self.background.target)
        gl.glEnable(gl.GL_BLEND)
        gl.glBindTexture(self.background.target, self.background.id)
        W = 10000.
        graphics.draw(4, gl.GL_QUADS,
                      ('v2f', (-W, -W, W, -W, W, W, -W, W)),
                      ('t2f', (0., 0., W * 5., 0., W * 5., W * 5., 0., W * 5.))
                      )
        gl.glDisable(self.background.target)
        for lane in self.world.lanes:
            self.draw_lane_surface(lane)
            self.draw_lane_lines(lane)
        for obj in self.world.objects:
            self.draw_object(obj)
        for car in self.world.cars:
            self.draw_car(car.trajectory[-1], car.color)
        gl.glPopMatrix()

        self.label.text = self.task_name
        self.label.draw()
        self.iter +=1
        if self.iter%10 == 0:
            print('Iterations: ', self.iter)
        if self.iter == self.max_iters:
            self.event_loop.exit() 
開發者ID:BerkeleyLearnVerify,項目名稱:VerifAI,代碼行數:33,代碼來源:simulator.py

示例6: scale

# 需要導入模塊: from pyglet import gl [as 別名]
# 或者: from pyglet.gl import glPushMatrix [as 別名]
def scale(x, y=None, z=None):
    if y is None:
        y, z = x, x
    elif z is None:
        z = 1

    gl.glPushMatrix()
    gl.glScalef(x, y, z)
    yield
    gl.glPopMatrix() 
開發者ID:edne,項目名稱:pineal,代碼行數:12,代碼來源:__init__.py

示例7: translate

# 需要導入模塊: from pyglet import gl [as 別名]
# 或者: from pyglet.gl import glPushMatrix [as 別名]
def translate(x, y=0, z=0):
    gl.glPushMatrix()
    gl.glTranslatef(x, y, z)
    yield
    gl.glPopMatrix() 
開發者ID:edne,項目名稱:pineal,代碼行數:7,代碼來源:__init__.py

示例8: rotate

# 需要導入模塊: from pyglet import gl [as 別名]
# 或者: from pyglet.gl import glPushMatrix [as 別名]
def rotate(angle, axis=(0, 0, 1)):
    gl.glPushMatrix()
    gl.glRotatef(angle * 180 / pi, *axis)
    yield
    gl.glPopMatrix() 
開發者ID:edne,項目名稱:pineal,代碼行數:7,代碼來源:__init__.py

示例9: set_state

# 需要導入模塊: from pyglet import gl [as 別名]
# 或者: from pyglet.gl import glPushMatrix [as 別名]
def set_state(self):
        gl.glPushMatrix()
        gl.glLoadIdentity() 
開發者ID:honix,項目名稱:Pyno,代碼行數:5,代碼來源:draw.py

示例10: show_drone

# 需要導入模塊: from pyglet import gl [as 別名]
# 或者: from pyglet.gl import glPushMatrix [as 別名]
def show_drone(self, position, rotation):
        """
        Show the drone 3D model with corresponding translation and rotation.
        """
        # Get the transform matrix for drone 3D model
        x, z, y = position
        transform = np.eye(4)
        transform[:3, 3] = [x, y, z]

        # NOTE: change the view size of drone 3D model
        transform[0, 0] = 2.5
        transform[1, 1] = 2.5
        transform[2, 2] = 2.5

        # Match drone model space x-y-z to openGL x-z-y
        # TODO: read the config.json and match the propeller positions
        model_space_transform = rotation_transform_mat(-np.pi / 2, 'roll')
        transform = np.dot(transform, model_space_transform)

        yaw, pitch, roll = rotation
        if self.debug_mode:
            # NOTE: manually set values to debug rotation,
            # it's useful when input act is in form [c, c, c, c].
            yaw = np.pi / 2
            # pitch = np.pi / 2
            # roll = np.pi / 2
        transform = np.dot(transform, rotation_transform_mat(yaw, 'yaw'))
        transform = np.dot(transform, rotation_transform_mat(pitch, 'pitch'))
        transform = np.dot(transform, rotation_transform_mat(roll, 'roll'))

        # Add a new matrix to the model stack to transform the model
        gl.glPushMatrix()
        gl.glMultMatrixf(rendering.matrix_to_gl(transform))

        # Enable the target texture
        if self.drone_texture is not None:
            gl.glEnable(self.drone_texture.target)
            gl.glBindTexture(self.drone_texture.target, self.drone_texture.id)

        # Draw the mesh with its transform applied
        self.drone_drawer.draw(mode=self.drone_vertex_list_mode)
        gl.glPopMatrix()

        # Disable texture after using
        if self.drone_texture is not None:
            gl.glDisable(self.drone_texture.target) 
開發者ID:PaddlePaddle,項目名稱:RLSchool,代碼行數:48,代碼來源:render.py


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