class MyWindow(Window):
    def __init__(self):
        super().__init__(500, 1000, 'my window 1', monitor=None, shared=None)
        self.framerate = 60

        # setup dolly
        d = self.devices.cameras.attach_fps_dolly(0, 0)
        d.move_boost = 5
        d.move_spd = 50

        # model for drawing
        self.modeler = AModeler()
        self.model = self.modeler.add_model(None)
        self.pnt_count = 0

    def draw(self, frame_count=None):
        if self.pnt_count < 100_000_000 and self.framerate % 10 == 0:
            p = self.modeler.add_pnt(
                self.model, *(random.randint(-10000, 10000) for _ in range(3)))
            p.frm = random.choice(('t', 'c', 's'))
            p.dia = random.randint(10, 100)
            self.pnt_count += 1

        with self.devices.panes[0] as p:
            p.clear(.1, .1, .1, 1)
            with self.devices.cameras[0]:
                self.modeler.render()
class MyWindow(Window):
    def __init__(self):
        super().__init__(500, 500, 'my window 1', monitor=None, shared=None)
        self.framerate = 60
        # enable camera move
        o = 100
        self.devices.cameras[0].tripod.lookat((o, o, o), (0, 0, 0), (0, 0, 1))
        self.devices.cameras.attach_fps_dolly(0, 0)

        # create model
        self.modeler = AModeler()
        self.model = self.modeler.add_model(None)

        # create triangles
        e = 50
        t0 = self.modeler.add_tgl(self.model, [0, 0, 0], [e, 0, 0], [0, e, 0])
        t1 = self.modeler.add_tgl(self.model, [0, 0, 0], [0, e, 0], [0, 0, e])
        t2 = self.modeler.add_tgl(self.model, [0, 0, 0], [e, 0, 0], [0, 0, e])
        # set fill color
        i, a = 1, 1
        t0.clr_fill = i, 0, 0, a
        t1.clr_fill = 0, i, 0, a
        t2.clr_fill = 0, 0, i, a
        # set edge color
        for t in (t0, t1, t2):
            t.clr_edge = 1, 1, 1, 1
            t.edge_thk = 5

    def draw(self, frame_count=None):
        with self.devices.panes[0] as p:
            with self.devices.cameras[0] as c:
                p.clear(.5, .5, .5, 1)
                self.modeler.render()
Exemple #3
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 #4
0
class MyWindow(Window):
    def __init__(self):
        super().__init__(500, 500, 'my window 1', monitor=None, shared=None)
        self.framerate = 60
        # enable camera move
        self.devices.cameras[0].tripod.lookat((200, 100, 200), (0, 0, 0),
                                              (0, 0, 1))

        # create model
        self.modeler = AModeler()
        self.model = self.modeler.add_model(None)

        e = 100
        self.modeler.add_tgl(self.model, [0, 0, 0], [e, 0, 0],
                             [0, e, 0]).clr_fill = 1, 0, 0, 1
        self.modeler.add_tgl(self.model, [0, 0, 0], [0, e, 0],
                             [0, 0, e]).clr_fill = 0, 1, 0, 1
        self.modeler.add_tgl(self.model, [0, 0, 0], [e, 0, 0],
                             [0, 0, e]).clr_fill = 0, 0, 1, 1

    def draw(self, frame_count=None):
        with self.devices.panes[0] as v:
            with self.devices.cameras[0] as c:
                v.clear(.5, .5, .5, 1)
                self.modeler.render()
class MainWindow(Window):
    def __init__(self):
        super().__init__(1000, 1000, 'mywindow')
        # 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)
        ffactory.append_render_buffer(
            iformat=ffactory.RNDR.DEPTH_STENCIL.DEPTH24_STENCIL8, aid='ds')
        ffactory.create()
        # create pane
        self.devices.panes.appendnew_pane(0, 0, 0.6, 0.6, self)

        self.modeler = AModeler()
        self.model = self.modeler.add_model(parent=None)
        p0 = self.modeler.add_pnt(self.model, 0, 0, 0)
        p0.dia = 2
        p0.clr = 1, 1, 0, 1
        p1 = self.modeler.add_pnt(self.model, 10, 10, 10)
        p1.dia = 5
        p1.clr = 1, 1, 0, 1
        p1.frm = 'c'

        P2 = self.modeler.add_pnt(self.model, 20, 20, 20)
        P2.dia = 5
        P2.clr = 1, 1, 0, 1
        P2.frm = 't'
        self.is_rendered = False

    def draw(self):
        with self.devices.frames[0] as f:
            f.clear(0, 0, 0, 1)
            f.clear_depth()
        with self.devices.cameras[0] as c:
            with self.devices.frames[1] as off:
                off.clear_depth()
                off.clear_texture(0, .5, .5, .5, 1)
                off.clear_texture(1, 0, 0, 0, 1)
                self.modeler.render()
                self.is_rendered = True
            off.render_pane_space(0, (0, 1, 0, 1), (-1, 1, -1, 1), 0.9)
