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


Python Matrix44.from_scale方法代码示例

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


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

示例1: test_oo_examples

# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import from_scale [as 别名]
    def test_oo_examples(self):
        from pyrr import Quaternion, Matrix44, Vector3
        import numpy as np

        point = Vector3([1.,2.,3.])
        orientation = Quaternion()
        translation = Vector3()
        scale = Vector3([1.,1.,1.])

        # translate along X by 1
        translation += [1.0, 0.0, 0.0]

        # rotate about Y by pi/2
        rotation = Quaternion.from_y_rotation(np.pi / 2.0)
        orientation = rotation * orientation

        # create a matrix
        # start our matrix off using the scale
        matrix = Matrix44.from_scale(scale)

        # apply our orientation
        # we can multiply matricies and quaternions directly!
        matrix = matrix * orientation

        # apply our translation
        translation = Matrix44.from_translation(translation)
        matrix = matrix * translation

        # transform our point by the matrix
        # vectors are transformable by matrices and quaternions directly
        point = matrix * point
开发者ID:RazerM,项目名称:Pyrr,代码行数:33,代码来源:test_examples.py

示例2: resize

# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import from_scale [as 别名]
    def resize (self: 'GLQuadRenderer', width: int, height: int) -> None:
        super ().resize (width, height)

        if not self.__loaded:
            return

        y = self.__image_height / self.__image_width * \
            self.gl_widget.width / self.gl_widget.height

        x = self.__image_width / self.__image_height * \
            self.gl_widget.height / self.gl_widget.width

        if self.gl_widget.height * self.__image_width / self.__image_height > self.gl_widget.width:
            self.world = Matrix44.from_scale ([1, y, 1]) * \
                         Matrix44.from_translation ([0, (1 - y) / 2, 0])
        else:
            self.world = Matrix44.from_scale ([x, 1, 1]) * \
                         Matrix44.from_translation ([(1 - x) / 2, 0, 0])

        GL.glUniformMatrix4fv (self.__uniform_world, 1, False, self.world)
开发者ID:fin-ger,项目名称:color-harmonization,代码行数:22,代码来源:gl_quad_renderer.py

示例3: init

# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import from_scale [as 别名]
def init(wid, hig):
    """Initialises the display."""
    global modelmtx, 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()
    rematr(wid, hig)
    modelmtx = matrix.from_scale([2, 2, 2]) * matrix.from_translation([0, 0, -.5])
    chaem = Raimv((), deltam)
    chaem.rotspe = 2*pi
    GL.glUniformMatrix4fv(GL.glGetUniformLocation(shaderp, 'viewmatrix'), 1, False, chaem.lookat())
    GL.glUniformMatrix4fv(GL.glGetUniformLocation(shaderp, 'modelmatrix'), 1, False, modelmtx)
开发者ID:bzalakos,项目名称:inscma,代码行数:17,代码来源:win.py

示例4: getModelMatrix

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

示例5: init

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

示例6: draw

# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import from_scale [as 别名]
def draw():
    """Put the main drawing code in here."""
    global luxp
    chaem.mochae(timedelta)
    GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
    GL.glEnable(GL.GL_TEXTURE_2D)

    GL.glUseProgram(shaderp)
    luxp = [sin(lasttime) * 5, cos(lasttime) * 5, 0.0]
    GL.glUniform3f(GL.glGetUniformLocation(shaderp, 'lightPos'), *luxp)
    GL.glUniform3f(GL.glGetUniformLocation(shaderp, 'viewpos'), *chaem.pos)
    rematr()
    architincture.draw()
    mmoodd = modelmatrix * matrix.from_scale([0.2, 0.2, 0.2]) * matrix.from_translation(luxp) * \
        matrix.from_eulers([lasttime, lasttime, lasttime])
    lux.draw(rematr, mmoodd)
开发者ID:bzalakos,项目名称:inscma,代码行数:18,代码来源:won.py


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