本文整理匯總了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
示例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)
示例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)
示例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
示例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()
示例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)