本文整理汇总了Java中com.jme3.terrain.heightmap.HeightMap类的典型用法代码示例。如果您正苦于以下问题:Java HeightMap类的具体用法?Java HeightMap怎么用?Java HeightMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HeightMap类属于com.jme3.terrain.heightmap包,在下文中一共展示了HeightMap类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.jme3.terrain.heightmap.HeightMap; //导入依赖的package包/类
public void run() {
for (int i = centerOnly ? 1 : 0; i < (centerOnly ? 3 : 4); i++) {
for (int j = centerOnly ? 1 : 0; j < (centerOnly ? 3 : 4); j++) {
Vector3f temp = location.add(quadIndex[i * 4 + j]);
if (cache.get(temp) == null) {
HeightMap heightMapAt = heightMapGrid.getHeightMapAt(temp);
TerrainQuad q = new TerrainQuad(getName() + "Quad" + temp, patchSize, quadSize, heightMapAt == null ? null : heightMapAt.getHeightMap(), lodCalculatorFactory);
Material mat = material.clone();
for (TerrainGridListener l : listeners.values()) {
mat = l.tileLoaded(mat, temp);
}
q.setMaterial(mat);
cache.put(temp, q);
}
}
}
}
示例2: getHeightMapAt
import com.jme3.terrain.heightmap.HeightMap; //导入依赖的package包/类
private HeightMap getHeightMapAt(Vector3f location) {
AbstractHeightMap heightmap = null;
FloatBuffer buffer = this.base.getBuffer(location.x * (this.quadSize - 1), location.z * (this.quadSize - 1), 0, this.quadSize);
float[] arr = buffer.array();
for (int i = 0; i < arr.length; i++) {
arr[i] = arr[i] * this.heightScale;
}
heightmap = new FloatBufferHeightMap(buffer);
heightmap.load();
return heightmap;
}
示例3: getTerrainQuadAt
import com.jme3.terrain.heightmap.HeightMap; //导入依赖的package包/类
public TerrainQuad getTerrainQuadAt(Vector3f location) {
HeightMap heightMapAt = getHeightMapAt(location);
TerrainQuad q = new TerrainQuad("Quad" + location, patchSize, quadSize, heightMapAt == null ? null : heightMapAt.getHeightMap());
return q;
}
示例4: run
import com.jme3.terrain.heightmap.HeightMap; //导入依赖的package包/类
/**
* This is executed if the camera has moved into a new CameraCell and will load in
* the new TerrainQuad tiles to be children of this TerrainGrid parent.
* It will first check the LRU cache to see if the terrain tile is already there,
* if it is not there, it will load it in and then cache that tile.
* The terrain tiles get added to the quad tree back on the OGL thread using the
* attachQuadAt() method. It also resets any cached values in TerrainQuad (such as
* neighbours).
*/
public void run() {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
int quadIdx = i * 4 + j;
final Vector3f quadCell = location.add(quadIndex[quadIdx]);
TerrainQuad q = cache.get(quadCell);
if (q == null) {
if (heightMapGrid != null) {
// create the new Quad since it doesn't exist
HeightMap heightMapAt = heightMapGrid.getHeightMapAt(quadCell);
q = new TerrainQuad(getName() + "Quad" + quadCell, patchSize, quadSize, heightMapAt == null ? null : heightMapAt.getHeightMap());
q.setMaterial(material.clone());
log.log(Level.FINE, "Loaded TerrainQuad {0} from HeightMapGrid", q.getName());
} else if (gridTileLoader != null) {
q = gridTileLoader.getTerrainQuadAt(quadCell);
// only clone the material to the quad if it doesn't have a material of its own
if(q.getMaterial()==null) q.setMaterial(material.clone());
log.log(Level.FINE, "Loaded TerrainQuad {0} from TerrainQuadGrid", q.getName());
}
}
cache.put(quadCell, q);
final int quadrant = getQuadrant(quadIdx);
final TerrainQuad newQuad = q;
if (isCenter(quadIdx)) {
// if it should be attached as a child right now, attach it
getControl(UpdateControl.class).enqueue(new Callable() {
// back on the OpenGL thread:
public Object call() throws Exception {
if (newQuad.getParent() != null) {
attachQuadAt(newQuad, quadrant, quadCell, true);
}
else {
attachQuadAt(newQuad, quadrant, quadCell, false);
}
return null;
}
});
} else {
getControl(UpdateControl.class).enqueue(new Callable() {
public Object call() throws Exception {
removeQuad(newQuad);
return null;
}
});
}
}
}
getControl(UpdateControl.class).enqueue(new Callable() {
// back on the OpenGL thread:
public Object call() throws Exception {
for (Spatial s : getChildren()) {
if (s instanceof TerrainQuad) {
TerrainQuad tq = (TerrainQuad)s;
tq.resetCachedNeighbours();
}
}
System.out.println("fixed normals "+location.clone().mult(size));
setNeedToRecalculateNormals();
return null;
}
});
}