Change the UVMap of an imported geometry

Hi! I want to change the UVMap of a geometry ingame, but I don’t find where I can change it.

I have a textureAtlas:

And two UVMaps in Blender:

  • The first UV (named UV1) make my cube look like this:


  • And the second (named UV2):


When I load the .blend and convet it to .j3o, it appear with the UV1. Now I want to change the UV used. Where I can find this? I look into the geometry:


But it only has one buffer with the type TexCoord:

VertexBuffer[fmt=Float, type=TexCoord, usage=Static, elements=12]

Is there a way to change the UVMap of a geometry easily (maybe make the blender loader load both texCoord buffers)?

If you have multiple UV maps in blender, when importing to JME it will just import one UV map.
You can get what you want in this way :
You can change the texture by changing it in material parameter :
You need to first Get material from your geometry

Material yourMaterial=yourGeometry.getMaterial();

then change texture as you want

yourMaterial.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Red.jpg"));

the next time change it to


Edit: Red and Green textures should be separate.

1 Like

Yeah, that’s one solution, but what I want is to have one pre-made texture atlas (not a texture atlas made in-game).

Isn’t there another way to do this using a static texture atlas?

Well jme does support multiple uv maps, so it might just be a problem with the importer doing not.

Anyway at least for block it would be strange to not generate them yourself in code. (If you do more complex models i would understand more)

JME3 supports up to 8 different uv maps (texCoord, texCoord2,…, texCoord8)
However only the lighting.j3md material uses this feature, and in a verylimited way. Only the light map support the use of a secondary uv map, so it won’t help you there.

If you want to switch uv map, you’ll have to do your own shader. Start with unshaded, and just use the inTexCoord, inTexCoord2 and switch from one to another using a material parameter.

Of course, the block is just an example.

In this case… do you know how to fix it? I’ve been looking at but I can’t see anything.

The problem isn’t if it supports it or not, the problem is that the texCoord buffers aren’t loading. I’ve configured two UVs on blender but when loading only the first UV is loading (the mesh only have one texCoord buffer). If the buffers aren’t there, I can’t use them :S.
I configure them like:


Ok I didn’t understand that.
If you are using the Blender loader, I guess @Kaelthas could possibly help you

You could just load it multiple times (one for each version) in some kind of preimporter you write yourself, then merge them together before saving as j3o.

Ok, thanks :smile: I’ll wait for @Kaelthas (In the meantime I’ll try to fix it myself, if I success I’ll feedback)

1 Like

Hi @Xelun

the blender importer will import only the first available UV coordinates set if you have the texture applied.
However if you have no textures but you defined UV coordinates - then the buffers of user defined UV’s will be added to the mesh (I think there was such a request long time ago :slight_smile: )

If you want I could just add a buffer of each user’s UV coords set to the mesh (up to 8 buffers of course).

Well, If it isn’t to much annoyance, it would help me a lot as I would like to set the Texture Atlas on Blender and use the multiple UV buffers.

Thanks so much!

I have just commited the change. Please let me know if everything works when you have it in your code :wink:

1 Like