且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么我不能将 .OBJ 文件加载到 Python Ursina 中?

更新时间:2023-01-03 14:42:07

问题是三角测量.模型面只能是三角形.您可以在 Blender 或其他此类 3d 软件中执行此操作.感谢 Github 上的 Pokepetter,我在这个问题上获得了这些信息.

例如,考虑使用 Blender 或其他类似软件来创建您的模型,并在网格上使用 triangulate 修改器,使其与 Ursina Engine 兼容.>

I am using the python Ursina engine. I want to import a .OBJ file, but it never works, yet no errors are raised. I have tried:

from ursina import *
from ursina.mesh_importer import *

app = Ursina()

model123 = load_model('model123.obj')
model123Entity = Entity(model=model123)
    
def update():
    move()

EditorCamera()
app.run()

I have also tried it without the .obj ending. Any help?

I have now tried:

from ursina import *
from ursina.mesh_importer import *

app = Ursina()

model123 = load_model(obj_to_ursinamesh('model123.obj'))
model123_Entity = Entity(model=model123)

app.run()

I get the error:

AttributeError: 'str' object has no attribute 'glob'
AL lib: (EE) ALCwasapiPlayback_mixerProc: WaitForSingleObjectEx error: 0x102

The issue is triangulation. The models faces must only be triangles. You can do this in Blender or other 3d software of that such type. I got this information thanks to Pokepetter on Github, at this issue.

For example, consider using Blender, or other software similar, to create your models and use the triangulate modifier on meshes to make them compatible with Ursina Engine.