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


Python Matrix.perspective方法代码示例

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


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

示例1: update_glsl

# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import perspective [as 别名]
    def update_glsl(self, *largs):
        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)

        matrix_camera = Matrix().identity()
        matrix_camera.look_at(0, 100, 300, 100, 0, -100, 0, 1, 0)
        self.canvas['projection_mat'] = proj
        self.canvas['diffuse_light'] = (0.0, 1.0, 0.0)
        self.canvas['ambient_light'] = (0.1, 0.1, 0.1)
        if self.shadow:
            self.canvas['texture1'] = 1
            self.canvas["enabled_shadow"] = 1.0
        else:

            self.canvas["enabled_shadow"] = 0.0
            self.canvas["texture1"] = 0

        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.canvas['depthMVP'] = depthMVP
        self.canvas['cond'] = (0.0, 0.7)
        self.canvas['val_sin'] = (self.alpha, 0.0)

        if self.shadow:
            self.update_fbo(largs[0])
开发者ID:Cophy08,项目名称:kivy3dgui,代码行数:35,代码来源:canvas3d.py

示例2: updateScene

# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import perspective [as 别名]
	def updateScene(self, fb, *largs):
		# smooth camera
		cam = fb.scene.camera
		cam._rotation = helpers.mix(cam._rotation, cam._rotationTarget, 0.9)
		cam._distance = helpers.mix(cam._distance, cam._distanceTarget, 0.9)

		# compute camera pos
		cam.position[0] = cos(cam._rotation[2])*cos(cam._rotation[1])*cam._distance
		cam.position[2] = sin(cam._rotation[2])*cos(cam._rotation[1])*cam._distance
		cam.position[1] = sin(cam._rotation[1])*cam._distance

		# setup camera
		fov = cam.fov
		pos = cam.position
		target = fb.scene.camera.target
		asp = self.width / float(self.height)
		proj = Matrix()
		proj.perspective(fov, asp, 0.1, 100)
		modelView = Matrix()
		modelView = modelView.look_at(pos[0],pos[2],pos[1], target[0], target[2], target[1], 0,0,1)

		self.canvas['modelview_mat'] = modelView
		self.canvas['projection_mat'] = proj
		self.canvas['diffuse_light'] = (1.0, 1.0, 0.8)
		self.canvas['ambient_light'] = (0.1, 0.1, 0.1)

		self.mesh1['modelview_mat'] = modelView
		self.mesh1['projection_mat'] = proj
		self.mesh1['diffuse_light'] = (1.0, 2.0, 0.8)
		self.mesh1['ambient_light'] = (0.1, 0.1, 0.1)

		self.mesh2['modelview_mat'] = modelView
		self.mesh2['projection_mat'] = proj
		self.mesh2['diffuse_light'] = (2.0, 1.0, 0.8)
		self.mesh2['ambient_light'] = (0.1, 0.1, 0.1)
开发者ID:mikepan,项目名称:kivyBox,代码行数:37,代码来源:renderer.py

示例3: update_glsl

# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import perspective [as 别名]
 def update_glsl(self, dt):
     from kivy.core.window import Window
     g = self.params.get
     w, h = Window.system_size
     projection_mat = Matrix()
     #projection_mat.view_clip(0.0, w, 0.0, h, 10.0, 1000.0, 1)
     projection_mat.perspective(g('fovy', 45.), g('aspect', 1), g('zNear', 10), g('zFar', 1000))
     #projection_mat.view_clip(0.0, w, 0.0, h, -1, 1, 0)
     modelview_mat = Matrix().look_at(0, 200, -200, self.targetx, self.targety, 0, 0, 1, 0)
     self.canvas['projection_mat'] = projection_mat
     self.canvas['modelview_mat'] = modelview_mat
开发者ID:093pk01,项目名称:Code-Dump,代码行数:13,代码来源:3dview_example.py

示例4: update_fbo

# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import perspective [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)
开发者ID:Cophy08,项目名称:kivy3dgui,代码行数:48,代码来源:canvas3d.py

示例5: update_camera

# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import perspective [as 别名]
    def update_camera(self, pos, angle):
        self.eye_pos = pos
        self.eye_angle = angle
        x, y, z = pos
        azi, ele = angle
        asp = self.width / float(self.height)
        mat = self.get_look_at(x, y, z, azi, ele)

        proj = Matrix()
        proj.perspective(30, asp, 1, 100)

        self.canvas['projection_mat'] = proj
        self.canvas['modelview_mat'] = mat

        self.fixed_x.x = x
        self.fixed_y.y = y
        self.fixed_z.z = z
        self.fixed_azi.angle = azi * 180/np.pi
        self.fixed_ele.angle = ele * 180/np.pi
开发者ID:eflynch,项目名称:ectophylla,代码行数:21,代码来源:display.py

示例6: update_projection_matrix

# 需要导入模块: from kivy.graphics.transformation import Matrix [as 别名]
# 或者: from kivy.graphics.transformation.Matrix import perspective [as 别名]
 def update_projection_matrix(self):
     m = Matrix()
     m.perspective(self.fov * 0.5, self.aspect, self.near, self.far)
     self.projection_matrix = m
开发者ID:3demax,项目名称:kivy3,代码行数:6,代码来源:camera.py


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