class MyWindow(Window):
    def __init__(self):
        super().__init__(1000, 1000, 'my window 1', monitor=None, shared=None)
        self.framerate = 60
        # enable camera move
        o = 200
        self.devices.cameras[0].tripod.lookat(eye=(0, 0, o),
                                              at=(0, 0, 0),
                                              up=(0, 1, 0))
        self.devices.cameras.attach_fps_dolly(0, 0)

        # create model
        self.modeler = AModeler()
        self.model = self.modeler.add_model(parent=None)
        v0 = [0, 0, 0]
        v1 = [20, 0, 0]
        v2 = [25, 15, 0]
        v3 = [18, 20, 0]
        v4 = [10, 10, 0]
        v5 = [-10, 30, 0]
        v6 = [-5, 12, 0]
        v7 = [-20, 5, 0]
        vrtxs = [v0, v1, v2, v3, v4, v5, v6, v7, v0]
        # triangles draw
        self.modeler.add_tgl(self.model, v0, v1, v4)
        self.modeler.add_tgl(self.model, v1, v2, v4)
        self.modeler.add_tgl(self.model, v2, v3, v4)
        self.modeler.add_tgl(self.model, v0, v4, v6)
        self.modeler.add_tgl(self.model, v0, v6, v7)
        self.modeler.add_tgl(self.model, v4, v5, v6)

        for i in range(len(vrtxs)):
            x, y, z = vrtxs[i]
            vrtxs[i] = x, y + 30, z
        p = self.modeler.add_pgon(self.model, *vrtxs)
        p.thk = 2

    def draw(self, frame_count=None):
        with self.devices.panes[0] as p:
            with self.devices.cameras[0] as c:
                p.clear(.5, .5, .5, 1)
                # e = 100
                self.modeler.render()
class MyWindow(Window):
    def __init__(self):
        super().__init__(1000, 500, 'my window 1', monitor=None, shared=None)
        self.framerate = 60

        self.fcount = 0
        # enable camera move
        self.devices.cameras[0].tripod.lookat((0, 0, 2000), (0, 0, 0), (0, 1, 0))
        d = self.devices.cameras.attach_fps_dolly(0, 0)
        d.move_boost = 10
        d.move_spd = 5
        # create model
        self.modeler = AModeler()
        self.model = self.modeler.add_model(parent=None)

        self.num_scratch = 0
        self.ori = None
        self.lin_vec = None
        self.offset_vec = None
        self.thk = None

    def draw(self):
        if not self.num_scratch:
            self.ori = gt.Pnt(*(random.randint(-1500, 1500) for _ in range(2)), random.randint(-200, 200))
            self.lin_vec = gt.Vec(*(random.uniform(-1, 1) for _ in range(2))).amplify(random.randint(200, 500))
            self.offset_vec = gt.Vec.cross(gt.ZVec(), self.lin_vec).amplify(random.randint(10, 100))
            self.num_scratch = random.randint(0, 25)
            self.thk = random.randint(2, 15)

        if self.fcount % 3 == 0:
            geo = gt.Lin.from_pnt_vec(self.ori + self.offset_vec * self.num_scratch, self.lin_vec)
            lin = self.modeler.add_raw(self.model, geo)
            lin.thk = self.thk
            self.num_scratch -= 1
        self.fcount += 1

        with self.devices.panes[0] as p:
            with self.devices.cameras[0] as c:
                p.clear(.5, .5, .5, 1)
                self.modeler.render()
