/** * Creates a terrain with: * <ul> * <li>the total, real-world, size of the terrain</li> * <li>the patchSize, or the size of each geometry tile of the terrain</li> * <li>the heightmap that defines the height of the terrain</li> * </ul> * <p> * A TerrainQuad of totalSize 513x513 will be 513 units wide and 513 units long. * PatchSize is just used to subdivide the terrain into tiles that can be culled. * </p> * @param name the name of the scene element. This is required for * identification and comparison purposes. * @param patchSize size of the individual patches (geometry). Power of 2 plus 1, * must be smaller than totalSize. (eg. 33, 65...) * @param totalSize the size of this entire terrain (on one side). Power of 2 plus 1 * (eg. 513, 1025, 2049...) * @param heightMap The height map to generate the terrain from (a flat * height map will be generated if this is null). The size of one side of the heightmap * must match the totalSize. So a 513x513 heightmap is needed for a terrain with totalSize of 513. */ public TerrainQuad(String name, int patchSize, int totalSize, float[] heightMap) { this(name, patchSize, totalSize, Vector3f.UNIT_XYZ, heightMap); affectedAreaBBox = new BoundingBox(new Vector3f(0,0,0), size*2, Float.MAX_VALUE, size*2); fixNormalEdges(affectedAreaBBox); addControl(new NormalRecalcControl(this)); }
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public Object jmeClone() { NormalRecalcControl control = (NormalRecalcControl)super.jmeClone(); control.setEnabled(true); return control; }
@Override public TerrainQuad clone(boolean cloneMaterials) { TerrainQuad quadClone = (TerrainQuad) super.clone(cloneMaterials); quadClone.name = name.toString(); quadClone.size = size; quadClone.totalSize = totalSize; if (stepScale != null) { quadClone.stepScale = stepScale.clone(); } if (offset != null) { quadClone.offset = offset.clone(); } quadClone.offsetAmount = offsetAmount; quadClone.quadrant = quadrant; //quadClone.lodCalculatorFactory = lodCalculatorFactory.clone(); //quadClone.lodCalculator = lodCalculator.clone(); TerrainLodControl lodControlCloned = this.getControl(TerrainLodControl.class); TerrainLodControl lodControl = quadClone.getControl(TerrainLodControl.class); if (lodControlCloned != null && !(getParent() instanceof TerrainQuad)) { //lodControlCloned.setLodCalculator(lodControl.getLodCalculator().clone()); } NormalRecalcControl normalControl = getControl(NormalRecalcControl.class); if (normalControl != null) normalControl.setTerrain(this); return quadClone; }
public Control cloneForSpatial(Spatial spatial) { NormalRecalcControl control = new NormalRecalcControl(terrain); control.setSpatial(spatial); control.setEnabled(true); return control; }
public TerrainGrid(String name, int patchSize, int maxVisibleSize, Vector3f scale, TerrainGridTileLoader terrainQuadGrid, Vector2f offset, float offsetAmount) { this.name = name; this.patchSize = patchSize; this.size = maxVisibleSize; this.stepScale = scale; this.offset = offset; this.offsetAmount = offsetAmount; initData(); this.gridTileLoader = terrainQuadGrid; terrainQuadGrid.setPatchSize(this.patchSize); terrainQuadGrid.setQuadSize(this.quadSize); addControl(new UpdateControl()); fixNormalEdges(new BoundingBox(new Vector3f(0,0,0), size*2, Float.MAX_VALUE, size*2)); addControl(new NormalRecalcControl(this)); }
@Override public TerrainQuad clone(boolean cloneMaterials) { TerrainQuad quadClone = (TerrainQuad) super.clone(cloneMaterials); quadClone.name = name.toString(); quadClone.size = size; quadClone.totalSize = totalSize; if (stepScale != null) { quadClone.stepScale = stepScale.clone(); } if (offset != null) { quadClone.offset = offset.clone(); } quadClone.offsetAmount = offsetAmount; quadClone.quadrant = quadrant; //quadClone.lodCalculatorFactory = lodCalculatorFactory.clone(); //quadClone.lodCalculator = lodCalculator.clone(); TerrainLodControl lodControlCloned = this.getControl(TerrainLodControl.class); TerrainLodControl lodControl = quadClone.getControl(TerrainLodControl.class); if (lodControlCloned != null && !(getParent() instanceof TerrainQuad)) { //lodControlCloned.setLodCalculator(lodControl.getLodCalculator().clone()); } NormalRecalcControl normalControl = getControl(NormalRecalcControl.class); if (normalControl != null) normalControl.setTerrain(this); return quadClone; }
/** * Creates a terrain with: * <ul> * <li>the total, real-world, size of the terrain</li> * <li>the patchSize, or the size of each geometry tile of the terrain</li> * <li>the heightmap that defines the height of the terrain</li> * </ul> * <p> * A TerrainQuad of totalSize 513x513 will be 513 units wide and 513 units long. * PatchSize is just used to subdivide the terrain into tiles that can be culled. * </p> * @param name the name of the scene element. This is required for * identification and comparison purposes. * @param patchSize size of the individual patches (geometry). Power of 2 plus 1, * must be smaller than totalSize. (eg. 33, 65...) * @param totalSize the size of this entire terrain (on one side). Power of 2 plus 1 * (eg. 513, 1025, 2049...) * @param heightMap The height map to generate the terrain from (a flat * height map will be generated if this is null). The size of one side of the heightmap * must match the totalSize. So a 513x513 heightmap is needed for a terrain with totalSize of 513. */ public TerrainQuad(String name, int patchSize, int totalSize, float[] heightMap) { this(name, patchSize, totalSize, Vector3f.UNIT_XYZ, heightMap); affectedAreaBBox = new BoundingBox(new Vector3f(0,0,0), size*2, Float.MAX_VALUE, size*2); fixNormalEdges(affectedAreaBBox); addControl(new NormalRecalcControl(this)); }
public TerrainGrid(String name, int patchSize, int maxVisibleSize, Vector3f scale, TerrainGridTileLoader terrainQuadGrid, Vector2f offset, float offsetAmount) { this.name = name; this.patchSize = patchSize; this.size = maxVisibleSize; this.stepScale = scale; this.offset = offset; this.offsetAmount = offsetAmount; initData(); this.gridTileLoader = terrainQuadGrid; terrainQuadGrid.setPatchSize(this.patchSize); terrainQuadGrid.setQuadSize(this.quadSize); addControl(new UpdateControl()); fixNormalEdges(new BoundingBox(new Vector3f(0,0,0), size*2, Float.MAX_VALUE, size*2)); addControl(new NormalRecalcControl(this)); }