io_scene_b3d: Materials are exported in the wrong order

Post Reply
User avatar
Mr. Rar
Member
Posts: 109
Joined: Tue Oct 04, 2016 20:13
GitHub: MrRar
In-game: MrRar

io_scene_b3d: Materials are exported in the wrong order

by Mr. Rar » Post

I'm using Blender 2.83
I use this exporter: https://github.com/GreenXenith/io_scene_b3d
I created an issue: https://github.com/GreenXenith/io_scene_b3d/issues/10
I think it also affects (it has the same bad code): https://github.com/minetest/B3DExport

The exporter iterates through the mesh and outputs materials as they are found used on polygons. So the material assigned to the first created polygon will be first to be listed in the B3D file. The exporter goes from oldest polygon to newest polygon finding materials.

The exporter should instead get the list of materials on the mesh and output those in order.

The order of materials is very important because Irrlicht works on material indices not material names.

The relevant function in the exporter is: write_brus

I found a workaround that worked for me:
It is possible to move a material to last in the list. Go to edit mode. Press A then A on the keyboard to deselect everything. Select the material and press select to select all polygons assigned to the material. Then press Mesh->Separate->Selection to create a new object from the selected polygons. Go to object mode. Drag the new object on top of the old object while pressing shift and drop it. This will parent the new object to the old object. Then select the old object and the new object and press Ctrl+J to join the objects back together.
"Only in Christ do we find real love, and the fullness of life. And so I invite you today to look to Christ." - St. John Paul II

User avatar
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: io_scene_b3d: Materials are exported in the wrong order

by Nathan.S » Post

Interesting. I use Blender 2.93.5 when exporting .b3d as newer versions the animation breaks, and the materials all work correctly for me. To be fair I've only made some changes to the player model and a few animated entities. Anything that isn't animated I stick to .obj
Can you try Blender 2.93.5 and see if that solves your problem, or is 2.83 the latest you computer can run.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
Mr. Rar
Member
Posts: 109
Joined: Tue Oct 04, 2016 20:13
GitHub: MrRar
In-game: MrRar

Re: io_scene_b3d: Materials are exported in the wrong order

by Mr. Rar » Post

Nathan.S wrote:
Thu Aug 04, 2022 01:59
Interesting. I use Blender 2.93.5 when exporting .b3d as newer versions the animation breaks, and the materials all work correctly for me. To be fair I've only made some changes to the player model and a few animated entities. Anything that isn't animated I stick to .obj
Can you try Blender 2.93.5 and see if that solves your problem, or is 2.83 the latest you computer can run.
I hadn't tested Blender 2.93.5 and it does not have the bones problem. I want to use the newest Blender that works with the exporter so I will now use 2.93.5. Previously I tried 2.92 and it did not work: viewtopic.php?f=47&t=28211

However 2.93.5 still has the same materials exported out of order bug. You can tell the material names are out of order just by opening the file in text/hex editor. The material names appear at the top of the file in order. I even made a test mod so you can see I am not lying: https://github.com/MrRar/b3d_problem
Boxes should display top to bottom RGB and they are out of order.
"Only in Christ do we find real love, and the fullness of life. And so I invite you today to look to Christ." - St. John Paul II

User avatar
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: io_scene_b3d: Materials are exported in the wrong order

by Nathan.S » Post

Yep, it's not just you. I tried out that mod, checked out the blend file, and even exported at .b3d myself, same issue you see I see. exporting as obj it works just fine, so definitely a problem with the .b3d exporter
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: io_scene_b3d: Materials are exported in the wrong order

by GreenXenith » Post

This has been a known issue for a very long time (like you said, it affects all exporter implementations). It's probably an issue ill fix in a rewrite (in progress).

In case anyone wonders, progress is slow on the addon mostly because I don't have a ton of time to put towards it, and I'd also like to encourage Minetest to support GLTF or Collada.
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests