pyrender
pyrender copied to clipboard
TypeError: Expected a Trimesh or a list, got a <class 'trimesh.scene.scene.Scene'>
Hi, I'm getting a TypeError: Expected a Trimesh or a list, got a <class 'trimesh.scene.scene.Scene'> when importing a .glb file. Is there any way to go around this?
import trimesh
import pyrender
fuz_trimesh = trimesh.load("donut_calibrate2_forgltf.glb")
mesh = pyrender.Mesh.from_trimesh(fuz_trimesh)
Hey, GLB can contain multiple geometries and a scene graph, so the return type is a trimesh.Scene to contain that information. If you run the pyrender scene conversion it should work:
pyrender.Scene.from_trimesh_scene(fuz_trimesh)
There are a few formats that can return a Scene OR a Trimesh (OBJ), it might be nice someday to have something like pyrender.utils.from_trimesh that could handle any input.
Thanks and yes. Just tried again, it was able to convert scene. But then it's getting another error.
scene = pyrender.Scene()
scene.add(mesh)
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python36\lib\site-packages\pyrender\scene.py", line 286, in add
raise TypeError('Unrecognized object type')
TypeError: Unrecognized object type
Hmm, is it able to import armature?
I think you want:
scene = pyrender.Scene.from_trimesh_scene(fuz_trimesh)
 ̄□ ̄| | Thank you. Another question: I'm trying to visualize animation clip by pyrender.Viewer(scene, use_raymond_lighting=True, run_in_thread=True) Then got error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Exception in thread Thread-5:
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Program Files\Python36\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "C:\Program Files\Python36\lib\site-packages\pyrender\viewer.py", line 997, in _init_and_start_app
height=self._viewport_size[1])
File "C:\Program Files\Python36\lib\site-packages\pyglet\window\win32\__init__.py", line 137, in __init__
super(Win32Window, self).__init__(*args, **kwargs)
File "C:\Program Files\Python36\lib\site-packages\pyglet\window\__init__.py", line 592, in __init__
config = screen.get_best_config(config)
File "C:\Program Files\Python36\lib\site-packages\pyglet\canvas\base.py", line 195, in get_best_config
configs = self.get_matching_configs(template)
File "C:\Program Files\Python36\lib\site-packages\pyglet\canvas\win32.py", line 67, in get_matching_configs
configs = template.match(canvas)
File "C:\Program Files\Python36\lib\site-packages\pyglet\gl\win32.py", line 58, in match
return self._get_arb_pixel_format_matching_configs(canvas)
File "C:\Program Files\Python36\lib\site-packages\pyglet\gl\win32.py", line 129, in _get_arb_pixel_format_matching_configs
wglext_arb.wglChoosePixelFormatARB(canvas.hdc, attrs, None, nformats, pformats, nformats)
File "C:\Program Files\Python36\lib\site-packages\pyglet\gl\lib.py", line 63, in MissingFunction
raise MissingFunctionException(name, requires, suggestions)
pyglet.gl.lib.MissingFunctionException: wglChoosePixelFormatARB is not exported by the available OpenGL driver. ARB_pixel_format is required for this functionality.
File "C:\Program Files\Python36\lib\site-packages\pyglet\window\__init__.py", line 661, in __repr__
(self.__class__.__name__, self.width, self.height)
TypeError: %d format: a number is required, not NoneType
same problem, is this fixed?
same problem, is this fixed?
You can create a list to load all elements in the trimesh.geometry.values() and add them into scene one by one
import trimesh import pyrender fuz_trimesh = trimesh.load("donut_calibrate2_forgltf.glb") mesh = pyrender.Mesh.from_trimesh(fuz_trimesh)
In the line 3 if you want to force it to return a Mesh object, instead of a scene object try to use 'force' option of .load() method. Example: fuz_trimesh = trimesh.load("donut_calibrate2_forgltf.glb", force='mesh')
There are other force options inside this method. you can look into the documentation for detailed info.
This does not work.
I have the same problem when loading a .ply file.