Exemple #8
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()
class MyWindow(Window):
    def __init__(self):
        super().__init__(1000, 2000, 'my window 1', monitor=None, shared=None)
        self.framerate = 60
        # enable camera move
        o = 200
        self.devices.cameras[0].tripod.lookat(eye=(0, 0, o),
                                              at=(0, 0, 0),
                                              up=(0, 1, 0))
        self.devices.cameras.factory.set_lrbt_dimension(
            -1, 1, -1, 1, 1, 1_000_000).set_frustum_shape('o').create()
        self.devices.panes.appendnew_pane(0.5, 0.5, 0.5, 0.5, self)
        self.devices.cameras[0].focus_pane(pane=self.devices.panes[1],
                                           focus=(0, 0, 0),
                                           clip_off=100)
        self.devices.cameras[1].focus_pane(pane=self.devices.panes[1],
                                           focus=(0, 0, 0),
                                           clip_off=100)

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

        hpw, hph = [d / 2 for d in self.devices.panes[1].size.xy]
        self.modeler.add_pnt(self.model, 0, 0, 0)
        for dx in (-1, 1):
            for dy in (-1, 1):
                for z in range(-500, 1, 100):
                    p = self.modeler.add_pnt(self.model, hpw * dx, hph * dy, z)
                    p.frm = 'c'
                    p.dia = 30

    def draw(self, frame_count=None):
        with self.devices.panes[1] as p:
            with self.devices.cameras[0] as c:
                p.clear(.5, .5, .5, 1)
                self.modeler.render()
class MyWindow(Window):
    def __init__(self):
        super().__init__(500, 1000, 'my window 1', monitor=None, shared=None)
        self.framerate = 60
        # enable camera move
        o = 200
        self.devices.cameras[0].tripod.lookat((-o, o, o / 2), (o, 0, 0),
                                              (0, 0, 1))
        self.devices.cameras.attach_fps_dolly(0, 0)

        # create model
        self.modeler = AModeler()
        self.model = self.modeler.add_model(None)
        l = 100
        self.modeler.add_plin(self.model, [0, 0, 0], [l, 0, 0], [0, l, l],
                              [l, l, l])
        k = 50
        self.modeler.add_plin(self.model, [k, 0, k], [0, k, k], [k, k, k * 2])

    def draw(self, frame_count=None):
        with self.devices.panes[0] as p:
            with self.devices.cameras[0] as c:
                p.clear(.5, .5, .5, 0)
                self.modeler.render()
Exemple #11
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
Exemple #12
0
class MainWindow(Window):
    def __init__(self):
        super().__init__(500, 1000, 'mywindow')
        self.fps = 1

        # 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)
        ffactory.append_render_buffer(
            iformat=ffactory.RNDR.DEPTH_STENCIL.DEPTH24_STENCIL8, aid='ds')
        ffactory.create()

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

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

        p0 = self.modeler.add_pnt(self.model, 5, 5, 5)
        p0.dia = 10
        p0.clr = 0, 0, 1, 1
        p0.goid_flag = True
        p2 = self.modeler.add_pnt(self.model, 15, 15, 15)
        p2.dia = 10
        p2.clr = 1, 0, 0, 1
        p2.frm = 't'
        p2.goid_flag = True
        p1 = self.modeler.add_pnt(self.model, 10, 10, 20)
        p1.dia = 10
        p1.clr = 1, 1, 0, 1
        p1.frm = 'c'
        p1.goid_flag = False

        self.is_rendered = False

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

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

            with self.devices.panes[1]:
                self.devices.frames[1].render_pane_space(
                    0, (0, 1, 0, 1), (-1, 1, -1, 1), 0.9)

            with self.devices.frames[1] as rf:
                # manual pos transformation
                pos = self.devices.cursors[0].pos_global
                pos -= self.devices.panes[1].pos
                pos /= self.devices.panes[1].size
                # pick color id
                goid, bitpattern = rf.pick_pixels(aid=1, pos=pos, size=(1, 1))
                e = GIDP().get_registered_byvalue(
                    goid[0][0], bitpattern)  # for last two bits being alpha
                if e:
                    print(e)
