Monday, 11 January 2021

How to draw a .obj file in pyqtgraph?

This line of code renders a line.

import pywavefront
import pyqtgraph.opengl as gl
from pyqtgraph.Qt import QtWidgets
import numpy as np
import sys

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    w = gl.GLViewWidget()

    xx = 0
    yx = 0
    zx = 0

    xy = 1
    yy = 0
    zy = 0

    Xdot = (xx, yx, zx)
    Ydot = (xy, yy, zy)

    pts = np.array([Xdot, Ydot])
    sh1 = gl.GLLinePlotItem(pos=pts, width=1, antialias=False)
    w.addItem(sh1)
    w.show()
    app.exec()

How can I have pyqtgraph render an .obj file? Adding the lines below

scene = pywavefront.Wavefront('./mogaze/meshfiles/cup.obj',create_materials=True)
w.addItem(scene)

return the error

QWindowsContext: OleInitialize() failed:  "COM error 0xffffffff80010106 RPC_E_CHANGED_MODE (Unknown error 0x080010106)"
Unimplemented OBJ format statement 's' on line 's 1'
Traceback (most recent call last):
  File "draw-human-objects-pred.py", line 137, in <module>
    w.addItem(scene)
  File "C:\Users\ha_ha\anaconda3\envs\pywavefront\lib\site-packages\pyqtgraph\opengl\GLViewWidget.py", line 64, in addItem
    item._setView(self)
AttributeError: 'Wavefront' object has no attribute '_setView'


from How to draw a .obj file in pyqtgraph?

No comments:

Post a Comment