forked from nobuyuki83/python_graphics_demos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_loadobj_polygon_mesh.py
More file actions
29 lines (22 loc) · 907 Bytes
/
03_loadobj_polygon_mesh.py
File metadata and controls
29 lines (22 loc) · 907 Bytes
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
import typing
from pathlib import Path
import moderngl
from PyQt5 import QtWidgets
from util_moderngl_qt import DrawerMesh, QGLWidgetViewer3
from del_msh import WavefrontObj
if __name__ == "__main__":
# newpath = Path('.') / 'asset' / 'HorseSwap.obj'
newpath = Path('.') / 'asset' / 'Babi' / 'Babi.obj'
obj = WavefrontObj.load(str(newpath), is_centerize=True, normalized_size=1.8)
edge2vtx = obj.edge2vtxxyz()
tri2vtx = obj.tri2vtxxyz()
with QtWidgets.QApplication([]) as app:
drawer = DrawerMesh.Drawer(
vtx2xyz=obj.vtxxyz2xyz,
list_elem2vtx=[
DrawerMesh.ElementInfo(index=edge2vtx, color=(0, 0, 0), mode=moderngl.LINES),
DrawerMesh.ElementInfo(index=tri2vtx, color=(1, 1, 1), mode=moderngl.TRIANGLES)]
)
win = QGLWidgetViewer3.QtGLWidget_Viewer3([drawer])
win.show()
app.exec()