pokepetter / ursina

A game engine powered by python and panda3d.
https://pokepetter.github.io/ursina/
MIT License
2.17k stars 328 forks source link

Exception: Error in Mesh. Ensure Mesh is valid and the inputs have same length #713

Open ShivamKR12 opened 3 weeks ago

ShivamKR12 commented 3 weeks ago

PS C:\Users\Shivam\Desktop\voxel 3d\Rally-master> py main.py

Hello from the Rally Server!

warning: Tried to instantiate Entity before Ursina. Please create an instance of Ursina first (app = Ursina()) Traceback(filename='C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\audio.py', lineno=17, function='init', code_context=[' super().init(kwargs)\n'], index=0, positions=Positions(lineno=17, end_lineno=17, col_offset=8, end_col_offset=34)) no audio found with name: /ringtones/clicking.ogg supported formats: .ogg, .wav warning: missing audio clip: /ringtones/clicking.ogg warning: Tried to instantiate Entity before Ursina. Please create an instance of Ursina first (app = Ursina()) Traceback(filename='C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\audio.py', lineno=17, function='init', code_context=[' super().init(kwargs)\n'], index=0, positions=Positions(lineno=17, end_lineno=17, col_offset=8, end_col_offset=34)) no audio found with name: /ringtones/subtle.ogg supported formats: .ogg, .wav warning: missing audio clip: /ringtones/subtle.ogg warning: Tried to instantiate Entity before Ursina. Please create an instance of Ursina first (app = Ursina()) Traceback(filename='C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\audio.py', lineno=17, function='init', code_context=[' super().init(*kwargs)\n'], index=0, positions=Positions(lineno=17, end_lineno=17, col_offset=8, end_col_offset=34)) no audio found with name: /ringtones/uplifting.ogg supported formats: .ogg, .wav warning: missing audio clip: /ringtones/uplifting.ogg warning: Tried to instantiate Entity before Ursina. Please create an instance of Ursina first (app = Ursina()) Traceback(filename='C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\ursinastuff.py', lineno=230, function='call', code_context=[' obj = type.call(cls, args, **kwargs)\n'], index=0, positions=Positions(lineno=230, end_lineno=230, col_offset=14, end_col_offset=49)) info: Using primary monitor: Monitor(x=0, y=0, width=1366, height=768, width_mm=344, height_mm=193, name='\\.\DISPLAY1', is_primary=True) :prc(warning): Invalid integer value for ConfigVariable win-size: 614.4000244140625 :prc(warning): Invalid integer value for ConfigVariable win-size: 1092.800048828125 Known pipe types: wglGraphicsPipe (3 aux display modules not yet loaded.) set window position: Vec2(137, 77) :prc(warning): changing default value for ConfigVariable paste-emit-keystrokes from '1' to '0'. :pnmimage:png(warning): iCCP: known incorrect sRGB profile package_folder: C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina asset_folder: . set fullscreen to True Monitor(x=0, y=0, width=1366, height=768, width_mm=344, height_mm=193, name='\\.\DISPLAY1', is_primary=True) set window position: Vec2(0, 0) ---------------set size to: Vec2(1366, 768) read obj at: assets\cars\sports-car.obj read obj at: assets\cars\sports-car.obj Traceback (most recent call last): :thread(error): Exception occurred within PythonThread PythonThread-0 Traceback (most recent call last): File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\mesh.py", line 90, in _set_array_data File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\mesh.py", line 90, in _set_array_data vmem[:] = a vmem[:] = a


    ~~~~^^^
ValueError: memoryview assignment: lvalue and rvalue have different structures

ValueError: memoryview assignment: lvalue and rvalue have different structures

