Hello I am new at this forum so i apologize if there is topic like this, but i didnt find it.
I am using RawHeightMap and i want to put some texture on it just like on imageBasedHeightMap.
I have this code:
private void complexTerrain() {
// This grayscale image will be our terrain
RawHeightMap heightMap = new RawHeightMap(Terrain.class
.getClassLoader().getResource(
"jmetest/data/texture/mapa1.raw"),
128, RawHeightMap.FORMAT_16BITLE, false);
heightMap.setHeightScale(0.001f);
Vector3f terrainScale = new Vector3f(1, 0.003f, 1);
TerrainBlock tb = new TerrainBlock("Terrain", heightMap.getSize(), terrainScale,
heightMap.getHeightMap(), new Vector3f(0, 0, 0), false);
tb.setLocalTranslation(new Vector3f(0, -150, 0));
tb.setDetailTexture(1, 16);
ProceduralTextureGenerator pt = new ProceduralTextureGenerator(heightMap);
pt.addTexture(new ImageIcon(Terrain.class.getClassLoader().getResource(
"jmetest/data/texture/grass.jpg")), -128, 0, 128);
pt.addTexture(new ImageIcon(Terrain.class.getClassLoader().getResource(
"jmetest/data/texture/dirt.jpg")), 0, 128, 255);
pt.addTexture(new ImageIcon(Terrain.class.getClassLoader().getResource(
"jmetest/data/texture/highest.jpg")), 128, 255, 384);
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);
Texture t2 = TextureManager.loadTexture(Terrain.class.getClassLoader().
getResource(
"jmetest/data/texture/Detail.jpg"),
Texture.MM_LINEAR_LINEAR,
Texture.FM_LINEAR);
ts.setTexture(t2, 1);
t2.setWrap(Texture.WM_WRAP_S_WRAP_T);
t1.setApply(Texture.AM_COMBINE);
t1.setCombineFuncRGB(Texture.ACF_MODULATE);
t1.setCombineSrc0RGB(Texture.ACS_TEXTURE);
t1.setCombineOp0RGB(Texture.ACO_SRC_COLOR);
t1.setCombineSrc1RGB(Texture.ACS_PRIMARY_COLOR);
t1.setCombineOp1RGB(Texture.ACO_SRC_COLOR);
t1.setCombineScaleRGB(1.0f);
t2.setApply(Texture.AM_COMBINE);
t2.setCombineFuncRGB(Texture.ACF_ADD_SIGNED);
t2.setCombineSrc0RGB(Texture.ACS_TEXTURE);
t2.setCombineOp0RGB(Texture.ACO_SRC_COLOR);
t2.setCombineSrc1RGB(Texture.ACS_PREVIOUS);
t2.setCombineOp1RGB(Texture.ACO_SRC_COLOR);
t2.setCombineScaleRGB(1.0f);
tb.setRenderState(ts);
FogState fs = display.getRenderer().createFogState();
fs.setDensity(0.5f);
fs.setEnabled(true);
fs.setColor(new ColorRGBA(0.5f, 0.5f, 0.5f, 0.5f));
fs.setEnd(1000);
fs.setStart(500);
fs.setDensityFunction(FogState.DF_LINEAR);
fs.setApplyFunction(FogState.AF_PER_VERTEX);
tb.setRenderState(fs);
rootNode.attachChild(tb);
}
And result is this: http://www.stud.fit.vutbr.cz/~xhacaj00/map.jpg
It is grayscale and pretty dark.
And when i set localTranslation to 0,0,0 its position is aprox. 0,200,0... Why?
Thanks for all replies...
PS: sorry for my english... i am from slovak rep..