-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path02_mesh_primitive.py
34 lines (28 loc) · 1.19 KB
/
02_mesh_primitive.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import moderngl
from PyQt5 import QtWidgets
from util_moderngl_qt import DrawerMesh, QGLWidgetViewer3
from del_msh import TriMesh
def draw_mesh(tri2vtx, vtx2xyz):
edge2vtx = TriMesh.edge2vtx(tri2vtx=tri2vtx, num_vtx=vtx2xyz.shape[0])
with QtWidgets.QApplication([]) as app:
drawer = DrawerMesh.Drawer(
vtx2xyz=vtx2xyz,
list_elem2vtx=[
DrawerMesh.ElementInfo(index=tri2vtx, color=(1, 0, 0), mode=moderngl.TRIANGLES),
DrawerMesh.ElementInfo(index=edge2vtx, color=(0, 0, 0), mode=moderngl.LINES)]
)
win = QGLWidgetViewer3.QtGLWidget_Viewer3([drawer])
win.show()
app.exec()
if __name__ == "__main__":
'''
from util_moderngl_qt import primitive_shapes
draw_mesh(*primitive_shapes.sphere(radius=1.0, n_longtitude=8, n_latitude=16))
draw_mesh(*primitive_shapes.cylinder(radius=1.0))
'''
#
draw_mesh(*TriMesh.hemisphere(radius=1.0, ndiv_longtitude=8))
draw_mesh(*TriMesh.torus(major_radius=0.4, minor_radius=0.2))
draw_mesh(*TriMesh.capsule(radius=0.1, height=1.2, ndiv_longtitude=8))
draw_mesh(*TriMesh.cylinder(radius=0.3, height=1.2))
draw_mesh(*TriMesh.sphere(radius=1.0))