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


Python Matrix44.perspective_projection方法代碼示例

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


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

示例1: resizeGL

# 需要導入模塊: from pyrr import Matrix44 [as 別名]
# 或者: from pyrr.Matrix44 import perspective_projection [as 別名]
 def resizeGL(self, w, h):
     glViewport(0, 0, w, h)
     self.viewport = (w, h)
     self.projTransform = Matrix44.perspective_projection(
         50, float(w) / h,
         0.01, 100.0,
     )
開發者ID:mkovacs,項目名稱:sphaira,代碼行數:9,代碼來源:view.py

示例2: render

# 需要導入模塊: from pyrr import Matrix44 [as 別名]
# 或者: from pyrr.Matrix44 import perspective_projection [as 別名]
    def render(self, time: float, frame_time: float):
        self.ctx.clear(1.0, 1.0, 1.0)
        self.ctx.enable(moderngl.DEPTH_TEST)

        proj = Matrix44.perspective_projection(45.0, self.aspect_ratio, 0.1, 1000.0)
        lookat = Matrix44.look_at(
            (47.697, -8.147, 24.498),
            (0.0, 0.0, 8.0),
            (0.0, 0.0, 1.0),
        )

        rotate = Matrix44.from_z_rotation(np.sin(time) * 0.5 + 0.2)

        self.use_texture.value = False

        self.light.value = (67.69, -8.14, 52.49)
        self.mvp.write((proj * lookat * rotate).astype('f4').tobytes())

        self.color.value = (0.67, 0.49, 0.29)
        self.objects['ground'].render()

        self.color.value = (0.46, 0.67, 0.29)
        self.objects['grass'].render()

        self.color.value = (1.0, 1.0, 1.0)
        self.objects['billboard'].render()

        self.color.value = (0.2, 0.2, 0.2)
        self.objects['billboard-holder'].render()

        self.use_texture.value = True
        self.texture.use()

        self.objects['billboard-image'].render()
開發者ID:cprogrammer1994,項目名稱:ModernGL,代碼行數:36,代碼來源:04_colors_and_texture.py

示例3: onsc

# 需要導入模塊: from pyrr import Matrix44 [as 別名]
# 或者: from pyrr.Matrix44 import perspective_projection [as 別名]
def onsc(window, yof):
    """Wheels. """
    global whel
    sz = window.get_size()
    whel = clip(whel - yof, 1, 180)
    pm = matrix.perspective_projection(whel, sz[0] / sz[1], 0.01, 100)
    GL.glUniformMatrix4fv(GL.glGetUniformLocation(shaderp, 'projectmatrix'), 1, False, pm)
開發者ID:bzalakos,項目名稱:inscma,代碼行數:9,代碼來源:win.py

示例4: rematr

# 需要導入模塊: from pyrr import Matrix44 [as 別名]
# 或者: from pyrr.Matrix44 import perspective_projection [as 別名]
def rematr(wid, hig):
    """Resets the projection matrix."""
    if hig == 0:
        hig = 1
    # This method has FOV in degrees for some reason???
    pm = matrix.perspective_projection(whel, wid/hig, 0.01, 100)
    GL.glUniformMatrix4fv(GL.glGetUniformLocation(shaderp, 'projectmatrix'), 1, False, pm)
開發者ID:bzalakos,項目名稱:inscma,代碼行數:9,代碼來源:win.py

示例5: update

