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


Python Pipeline.set_camera方法代码示例

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


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

示例1: on_display

# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import set_camera [as 别名]
    def on_display(self):
        """
        Rendering callback.
        """
        self._camera.render()

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        self._scale += 0.1
        pipeline = Pipeline(rotation=[0, self._scale, 0],
                            translation=[0, 0, 6],
                            projection=self._projection)
        pipeline.set_camera(self._camera)

        self._effect.set_wvp(pipeline.get_wvp())
        self._effect.set_directional_light(
            self._dir_light_color, self._dir_light_ambient_intensity)

        position, tex_coord = 0, 1
        glEnableVertexAttribArray(position)
        glEnableVertexAttribArray(tex_coord)

        glBindBuffer(GL_ARRAY_BUFFER, self._vbo)
        glVertexAttribPointer(position, 3, GL_FLOAT, GL_FALSE, 20, ctypes.c_void_p(0))
        glVertexAttribPointer(tex_coord, 2, GL_FLOAT, GL_FALSE, 20, ctypes.c_void_p(12))
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self._ibo)

        self._texture.bind(GL_TEXTURE0)
        glDrawElements(GL_TRIANGLES, 18, GL_UNSIGNED_INT, ctypes.c_void_p(0))
        glDisableVertexAttribArray(position)
        glDisableVertexAttribArray(tex_coord)
        glutSwapBuffers()
开发者ID:devforfu,项目名称:pyogldev,代码行数:34,代码来源:glutwindow.py

示例2: display

# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import set_camera [as 别名]
    def display():
        CAMERA.render()
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        nonlocal scale
        scale_location = gl.glGetUniformLocation(program, "gScale")
        assert scale_location != 0xffffffff
        world_location = gl.glGetUniformLocation(program, "gWorld")
        assert world_location != 0xffffffff

        scale += 0.01

        pipeline = Pipeline(rotation=[0.0, 30*scale, 0.0],
                            # scaling=[math.sin(scale)] * 3,
                            translation=[0, 0, 6],
                            projection=ProjParams(WINDOW_WIDTH, WINDOW_HEIGHT, 1.0, 100.0, 60.0))
        pipeline.set_camera(CAMERA)

        gl.glUniformMatrix4fv(world_location, 1, gl.GL_TRUE, pipeline.get_wvp())
        gl.glDrawElements(gl.GL_TRIANGLES, 18, gl.GL_UNSIGNED_INT, ctypes.c_void_p(0))
        glut.glutSwapBuffers()
开发者ID:devforfu,项目名称:pyogldev,代码行数:23,代码来源:triangle.py

示例3: GlPlotWidget

# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import set_camera [as 别名]
class GlPlotWidget(QGLWidget):

    width, height = 600, 600

    def __init__(self):
        super(GlPlotWidget, self).__init__()
        self.vbo = None
        self.ibo = None
        self.pipeline = None
        self.camera = None
        self.data = np.array([])
        self.index = np.array([])
        self.count = 0
        self.step = 0.0
        self.shaders = {
            GL_VERTEX_SHADER: os.path.join('qtwindow', 'vs.glsl'),
            GL_FRAGMENT_SHADER: os.path.join('qtwindow', 'fs.glsl')
        }
        self.program = None
        self.initializeGL()

    def set_data(self, data, index):
        self.data = data
        self.index = index
        self.count = data.shape[0]

    def initializeGL(self):
        glClear(GL_COLOR_BUFFER_BIT)
        glClearColor(0, 0, 0, 1)
        self.vbo = glGenBuffers(1)
        glBindBuffer(GL_ARRAY_BUFFER, self.vbo)
        glBufferData(GL_ARRAY_BUFFER,
                     self.data.nbytes, self.data, GL_STATIC_DRAW)
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, ctypes.c_void_p(0))

        self.ibo = glGenBuffers(1)
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self.ibo)
        glBufferData(GL_ELEMENT_ARRAY_BUFFER,
                     self.index.nbytes, self.index, GL_STATIC_DRAW)

        # load and compile shaders
        self.program = glCreateProgram()
        for t, path in self.shaders.items():
            shader = glCreateShader(t)
            with open(path, 'r') as sh:
                glShaderSource(shader, sh.read())
            glCompileShader(shader)
            if not glGetShaderiv(shader, GL_COMPILE_STATUS):
                info = glGetShaderInfoLog(shader)
                print("{} shader error occurred".format(os.path.basename(path)))
                print(bytes.decode(info))
                sys.exit(1)
            glAttachShader(self.program, shader)
            # glDeleteShader(shader)
        glLinkProgram(self.program)
        glUseProgram(self.program)

        # init camera
        camera_pos = [0.0, 0.0, 0.0]  # camera position
        camera_target = [0.0, 0.0, 1.0]  # "look at" direction
        camera_up = [0.0, 1.0, 0.0]  # camera vertical axis

        def warp_pointer(cx, cy):
            c = self.cursor()
            self.cursor()
            c.setPos(self.mapToGlobal(QPoint(cx, cy)))
            c.setShape(Qt.BlankCursor)
            self.setCursor(c)

        self.camera = Camera(camera_pos, camera_target, camera_up,
                             self.width, self.height, warp_pointer)
        #self.pipeline.set_camera(self.camera)

    def paintGL(self):
        self.step += 0.1
        self.camera.render()
        projection = ProjParams(self.width, self.height, 1.0, 100.0, 60.0)
        self.pipeline = Pipeline(rotation=[0, 30*self.step, 0],
                                 translation=[0, 0, 3],
                                 projection=projection)
        self.pipeline.set_camera(self.camera)
        glClear(GL_COLOR_BUFFER_BIT)
        glEnableVertexAttribArray(0)
        world_location = glGetUniformLocation(self.program, "gWorld")
        glUniformMatrix4fv(world_location, 1, GL_TRUE, self.pipeline.get_wvp())
        glDrawElements(GL_TRIANGLES, self.index.shape[0],
                       GL_UNSIGNED_INT, ctypes.c_void_p(0))
        glDisableVertexAttribArray(0)

    def resizeGL(self, width, height):
        self.width, self.height = width, height
        glViewport(0, 0, self.width, self.height)
开发者ID:devforfu,项目名称:pyogldev,代码行数:94,代码来源:pyqtwindow.py


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