コード例 #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
コード例 #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()
コード例 #3
0
    class MainWindow(Window):
        def __init__(self):
            super().__init__(500, 800, 'mywindow')
            self.framerate = 60
            # want to create frame
            w, h = self.glyph.size
            ffactory = self.devices.frames.factory
            ffactory.set_size(w, h)
            ffactory.append_color_texture(
                target=ffactory.TXTR.TRGT.TWO_D,
                iformat=ffactory.TXTR.CLR_FRMT.RGBA.RGBA,
                aid=0)
            ffactory.append_color_texture(
                target=ffactory.TXTR.TRGT.TWO_D,
                iformat=ffactory.TXTR.CLR_FRMT.RGB.RGB,
                aid=1)  # color id texture
            ffactory.append_depth_texture(
                target=ffactory.TXTR.TRGT.TWO_D,
                iformat=ffactory.TXTR.DEPTH_FRMT.DEPTH_COMPONENT)
            ffactory.create()

            # create pane
            self.devices.panes.appendnew_pane(0.1, 0.1, 0.6, 0.6, self)

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

            self.devices.cameras.attach_fps_dolly(camera_id=0, cursor_id=0)

            # draw something
            self.modeler = AModeler()
            self.model = self.modeler.add_model(parent=None)

            for x in range(3):
                for y in range(3):
                    p = self.modeler.add_pnt(self.model, x * 20, y * 20, 0)
                    p.dia = 5
                    p.clr = 1, 0, 0, 1
                    p.frm = 'c'

            p1 = self.modeler.add_pnt(self.model, 12, 12, 12)
            p1.dia = 5
            p1.clr = 1, 0, 0, 1
            p1.frm = 'c'

            p2 = self.modeler.add_pnt(self.model, 10, 10, 10)
            p2.dia = 5
            p2.clr = 1, 1, 0, 1
            p2.frm = 't'

            p3 = self.modeler.add_pnt(self.model, 80, 30, 0)
            p3.dia = 5
            p3.clr = 1, 1, 1, 1
            p3.frm = 't'

            self.ref0 = self.modeler.add_pnt(self.model, 0, 0, 0)
            self.ref1 = self.modeler.add_pnt(self.model, 0, 0, 0)
            self.ref2 = self.modeler.add_pnt(self.model, 0, 0, 0)

            self.ref0.dia = 0.5
            self.ref1.dia = 0.5
            self.ref2.dia = 0.5
            self.ref1.frm = 't'
            self.modeler.add_ground(self.model, clr.ClrRGBA(.8, .8, .8, 1))
            self.count = 0

            print('press "1" to export current scene')

        def draw(self):
            # clean default frame
            with self.devices.frames[0] as deff:
                deff.clear(0, 0, 0, 1)
                deff.clear_depth()

            # draw on draw frame
            with self.devices.frames[1] as f:
                f.clear_depth()
                f.clear_texture(0, .5, .5, .5, 1)
                f.clear_texture(1, 0, 0, 0, 1)
                self.modeler.render()

            with self.devices.panes[1]:
                self.devices.frames[1].render_pane_space_depth(
                    0, (0, 1, 0, 1), (-1, 1, -1, 1))
                if self.devices.keyboard.get_key_status('1'):
                    self.devices.frames[1].frame_bffr.textures[0].image_export(
                        f"{self.count}.jpg")
                    self.count += 1
コード例 #4
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)
コード例 #5
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)
コード例 #6
0
class MainWindow(Window):
    def __init__(self):
        super().__init__(800, 1000, 'mywindow')
        self.framerate = 5
        # want to create frame
        w, h = self.glyph.size
        ffactory = self.devices.frames.factory
        ffactory.set_size(w, h)
        ffactory.append_color_texture(target=ffactory.TXTR.TRGT.TWO_D,
                                      iformat=ffactory.TXTR.CLR_FRMT.RGBA.RGBA,
                                      aid=0)
        ffactory.append_color_texture(target=ffactory.TXTR.TRGT.TWO_D,
                                      iformat=ffactory.TXTR.CLR_FRMT.RGB.RGB,
                                      aid=1)  # color id texture
        ffactory.append_depth_texture(target=ffactory.TXTR.TRGT.TWO_D,
                                      iformat=ffactory.TXTR.DEPTH_FRMT.DEPTH_COMPONENT)
        ffactory.create()

        # create pane
        self.devices.panes.appendnew_pane(0.1, 0.1, 0.6, 0.6, self)

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

        # draw something
        self.modeler = AModeler()
        self.model = self.modeler.add_model(parent=None)
        self.modeler.add_ground(self.model, (1, 1, 1, 1))
        for x in range(3):
            for y in range(3):
                p = self.modeler.add_pnt(self.model, x*20, y*20, 0)
                p.dia = 5
                p.clr = 1, 0, 0, 1
                p.frm = 's'

        p1 = self.modeler.add_pnt(self.model, 12, 12, 12)
        p1.dia = 5
        p1.clr = 1, 0, 0, 1
        p1.frm = 's'

        p2 = self.modeler.add_pnt(self.model, 10, 10, 10)
        p2.dia = 5
        p2.clr = 1, 1, 0, 1
        p2.frm = 't'

        p3 = self.modeler.add_pnt(self.model, 80, 30, 0)
        p3.dia = 5
        p3.clr = 1, 1, 1, 1
        p3.frm = 't'

        self.modeler.add_ground(self.model, (.5,.5,.5,.5))
        self.is_rendered = False

    def draw(self):
        with self.devices.frames[0] as deff:
            deff.clear(0, 0, 0, 1)
            deff.clear_depth()
        with self.devices.cameras[0] as cam:
            if not self.is_rendered:
                with self.devices.frames[1] as f:
                    f.clear_depth()
                    f.clear_texture(0, .5, .5, .5, 1)
                    f.clear_texture(1, 0, 0, 0, 1)
                    self.modeler.render()
                    self.is_rendered = True

        with self.devices.panes[1] as p:
            self.devices.frames[1].render_pane_space_depth(0, (0, 1, 0, 1), (-1, 1, -1, 1))
