Exemplo n.º 1
0
    def createShaders(self):

        self._shaders += t.shader_path("widget/widget.vsh")
        self._shaders += t.shader_path("widget/widget.fsh")

        # create buffers
        self._vertices = VBO(VERTEX_BUFFER)
        self._index = VBO(INDEX_BUFFER)
        self._vertices.create()
        self._index.create()

        # allocate buffers
        self._vertices.bind()
        self._vertices.allocate(
            self._mesh,
            len(self._mesh) * 4
        )
        self._vertices.release()
        self._index.bind()
        self._index.allocate(
            self._indices,
            len(self._indices) * 4
        )
        self._index.release()

        for widget in self._children:
            widget.createShaders()
Exemplo n.º 2
0
    def __init__(self, *args, **kwargs):

        npoints = 30
        X = np.linspace(-1, 1, npoints).astype(np.float32)
        Y = np.linspace(-1, 1, npoints).astype(np.float32)
        Z = np.zeros((npoints, npoints), dtype=np.float32)
        x, y = np.meshgrid(X, Y)
        mesh = np.vstack((x, y, Z)).reshape(3, -1).T.astype(np.float32)

        super(Rippler, self).__init__(mesh, linetype=o.TriangleMesh(data=mesh))

        self._shaders += t.shader_path("rippler/rippler.vsh")
        self._shaders += t.shader_path("rippler/rippler.fsh")

        self._time = datetime.datetime.now()

        self._widget = Application()
        self._widget.title.text = "Window title"
        button1 = Button()
        button2 = Button()
        button1.text.font_size = 20
        button2.text.font_size = 20
        button1.text = "Hello world !"
        button2.text = "Viva Sponge Bob !"
        self._widget.x = 300
        self._widget.y = 300
        button1.click.connect(self._echo)
        button2.click.connect(self._echo)
        button1.size_hint_x = None
        button2.size_hint_x = None
        button1.size_hint_y = 0.5
        button2.size_hint_y = 0.5
        self._widget.addWidget(button1)
        self._widget.addWidget(button2)
Exemplo n.º 3
0
    def __init__(self, *args, **kwargs):

        # set the reader
        super(Mock, self).__init__(*args, **kwargs)

        self._projections = ["Celestial sphere", "Redshift space", "Cartesian"]
        self.widgetChanged = Signal()
        self.widgetChanged.connect(self.updateWidget)

        # load data from mock catalogue
        self._load_data()

        # make cartesian projection by default
        self._projection_cartesian()

        # colormap
        colormap = getattr(CM, "LinearInterpolation")
        self._colormap = colormap(self._data[self._quantity].values)
        self._callback_colormap()
        self._colormap.changed.connect(self._callback_colormap)

        self._voxelSize = 0.01
        self._voxelSize_max = 0.05

        self._shaders = Shaders()
        self._shaders += t.shader_path("reader/mock/couleurs.vsh")
        self._shaders += t.shader_path("reader/mock/couleurs.fsh")
Exemplo n.º 4
0
    def createShaders(self):

        # set shaders
        self._shaders += t.shader_path("text/text.vsh")
        self._shaders += t.shader_path("text/text.fsh")

        # create buffers
        self._vertices = VBO(VERTEX_BUFFER)
        self._index = VBO(INDEX_BUFFER)
        self._vertices.create()
        self._index.create()

        # allocate buffers
        self._vertices.bind()
        self._vertices.allocate(
            self._mesh,
            len(self._mesh) * 4
        )
        self._vertices.release()

        # window
        self._index.bind()
        self._index.allocate(
            self._indices,
            len(self._indices) * 4
        )
        self._index.release()
Exemplo n.º 5
0
    def __init__(self, *args, **kwargs):

        npoints = 800
        phi = np.linspace(0, 2. * np.pi, npoints).astype(np.float32)
        theta = np.linspace(
            0.5 * np.pi,
            -0.5 * np.pi,
            npoints,
        ).astype(np.float32)
        r = np.zeros((npoints, npoints), dtype=np.float32)
        r[:, :] = 1.
        p, tt = np.meshgrid(phi, theta)
        mesh = np.vstack((p, tt, r)).reshape(3, -1).T.astype(np.float32)

        super(Earth, self).__init__(
            mesh,
            linetype=o.TriangleMesh(
                data=mesh,
                side_x=npoints,
                side_y=npoints,
            ),
        )

        phi = self._data[::3]
        theta = self._data[1::3]
        r = self._data[2::3]
        X = r * np.cos(phi) * np.cos(theta)
        Y = r * np.sin(phi) * np.cos(theta)
        Z = r * np.sin(theta)
        self._data[::3] = X
        self._data[1::3] = Y
        self._data[2::3] = Z

        self._shaders += t.shader_path("earth/earth.vsh")
        self._shaders += t.shader_path("earth/earth.fsh")
Exemplo n.º 6
0
    def __init__(self, *args, **kwargs):

        npoints = 80
        X = np.linspace(-1, 1, npoints).astype(np.float32)
        Y = np.linspace(-1, 1, npoints).astype(np.float32)
        Z = np.zeros((npoints,npoints), dtype=np.float32)
        x, y = np.meshgrid(X, Y)
        mesh = np.vstack((x, y, Z)).reshape(3, -1).T.astype(np.float32)

        super(HeightMap, self).__init__(
            mesh,
            linetype=o.TriangleMesh(
                data=mesh,
                side_x=npoints,
                side_y=npoints,
            ),
        )

        self._shaders += t.shader_path("heightmap/heightmap.vsh")
        self._shaders += t.shader_path("heightmap/heightmap.fsh")
Exemplo n.º 7
0
    def __init__(self, *args, **kwargs):

        npoints = 10000
        rand = np.random.rand(npoints, 3)

        r = rand[:, 0] ** (1. / 3.)
        thet = np.arccos(2 * rand[:, 1] - 1)
        phi = 2. * np.pi * rand[:, 2]

        pos = np.array(
            [
                r * np.cos(phi) * np.sin(thet),
                r * np.sin(phi) * np.sin(thet),
                r * np.cos(thet)
            ],
            dtype=np.float32,
        ).T

        self._indices = np.array(range(npoints)).astype("uint32")

        super(Sprites, self).__init__(pos)

        self._shaders += t.shader_path("sprite/sprite.vsh")
        self._shaders += t.shader_path("sprite/sprite.fsh")
Exemplo n.º 8
0
 def createShaders(self, parent):
     if len(self._shaders) == 0:
         self._shaders += t.shader_path("basic.vsh")
         self._shaders += t.shader_path("basic.fsh")
     self._shaders.link()