Exemple #1
0
class MyWindow(Window):
    def __init__(self):
        super().__init__(500, 800, 'mywindow', None, None)
        self.framerate = 120
        camera = self.devices.cameras[0]
        camera.tripod.lookat(eye=(-100, -100, 100), at=(0, 0, 0), up=(0, 0, 1))
        # self.devices.cameras.attach_fps_dolly(0, 0)

        self.modeler = AModeler()
        self.model = self.modeler.add_model(parent=None)
        self.modeler.add_ground(self.model, [.5] * 4)
        self.modeler.add_pln(self.model, (0, 0, 0.001), (1, 0, 0), (0, 1, 0),
                             (0, 0, 1))
        self.picker = VicinityPicker()

    def draw(self):
        with self.devices.frames[0] as df:
            df.clear(0, 0, 0, 1)
            df.clear_depth()

            with self.devices.cameras[0] as c:
                self.modeler.render()

                selection = self.picker.pick(gt.Pln(), c,
                                             self.devices.cursors[0])
                if selection:
                    key, point = selection
                    if key == 'xy':
                        clr = 0, 0, 1, 0.5
                    elif key == 'yz':
                        clr = 1, 0, 0, 0.5
                    else:
                        clr = 0, 1, 0, 0.5
                    self.modeler.add_raw(self.model, point).clr = clr
Exemple #2
0
class MyWindow(Window):
    def __init__(self):
        super().__init__(500, 800, 'mywindow', None, None)
        camera = self.devices.cameras[0]
        camera.tripod.lookat(eye=(100, 50, 100), at=(0, 0, 0), up=(0, 0, 1))
        self.devices.cameras.attach_fps_dolly(0, 0)

        self.modeler = AModeler()
        self.model = self.modeler.add_model(parent=None)
        self.modeler.add_pln(self.model, (0, 0, 0.001), (1, 0, 0), (0, 1, 0),
                             (0, 0, 1))
        self.modeler.add_pln(self.model, (10, 23, 10), (6, 4, 24), (5, 6, 10),
                             (2, 100, 1))
        self.modeler.add_ground(self.model, (1, 1, 1, 1))

    def draw(self):
        with self.devices.frames[0] as df:
            df.clear(0, 0, 0, 1)
            df.clear_depth()

            with self.devices.cameras[0] as c:
                self.modeler.render()
Exemple #3
0
class MyWindow(Window):
    def __init__(self):
        super().__init__(500, 800, 'mywindow', None, None)
        self.fps = 5
        # set camera
        camera = self.devices.cameras[0]
        camera.tripod.lookat(eye=(100, 100, 100), at=(0, 0, 0), up=(0, 0, 1))
        # set frame
        ff = self.devices.frames.factory
        ff.append_color_texture(ff.TXTR.TRGT.TWO_D,
                                ff.TXTR.CLR_FRMT.RGBA.RGBA,
                                aid=0)  # color
        ff.append_color_texture(ff.TXTR.TRGT.TWO_D,
                                ff.TXTR.CLR_FRMT.RGBA.RGBA,
                                aid=1)  # id
        ff.append_color_texture(ff.TXTR.TRGT.TWO_D,
                                ff.TXTR.CLR_FRMT.RGB.RGB32F,
                                aid=2)  # coordinate
        ff.append_depth_texture(ff.TXTR.TRGT.TWO_D,
                                ff.TXTR.DEPTH_FRMT.DEPTH_COMPONENT)  # depth
        ff.set_size(*self.glyph.size)
        ff.create()

        # set model
        self.modeler = AModeler()
        self.model = self.modeler.add_model(parent=None)
        self.modeler.add_ground(self.model, (.5, .5, .5, 1))
        self.modeler.add_pnt(self.model, 0, 0, 0)
        t = self.modeler.add_tgl(self.model, (10, 0, 5), (0, 10, 5), (0, 0, 5))
        t.clr_edge = 1, 0, 0, 1
        t.edge_thk = 5
        l = self.modeler.add_lin(self.model, (10, 0, 10), (0, -100, 0))
        l.clr = 1, 0, 1, 1

        pl = self.modeler.add_plin(self.model, [0, 0, 0], [-5, 0, 10],
                                   [10, 0, 50])
        pl.clr = 1, 1, 1, 1

        self.modeler.add_pln(self.model, (0, 0, 0.001), (1, 0, 0), (0, 1, 0),
                             (0, 0, 1))

        a = 10
        for x in range(10):
            for y in range(10):
                for z in range(1):
                    p = self.modeler.add_pnt(self.model, a * x, a * y, a * z)
                    p.frm = 'c'
                    p.dia = 3
                    if z % 2 == 0:
                        p.frm = 't'
                    if (x + y + z) % 2 == 0:
                        p.frm = 's'

    def draw(self):
        with self.devices.frames[0] as df:
            df.clear(0, 0, 0, 1)
            df.clear_depth()

            with self.devices.cameras[0] as c:
                with self.devices.frames[1] as df:
                    df.clear(0, 0, 0, 1)
                    df.clear_depth()
                    self.modeler.render()

                    coord, _ = df.pick_pixels(
                        2,
                        self.devices.cursors[0].pos_global.astype(int),
                        size=(1, 1))
                    print(coord[0][0])

        df.render_pane_space_depth(aid=0)
