But, the terrain not accompanying the material, if I work with a terrainPhysicsNod???
The physics system does not use the material, but is based off of the geometry. And specifically in the case of Terrain, physics uses the heightmap to create its physics shape.
So what you need to do to smooth the terrain more, is to smooth out the initial heightmap image you are using.
You can do that by using a gaussian blur in an image editor. I’ve blurred it for you here, give it a try:
Finally I understood what is the Gaussian Blur.
But my big doubt, is why in the example
TestWalkingChar.java
the ground is soft with simple and known heightmap / mountains512.png ???
^^
*is smooth
because this same example of heightmap, is very rectangular when applied as a simple heightmap.
mountains512.png is blurred together nicely, while your heightmap image is quite grainy. That causes the sharp edges and ledges.
Ok, Just tell me where is the secret in this code, because no matter how grainy is the heightmap, it leaves very smoothing when I run the application.
look the code:
[java] private void createTerrain() {
matRock = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
matRock.setBoolean("useTriPlanarMapping", false);
matRock.setBoolean("WardIso", true);
matRock.setTexture("AlphaMap", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
matRock.setTexture("DiffuseMap", grass);
matRock.setFloat("DiffuseMap_0_scale", 64);
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
dirt.setWrap(WrapMode.Repeat);
matRock.setTexture("DiffuseMap_1", dirt);
matRock.setFloat("DiffuseMap_1_scale", 16);
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
rock.setWrap(WrapMode.Repeat);
matRock.setTexture("DiffuseMap_2", rock);
matRock.setFloat("DiffuseMap_2_scale", 128);
Texture normalMap0 = assetManager.loadTexture("Textures/Terrain/splat/grass_normal.png");
normalMap0.setWrap(WrapMode.Repeat);
Texture normalMap1 = assetManager.loadTexture("Textures/Terrain/splat/dirt_normal.png");
normalMap1.setWrap(WrapMode.Repeat);
Texture normalMap2 = assetManager.loadTexture("Textures/Terrain/splat/road_normal.png");
normalMap2.setWrap(WrapMode.Repeat);
matRock.setTexture("NormalMap", normalMap0);
matRock.setTexture("NormalMap_1", normalMap2);
matRock.setTexture("NormalMap_2", normalMap2);
matWire = new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md");
matWire.setColor("Color", ColorRGBA.Green);
AbstractHeightMap heightmap = null;
try {
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 0.25f);
heightmap.load();
} catch (Exception e) {
e.printStackTrace();
}
terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());
List<Camera> cameras = new ArrayList<Camera>();
cameras.add(getCamera());
TerrainLodControl control = new TerrainLodControl(terrain, cameras);
terrain.addControl(control);
terrain.setMaterial(matRock);
terrain.setModelBound(new BoundingBox());
terrain.updateModelBound();
terrain.setLocalScale(new Vector3f(2, 2, 2));
terrainPhysicsNode = new RigidBodyControl(CollisionShapeFactory.createMeshShape(terrain), 0);
terrain.addControl(terrainPhysicsNode);
rootNode.attachChild(terrain);
getPhysicsSpace().add(terrainPhysicsNode);
}[/java]
There isn’t a secret to it. The bumpiness of the terrain is solely based on the heightmap image, ie. mountains512.png
Did you try the alphamap image I posted above? I tried it and the terrain is very smooth.
Also dont use jpg images, or compress them very few.
I am using your image, the vertices are really smooth.
I think I’ve solved the problem 7 posts ago.
I guess I finally understood the logic of a heightmap.
I’ll study a little about Java and soon I’ll be giving some contributions
Glad to hear you got it working.
We are always looking forward to contributions
Thank you for your help!