I'm trying to move from individual textures to using a texture atlas for my boxes (they all show individual letters for a Scrabble-like game). I'm stuck with this, all the examples I find are for 2D sprites.
How do I create and assign the material to a 3D surface with the right mapping coordinates from an AtlasRegion?
public void createModelInstance(TextureAtlas letterAtlas) {
AtlasRegion region = letterAtlas.findRegion(this.textureID);
Material mat = new Material(???);
modelInstance = new ModelInstance(modelTile);
modelInstance.nodes.get(0).parts.get(0).material.set(mat);
}
When used individual files for each texture this worked:
Material mat = new Material(TextureAttribute.createDiffuse(
assetManager.get("textures/" + textureFile, Texture.class));
The surface is created:
MeshPartBuilder tileBuilder;
tileBuilder = modelBuilder.part("top", GL10.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.TextureCoordinates, new Material(ColorAttribute.createDiffuse(Color.WHITE)));
tileBuilder.rect(-0.45f, 0.1f, 0.45f, 0.45f, 0.1f, 0.45f, 0.45f, 0.1f, -0.45f, -0.45f, 0.1f, -0.45f, 0f, 1f, 0f);
...