Exemple #4
0
class MyWindow(Window):
    def __init__(self):
        super(MyWindow, self).__init__(500, 880, 'mywindow', None, None)
        self.fps = 30

        self.devices.cameras[0].tripod.lookat(eye=(100, 50, 100),
                                              at=(0, 0, 0),
                                              up=(0, 0, 1))
        # creeat frame
        ff = self.devices.frames.factory
        ff.append_color_texture(ff.TXTR.TRGT.TWO_D,
                                ff.TXTR.CLR_FRMT.RGBA.RGBA,
                                aid=0)
        ff.append_color_texture(ff.TXTR.TRGT.TWO_D,
                                ff.TXTR.CLR_FRMT.RGBA.RGB10_A2,
                                aid=1,
                                name='goid')
        ff.append_color_texture(ff.TXTR.TRGT.TWO_D,
                                ff.TXTR.CLR_FRMT.RGBA.RGBA32F,
                                aid=2,
                                name='coord')
        ff.append_depth_texture(ff.TXTR.TRGT.TWO_D,
                                ff.TXTR.DEPTH_FRMT.DEPTH_COMPONENT)
        ff.set_size(500, 880)
        ff.create()

        # attach dolly
        self.cad_dolly = self.devices.cameras.attach_cad_dolly(camera_id=0,
                                                               cursor_id=0,
                                                               def_offset=500)

        self.modeler = AModeler()
        self.model = self.modeler.add_model(parent=None)
        self.modeler.add_ground(self.model, (.5, .5, .5, .5))
        self.modeler.add_pln(self.model, (0, 0, 0), (1, 0, 0), (0, 1, 0),
                             (0, 0, 1))

        self.id_picker = self.devices.frames[1].create_pixel_picker(aid=1)
        self.coord_picker = self.devices.frames[1].create_pixel_picker(aid=2)
        self.controller = AController(self, self.modeler, self.model,
                                      self.id_picker, self.coord_picker,
                                      self.devices.cameras[0],
                                      self.devices.cursors[0])

        print("Press 'd' to remove selected point")

    def draw(self):
        with self.devices.frames[0] as rf:
            rf.clear(0, 0, 0, 0)
            rf.clear_depth()

            with self.devices.frames[1] as df:
                df.clear(0, 0, 0, 0)
                df.clear_depth()
                self.modeler.render()

                # update camera move
                # extract coordinate texture value
                txtr_pos = self.devices.cursors[
                    0].pos_local * self.devices.frames[1].size
                coord, _ = self.coord_picker.pick(pos=txtr_pos.astype(int),
                                                  size=(1, 1))
                coord = coord[0][0].tolist()[:3]
                if coord != [0, 0, 0]:
                    self.cad_dolly.set_ref_point(*coord)

            df.render_pane_space_depth(aid=0)
Exemple #5
0
class MyWindow(Window):
    def __init__(self):
        super(MyWindow, self).__init__(500, 880, 'mywindow', None, None)
        self.framerate = 30

        self.devices.cameras[0].tripod.lookat(eye=(100, 50, 100),
                                              at=(0, 0, 0),
                                              up=(0, 0, 1))

        # create pane and cursor
        self.devices.panes.appendnew_pane(0.1,
                                          0.1,
                                          0.8,
                                          0.8,
                                          parent=self.devices.panes[0])
        self.devices.cursors.appendnew_cursor(1)

        # creeat frame
        ff = self.devices.frames.factory
        ff.append_color_texture(ff.TXTR.TRGT.TWO_D,
                                ff.TXTR.CLR_FRMT.RGBA.RGBA,
                                aid=0)
        ff.append_color_texture(ff.TXTR.TRGT.TWO_D,
                                ff.TXTR.CLR_FRMT.RGBA.RGB10_A2,
                                aid=1)
        ff.append_color_texture(ff.TXTR.TRGT.TWO_D,
                                ff.TXTR.CLR_FRMT.RGBA.RGBA32F,
                                aid=2)
        ff.append_depth_texture(ff.TXTR.TRGT.TWO_D,
                                ff.TXTR.DEPTH_FRMT.DEPTH_COMPONENT)
        ff.set_size(500, 880)
        ff.create()

        # attach dolly
        self.cad_dolly = self.devices.cameras.attach_cad_dolly(camera_id=0,
                                                               cursor_id=0,
                                                               def_offset=500)

        self.modeler = AModeler()
        self.model = self.modeler.add_model(parent=None)

        self.modeler.add_pln(self.model, (0, 0, 0), (1, 0, 0), (0, 1, 0),
                             (0, 0, 1))
        self.modeler.add_ground(self.model, (.5, .5, .5, .5))
        a = 10
        for x in range(10):
            for y in range(10):
                self.modeler.add_pnt(self.model, x * a, y * a, a)

    def draw(self):
        with self.devices.frames[0] as f:
            f.clear(0, 0, 0, 0)
            f.clear_depth()

            with self.devices.frames[1] as f:
                f.clear(0, 0, 0, 0)
                f.clear_depth()
                self.modeler.render()

                # extract coordinate texture value
                # print(self.devices.cursors[1].pos_local, self.devices.cursors[1].pos_global)
                pos = self.devices.cursors[1].pos_local * self.devices.frames[
                    1].size
                coord, _ = f.pick_pixels(aid=2,
                                         pos=pos.astype(int),
                                         size=(1, 1))
                coord = coord[0][0][:3].tolist()
                if coord != [0, 0, 0]:
                    self.cad_dolly.set_ref_point(*coord)

            with self.devices.panes[1]:
                f.render_pane_space_depth(aid=0)