mandaw2014 / Rally

A Simple Racing Game Made In Python With The Ursina Engine
https://mandaw2014.itch.io/rally
MIT License
51 stars 20 forks source link

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

Open ShivamKR12 opened 2 months ago

ShivamKR12 commented 2 months 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 2 months ago

EXPLATION BY CHATGPT :

warning: Tried to instantiate Entity before Ursina. Please create an instance of Ursina first (app = Ursina()):

This indicates that you're trying to create an Entity object before initializing the Ursina application instance. Ursina requires that you first create an instance of Ursina using app = Ursina() before creating other entities. Ensure that your code follows this order. no audio found with name: ...:

This warning suggests that the audio files referenced in your project are not found at the specified paths. Ensure that the audio files (clicking.ogg, subtle.ogg, uplifting.ogg) are correctly placed in the ringtones folder and that the paths in your code are correct. Exception: Error in Mesh. Ensure Mesh is valid and the inputs have same length:

This is a critical error indicating that there’s an issue with the mesh data being loaded. Specifically, the error message details a mismatch between the number of vertices, triangles, normals, colors, and UVs:

Vertices: 8724 Triangles: 0 Normals: 8724 Colors: 8548 UVs: 8724 This means that the mesh data being loaded has inconsistent lengths for these attributes. For a mesh to be valid, all attributes (vertices, triangles, normals, colors, UVs) must have compatible lengths. If they don’t, the mesh cannot be properly constructed.

ShivamKR12 commented 2 months ago

@mandaw2014 please help man

ShivamKR12 commented 2 months ago

it gives these errors when using ursina 7.0.0 Screenshot 2024-08-21 150051 Screenshot 2024-08-21 150114 Screenshot 2024-08-21 150129

ShivamKR12 commented 2 months ago

but it works almost fine with ursina 5.2.0 Screenshot 2024-08-21 151920 Screenshot 2024-08-21 151935

ShivamKR12 commented 2 months ago

i have no idea about the versions in between

ShivamKR12 commented 2 months ago

here's what pokepetter had to say about it: https://github.com/pokepetter/ursina/issues/713#issuecomment-2301759817 https://github.com/pokepetter/ursina/issues/713#issuecomment-2301742797