fixing whitespace

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7634 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
bre..ns 14 years ago
parent 07a2a44f7f
commit bd114ed3ac
  1. 580
      engine/src/terrain/com/jme3/terrain/geomipmap/TerrainPatch.java
  2. 1585
      engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java

@ -88,26 +88,26 @@ import java.util.List;
*/ */
public class TerrainPatch extends Geometry { public class TerrainPatch extends Geometry {
protected LODGeomap geomap; protected LODGeomap geomap;
protected int lod = -1; // this terrain patch's LOD protected int lod = -1; // this terrain patch's LOD
private int maxLod = -1; private int maxLod = -1;
protected int previousLod = -1; protected int previousLod = -1;
protected int lodLeft, lodTop, lodRight, lodBottom; // it's neighbour's LODs protected int lodLeft, lodTop, lodRight, lodBottom; // it's neighbour's LODs
protected int size; protected int size;
protected int totalSize; protected int totalSize;
protected short quadrant = 1; protected short quadrant = 1;
// x/z step // x/z step
protected Vector3f stepScale; protected Vector3f stepScale;
// center of the block in relation to (0,0,0) // center of the block in relation to (0,0,0)
protected Vector2f offset; protected Vector2f offset;
// amount the block has been shifted. // amount the block has been shifted.
protected float offsetAmount; protected float offsetAmount;
protected LodCalculator lodCalculator; protected LodCalculator lodCalculator;
protected LodCalculatorFactory lodCalculatorFactory; protected LodCalculatorFactory lodCalculatorFactory;
@ -122,78 +122,78 @@ public class TerrainPatch extends Geometry {
super("TerrainPatch"); super("TerrainPatch");
} }
public TerrainPatch(String name) { public TerrainPatch(String name) {
super(name); super(name);
} }
public TerrainPatch(String name, int size) { public TerrainPatch(String name, int size) {
this(name, size, new Vector3f(1,1,1), null, new Vector3f(0,0,0)); this(name, size, new Vector3f(1,1,1), null, new Vector3f(0,0,0));
} }
/** /**
* Constructor instantiates a new <code>TerrainPatch</code> object. The * Constructor instantiates a new <code>TerrainPatch</code> object. The
* parameters and heightmap data are then processed to generate a * parameters and heightmap data are then processed to generate a
* <code>TriMesh</code> object for rendering. * <code>TriMesh</code> object for rendering.
* *
* @param name * @param name
* the name of the terrain block. * the name of the terrain block.
* @param size * @param size
* the size of the heightmap. * the size of the heightmap.
* @param stepScale * @param stepScale
* the scale for the axes. * the scale for the axes.
* @param heightMap * @param heightMap
* the height data. * the height data.
* @param origin * @param origin
* the origin offset of the block. * the origin offset of the block.
*/ */
public TerrainPatch(String name, int size, Vector3f stepScale, public TerrainPatch(String name, int size, Vector3f stepScale,
float[] heightMap, Vector3f origin) { float[] heightMap, Vector3f origin) {
this(name, size, stepScale, heightMap, origin, size, new Vector2f(), 0); this(name, size, stepScale, heightMap, origin, size, new Vector2f(), 0);
} }
/** /**
* Constructor instantiates a new <code>TerrainPatch</code> object. The * Constructor instantiates a new <code>TerrainPatch</code> object. The
* parameters and heightmap data are then processed to generate a * parameters and heightmap data are then processed to generate a
* <code>TriMesh</code> object for renderering. * <code>TriMesh</code> object for renderering.
* *
* @param name * @param name
* the name of the terrain block. * the name of the terrain block.
* @param size * @param size
* the size of the block. * the size of the block.
* @param stepScale * @param stepScale
* the scale for the axes. * the scale for the axes.
* @param heightMap * @param heightMap
* the height data. * the height data.
* @param origin * @param origin
* the origin offset of the block. * the origin offset of the block.
* @param totalSize * @param totalSize
* the total size of the terrain. (Higher if the block is part of * the total size of the terrain. (Higher if the block is part of
* a <code>TerrainPage</code> tree. * a <code>TerrainPage</code> tree.
* @param offset * @param offset
* the offset for texture coordinates. * the offset for texture coordinates.
* @param offsetAmount * @param offsetAmount
* the total offset amount. Used for texture coordinates. * the total offset amount. Used for texture coordinates.
*/ */
public TerrainPatch(String name, int size, Vector3f stepScale, public TerrainPatch(String name, int size, Vector3f stepScale,
float[] heightMap, Vector3f origin, int totalSize, float[] heightMap, Vector3f origin, int totalSize,
Vector2f offset, float offsetAmount) { Vector2f offset, float offsetAmount) {
super(name); super(name);
this.size = size; this.size = size;
this.stepScale = stepScale; this.stepScale = stepScale;
this.totalSize = totalSize; this.totalSize = totalSize;
this.offsetAmount = offsetAmount; this.offsetAmount = offsetAmount;
this.offset = offset; this.offset = offset;
setLocalTranslation(origin); setLocalTranslation(origin);
FloatBuffer heightBuffer = BufferUtils.createFloatBuffer(size*size); FloatBuffer heightBuffer = BufferUtils.createFloatBuffer(size*size);
heightBuffer.put(heightMap); heightBuffer.put(heightMap);
geomap = new LODGeomap(size, heightBuffer); geomap = new LODGeomap(size, heightBuffer);
Mesh m = geomap.createMesh(stepScale, new Vector2f(1,1), offset, offsetAmount, totalSize, false); Mesh m = geomap.createMesh(stepScale, new Vector2f(1,1), offset, offsetAmount, totalSize, false);
setMesh(m); setMesh(m);
} }
/** /**
* This calculation is slow, so don't use it often. * This calculation is slow, so don't use it often.
@ -216,23 +216,23 @@ public class TerrainPatch extends Geometry {
return lodEntropy; return lodEntropy;
} }
public FloatBuffer getHeightmap() { public FloatBuffer getHeightmap() {
return geomap.getHeightData(); return geomap.getHeightData();
} }
/** /**
* The maximum lod supported by this terrain patch. * The maximum lod supported by this terrain patch.
* If the patch size is 32 then the returned value would be log2(32)-2 = 3 * If the patch size is 32 then the returned value would be log2(32)-2 = 3
* You can then use that value, 3, to see how many times you can divide 32 by 2 * You can then use that value, 3, to see how many times you can divide 32 by 2
* before the terrain gets too un-detailed (can't stitch it any further). * before the terrain gets too un-detailed (can't stitch it any further).
* @return * @return
*/ */
public int getMaxLod() { public int getMaxLod() {
if (maxLod < 0) if (maxLod < 0)
maxLod = Math.max(1, (int) (FastMath.log(size-1)/FastMath.log(2)) -1); // -1 forces our minimum of 4 triangles wide maxLod = Math.max(1, (int) (FastMath.log(size-1)/FastMath.log(2)) -1); // -1 forces our minimum of 4 triangles wide
return maxLod; return maxLod;
} }
@ -243,30 +243,30 @@ public class TerrainPatch extends Geometry {
* @param updates update objects that may or may not contain this terrain patch * @param updates update objects that may or may not contain this terrain patch
* @return true if the geometry needs re-indexing * @return true if the geometry needs re-indexing
*/ */
protected boolean calculateLod(List<Vector3f> locations, HashMap<String,UpdatedTerrainPatch> updates) { protected boolean calculateLod(List<Vector3f> locations, HashMap<String,UpdatedTerrainPatch> updates) {
return lodCalculator.calculateLod(locations, updates); return lodCalculator.calculateLod(locations, updates);
} }
protected void reIndexGeometry(HashMap<String,UpdatedTerrainPatch> updated) { protected void reIndexGeometry(HashMap<String,UpdatedTerrainPatch> updated) {
UpdatedTerrainPatch utp = updated.get(getName()); UpdatedTerrainPatch utp = updated.get(getName());
if (utp != null && (utp.isReIndexNeeded() || utp.isFixEdges()) ) { if (utp != null && (utp.isReIndexNeeded() || utp.isFixEdges()) ) {
int pow = (int) Math.pow(2, utp.getNewLod()); int pow = (int) Math.pow(2, utp.getNewLod());
boolean left = utp.getLeftLod() > utp.getNewLod(); boolean left = utp.getLeftLod() > utp.getNewLod();
boolean top = utp.getTopLod() > utp.getNewLod(); boolean top = utp.getTopLod() > utp.getNewLod();
boolean right = utp.getRightLod() > utp.getNewLod(); boolean right = utp.getRightLod() > utp.getNewLod();
boolean bottom = utp.getBottomLod() > utp.getNewLod(); boolean bottom = utp.getBottomLod() > utp.getNewLod();
IntBuffer ib = null; IntBuffer ib = null;
if (lodCalculator.usesVariableLod()) if (lodCalculator.usesVariableLod())
ib = geomap.writeIndexArrayLodVariable(null, pow, (int) Math.pow(2, utp.getRightLod()), (int) Math.pow(2, utp.getTopLod()), (int) Math.pow(2, utp.getLeftLod()), (int) Math.pow(2, utp.getBottomLod())); ib = geomap.writeIndexArrayLodVariable(null, pow, (int) Math.pow(2, utp.getRightLod()), (int) Math.pow(2, utp.getTopLod()), (int) Math.pow(2, utp.getLeftLod()), (int) Math.pow(2, utp.getBottomLod()));
else else
ib = geomap.writeIndexArrayLodDiff(null, pow, right, top, left, bottom); ib = geomap.writeIndexArrayLodDiff(null, pow, right, top, left, bottom);
utp.setNewIndexBuffer(ib); utp.setNewIndexBuffer(ib);
} }
} }
public Vector2f getTex(float x, float z, Vector2f store) { public Vector2f getTex(float x, float z, Vector2f store) {
@ -768,176 +768,176 @@ public class TerrainPatch extends Geometry {
getMesh().setDynamic(); getMesh().setDynamic();
} }
/** /**
* Returns the offset amount this terrain block uses for textures. * Returns the offset amount this terrain block uses for textures.
* *
* @return The current offset amount. * @return The current offset amount.
*/ */
public float getOffsetAmount() { public float getOffsetAmount() {
return offsetAmount; return offsetAmount;
} }
/** /**
* Returns the step scale that stretches the height map. * Returns the step scale that stretches the height map.
* *
* @return The current step scale. * @return The current step scale.
*/ */
public Vector3f getStepScale() { public Vector3f getStepScale() {
return stepScale; return stepScale;
} }
/** /**
* Returns the total size of the terrain. * Returns the total size of the terrain.
* *
* @return The terrain's total size. * @return The terrain's total size.
*/ */
public int getTotalSize() { public int getTotalSize() {
return totalSize; return totalSize;
} }
/** /**
* Returns the size of this terrain block. * Returns the size of this terrain block.
* *
* @return The current block size. * @return The current block size.
*/ */
public int getSize() { public int getSize() {
return size; return size;
} }
/** /**
* Returns the current offset amount. This is used when building texture * Returns the current offset amount. This is used when building texture
* coordinates. * coordinates.
* *
* @return The current offset amount. * @return The current offset amount.
*/ */
public Vector2f getOffset() { public Vector2f getOffset() {
return offset; return offset;
} }
/** /**
* Sets the value for the current offset amount to use when building texture * Sets the value for the current offset amount to use when building texture
* coordinates. Note that this does <b>NOT </b> rebuild the terrain at all. * coordinates. Note that this does <b>NOT </b> rebuild the terrain at all.
* This is mostly used for outside constructors of terrain blocks. * This is mostly used for outside constructors of terrain blocks.
* *
* @param offset * @param offset
* The new texture offset. * The new texture offset.
*/ */
public void setOffset(Vector2f offset) { public void setOffset(Vector2f offset) {
this.offset = offset; this.offset = offset;
} }
/** /**
* Sets the size of this terrain block. Note that this does <b>NOT </b> * Sets the size of this terrain block. Note that this does <b>NOT </b>
* rebuild the terrain at all. This is mostly used for outside constructors * rebuild the terrain at all. This is mostly used for outside constructors
* of terrain blocks. * of terrain blocks.
* *
* @param size * @param size
* The new size. * The new size.
*/ */
public void setSize(int size) { public void setSize(int size) {
this.size = size; this.size = size;
maxLod = -1; // reset it maxLod = -1; // reset it
} }
/** /**
* Sets the total size of the terrain . Note that this does <b>NOT </b> * Sets the total size of the terrain . Note that this does <b>NOT </b>
* rebuild the terrain at all. This is mostly used for outside constructors * rebuild the terrain at all. This is mostly used for outside constructors
* of terrain blocks. * of terrain blocks.
* *
* @param totalSize * @param totalSize
* The new total size. * The new total size.
*/ */
public void setTotalSize(int totalSize) { public void setTotalSize(int totalSize) {
this.totalSize = totalSize; this.totalSize = totalSize;
} }
/** /**
* Sets the step scale of this terrain block's height map. Note that this * Sets the step scale of this terrain block's height map. Note that this
* does <b>NOT </b> rebuild the terrain at all. This is mostly used for * does <b>NOT </b> rebuild the terrain at all. This is mostly used for
* outside constructors of terrain blocks. * outside constructors of terrain blocks.
* *
* @param stepScale * @param stepScale
* The new step scale. * The new step scale.
*/ */
public void setStepScale(Vector3f stepScale) { public void setStepScale(Vector3f stepScale) {
this.stepScale = stepScale; this.stepScale = stepScale;
} }
/** /**
* Sets the offset of this terrain texture map. Note that this does <b>NOT * Sets the offset of this terrain texture map. Note that this does <b>NOT
* </b> rebuild the terrain at all. This is mostly used for outside * </b> rebuild the terrain at all. This is mostly used for outside
* constructors of terrain blocks. * constructors of terrain blocks.
* *
* @param offsetAmount * @param offsetAmount
* The new texture offset. * The new texture offset.
*/ */
public void setOffsetAmount(float offsetAmount) { public void setOffsetAmount(float offsetAmount) {
this.offsetAmount = offsetAmount; this.offsetAmount = offsetAmount;
} }
/** /**
* @return Returns the quadrant. * @return Returns the quadrant.
*/ */
public short getQuadrant() { public short getQuadrant() {
return quadrant; return quadrant;
} }
/** /**
* @param quadrant * @param quadrant
* The quadrant to set. * The quadrant to set.
*/ */
public void setQuadrant(short quadrant) { public void setQuadrant(short quadrant) {
this.quadrant = quadrant; this.quadrant = quadrant;
} }
public int getLod() { public int getLod() {
return lod; return lod;
} }
public void setLod(int lod) { public void setLod(int lod) {
this.lod = lod; this.lod = lod;
} }
public int getPreviousLod() { public int getPreviousLod() {
return previousLod; return previousLod;
} }
public void setPreviousLod(int previousLod) { public void setPreviousLod(int previousLod) {
this.previousLod = previousLod; this.previousLod = previousLod;
} }
protected int getLodLeft() { protected int getLodLeft() {
return lodLeft; return lodLeft;
} }
protected void setLodLeft(int lodLeft) { protected void setLodLeft(int lodLeft) {
this.lodLeft = lodLeft; this.lodLeft = lodLeft;
} }
protected int getLodTop() { protected int getLodTop() {
return lodTop; return lodTop;
} }
protected void setLodTop(int lodTop) { protected void setLodTop(int lodTop) {
this.lodTop = lodTop; this.lodTop = lodTop;
} }
protected int getLodRight() { protected int getLodRight() {
return lodRight; return lodRight;
} }
protected void setLodRight(int lodRight) { protected void setLodRight(int lodRight) {
this.lodRight = lodRight; this.lodRight = lodRight;
} }
protected int getLodBottom() { protected int getLodBottom() {
return lodBottom; return lodBottom;
} }
protected void setLodBottom(int lodBottom) { protected void setLodBottom(int lodBottom) {
this.lodBottom = lodBottom; this.lodBottom = lodBottom;
} }
public LodCalculator getLodCalculator() { public LodCalculator getLodCalculator() {
return lodCalculator; return lodCalculator;

Loading…
Cancel
Save