The main cause of trouble I had with this prototype was figuring out how to edit a texture that was loaded from a file in jME3. Google showed me this forum post for how to fill in the texture data from scratch, but I had to figure out how to start with a texture I'd loaded from a .png. Here's the solution I came up with. I'm putting it here in the hopes that it helps someone in the future. I added this function to the class I found in the link above:
// tex is a texture I loaded from a file
public void setTexture(Texture tex)
{
// store the loaded texture in the class
texture = (Texture2D) tex;
// I don't want any filtering on this texture
texture.setMagFilter(MagFilter.Nearest);
// grab the image that actually holds the texture data
image = texture.getImage();
// Image holds a list of ByteBuffers for each mip level
// loop through the buffer to fill out the array
ByteBuffer buffer = image.getData(0);
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
// the texture loaded from PNG in the format BGR8,
// so I have to index into the byte buffer using 3 bytes
// per pixel in BGR order
buffer.position(((y * width) + x) * 3);
// this seems to be the best way to preserve byte
// values when assigning byte to int in Java
// because bytes are signed
int b = (int) buffer.get() & 0xff;
int g = (int) buffer.get() & 0xff;
int r = (int) buffer.get() & 0xff;
Color c = new Color(r, g, b, r);
setPixel(x, y, c);
}
}
// set the image format to what you want before creating
// a new when getTexture() gets called
image.setFormat(Image.Format.RGBA8);
}