Exemple #1
0
    def update_viewport(self):
        from kivy.graphics.opengl import glViewport
        from kivy.graphics.transformation import Matrix

        width, height = self.system_size
        w2 = width / 2.
        h2 = height / 2.

        # prepare the viewport
        glViewport(0, 0, width, height)
        projection_mat = Matrix()
        projection_mat.view_clip(0.0, width, 0.0, height, -1.0, 1.0, 0)
        self.render_context['projection_mat'] = projection_mat

        # use the rotated size.
        # XXX FIXME fix rotation
        '''
        width, height = self.size
        w2 = width / 2.
        h2 = height / 2.
        glTranslatef(-w2, -h2, -500)

        # set the model view
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        glTranslatef(w2, h2, 0)
        glRotatef(self._rotation, 0, 0, 1)
        glTranslatef(-w2, -h2, 0)
        '''

        self.update_childsize()
Exemple #2
0
    def update_viewport(self):
        from kivy.graphics.opengl import glViewport
        from kivy.graphics.transformation import Matrix
        from math import radians

        w, h = self.system_size
        w2, h2 = w / 2., h / 2.
        r = radians(self.rotation)

        # prepare the viewport
        glViewport(0, 0, w, h)

        # do projection matrix
        projection_mat = Matrix()
        projection_mat.view_clip(0.0, w, 0.0, h, -1.0, 1.0, 0)
        self.render_context['projection_mat'] = projection_mat

        # do modelview matrix
        modelview_mat = Matrix().translate(w2, h2, 0)
        modelview_mat = modelview_mat.multiply(Matrix().rotate(r, 0, 0, 1))

        w, h = self.size
        w2, h2 = w / 2., h / 2.
        modelview_mat = modelview_mat.multiply(Matrix().translate(-w2, -h2, 0))
        self.render_context['modelview_mat'] = modelview_mat

        # redraw canvas
        self.canvas.ask_update()

        # and update childs
        self.update_childsize()
Exemple #3
0
    def update_viewport(self):
        from kivy.graphics.opengl import glViewport
        from kivy.graphics.transformation import Matrix

        width, height = self.system_size
        w2 = width / 2.
        h2 = height / 2.

        # prepare the viewport
        glViewport(0, 0, width, height)
        projection_mat = Matrix()
        projection_mat.view_clip(0.0, width, 0.0, height, -1.0, 1.0, 0)
        self.render_context['projection_mat'] = projection_mat

        # use the rotated size.
        # XXX FIXME fix rotation
        '''
        width, height = self.size
        w2 = width / 2.
        h2 = height / 2.
        glTranslatef(-w2, -h2, -500)

        # set the model view
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        glTranslatef(w2, h2, 0)
        glRotatef(self._rotation, 0, 0, 1)
        glTranslatef(-w2, -h2, 0)
        '''

        self.update_childsize()
Exemple #4
0
    def get_projection(self) -> Matrix:
        width = self.viewport_width / 2
        height = self.viewport_height / 2

        x = -self.pos_x
        y = -self.pos_y

        projection = Matrix()
        projection.view_clip(0, self.viewport_width, 0, self.viewport_height, -1.0, 1.0, 0)
        projection.scale(self.zoom, self.zoom, self.zoom)
        projection.translate(1 + x / width * self.zoom, 1 + y / height * self.zoom, 0)

        return projection
Exemple #5
0
    def update_viewport(self):
        from kivy.graphics.opengl import glViewport
        from kivy.graphics.transformation import Matrix
        from math import radians

        w, h = self.system_size
        if self._density != 1:
            w, h = self.size

        smode = self.softinput_mode
        target = self._system_keyboard.target
        targettop = target.to_window(0, target.y)[1] if target else 0
        kheight = self.keyboard_height

        w2, h2 = w / 2., h / 2.
        r = radians(self.rotation)

        x, y = 0, 0
        _h = h
        if smode == 'pan':
            y = kheight
        elif smode == 'below_target':
            y = 0 if kheight < targettop else (kheight - targettop) + dp(9)
        if smode == 'scale':
            _h -= kheight

        # prepare the viewport
        glViewport(x, y, w, _h)

        # do projection matrix
        projection_mat = Matrix()
        projection_mat.view_clip(0.0, w, 0.0, h, -1.0, 1.0, 0)
        self.render_context['projection_mat'] = projection_mat

        # do modelview matrix
        modelview_mat = Matrix().translate(w2, h2, 0)
        modelview_mat = modelview_mat.multiply(Matrix().rotate(r, 0, 0, 1))

        w, h = self.size
        w2, h2 = w / 2., h / 2.
        modelview_mat = modelview_mat.multiply(Matrix().translate(-w2, -h2, 0))
        self.render_context['modelview_mat'] = modelview_mat

        # redraw canvas
        self.canvas.ask_update()

        # and update childs
        self.update_childsize()