コード例 #7
0
class MainWindow(Window):
    def __init__(self):
        super().__init__(800, 1000, 'mywindow')
        self.framerate = 60
        # want to create frame
        w, h = self.glyph.size
        ffactory = self.devices.frames.factory
        ffactory.set_size(w, h)
        ffactory.append_color_texture(target=ffactory.TXTR.TRGT.TWO_D,
                                      iformat=ffactory.TXTR.CLR_FRMT.RGBA.RGBA,
                                      aid=0)
        ffactory.append_color_texture(
            target=ffactory.TXTR.TRGT.TWO_D,
            iformat=ffactory.TXTR.CLR_FRMT.RGBA.RGB10_A2,
            aid=1)  # color id texture
        ffactory.append_depth_texture(
            target=ffactory.TXTR.TRGT.TWO_D,
            iformat=ffactory.TXTR.DEPTH_FRMT.DEPTH_COMPONENT)
        ffactory.create()

        # create pane
        self.devices.panes.appendnew_pane(0.1, 0.1, 0.6, 0.6, self)

        # set camera
        self.devices.cameras[0].tripod.lookat(eye=(100, 50, 30),
                                              at=(0, 0, 0),
                                              up=(0, 0, 1))
        self.devices.cameras.attach_fps_dolly(camera_id=0, cursor_id=0)

        # draw something
        self.modeler = AModeler()
        self.model = self.modeler.add_model(parent=None)
        self.modeler.add_ground(self.model, (.8, .8, .8, 1))

        for x in range(3):
            for y in range(3):
                p = self.modeler.add_pnt(self.model, x * 20, y * 20, 0)
                p.dia = 5
                p.clr = 1, 0, 0, 1
                p.frm = 'c'

        p1 = self.modeler.add_pnt(self.model, 12, 12, 12)
        p1.dia = 5
        p1.clr = 1, 0, 0, 1
        p1.frm = 'c'

        p2 = self.modeler.add_pnt(self.model, 10, 10, 10)
        p2.dia = 5
        p2.clr = 1, 1, 0, 1
        p2.frm = 't'

        p3 = self.modeler.add_pnt(self.model, 80, 30, 0)
        p3.dia = 5
        p3.clr = 1, 1, 1, 1
        p3.frm = 't'

        self._ref_pnts = []
        for _ in range(4):
            pnt = self.modeler.add_pnt(self.model, 0, 0, 0)
            pnt.dia = 0.05
            self._ref_pnts.append(pnt)

        self.is_rendered = False

    def draw(self):
        with self.devices.frames[0] as deff:
            deff.clear(0, 0, 0, 1)
            deff.clear_depth()
        with self.devices.cameras[0] as cam:
            for pnt, (dx, dy) in zip(self._ref_pnts,
                                     ((1, 1), (-1, -1), (1, -1), (-1, 1))):
                a = 0.1
                x, y = dx * a, dy * a
                pnt.geo = cam.tripod.plane.TM * gt.Pnt(x, y, -10)

            with self.devices.frames[1] as f:
                f.clear_depth()
                f.clear_texture(0, .5, .5, .5, 1)
                f.clear_texture(1, 0, 0, 0, 1)
                self.modeler.render()
                self.is_rendered = True

        with self.devices.panes[1] as p:
            self.devices.frames[1].render_pane_space_depth(
                0, (0, 1, 0, 1), (-1, 1, -1, 1))
            with self.devices.frames[1] as deff:
                # pos = p.cursor_pos(parameterize=True)
                goid, bitpattern = deff.pick_pixels(aid=1,
                                                    pos=(.5, .5),
                                                    size=(1, 1))
                goid = goid[0][0]
                e = GIDP().get_registered_byvalue(goid, bitpattern)
                if e:
                    print(goid, e)
コード例 #8
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)