-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rmodels] OBJ models with multiple materials/meshes not loading correctly #3576
Comments
@njegg OBJ loading was redesigned due to other issues when mixing different number of materials and meshes. It probably needs another redesign. |
Model loading breaks when calling
|
Le voy a tirar un ojo ! |
I have the same issue. My OBJ models are exported from Blender triangulated - the else statement here is the issue - the tri count is actually an offset when there are two or more models in the same file: Lines 4070 to 4076 in dc7f81a
Here's an example - it crashes the demo here too - https://www.raylib.com/examples/models/loader.html?name=models_loading My fix is to use the length (despite the comment) warning about quads else tris = meshes[i].length; |
Hello |
I had a similar issue, and the above code by BobSleigh38 didn't work for me with the materials not being set properly to the meshes. What I did was just export in Blender as a .glb file instead of an .obj file (so this isn't really a fix to this issue, rather a workaround). When I initially did this however, all my meshes were centered at (0,0,0) and with normalized scales, so my fix was just to select all the objects in Blender (A), and apply the transforms by pressing Ctrl+A and selecting All Transforms like so: |
If it helps anyone else, for OBJ model loaded I ended up using this single file library to load OBJ models into raylib: https://github.com/Not-Nik/rlobj Not sure the author would agree to swapping it out, but for anything more complicated than a single object it's required |
The license for rlobj is a bit sketchy. There is a statement about an exception at the repository but there is no such statement in the license document itself. The exception is also for (indirectly-)named individuals, not arbitrary users of raylib. I'm not sure it could even be incorporated here as an external. |
@x1nixmzeng, @orcmid is right, the license does not seem to be compatible with raylib. |
Is there any progress being done on this? |
The OBJ format is broken for any file that uses multiple materials. Making it as a format in the current state useless. |
I have written a new LoadOBJ in this branch. It till needs massive testing and Debugging. |
I literally just ran into this issue after trying to load an .obj file I created in Blender. Very interested in what you're doing, @JeffM2501 ! In the mean time maybe I should try to convert my .obj files to gltx or some other supported function? |
Yes use glb when possible, obj is an old and fragile format. |
I'm closing this issue, feel free to send a PR when ready for further discussion there. |
I’m eager to try material exports from blender. .gltf does not look reasonable in naylib. I’m using a icosphere at level 5 (I think 5 is highest you can go, I tried 10 and I had to kill my blender. Currently I only have one material… |
Issue description
I have a model made in blender with multiple meshes and materials that load correctly in raylib 4.5, but after updating to 5.0 everything is in one material. I have provided a minimal example with a simple 2 mesh/material model.
Environment
Tried on multiple machines and operating systems
Issue Screenshot
4.5
master/5.0
Code Example
model.zip
The text was updated successfully, but these errors were encountered: