Ok… I found out that cloning of a geometry results in just a shallow geometry. The new geometry references to the same data as the original.
So I created the copy I need by loading the same model from disk. I now would have thought that whenever I mess with the data of the original, the second geometry would not change. But it turns out I was wrong.
The relevant parts of the code:
//Icosphere import base for globe terrain //The icosphere is just a smooth sphere. No mountains yet! globe = (Node) app.getAssetManager().loadModel("Models/icosphere.glb"); Geometry globeGeo = (Geometry) globe.getChild("polymesh"); vertBuffer = globeMesh.getBuffer(VertexBuffer.Type.Position); vertData = (FloatBuffer) vertBuffer.getData(); ... Node waterNode = (Node) app.getAssetManager().loadModel("Models/icosphere.glb"); water= (Geometry) waterNode.getChild("polymesh"); ... // Creating terrain by messing with vertData (which is the data of the globe, not of the water vertData.put(pos, vec.x); vertData.put(pos + 1, vec.y); vertData.put(pos + 2, vec.z);
I now end up with this:
The water got mountains too! Why?