Hi everyone,
I created my terrain with a custom heightmap made in photoshop:
Now I want to put a texture on it! For testing this idea I enlarged the heightmap picture REALLY much and painted a little green on the edge!
When I put it on my terrain it stays black everywhere! So my quick question is:
- Is this method right? Can I just paint the contour of the image and put it on the terrain ??
- Should I change the light?
Here is some of my code:
private void initLight() {
DirectionalLight light = new DirectionalLight();
light.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
light.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, .5f));
light.setDirection(new Vector3f(1, -1, 0));
light.setShadowCaster(true);
light.setEnabled(true);
/** Attach the light to a lightState and the lightState to rootNode. */
LightState lightState = disp.getRenderer().createLightState();
lightState.setEnabled(true);
lightState.setGlobalAmbient(new ColorRGBA(.2f, .2f, .2f, 1f));
lightState.attach(light);
rootNode.setRenderState(lightState);
}
and the TerrainMaker File:
public static TerrainPage buildSampleTerrain(DisplaySystem display) {
RawHeightMap heightMap = new RawHeightMap(Start.class.getClassLoader().getResource(
"data/terrain/heights.raw").getFile(), 513,
RawHeightMap.FORMAT_16BITLE, false);
Vector3f terrainScale = new Vector3f(1.5f, 0.0002f, 1.5f);
heightMap.setHeightScale(0.0001f);
TerrainPage page = new TerrainPage("Terrain", 33, heightMap.getSize(),
terrainScale, heightMap.getHeightMap(), false);
page.setDetailTexture(1, 16);
ProceduralTextureGenerator pt = new ProceduralTextureGenerator(
heightMap);
pt.addTexture(new ImageIcon(TerrainManager.class.getClassLoader()
.getResource("data/terrain/unbenannt2.png")), -128, 0, 128);
pt.createTexture(512);
TextureState ts = display.getRenderer().createTextureState();
ts.setEnabled(true);
Texture t1 = TextureManager.loadTexture(pt.getImageIcon().getImage(),
Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR, true);
ts.setTexture(t1, 0);
page.setRenderState(ts);
return page;
}
So I am happy for any quick responses ;)
Thanks Rapidm