Ejemplo n.º 1
0
    def __init__(self,
                 vertices,
                 faces,
                 uniform_colour=(0.5, 0.5, 1.0),
                 uniform_opacity=1.0,
                 vertex_colours=None,
                 wireframe=False,
                 wireframe_offset=None):
        """
        Creates a primitive visual based on
        :class:`vispy.visuals.mesh.MeshVisual` class.

        Parameters
        ----------
        vertices : array_like
            Vertices data.
        faces : array_like
            Faces data.
        uniform_colour : array_like, optional
            Uniform mesh colour.
        uniform_opacity : numeric, optional
            Uniform mesh opacity.
        vertex_colours : array_like, optional
            Per vertex varying colour.
        wireframe : bool, optional
            Use wireframe display.
        wireframe_offset : array_like, optional
            Wireframe offset.

        Notes
        -----
        -   `vertex_colours` argument takes precedence over `uniform_colour` if
            provided.
        -   `uniform_opacity` argument will be stacked to `vertex_colours`
            argument if the latter last dimension is equal to 3.
        """

        self._wireframe = wireframe
        self._wireframe_offset = wireframe_offset
        mode = 'lines' if self._wireframe else 'triangles'

        uniform_colour = ColorArray(uniform_colour, alpha=uniform_opacity).rgba
        if vertex_colours is not None:
            if vertex_colours.shape[-1] == 3:
                vertex_colours = np.hstack(
                    (vertex_colours,
                     np.full((vertex_colours.shape[0], 1), uniform_opacity,
                             DEFAULT_FLOAT_DTYPE)))
            else:
                vertex_colours[..., 3] = uniform_opacity

        MeshVisual.__init__(
            self,
            vertices,
            faces,
            vertex_colours,
            None,
            uniform_colour,
            mode=mode)
Ejemplo n.º 2
0
    def __init__(self, data=None, level=None, vertex_colors=None,
                 face_colors=None, color=(0.5, 0.5, 1, 1), **kwargs):
        self._data = None
        self._level = level
        self._vertex_colors = vertex_colors
        self._face_colors = face_colors
        self._color = Color(color)

        # We distinguish between recomputing and just changing the visual
        # properties - in the latter case we don't recompute the faces.
        self._vertices_cache = None
        self._faces_cache = None
        self._recompute = True
        self._update_meshvisual = True

        MeshVisual.__init__(self, **kwargs)
        if data is not None:
            self.set_data(data)
Ejemplo n.º 3
0
    def __init__(self,
                 data=None,
                 level=None,
                 vertex_colors=None,
                 face_colors=None,
                 color=(0.5, 0.5, 1, 1),
                 **kwargs):
        self._data = None
        self._level = level
        self._vertex_colors = vertex_colors
        self._face_colors = face_colors
        self._color = Color(color)

        # We distinguish between recomputing and just changing the visual
        # properties - in the latter case we don't recompute the faces.
        self._vertices_cache = None
        self._faces_cache = None
        self._recompute = True
        self._update_meshvisual = True

        MeshVisual.__init__(self, **kwargs)
        if data is not None:
            self.set_data(data)