Exemple #13
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 #14
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 #15
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)
Exemple #16
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)
Exemple #17
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))
Exemple #18
0
class MyWindow(Window):
    def __init__(self):
        super().__init__(1000, 1000, 'my window 1', monitor=None, shared=None)
        self.framerate = 60
        # enable camera move
        o = 200
        # self.devices.cameras[0].tripod.lookat(eye=(0, 0, o), at=(0, 0, 0), up=(0, 1, 0))
        self.devices.cameras[0].focus_pane(pane=self.devices.panes[0],
                                           focus=(0, 0, 0),
                                           clip_off=100)

        # create model
        self.modeler = AModeler()
        model = self.modeler.add_model(None)
        plns = []
        self.model1 = model
        pw, ph = self.devices.panes[0].size.xy
        n = 7
        nw, nh = pw // n, ph // n
        for x in range(-pw // 2 + nw, pw // 2 - nw + 1, nw):
            for y in range(-ph // 2 + nh, ph // 2 - nh + 1, nh):
                plns.append(gt.Pln(o=(x, y, 0)))
                self.modeler.add_pnt(model, x, y, 1).clr = ClrRGBA(1, 1, 0, 1)

        e = 100
        q = e / 4
        h = e / 2
        o = e / 10
        t = e / 3
        pgons = []

        # A
        pgons.append(
            gt.Pgon((0, 0, 0), (q, 0, 0), (t, q, 0), (2 * t, q, 0),
                    (3 * q, 0, 0), (e, 0, 0), (h, e, 0), (0, 0, 0)))
        # B
        k = e - 3 * o
        pgons.append(
            gt.Pgon((0, 0, 0), (k, 0, 0), (e, o, 0), (e, h - o, 0), (k, h, 0),
                    (e, h + o, 0), (e, e - o, 0), (k, e, 0), (0, e, 0),
                    (0, 0, 0)))
        # C
        pgons.append(
            gt.Pgon((q, 0, 0), (h, 0, 0), (e, 0, 0), (e, q, 0), (h, q, 0),
                    (t, t, 0), (t, 2 * t, 0), (h, e - q, 0), (e, e - q, 0),
                    (e, e, 0), (q, e, 0), (0, e - q, 0), (0, q, 0), (q, 0, 0)))
        # D
        pgons.append(
            gt.Pgon((0, 0, 0), (3 * q, 0, 0), (e, q, 0), (e, e - q, 0),
                    (e - q, e, 0), (0, e, 0), (0, 0, 0)))
        # E
        k = e / 5
        pgons.append(
            gt.Pgon((0, 0, 0), (e, 0, 0), (e, k, 0), (h, k, 0), (h, 2 * k, 0),
                    (e, 2 * k, 0), (e, 3 * k, 0), (h, 3 * k, 0), (h, 4 * k, 0),
                    (e, 4 * k, 0), (e, e, 0), (0, e, 0), (0, 0, 0)))
        # F
        k = e / 5
        pgons.append(
            gt.Pgon((0, 0, 0), (t, 0, 0), (t, q, 0), (2 * t, q, 0),
                    (2 * t, h, 0), (t, h, 0), (t, 3 * q, 0), (e, 3 * q, 0),
                    (e, e, 0), (0, e, 0), (0, 0, 0)))
        # G
        pgons.append(
            gt.Pgon((0, 0, 0), (e, 0, 0), (e, 2 * t - o, 0),
                    (e - q - o, 2 * t - o, 0), (e - q, t, 0), (q, t, 0),
                    (q, 2 * t, 0), (e, 2 * t, 0), (e, e, 0), (0, e, 0),
                    (0, 0, 0)))
        # H
        pgons.append(
            gt.Pgon((0, 0, 0), (t, 0, 0), (t, t, 0), (2 * t, t, 0),
                    (2 * t, 0, 0), (e, 0, 0), (e, e, 0), (2 * t, e, 0),
                    (2 * t, 2 * t, 0), (t, 2 * t, 0), (t, e, 0), (0, e, 0),
                    (0, 0, 0)))
        # I
        pgons.append(
            gt.Pgon((0, 0, 0), (e, 0, 0), (e, t, 0), (2 * t, t, 0),
                    (2 * t, 2 * t, 0), (e, 2 * t, 0), (e, e, 0), (0, e, 0),
                    (0, 2 * t, 0), (t, 2 * t, 0), (t, t, 0), (0, t, 0),
                    (0, 0, 0)))
        # J
        pgons.append(
            gt.Pgon((q, 0, 0), (2 * t, 0, 0), (e - o, t, 0), (e - o, e - q, 0),
                    (e, e - q, 0), (e, e, 0), (h, e, 0), (h, e - q, 0),
                    (2 * t, e - q, 0), (2 * t, h, 0), (h, q, 0), (t, q, 0),
                    (t, h, 0), (0, h, 0), (0, q, 0), (q, 0, 0)))
        # K
        pgons.append(
            gt.Pgon((0, 0, 0), (t, 0, 0), (t, q, 0), (h, 0, 0), (e, 0, 0),
                    (h, h, 0), (e, e - q, 0), (e, e, 0), (t, e - t, 0),
                    (t, e, 0), (0, e, 0), (0, 0, 0)))
        # L
        pgons.append(
            gt.Pgon((0, 0, 0), (e, 0, 0), (e, t, 0), (t, t, 0), (t, e, 0),
                    (0, e, 0), (0, 0, 0)))
        # M
        pgons.append(
            gt.Pgon((0, 0, 0), (q, 0, 0), (q, h, 0), (1.5 * q, q, 0),
                    (2.5 * q, q, 0), (3 * q, h, 0), (3 * q, 0, 0), (e, 0, 0),
                    (e, e, 0), (3 * q, e, 0), (2.2 * q, h, 0), (1.8 * q, h, 0),
                    (q, e, 0), (0, e, 0), (0, 0, 0)))
        # N
        pgons.append(
            gt.Pgon((0, 0, 0), (q, 0, 0), (q, h, 0), (3 * q, 0, 0), (e, 0, 0),
                    (e, e, 0), (3 * q, e, 0), (3 * q, h, 0), (q, e, 0),
                    (0, e, 0), (0, 0, 0)))
        # O
        pgons.append(
            gt.Pgon((q, 0, 0), (e - q, 0, 0), (e, q, 0), (e, e - q, 0),
                    (e - q, e, 0), (q, e, 0), (0, e - q, 0), (0, q, 0),
                    (q, 0, 0)))
        # P
        pgons.append(
            gt.Pgon((0, 0, 0), (q, 0, 0), (q, h, 0), (e, h, 0), (e, e, 0),
                    (0, e, 0), (0, 0, 0)))
        # Q
        pgons.append(
            gt.Pgon((q, 0, 0), (h + o, 0, 0), (t * 2 + o, o, 0), (e - o, 0, 0),
                    (e, o, 0), (e - o, t - o, 0), (e, h - o, 0), (e, e - q, 0),
                    (e - q, e, 0), (q, e, 0), (0, e - q, 0), (0, q, 0),
                    (q, 0, 0)))
        # R
        pgons.append(
            gt.Pgon((0, 0, 0), (h, 0, 0), (h, q, 0), (e - q, 0, 0), (e, q, 0),
                    (e - q, h, 0), (e, h, 0), (e, e, 0), (0, e, 0), (0, 0, 0)))
        # S
        pgons.append(
            gt.Pgon((0, 0, 0), (e, 0, 0), (e, e - t, 0), (t, e - t, 0),
                    (t, e - t + o, 0), (e, e - t + o, 0), (e, e, 0), (0, e, 0),
                    (0, t, 0), (e - t, t, 0), (e - t, t - o, 0), (0, t - o, 0),
                    (0, 0, 0)))
        # T
        pgons.append(
            gt.Pgon((q, 0, 0), (e - q, 0, 0), (e - q, e - q, 0), (e, e - q, 0),
                    (e, e, 0), (0, e, 0), (0, e - q, 0), (q, e - q, 0),
                    (q, 0, 0)))
        # U
        pgons.append(
            gt.Pgon((q, 0, 0), (e - q, 0, 0), (e, q, 0), (e, e, 0),
                    (e - t, e, 0), (e - t, h, 0), (t, h, 0), (t, e, 0),
                    (0, e, 0), (0, q, 0), (q, 0, 0)))
        # V
        pgons.append(
            gt.Pgon((q, 0, 0), (e - q, 0, 0), (e, e, 0), (e - t, e, 0),
                    (h, h, 0), (t, e, 0), (0, e, 0), (q, 0, 0)))
        # W
        f = e / 5
        pgons.append(
            gt.Pgon((f, 0, 0), (f * 2, 0, 0), (h, h, 0), (f * 3, 0, 0),
                    (f * 4, 0, 0), (e, e, 0), (e - f, e, 0),
                    (e - f * 1.5, h, 0), (f * 3, e, 0), (f * 2, e, 0),
                    (f * 1.5, h, 0), (f, e, 0), (0, e, 0), (f, 0, 0)))
        # X
        pgons.append(
            gt.Pgon((0, 0, 0), (q, 0, 0), (h, t, 0), (e, 0, 0), (e, q, 0),
                    (e - t, h, 0), (e, e, 0), (e - q, e, 0), (h, e - t, 0),
                    (0, e, 0), (0, e - q, 0), (t, h, 0), (0, 0, 0)))
        # Y
        pgons.append(
            gt.Pgon((t, 0, 0), (t * 2, 0, 0), (t * 2, h, 0), (e, e - t, 0),
                    (e, e, 0), (h, e - q, 0), (0, e, 0), (0, e - t, 0),
                    (t, h, 0), (t, 0, 0)))
        # Z
        pgons.append(
            gt.Pgon((0, 0, 0), (e, 0, 0), (e, q, 0), (h, q, 0), (e, e, 0),
                    (0, e, 0), (0, e - q, 0), (h, e - q, 0), (0, 0, 0)))

        for pgon, pln in zip(pgons, plns):
            self.modeler.add_raw(model, pln.orient(pgon,
                                                   gt.Pln())).edge_thk = 5
        self.model = model

    def draw(self, frame_count=None):
        with self.devices.panes[0] as p:
            with self.devices.cameras[0] as c:
                p.clear(.5, .5, .5, 1)
                # e = 100
                self.modeler.render()
Exemple #19
0
class MyWindow(Window):
    def __init__(self):
        super().__init__(1000, 1000, 'my window 1', monitor=None, shared=None)
        self.framerate = 60
        # enable camera move
        o = 200
        # self.devices.cameras[0].tripod.lookat(eye=(0, 0, o), at=(0, 0, 0), up=(0, 1, 0))
        self.devices.cameras[0].focus_pane(pane=self.devices.panes[0],
                                           focus=(0, 0, 0),
                                           clip_off=100)

        # create model
        self.modeler = AModeler()
        self.model = self.modeler.add_model(parent=None)
        plns = []
        pw, ph = self.devices.panes[0].size.xy
        n = 6
        nw, nh = pw // n, ph // n
        for x in range(-pw // 2 + nw, pw // 2 - nw + 1, nw):
            for y in range(-ph // 2 + nh, ph // 2 - nh + 1, nh):
                plns.append(gt.Pln(o=(x, y, 0)))
                self.modeler.add_pnt(self.model, x, y,
                                     1).clr = ClrRGBA(1, 1, 0, 1)

        e = 100
        q = e / 4
        h = e / 2
        o = e / 10
        t = e / 3
        pgons = []

        # triangle
        pgons.append(gt.Pgon((0, 0, 0), (e, 0, 0), (0, e, 0), (0, 0, 0)))
        # rectangle
        pgons.append(
            gt.Pgon((0, 0, 0), (e, 0, 0), (e, e, 0), (0, e, 0), (0, 0, 0)))
        # block
        pgons.append(
            gt.Pgon((0, 0, 0), (h, 0, 0), (h, h, 0), (e, h, 0), (e, e, 0),
                    (0, e, 0), (0, 0, 0)))
        # hills
        pgons.append(
            gt.Pgon((0, 0, 0), (e, 0, 0), (e, h, 0), (q * 3, e, 0),
                    (q * 2, h, 0), (q, e, 0), (0, h, 0), (0, 0, 0)))
        # beanie
        pgons.append(
            gt.Pgon((0, 0, 0), (e, 0, 0), (e, h, 0), (q * 3, e, 0), (q, e, 0),
                    (0, h, 0), (0, 0, 0)))
        # cat
        pgons.append(
            gt.Pgon((0, 0, 0), (e, 0, 0), (e, h, 0), (q * 3, e, 0),
                    (q * 3, h, 0), (q, h, 0), (q, e, 0), (0, h, 0), (0, 0, 0)))
        # reverse house
        pgons.append(
            gt.Pgon((h, 0, 0), (e, h, 0), (e, e, 0), (0, e, 0), (0, h, 0),
                    (h, 0, 0)))
        # left dialog
        pgons.append(
            gt.Pgon((q, 0, 0), (h, h, 0), (e, h, 0), (e, e, 0), (0, e, 0),
                    (0, h, 0), (q, 0, 0)))
        # diamond
        pgons.append(
            gt.Pgon((h, 0, 0), (e, h, 0), (h, e, 0), (0, h, 0), (h, 0, 0)))
        # quad triangle
        pgons.append(
            gt.Pgon((h, 0, 0), (e, 0, 0), (h, e, 0), (0, 0, 0), (h, 0, 0)))
        # right dialog
        pgons.append(
            gt.Pgon((3 * q, 0, 0), (e, h, 0), (e, e, 0), (0, e, 0), (0, h, 0),
                    (h, h, 0), (3 * q, 0, 0)))
        # torn paper
        pgons.append(
            gt.Pgon((0, 0, 0), (-q, -q, 0), (0, -q, 0), (e, -q, 0),
                    (e - q, h, 0), (e, e, 0), (-q, e, 0), (0, h + q, 0),
                    (-q, q, 0), (0, 0, 0)))
        # flag right
        pgons.append(
            gt.Pgon((0, 0, 0), (e, 0, 0), (3 * q, h, 0), (e, e, 0), (0, e, 0),
                    (0, 0, 0)))

        # cravas
        pgons.append(
            gt.Pgon((0, 0, 0), (q, h, 0), (h, q, 0), (e, e, 0), (-h, e, 0),
                    (0, 0, 0)))
        # mountain
        pgons.append(
            gt.Pgon((0, 0, 0), (e, 0, 0), (e - q, 2 * q, 0), (e - q, q, 0),
                    (h, 3 * q, 0), (h, 2 * q, 0), (q, e, 0), (0, 0, 0)))
        # bow tie
        pgons.append(
            gt.Pgon((0, 0, 0), (h, q, 0), (e, 0, 0), (e, e, 0), (h, 3 * q, 0),
                    (0, e, 0), (0, 0, 0)))
        # pants
        pgons.append(
            gt.Pgon((0, 0, 0), (q, 0, 0), (h, h, 0), (3 * q, 0, 0), (e, 0, 0),
                    (e, e, 0), (0, e, 0), (0, 0, 0)))
        # bad m
        pgons.append(
            gt.Pgon((0, 0, 0), (q, 0, 0), (q, h, 0), (h, q, 0), (3 * q, h, 0),
                    (3 * q, 0, 0), (e, 0, 0), (e, e, 0), (0, e, 0), (0, 0, 0)))
        # M
        pgons.append(
            gt.Pgon((0, 0, 0), (q, 0, 0), (q, h, 0), (1.5 * q, q, 0),
                    (2.5 * q, q, 0), (3 * q, h, 0), (3 * q, 0, 0), (e, 0, 0),
                    (e, e, 0), (3 * q, e, 0), (2.2 * q, h, 0), (1.8 * q, h, 0),
                    (q, e, 0), (0, e, 0), (0, 0, 0)))
        # N
        pgons.append(
            gt.Pgon((0, 0, 0), (q, 0, 0), (q, h, 0), (3 * q, 0, 0), (e, 0, 0),
                    (e, e, 0), (3 * q, e, 0), (3 * q, h, 0), (q, e, 0),
                    (0, e, 0), (0, 0, 0)))
        # drill
        pgons.append(
            gt.Pgon((h - o, 0, 0), (h + o, 0, 0), (2 * t, h, 0),
                    (2.5 * t, h, 0), (e, h + q, 0), (e, e, 0), (0, e, 0),
                    (0, h + q, 0), (0.5 * t, h, 0), (t, h, 0), (h - o, 0, 0)))
        # gate
        pgons.append(
            gt.Pgon((0, 0, 0), (t, 0, 0), (t, h, 0), (2 * t, h, 0),
                    (2 * t, 0, 0), (e, 0, 0), (e, e, 0), (0, e, 0), (0, 0, 0)))
        # # thin leg
        pgons.append(
            gt.Pgon((0, 0, 0), (t, 0, 0), (t, h, 0), (2 * t, h, 0),
                    (2 * t, 0, 0), (e, e, 0), (0, e, 0), (0, 0, 0)))

        # nepal
        pgons.append(
            gt.Pgon((0, 0, 0), (e, q, 0), (q, h, 0), (3 * q, 3 * q, 0),
                    (0, e, 0), (0, 0, 0)))
        # tick
        pgons.append(
            gt.Pgon((0, 0, 0), (h, h, 0), (0, -h, 0), (-h, 0, 0), (0, 0, 0)))

        for pgon, pln in zip(pgons, plns):
            self.modeler.add_raw(self.model, pln.orient(pgon,
                                                        gt.Pln())).edge_thk = 5

    def draw(self, frame_count=None):
        with self.devices.panes[0] as p:
            with self.devices.cameras[0] as c:
                p.clear(.5, .5, .5, 1)
                self.modeler.render()