Page 1 of 1

Mesh node with multiple textures not working

Posted: Tue Aug 06, 2019 05:12
by Blockhead
Hi! I am trying to create a custom signal set for advtrains based on the Victorian 3-position speed signalling system. These signals have 2 lamps, one atop the other:

Image

I have copied the general idea of the ks signal set, which has one mesh but multiple textures applied. This works fine for the ks main signal, but I can't figure out how to make it work for mine!

The textures are applied correctly in Blender and UV-unwrapped. Important note: I am using Blender 2.8. There are 3 materials: one for each light, and currently they are three different meshes. I have tried them as one mesh with three materials and as three meshes with one material each. The settings are similar for each:

Image

Screenshot blender UV wrapping and material setup

I then export to .obj which I understand minetest (i.e. irrlicht) is supposed to support, but I find that the same texture is applied to all three components. Is a custom export plugin required? I had tried the b3d exporter python script for 2.79 (yes, with 2.79 installed) but it didn't appear in the export menu - regardless, obj should work.

In lua, the textures are defined as a table of 3 textures as property 'tiles' (code excerpt):

Code: Select all

	...
	RY = {
		asp = {
			main = {free = true, speed = 40},
			dst = {free = false},
			shunt = {free = false}
		},
		tex = {"vss_3pos-texture.png", "vss_lampred.png", "vss_lampyellow.png"}
	}
}) do
	minetest.register_node("vss:home_"..signalType --[[.."_"..rot--]], {
		description = "Victorian Home Signal ("..signalType..")",
		drawtype = "mesh",
		mesh = "threepos-home.obj",
		tiles = siginf.tex,
	...
This does not work for some reason that I do not understand - because the ks signal set uses the same property 'tiles' and it works just fine! Instead the same texture is applied to the 3 meshes:
Image

Can someone with more expertise please let me know what I'm doing wrong?

Re: Mesh node with multiple textures not working

Posted: Tue Aug 06, 2019 05:58
by GreenXenith
Without looking at the files (I don't have time at the moment), it looks like you need to export material groups.
Your .obj export settings should look like this:
Image
Default values with Write Materials unchecked (because it just generates a usually useless file) and Material Groups checked. This should use all the material slots.

Once this is done, you may need to swap around the textures in the table to get them in the right spot - they don't like to follow the list order.

Re: Mesh node with multiple textures not working

Posted: Tue Aug 06, 2019 07:07
by Blockhead
Thank you very much! I hadn't seen the export options. They are in the bottom left of the file save dialogue in Blender 2.8. After checking the box the textures applied in a funny order; I simply had to re-arrange their orders and everything worked perfectly (ok, except for a minor UV unwrapping issue which was easy).

Image

Edit: If someone can please add this to the developer wiki page (so I don't have to register there) - it's not mentioned anywhere but it's very important.