During handling of the above exception, another exception occurred:
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
Traceback (most recent call last):
  File "C:\Users\Shivam\Desktop\voxel 3d\Rally-master\main.py", line 106, in <module>
  File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\direct\stdpy\thread.py", line 107, in threadFunc      
    car = Car()
          ^^^^^
    function(*args, **kwargs)
  File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\ursinastuff.py", line 230, in __call__
  File "C:\Users\Shivam\Desktop\voxel 3d\Rally-master\main.py", line 95, in load_assets
    obj = type.__call__(cls, *args, **kwargs)
    load_model(m)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\mesh_importer.py", line 79, in load_model      
  File "C:\Users\Shivam\Desktop\voxel 3d\Rally-master\car.py", line 11, in __init__
    m = obj_to_ursinamesh(path=path, name=name, return_mesh=True)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    super().__init__(
  File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\mesh_importer.py", line 375, in obj_to_ursinamesh
  File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\entity.py", line 107, in __init__
    setattr(self, key, kwargs[key])
  File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\entity.py", line 198, in model_setter
    return Mesh(
           ^^^^^
  File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\mesh.py", line 69, in __init__
    m = load_model(value, application.asset_folder)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    self.generate()
  File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\mesh_importer.py", line 79, in load_model      
  File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\mesh.py", line 180, in generate
    m = obj_to_ursinamesh(path=path, name=name, return_mesh=True)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    self._set_array_data(vdata.modify_array(color_attribute_index), self._ravel(self.colors), 'f')
  File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\mesh_importer.py", line 375, in obj_to_ursinamesh
  File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\mesh.py", line 92, in _set_array_data
    return Mesh(
    raise Exception(f'Error in Mesh. Ensure Mesh is valid and the inputs have same length: vertices:{len(self.vertices)}, triangles:{len(self.triangles)}, normals:{len(self.normals)}, colors:{len(self.colors)}, uvs:{len(self.uvs)}')
           ^^^^^
Exception: Error in Mesh. Ensure Mesh is valid and the inputs have same length: vertices:8724, triangles:0, normals:8724, colors:8548, uvs:8724
  File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\mesh.py", line 69, in __init__
    self.generate()
  File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\mesh.py", line 180, in generate
    self._set_array_data(vdata.modify_array(color_attribute_index), self._ravel(self.colors), 'f')
  File "C:\Users\Shivam\AppData\Local\Programs\Python\Python312\Lib\site-packages\ursina\mesh.py", line 92, in _set_array_data
    raise Exception(f'Error in Mesh. Ensure Mesh is valid and the inputs have same length: vertices:{len(self.vertices)}, triangles:{len(self.triangles)}, normals:{len(self.normals)}, colors:{len(self.colors)}, uvs:{len(self.uvs)}')
Exception: Error in Mesh. Ensure Mesh is valid and the inputs have same length: vertices:8724, triangles:0, normals:8724, colors:8548, uvs:8724
PS C:\Users\Shivam\Desktop\voxel 3d\Rally-master> 
ShivamKR12 commented 3 weeks ago

@pokepetter please help man

pokepetter commented 3 weeks ago

How can I reproduce it?

ShivamKR12 commented 3 weeks ago

copy this repo: https://github.com/mandaw2014/Rally

ShivamKR12 commented 3 weeks ago

download all the dependencies. if you use the latest version of ursina, you will get the same error message

ShivamKR12 commented 3 weeks ago

Screenshot 2024-08-21 145850 here's the version that i used

ShivamKR12 commented 3 weeks ago

Screenshot 2024-08-21 150051 Screenshot 2024-08-21 150114 Screenshot 2024-08-21 150129 here's the console message.

ShivamKR12 commented 3 weeks ago

also, is this not a ursina function "render.setShaderAuto()" ?

ShivamKR12 commented 3 weeks ago

@pokepetter but it works for ursina 5.2.0 Screenshot 2024-08-21 151920 Screenshot 2024-08-21 151935

ShivamKR12 commented 3 weeks ago

i have no idea about the version in between.

pokepetter commented 3 weeks ago

The issue is that sports-car.obj has fewer vertex colors than vertices. So the obj is kind of invalid in that sense.

pokepetter commented 3 weeks ago

Looking at the .objs, none of them seems to have been triangulated, which they must be. This is probably the root of the issue.

ShivamKR12 commented 3 weeks ago

@pokepetter if it is the cause , then should we do?

pokepetter commented 3 weeks ago

If you delete the.mtl files, the models will successfully load. They don't seem to be used, but I'm not sure, there could be a small tint to some materials. However, there are other issues with the code, like incorrect variables to Audio and incorrect origin value for text. origin = 0 should be origin = (0,0).

If you could somehow figure out which specific version Rally was made with, and install that, that would work too.