0

I want to show only 1 quarter of a plane, is there any method to do that? I've tried all options of visuals.Plane() but not successfully. I also tried to change value of vertices['color'] and the result is same. Here is my code:

import vispy
from vispy import geometry
from vispy.scene import visuals, widgets
from vispy.scene.cameras import TurntableCamera
from vispy.scene import SceneCanvas

class Vis():
    def __init__(self):  
        self.canvas = SceneCanvas(keys='interactive', title='vispy', show=True, size=(1280, 720))
        self.canvas.events.key_press.connect(self._key_press)
        self.grid = self.canvas.central_widget.add_grid()
        self.view = widgets.ViewBox(parent=self.canvas.scene,
                                camera=TurntableCamera(distance=10.0))
        self.grid.add_widget(self.view)
        visuals.XYZAxis(parent=self.view.scene)
        vertices, faces, outline = geometry.create_plane(width=2,
                                                        height=2,
                                                        direction='+z', width_segments=1, height_segments=1)
        self.floor = visuals.Plane(width=2,
                                 height=2,
                                 width_segments=1, height_segments=1,
                                 vertex_colors=vertices['color'], edge_color='k', direction='+z',
                                 parent=self.view.scene)

    def run(self):
        self.canvas.app.run()

    def _key_press(self, event):
        if event.key == 'Q':
            self.destroy()

    def destroy(self):
        self.canvas.close()
        vispy.app.quit()

if __name__ == "__main__":
    vis = Vis()
    vis.run()
Itai Klapholtz
  • 196
  • 1
  • 2
  • 15
Odirection
  • 31
  • 3
  • If you want to draw 1/4th of a plane, why not just change the coordinates of the plane to 1/4th of itself? – Robin De Schepper Jun 21 '22 at 10:23
  • Could you describe your use case? Why do you want to view only a quarter of the plane you're creating? You could try changing the coordinates as suggested by @RobinDeSchepper or you could add a camera (view.camera = 'panzoom') and "move" the camera to a position so it only sees 1/4th of the plane. – djhoese Jun 21 '22 at 13:09
  • yes, changing the coordinate by adding (delta_x, delta_y, de;ta_z) is solution. Thanks – Odirection Jun 22 '22 at 04:58
  • By the way, do you have any solution to draw cube at any position using vispy. The API provided by vispy just draw tube at (0, 0, 0) and there is no option for pos. I dont want to draw it by many lines – Odirection Jun 22 '22 at 05:27

0 Answers0