本文整理汇总了Python中pyrr.Matrix44.from_y_rotation方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix44.from_y_rotation方法的具体用法?Python Matrix44.from_y_rotation怎么用?Python Matrix44.from_y_rotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyrr.Matrix44
的用法示例。
在下文中一共展示了Matrix44.from_y_rotation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getModelMatrix
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import from_y_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
示例2: render
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import from_y_rotation [as 别名]
def render(self, app, currentTime):
glBindVertexArray(self._vao.identifier)
try:
glUseProgram(self._program.identifier)
bg_color = (
math.sin(currentTime) * 0.5 + 0.5,
math.cos(currentTime) * 0.5 + 0.5,
0.0,
1.0
)
glClearBufferfv(GL_COLOR, 0, bg_color)
glClearBufferfv(GL_DEPTH, 0, [1])
f = currentTime * 0.3
mv_matrix = Matrix44.identity(dtype='f4')
mv_matrix *= Matrix44.from_x_rotation(
currentTime * math.radians(81))
mv_matrix *= Matrix44.from_y_rotation(
currentTime * math.radians(45))
mv_matrix *= Matrix44.from_translation([
math.sin(2.1 * f) * 0.5,
math.cos(1.7 * f) * 0.5,
math.sin(1.3 * f) * math.cos(1.5 * f) * 2.0])
mv_matrix *= Matrix44.from_translation([0.0, 0.0, -4.0])
self._uniform_block.mv_matrix[:] = mv_matrix.reshape(16)
glBufferSubData(
GL_UNIFORM_BUFFER,
0,
ctypes.sizeof(self._uniform_block),
ctypes.byref(self._uniform_block))
self._torus_obj.render()
finally:
glBindVertexArray(NULL_GL_OBJECT)
示例3: getModelMatrix
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import from_y_rotation [as 别名]
def getModelMatrix(self):
# TODO: maybe spin planet around another axis and add scaling
rot = mat4.from_y_rotation(self.rot, dtype='f')
trans = mat4.from_translation(self.position, dtype='f')
return rot * trans