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()
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 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__(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)