Example #1
0
    def process_inputs(self):

        self.io.display_size = pyxie.viewSize()
        w, h = pyxie.viewSize()
        self.camera.screenOffset = -w, h

        touch = pyxie.singleTouch()
        if touch != None:
            curX = touch['cur_x'] + w // 2
            curY = -touch['cur_y'] + h // 2
            self.io.mouse_pos = curX, curY
            self.io.mouse_down[0] = touch['is_holded'] | touch['is_moved']
Example #2
0
    def toWorldCoordinate(self, scrx, scry, worldz, cam):
        invproj = vmath.inverse(cam.projectionMatrix)
        invview = cam.viewInverseMatrix

        w, h = pyxie.viewSize()
        x = scrx / w * 2
        y = scry / h * 2

        pos = vmath.vec4(x, y, 0.0, 1.0)
        npos = invproj * pos
        npos = invview * npos
        npos.z /= npos.w
        npos.x /= npos.w
        npos.y /= npos.w
        npos.w = 1.0
        pos = vmath.vec4(x, y, 1.0, 1.0)
        fpos = invproj * pos
        fpos = invview * fpos
        fpos.z /= fpos.w
        fpos.x /= fpos.w
        fpos.y /= fpos.w
        fpos.w = 1.0

        dir = vmath.normalize(fpos - npos)
        print(npos + (dir * (npos.z - worldz)))
        return npos + (dir * (npos.z - worldz))
    def ConvertScreenToWorld(self, scrx, scry, worldz, cam, w=None, h=None):
        invproj = vmath.inverse(cam.projectionMatrix)
        invview = cam.viewInverseMatrix
        if not w or not h:
            w, h = pyxie.viewSize()
        x = scrx / w * 2
        y = scry / h * 2

        pos = vmath.vec4(x, y, 0.0, 1.0)
        npos = invproj * pos
        npos = invview * npos
        npos.z /= npos.w
        npos.x /= npos.w
        npos.y /= npos.w
        npos.w = 1.0
        pos = vmath.vec4(x, y, 1.0, 1.0)
        fpos = invproj * pos
        fpos = invview * fpos
        fpos.z /= fpos.w
        fpos.x /= fpos.w
        fpos.y /= fpos.w
        fpos.w = 1.0

        dir = vmath.normalize(fpos - npos)
        return npos + (dir * (npos.z - worldz))
Example #4
0
    def _create_device_objects(self):
        self.camera = pyxie.camera('2dcamera')
        self.camera.orthographicProjection = True
        self.camera.position = pyvmath.vec3(0, 0, 1)
        self.camera.screenScale = (1, -1)
        w, h = pyxie.viewSize()
        self.camera.screenOffset = -w, h

        gen = pyxie.shaderGenerator()
        gen.setColorTexture(True)
        gen.setVertexColor(True)
        self.editableFigure = pyxie.editableFigure('font')
        self.editableFigure.addMaterial("mate01", gen)
        self.editableFigure.setMaterialParam("mate01", "DiffuseColor",
                                             (1.0, 1.0, 1.0, 1.0))
        self.editableFigure.setMaterialRenderState("mate01", "blend_enable",
                                                   True)
        self.editableFigure.addJoint('joint')
        self.showcase = pyxie.showcase('imgui')
        self.showcase.add(self.editableFigure)