当前位置: 首页>>代码示例>>Python>>正文


Python Matrix44.from_z_rotation方法代码示例

本文整理汇总了Python中pyrr.Matrix44.from_z_rotation方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix44.from_z_rotation方法的具体用法?Python Matrix44.from_z_rotation怎么用?Python Matrix44.from_z_rotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyrr.Matrix44的用法示例。


在下文中一共展示了Matrix44.from_z_rotation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: render

# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import from_z_rotation [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

示例2: getModelMatrix

# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import from_z_rotation [as 别名]
  def getModelMatrix(self):
      scale = mat4.from_scale([0.2, 0.2, 0.2])
      
      roty = mat4.from_y_rotation(-self.hAngle)

      vdiff = self.vAngle - self.oldvAngle
      rotx = mat4.from_x_rotation(self.getxRot(vdiff))
      
      zdiff = self.hAngle - self.oldhAngle
      rotz = mat4.from_z_rotation(-self.getzRot(zdiff))

      trans = mat4.from_translation(self.position, dtype='f')
      self.oldhAngle = self.hAngle
      self.oldvAngle = self.vAngle
      
      return scale * rotz * rotx * roty * trans
开发者ID:bogdanteleaga,项目名称:TSBK07,代码行数:18,代码来源:spaceship.py

示例3: render

# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import from_z_rotation [as 别名]
    def render(self, time, frame_time):
        self.ctx.clear(1.0, 1.0, 1.0)
        # self.ctx.enable(mgl.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)

        w, h = self.texture.size
        gw, gh = 16, 16
        nx, ny, nz = int(w/gw), int(h/gh), 1

        print('=' * 50)

        self.compute['time'] = time
        GL_WRITE_ONLY = 0x88B9
        GL_R32F = 0x822E
        self.texture.bind_to_image(0,GL_WRITE_ONLY, GL_R32F)
        self.compute.run(nx, ny, nz)
        print('-' * 50)

        with self.scope:
            self.prog['UseTexture'] = False

            self.prog['Light'] = (67.69, -8.14, 52.49)
            self.prog['Mvp'] = (proj * lookat * rotate).astype('f4').tobytes()

            self.prog['Color'] = (0.67, 0.49, 0.29)
            self.objects['ground'].render()

            self.prog['Color'] = (0.46, 0.67, 0.29)
            self.objects['grass'].render()

            self.prog['Color'] = (1.0, 1.0, 1.0)
            self.objects['billboard'].render()

            self.prog['Color'] = (0.2, 0.2, 0.2)
            self.objects['billboard-holder'].render()

            self.prog['UseTexture'] = True

            self.objects['billboard-image'].render()
开发者ID:cprogrammer1994,项目名称:ModernGL,代码行数:48,代码来源:render_texture_compute_shader.py

示例4: render

# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import from_z_rotation [as 别名]
    def render(self):
        width, height = self.wnd.size
        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, width / height, 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(self.wnd.time) * 0.5 + 0.2)

            self.prog['UseTexture'] = False

            self.prog['Light'] = (67.69, -8.14, 52.49)
            self.prog['Mvp'] = (proj * lookat * rotate).astype('f4').tobytes()

            self.prog['Color'] = (0.67, 0.49, 0.29)
            self.objects['ground'].render()

            self.prog['Color'] = (0.46, 0.67, 0.29)
            self.objects['grass'].render()

            self.prog['Color'] = (1.0, 1.0, 1.0)
            self.objects['billboard'].render()

            self.prog['Color'] = (0.2, 0.2, 0.2)
            self.objects['billboard-holder'].render()

            self.prog['UseTexture'] = True
            # self.texture.use()
            self.sampler.use()

            self.objects['billboard-image'].render()
开发者ID:cprogrammer1994,项目名称:ModernGL,代码行数:39,代码来源:04_colors_and_texture.py

示例5: render

# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import from_z_rotation [as 别名]
    def render(self, time, frame_time):
        self.ctx.clear(1.0, 1.0, 1.0)
        # self.ctx.enable(mgl.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.fbo.clear(0, (1.0, 1.0, 1.0))
        self.fbo.clear(-1, 1.0)
        for scope in [self.scope1, self.scope2]:
            with scope:
                self.prog['UseTexture'] = False

                self.prog['Light'] = (67.69, -8.14, 52.49)
                self.prog['Mvp'] = (proj * lookat * rotate).astype('f4').tobytes()

                self.prog['Color'] = (0.67, 0.49, 0.29)
                self.objects['ground'].render()

                self.prog['Color'] = (0.46, 0.67, 0.29)
                self.objects['grass'].render()

                self.prog['Color'] = (1.0, 1.0, 1.0)
                self.objects['billboard'].render()

                self.prog['Color'] = (0.2, 0.2, 0.2)
                self.objects['billboard-holder'].render()

                self.prog['UseTexture'] = True

                self.objects['billboard-image'].render()
开发者ID:cprogrammer1994,项目名称:ModernGL,代码行数:38,代码来源:render_to_texture_example.py


注:本文中的pyrr.Matrix44.from_z_rotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。