Hi,
after a long time of doing nothing with jme, I am working now on a level editor and therefor on terrain editing. I made a simple app so far in which you can raise/lower the terrain by clicking into it. For doing so, I initialize height data as a float array with 0-values. This I put into a SimpleHeightMap which extends AbstractHeightMap (see below). When I am using ProceduralTextureGenerator now, it seems that it only uses one texture I choose (applying textures is done via a swing gui). It is the texture I choose for being around minimum height of 0. If I set the minimum height to 1, the generated texture becomes black. As I said, only one texture is applied in the generator at once, though I checked, that it acutally takes both textures in account, but I can’t see both. ← I hope I made my point somewhat understandable…
I think it the problem could be my implementation of AbstractHeightMap and the values of the heightData in it, but the values I printed out in the console seem to be right (between 0.0 and 200.0 or something, negative values also possible).
Here is my SimpleHeightMap:
public class SimpleHeightMap extends AbstractHeightMap {
public SimpleHeightMap(float[] heightData) {
this.heightData = new float[heightData.length];
for (int i = 0; i < heightData.length; i++)
this.heightData = heightData * 10;
load();
}
@Override
public boolean load() {
return true;
}
}
and here is where the textures are combined and the generator creates the texture (Tupel is a class similar to pair in C++, the int[] values are the minimum, best and maximum values, nothing is wrong with that):
if (generate) {
if (SceneManager.getInstance().getTerrain() != null) {
TerrainBlock terrain = SceneManager.getInstance().getTerrain();
SimpleHeightMap sm = new SimpleHeightMap(terrain.getHeightMap());
ProceduralTextureGenerator pg = new ProceduralTextureGenerator(sm);
for (Tupel<ImageIcon, int[]> texProp : terrainTexProps) {
pg.addTexture(texProp.first(), texProp.second()[0], texProp
.second()[1], texProp.second()[2]);
}
pg.createTexture(1024);
TextureState ts = DisplaySystem.getDisplaySystem()
.getRenderer().createTextureState();
ts.setTexture(TextureManager.loadTexture(pg.getImageIcon()
.getImage(), Texture.MinificationFilter.Trilinear,
Texture.MagnificationFilter.Bilinear, true));
terrain.setRenderState(ts);
terrain.updateRenderState();
}
}
I probably do not understand the whole thing properly…
hmmm… the code-tag swallows brackets
Tupel is a pair of ImageIcon and int[]