Subimage? question

So I have a texture atlas…right now it’s 7x7, loads fine, looks beautiful on textured objects.


I need to be able to extract out each texture image in the atlas and display the sub-image in a Picture - just the picture texture, no need to see it with bump mapping or anything. I can get to the overall combined Image (.getImage()) but I have no idea how to get a part of that image. Is it possible?

For what you need a subimage? basically you modify the uv values of the model so only a part of the atlas is used.

I got that covered. Textures work on the models, everything is fine. The issue is that I want to display each subtexture in a Picture, and the image for a Picture can only be set using the assetManager…as far as I know.

I really don’t want to duplicate the texture atlas as the individual textures. There’s got to be some way to extract out a sub-image or sub-texture but I’m new to the engine and this isn’t quite as obvious as the rest of what I’ve needed to learn.

Well you can use the SetMaterial as well since it is a Geometry,

basically you have two options here:

make a own material that uses a simple shader to select the texture you want from the atlas (aka give it the start and endpoint)

Second option is the get the bytearray then depening on the foramt you know for example that

4 bytes per color channel, and (rgb8) and no apha exist

you also know the size of the texture.

now you can generate your own bytearray with only the pixels you want to keep.

and set up a texture properly in the last step, after this you use a modified version of the setTexutre from Picture (take a look at it, then you see what to do) an apply the new Image to it.

I gave up and cheated. I create a quad in guiNode space, texture it with the subtexture, and move it to wherever I need it. Bit of a cheat, but it works.