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


Python Camera.viewMat方法代码示例

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


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

示例1: MeshDisplayGL

# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import viewMat [as 别名]

#.........这里部分代码省略.........
        # Set up callbacks
        glutDisplayFunc(self.redraw)
        glutReshapeFunc(self.resize)
        glutKeyboardFunc(self.keyfunc)
        glutMouseFunc(self.mousefunc)
        glutMotionFunc(self.motionfunc)
        self.userKeyCallbacks = dict() # key => (function, docstring)

        # Set colors
        self.shapeColor = np.array(self.colors['orange'])
        self.edgeColorLight = np.array(self.colors['almost_white'])
        self.edgeColorDark = np.array(self.colors['dark_grey'])

        # Set up the mesh shader program
        self.prepareShapeProgram()
        self.prepareEdgeProgram()
        self.prepareVertexProgram()

        if mesh is not None:
            self.setMesh(mesh)


    def prepareShapeProgram(self):
        """Create an openGL program and all associated buffers to render mesh triangles"""

        self.shapeProg = ShaderProgram(vertShaders[self.shapeVertShader],
                                      fragShaders[self.shapeFragShader])

        # Bind the output location for the fragment shader
        glBindFragDataLocation(self.shapeProg.handle, 0, "outputF");

        # Create uniforms
        self.shapeProg.createUniform('projMatrix', 'u_projMatrix', 'matrix_4')
        self.shapeProg.createUniform('viewMatrix', 'u_viewMatrix', 'matrix_4')
        self.shapeProg.createUniform('alpha', 'u_alpha', 'scalar')
        self.shapeProg.createUniform('eyeLoc', 'u_eye', 'vector_3')
        self.shapeProg.createUniform('lightLoc', 'u_light', 'vector_3')
        self.shapeProg.createUniform('dataCenter', 'u_dataCenter', 'vector_3')

        # Make a VAO for the mesh
        self.shapeProg.createVAO('meshVAO')

        # VBO for positions
        self.shapeProg.createVBO(
            vboName = 'vertPos', varName = 'a_position', vaoName = 'meshVAO', nPerVert = 3)

        # VBO for colors
        self.shapeProg.createVBO(
            vboName = 'vertColor', varName = 'a_color', vaoName = 'meshVAO', nPerVert = 3)

        # VBO for normals
        self.shapeProg.createVBO(
            vboName = 'vertNorm', varName = 'a_normal', vaoName = 'meshVAO', nPerVert = 3)

        # VBO for array indices
        self.shapeProg.createIndexBuffer(vboName = 'triIndex',  vaoName = 'meshVAO')

        # Set a draw function for the mesh program
        def drawMesh():
            # Setup
            glBindVertexArray(self.shapeProg.vaoHandle['meshVAO'])

            # Draw
            glDrawElements(GL_TRIANGLES, 3*self.nFaces, GL_UNSIGNED_INT, None)
            # glDrawElements(GL_LINES, self.nEdges, GL_UNSIGNED_INT, None)
        self.shapeProg.drawFunc = drawMesh
开发者ID:pavelkang,项目名称:research,代码行数:70,代码来源:MeshDisplayGL.py


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