# 需要導入模塊: from pyrr import Matrix44 [as 別名]
# 或者: from pyrr.Matrix44 import perspective_projection [as 別名]
def update(dt):
    ctx.viewport = (0, 0, wnd.width, wnd.height)
    ctx.clear(0.9, 0.9, 0.9)
    ctx.enable(ModernGL.DEPTH_TEST)

    proj = Matrix44.perspective_projection(45.0, wnd.width / wnd.height, 0.1, 1000.0)
    lookat = Matrix44.look_at(
        (40.0, 30.0, 20.0),
        (0.0, 0.0, 0.0),
        (0.0, 0.0, 1.0),
開發者ID:cprogrammer1994,項目名稱:ModernGL,代碼行數:12,代碼來源:perspective_projection.py

示例6: draw

# 需要導入模塊: from pyrr import Matrix44 [as 別名]
# 或者: from pyrr.Matrix44 import perspective_projection [as 別名]
    def draw(self, *args):
        width, height = Window.size
        self.ctx.viewport = (0, 0, width, height)
        self.ctx.clear(0.9, 0.9, 0.9)
        self.ctx.enable(ModernGL.DEPTH_TEST)

        proj = Matrix44.perspective_projection(45.0, width / height, 0.1, 1000.0)
        lookat = Matrix44.look_at(
            (40.0, 30.0, 20.0),
            (0.0, 0.0, 0.0),
            (0.0, 0.0, 1.0),
開發者ID:cprogrammer1994,項目名稱:ModernGL,代碼行數:13,代碼來源:perspective_projection.py

示例7: render

# 需要導入模塊: from pyrr import Matrix44 [as 別名]
# 或者: from pyrr.Matrix44 import perspective_projection [as 別名]
    def render(self):
        self.ctx.screen.viewport = self.wnd.viewport
        self.ctx.clear(1.0, 1.0, 1.0)
        with self.ctx.scope(mgl.DEPTH_TEST):
            proj = Matrix44.perspective_projection(45.0, self.wnd.ratio, 0.1, 1000.0)
            lookat = Matrix44.look_at(
                (40.0, 30.0, 30.0),
                (0.0, 0.0, 0.0),
                (0.0, 0.0, 1.0),
            )

            self.prog['Mvp'] = (proj * lookat).astype('f4').tobytes()
            self.vao.render(mgl.LINES)
開發者ID:cprogrammer1994,項目名稱:ModernGL,代碼行數:15,代碼來源:simple_grid.py

示例8: render

# 需要導入模塊: from pyrr import Matrix44 [as 別名]
# 或者: from pyrr.Matrix44 import perspective_projection [as 別名]
    def render(self, time, frame_time):
        self.ctx.clear(1.0, 1.0, 1.0)
        self.ctx.enable(moderngl.DEPTH_TEST)

        proj = Matrix44.perspective_projection(45.0, self.aspect_ratio, 0.1, 1000.0)
        lookat = Matrix44.look_at(
            (40.0, 30.0, 30.0),
            (0.0, 0.0, 0.0),
            (0.0, 0.0, 1.0),
        )

        self.mvp.write((proj * lookat).astype('f4').tobytes())
        self.vao.render(moderngl.LINES)
開發者ID:cprogrammer1994,項目名稱:ModernGL,代碼行數:15,代碼來源:simple_grid.py

示例9: main

# 需要導入模塊: from pyrr import Matrix44 [as 別名]
# 或者: from pyrr.Matrix44 import perspective_projection [as 別名]
def main():
    window = initWindow()
    classicProgram, normalMapProgram, skyboxProgram, asteroidProgram = initShaders()
    glEnable(GL_DEPTH_TEST)
    glDepthFunc(GL_LESS)

    # Initialize objects
    planets, spaceship, skybox, belt = initObjects(classicProgram, normalMapProgram,
                                             skyboxProgram, asteroidProgram)

    projMatrix = mat4.perspective_projection(60,
                                             float(WIDTH/HEIGHT),
                                             0.1,
                                             10000.0,
                                             dtype='f')
    eye, viewMatrix = initCamera()

    dt, oldTime = 0.0, glfw.GetTime()
    animation_speed = 800
    while not glfw.WindowShouldClose(window):
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        currentTime = glfw.GetTime()
        dt = currentTime - oldTime
        oldTime = currentTime

        hAngle, vAngle, eye, direction, right, up, viewMatrix, animation_speed = getNewViewMatrixAndEye(window,
                                                                  animation_speed,
                                                                  dt,
                                                                  eye,
                                                                  WIDTH,
                                                                  HEIGHT)

        for planet in planets:
            planet.update(animation_speed)
            planet.draw(eye, viewMatrix, projMatrix)

        spaceship.update(eye, direction, right, up, hAngle, vAngle)
        spaceship.draw(eye, viewMatrix, projMatrix)

        belt.update(0.1)
        belt.draw(eye, viewMatrix, projMatrix)

        skybox.draw(viewMatrix, projMatrix)
        # Swap front and back buffers
        glfw.SwapBuffers(window)

        # Poll for and process events
        glfw.PollEvents()

    glfw.Terminate()
開發者ID:bogdanteleaga,項目名稱:TSBK07,代碼行數:53,代碼來源:main.py

示例10: render

# 需要導入模塊: from pyrr import Matrix44 [as 別名]
# 或者: from pyrr.Matrix44 import perspective_projection [as 別名]
    def render(self, time: float, frame_time: float):
        camera_pos = (np.cos(time) * 300.0, np.sin(time) * 300.0, 120.0)
        proj = Matrix44.perspective_projection(45.0, self.aspect_ratio, 0.1, 1000.0)
        lookat = Matrix44.look_at(
            camera_pos,
            (0.0, 0.0, 50.0),
            (0.0, 0.0, 1.0),
        )

        with self.scope:
            self.prog['Mvp'] = (proj * lookat).astype('f4').tobytes()
            self.prog['Eye'] = camera_pos
            self.ctx.clear(1.0, 1.0, 1.0)
            self.vao.render()
開發者ID:cprogrammer1994,項目名稱:ModernGL,代碼行數:16,代碼來源:texture_cube.py

示例11: render

# 需要導入模塊: from pyrr import Matrix44 [as 別名]
# 或者: from pyrr.Matrix44 import perspective_projection [as 別名]
    def render(self, time, frame_time):
        angle = time * 0.2
        self.ctx.clear(1.0, 1.0, 1.0)
        self.ctx.enable(moderngl.DEPTH_TEST)

        proj = Matrix44.perspective_projection(45.0, self.aspect_ratio, 0.1, 1000.0)
        lookat = Matrix44.look_at(
            (np.cos(angle), np.sin(angle), 0.8),
            (0.0, 0.0, 0.1),
            (0.0, 0.0, 1.0),
        )

        self.mvp.write((proj * lookat).astype('f4').tobytes())
        self.vao.render(moderngl.TRIANGLE_STRIP)
開發者ID:cprogrammer1994,項目名稱:ModernGL,代碼行數:16,代碼來源:multi_texture_terrain.py

示例12: render

# 需要導入模塊: from pyrr import Matrix44 [as 別名]
# 或者: from pyrr.Matrix44 import perspective_projection [as 別名]
    def render(self, time, frame_time):
        angle = time
        self.ctx.clear(1.0, 1.0, 1.0)

        camera_pos = (np.cos(angle) * 5.0, np.sin(angle) * 5.0, 2.0)

        proj = Matrix44.perspective_projection(45.0, self.aspect_ratio, 0.1, 1000.0)
        lookat = Matrix44.look_at(
            camera_pos,
            (0.0, 0.0, 0.0),
            (0.0, 0.0, 1.0),
        )

        self.prog['Mvp'] = (proj * lookat).astype('f4').tobytes()
        self.prog['Light'] = camera_pos
        self.vao.render()
開發者ID:cprogrammer1994,項目名稱:ModernGL,代碼行數:18,代碼來源:texture_3d_visual_test.py

示例13: init

# 需要導入模塊: from pyrr import Matrix44 [as 別名]
# 或者: from pyrr.Matrix44 import perspective_projection [as 別名]
def init():
    """Initialises the display."""
    global projectmatrix, modelmatrix, chaem
    GL.glClearColor(0.0, 0.2, 0.15, 0.0)
    GL.glClearDepth(1.0)
    GL.glDepthFunc(GL.GL_LESS)
    GL.glEnable(GL.GL_DEPTH_TEST)
    GL.glShadeModel(GL.GL_SMOOTH)
    shades()
    chaem = Fremv((), deltam)
    GL.glUniform3f(GL.glGetUniformLocation(shaderp, 'lightColour'), *[1.0, 1.0, 1.0])
    modelmatrix = matrix.from_scale([2, 2, 2]) * matrix.from_translation([0, 0, -1])
    wid, hig = window.get_size()
    hig = hig or 1
    projectmatrix = matrix.perspective_projection(whel, wid/hig, 0.01, 100)
    rematr()
開發者ID:bzalakos,項目名稱:inscma,代碼行數:18,代碼來源:won.py

示例14: render

# 需要導入模塊: from pyrr import Matrix44 [as 別名]
# 或者: from pyrr.Matrix44 import perspective_projection [as 別名]
    def render(self):
        angle = self.wnd.time
        self.ctx.screen.viewport = self.wnd.viewport

        camera_pos = (np.cos(angle) * 5.0, np.sin(angle) * 5.0, 2.0)

        proj = Matrix44.perspective_projection(45.0, self.wnd.ratio, 0.1, 1000.0)
        lookat = Matrix44.look_at(
            camera_pos,
            (0.0, 0.0, 0.5),
            (0.0, 0.0, 1.0),
        )

        self.prog['Mvp'] = (proj * lookat).astype('f4').tobytes()
        self.prog['Light'] = camera_pos

        self.ctx.replay(self.bytecode)
開發者ID:cprogrammer1994,項目名稱:ModernGL,代碼行數:19,代碼來源:crate_render_batch.py

示例15: render

# 需要導入模塊: from pyrr import Matrix44 [as 別名]
# 或者: from pyrr.Matrix44 import perspective_projection [as 別名]
    def render(self, time, frame_time):
        self.ctx.clear(1.0, 1.0, 1.0)
        self.ctx.enable(moderngl.DEPTH_TEST)

        proj = Matrix44.perspective_projection(45.0, self.aspect_ratio, 0.1, 1000.0)
        lookat = Matrix44.look_at(
            (-85, -180, 140),
            (0.0, 0.0, 65.0),
            (0.0, 0.0, 1.0),
        )

        self.light.value = (-140.0, -300.0, 350.0)
        self.color.value = (1.0, 1.0, 1.0, 0.25)
        self.mvp.write((proj * lookat).astype('f4').tobytes())

        self.texture.use()
        self.vao.render()
開發者ID:cprogrammer1994,項目名稱:ModernGL,代碼行數:19,代碼來源:loading_obj_files.py


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