public float[] getHeightMap() { return geomap.getHeightArray(); }
protected void setHeight(List<LocationHeight> locationHeights, boolean overrideHeight) { final float[] heightArray = geomap.getHeightArray(); final VertexBuffer vertexBuffer = mesh.getBuffer(Type.Position); final FloatBuffer floatBuffer = mesh.getFloatBuffer(Type.Position); for (LocationHeight lh : locationHeights) { if (lh.x < 0 || lh.z < 0 || lh.x >= size || lh.z >= size) { continue; } int idx = lh.z * size + lh.x; if (overrideHeight) { heightArray[idx] = lh.h; } else { float currentHeight = floatBuffer.get(idx * 3 + 1); heightArray[idx] = currentHeight + lh.h; } } floatBuffer.clear(); geomap.writeVertexArray(floatBuffer, stepScale, false); vertexBuffer.setUpdateNeeded(); }
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { super.cloneFields(cloner, original); this.stepScale = cloner.clone(stepScale); this.offset = cloner.clone(offset); this.leftNeighbour = null; this.topNeighbour = null; this.rightNeighbour = null; this.bottomNeighbour = null; // Don't feel like making geomap cloneable tonight // so I'll copy the old logic. this.geomap = new LODGeomap(size, geomap.getHeightArray()); Mesh m = geomap.createMesh(stepScale, Vector2f.UNIT_XY, offset, offsetAmount, totalSize, false); this.setMesh(m); // In this case, we always clone material even if the cloner is setup // not to clone it. Terrain uses mutable textures and stuff so it's important // to clone it. (At least that's my understanding and is evidenced by the old // clone code specifically cloning material.) -pspeed this.material = material.clone(); }
@Override public TerrainPatch clone() { TerrainPatch clone = new TerrainPatch(); clone.name = name.toString(); clone.size = size; clone.totalSize = totalSize; clone.quadrant = quadrant; clone.stepScale = stepScale.clone(); clone.offset = offset.clone(); clone.offsetAmount = offsetAmount; //clone.lodCalculator = lodCalculator.clone(); //clone.lodCalculator.setTerrainPatch(clone); //clone.setLodCalculator(lodCalculatorFactory.clone()); clone.geomap = new LODGeomap(size, geomap.getHeightArray()); clone.setLocalTranslation(getLocalTranslation().clone()); Mesh m = clone.geomap.createMesh(clone.stepScale, Vector2f.UNIT_XY, clone.offset, clone.offsetAmount, clone.totalSize, false); clone.setMesh(m); clone.setMaterial(material.clone()); return clone; }
public float[] getHeightMap() { return geomap.getHeightArray(); }
@Deprecated public FloatBuffer getHeightmap() { return BufferUtils.createFloatBuffer(geomap.getHeightArray()); }
protected void setHeight(List<LocationHeight> locationHeights, boolean overrideHeight) { for (LocationHeight lh : locationHeights) { if (lh.x < 0 || lh.z < 0 || lh.x >= size || lh.z >= size) continue; int idx = lh.z * size + lh.x; if (overrideHeight) { geomap.getHeightArray()[idx] = lh.h; } else { float h = getMesh().getFloatBuffer(Type.Position).get(idx*3+1); geomap.getHeightArray()[idx] = h+lh.h; } } FloatBuffer newVertexBuffer = geomap.writeVertexArray(null, stepScale, false); getMesh().clearBuffer(Type.Position); getMesh().setBuffer(Type.Position, 3, newVertexBuffer); }
@Override public TerrainPatch clone() { TerrainPatch clone = new TerrainPatch(); clone.name = name.toString(); clone.size = size; clone.totalSize = totalSize; clone.quadrant = quadrant; clone.stepScale = stepScale.clone(); clone.offset = offset.clone(); clone.offsetAmount = offsetAmount; //clone.lodCalculator = lodCalculator.clone(); //clone.lodCalculator.setTerrainPatch(clone); //clone.setLodCalculator(lodCalculatorFactory.clone()); clone.geomap = new LODGeomap(size, geomap.getHeightArray()); clone.setLocalTranslation(getLocalTranslation().clone()); Mesh m = clone.geomap.createMesh(clone.stepScale, Vector2f.UNIT_XY, clone.offset, clone.offsetAmount, clone.totalSize, false); clone.setMesh(m); clone.setMaterial(material.clone()); return clone; }