I’m trying to create a texture, but in the end it is just black.
[java]
data = ByteBuffer.allocateDirect(sizesize12); // x * y * 12 bytes (3 floats)
for(int x = 0; x < size; x++)
{
for(int y = 0; y < size; y++)
{
float value = (float)perlin.getValue(x, y, 0);
data.putFloat(value); // R
data.putFloat(value); // G
data.putFloat(value); // B
}
}
//data.flip();
image = new Image(Image.Format.RGB8, size, size, data);[/java]
Have you took a look atht he image painter stuff?
It has swing like seters for pixel colors. You can either use it, or look how it does the manipulations.
Image.Format.RGB8 specifies an 8 bit per channel - of which there are 3 (R,G,B) - format. 8 bit represent a byte.
A float commonly is 4 bytes in size, thus the image wont take the values from the correct index in the buffer.
You would need to scale your perlin result into the range of 0…255 and store that as byte rather than as float for its corresponding channel in order to work I’d say.
Hi,
Like Empire suggested, I recommend using the ImageRaster class. For an example you can see how I use it here: http://hub.jmonkeyengine.org/forum/topic/gpu-improved-perlin-noise/
Good luck.