Exemple #6
0
    def get_projection(self) -> Tuple[Matrix, Matrix]:
        viewport_w = self.viewport_width
        viewport_h = self.viewport_height
        width = viewport_w / 2
        height = viewport_h / 2

        x = -self.pos_x
        y = -self.pos_y

        projection = Matrix()
        projection.view_clip(0, viewport_w, 0, viewport_h, -1.0, 1.0, 0)
        projection.scale(self.zoom, self.zoom, self.zoom)
        projection.translate(1 + x / width * self.zoom,
                             1 + y / height * self.zoom, 0)

        model_view = Matrix()

        return projection, model_view
Exemple #7
0
    def update_viewport(self):
        from kivy.graphics.opengl import glViewport
        from kivy.graphics.transformation import Matrix
        from math import radians

        w, h = self.system_size
        if self._density != 1:
            w, h = self.size

        smode = self.softinput_mode
        kheight = self.keyboard_height

        w2, h2 = w / 2.0, h / 2.0
        r = radians(self.rotation)

        x, y = 0, 0
        _h = h
        if smode:
            y = kheight
        if smode == "scale":
            _h -= kheight

        # prepare the viewport
        glViewport(x, y, w, _h)

        # do projection matrix
        projection_mat = Matrix()
        projection_mat.view_clip(0.0, w, 0.0, h, -1.0, 1.0, 0)
        self.render_context["projection_mat"] = projection_mat

        # do modelview matrix
        modelview_mat = Matrix().translate(w2, h2, 0)
        modelview_mat = modelview_mat.multiply(Matrix().rotate(r, 0, 0, 1))

        w, h = self.size
        w2, h2 = w / 2.0, h / 2.0
        modelview_mat = modelview_mat.multiply(Matrix().translate(-w2, -h2, 0))
        self.render_context["modelview_mat"] = modelview_mat

        # redraw canvas
        self.canvas.ask_update()

        # and update childs
        self.update_childsize()
Exemple #8
0
    def update_viewport(self):
        from kivy.graphics.opengl import glViewport
        from kivy.graphics.transformation import Matrix
        from math import radians

        w, h = self.system_size

        smode = self.softinput_mode
        kheight = self.keyboard_height

        w2, h2 = w / 2., h / 2.
        r = radians(self.rotation)


        x, y = 0, 0
        _h = h
        if smode:
            y = kheight
        if smode == 'scale':
            _h -= kheight

        # prepare the viewport
        glViewport(x, y, w, _h)

        # do projection matrix
        projection_mat = Matrix()
        projection_mat.view_clip(0.0, w, 0.0, h, -1.0, 1.0, 0)
        self.render_context['projection_mat'] = projection_mat

        # do modelview matrix
        modelview_mat = Matrix().translate(w2, h2, 0)
        modelview_mat = modelview_mat.multiply(Matrix().rotate(r, 0, 0, 1))

        w, h = self.size
        w2, h2 = w / 2., h / 2.
        modelview_mat = modelview_mat.multiply(Matrix().translate(-w2, -h2, 0))
        self.render_context['modelview_mat'] = modelview_mat

        # redraw canvas
        self.canvas.ask_update()

        # and update childs
        self.update_childsize()
Exemple #9
0
 def update_glsl(self, *largs):
     asp = self.width / float(self.height)
     asp = asp*0.3
     proj = Matrix()
     mat = Matrix()
     mat = mat.look_at(0, 0, self.camera_translate[2], 0, 0, -3, 0, 1, 0)
     proj = proj.view_clip(-asp, asp, -.3, .3, 1, 100, 1)
     
     self.canvas['projection_mat'] = proj
     self.canvas['modelview_mat'] = mat
    def update_glsl(self, *largs):
        asp = self.width / float(self.height)
        asp = asp * 0.3
        asp = 0.8
        proj = Matrix()
        mat = Matrix()
        mat = mat.look_at(0.0, 0.6, self.camera_translate[2], 0, 0, 0, 0, 1, 0)
        proj = proj.view_clip(-asp, asp, -0.6, .6, 1, 100, 1)

        self.canvas['projection_mat'] = proj
        self.canvas['modelview_mat'] = mat
Exemple #11
-1
    def update_glsl(self, *largs):
        asp = self.width / float(self.height)
        asp = 15 / 6.0
        proj = Matrix()
        mat = Matrix()
        mat = mat.look_at(
            self.camera_loc[0] * self.camera_r,
            self.camera_loc[1] * self.camera_r,
            self.camera_loc[2] * self.camera_r,
            0,
            0,
            0,
            self.camera_up[0],
            self.camera_up[1],
            self.camera_up[2],
        )
        proj = proj.view_clip(-asp * 0.5, asp * 0.5, -0.5, 0.5, 1, 10, 1)

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