本文整理汇总了Python中kivy.graphics.transformation.Matrix.translate方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.translate方法的具体用法?Python Matrix.translate怎么用?Python Matrix.translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.graphics.transformation.Matrix
的用法示例。
在下文中一共展示了Matrix.translate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_window_matrix
# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import translate [as 别名]
def get_window_matrix(self, x=0, y=0):
'''Calculate the transformation matrix to convert between window and
widget coordinates.
:Parameters:
`x`: float, defaults to 0
Translates the matrix on the x axis.
`y`: float, defaults to 0
Translates the matrix on the y axis.
'''
m = Matrix()
m.translate(x, y, 0)
m = self._apply_transform(m)
return m
示例2: look_at
# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import translate [as 别名]
def look_at(self, v):
m = Matrix()
pos = self._position * -1
m = m.translate(pos[0], pos[1], pos[2])
self.modelview_matrix = m
self._look_at = v
self.update()
示例3: update_glsl
# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import translate [as 别名]
def update_glsl(self, *largs):
global no_width_error_enable
if self.player_velocity[0] != 0:
self.camera_translate_instruction.x += self.player_velocity[0]
if self.player_velocity[1] != 0:
self.camera_translate_instruction.y += self.player_velocity[1]
if self.player_velocity[2] != 0:
self.camera_translate_instruction.z += self.player_velocity[2]
if self.height > 0:
asp = self.width / float(self.height)
else:
if no_width_error_enable:
print("[ TestingKivy3D ] ERROR in update_glsl: Failed to get width.")
no_width_error_enable = False
clip_top = 0.06 # NOTE: 0.03 is ~1.72 degrees, if that matters
# formerly field_of_view_factor
# was changed to .03 when projection_near was changed from 1 to .1
# was .3 when projection_near was 1
clip_right = asp*clip_top # formerly overwrote asp
self.projection_near = 0.1
projectionMatrix = Matrix().view_clip(-clip_right, clip_right, -1*clip_top, clip_top, self.projection_near, 100, 1) # last params: far, perspective
#projectionMatrix = Matrix().view_clip(-asp, asp, -1, 1, 1, 100, 1) # last params: far, perspective
modelViewMatrix = Matrix()
modelViewMatrix.translate(self.camera_translate_instruction.x, self.camera_translate_instruction.y, self.camera_translate_instruction.z)
if (self.camera_translate_instruction.x != self.look_point[0] or
self.camera_translate_instruction.y != self.look_point[1] or
self.camera_translate_instruction.z != self.look_point[2]):
try:
modelViewMatrix = modelViewMatrix.look_at(self.camera_translate_instruction.x, self.camera_translate_instruction.y, self.camera_translate_instruction.z, self.look_point[0], self.look_point[1], self.look_point[2], 0, 1, 0) # 0,1,0 is y-up orientation
except:
print("[ TestingKivy3D ] Could not finish modelViewMatrix.look_at:")
else:
print("[ TestingKivy3D ] Can't run modelViewMatrix.look_at since camera is at look_point")
self.gl_widget.canvas['projection_mat'] = projectionMatrix
self.gl_widget.canvas['modelview_mat'] = modelViewMatrix
self.gl_widget.canvas["camera_world_pos"] = [self.camera_translate_instruction.x, self.camera_translate_instruction.y, self.camera_translate_instruction.z]
self.gl_widget.canvas['ambient_light'] = (0.1, 0.1, 0.1)
示例4: update_fbo
# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import translate [as 别名]
def update_fbo(self, time):
width = self.width if self.width > 1 else 100
height = self.height if self.height > 1 else 100
asp = (width / float(height))
proj = Matrix().view_clip(-asp, asp, -1, 1, 1, 600, 1)
proj = Matrix()
proj.perspective(self.perspective_value, asp, 1, 1000)
lightInvDir = (0.5, 2, 2)
depthProjectionMatrix = Matrix().view_clip(-100 * self.shadow_threshold, 100 * self.shadow_threshold,
-100 * self.shadow_threshold, 100 * self.shadow_threshold,
-100 * self.shadow_threshold, 200 * self.shadow_threshold * 2, 0)
depthViewMatrix = Matrix().look_at(-0.5, -50, -100, 0, 0, 0, 0, 1, 0)
depthModelMatrix = Matrix().identity()
depthMVP = depthProjectionMatrix.multiply(depthViewMatrix).multiply(depthModelMatrix)
self.fbo['projection_mat'] = proj
self.fbo['depthMVP'] = depthMVP
self.fbo['diffuse_light'] = (0.0, 1.0, 0.0)
self.fbo['ambient_light'] = (0.1, 0.1, 0.1)
for m_pos in range(len(self.nodes)):
motion_matrix = Matrix().view_clip(-asp, asp, -1, 1, 1, 600, 1)
angle = self.nodes[m_pos].rotate[0] * 3.14 / 180
pos = self.nodes[m_pos].get_pos()
trans = self.nodes[m_pos].translate[:]
result = [0, 0, 0]
result[0] = 0.3 if trans[0] < pos[0] else -0.3
result[1] = 0.3 if trans[1] < pos[1] else -0.3
result[2] = 0.3 if trans[2] < pos[2] else -0.3
motion_matrix = motion_matrix.translate(trans[0] + 0.1,
trans[1] + 0.1,
trans[2])
self.motion_blur_fbo['oldTransformation{0}'.format(str(m_pos))] = motion_matrix
self.motion_blur_fbo['projection_mat'] = proj
self.motion_blur_fbo['depthMVP'] = depthMVP
if self.picking_fbo:
self.picking_fbo['projection_mat'] = proj
self.alpha += 10 * time
self.fbo['cond'] = (0.0, 0.7)
self.fbo['val_sin'] = (self.alpha, 0.0)
示例5: get_window_matrix
# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import translate [as 别名]
def get_window_matrix(self, x=0, y=0):
m = Matrix()
m.translate(x, y, 0)
return m