moved player location in HelloTerrainCollision. Set a backwards compatibility scale for ImageBasedHeightmap
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10028 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
f35c90238f
commit
fdf238cc08
@ -32,13 +32,8 @@
|
|||||||
package com.jme3.terrain.heightmap;
|
package com.jme3.terrain.heightmap;
|
||||||
|
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.system.JmeSystem;
|
|
||||||
import com.jme3.texture.Image;
|
import com.jme3.texture.Image;
|
||||||
import com.jme3.texture.image.DefaultImageRaster;
|
|
||||||
import com.jme3.texture.image.ImageRaster;
|
import com.jme3.texture.image.ImageRaster;
|
||||||
import com.jme3.util.NativeObject;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.ShortBuffer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>ImageBasedHeightMap</code> is a height map created from the grayscale
|
* <code>ImageBasedHeightMap</code> is a height map created from the grayscale
|
||||||
@ -53,6 +48,7 @@ public class ImageBasedHeightMap extends AbstractHeightMap implements ImageHeigh
|
|||||||
|
|
||||||
|
|
||||||
protected Image colorImage;
|
protected Image colorImage;
|
||||||
|
private float backwardsCompScale = 255f;
|
||||||
|
|
||||||
|
|
||||||
public void setImage(Image image) {
|
public void setImage(Image image) {
|
||||||
@ -124,13 +120,13 @@ public class ImageBasedHeightMap extends AbstractHeightMap implements ImageHeigh
|
|||||||
for (int w = imageWidth - 1; w >= 0; --w) {
|
for (int w = imageWidth - 1; w >= 0; --w) {
|
||||||
//int baseIndex = (h * imageWidth)+ w;
|
//int baseIndex = (h * imageWidth)+ w;
|
||||||
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
|
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
|
||||||
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale;
|
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale*backwardsCompScale;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int w = 0; w < imageWidth; ++w) {
|
for (int w = 0; w < imageWidth; ++w) {
|
||||||
//int baseIndex = (h * imageWidth)+ w;
|
//int baseIndex = (h * imageWidth)+ w;
|
||||||
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
|
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
|
||||||
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale;
|
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale*backwardsCompScale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,13 +136,13 @@ public class ImageBasedHeightMap extends AbstractHeightMap implements ImageHeigh
|
|||||||
for (int w = imageWidth - 1; w >= 0; --w) {
|
for (int w = imageWidth - 1; w >= 0; --w) {
|
||||||
//int baseIndex = (h * imageWidth)+ w;
|
//int baseIndex = (h * imageWidth)+ w;
|
||||||
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
|
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
|
||||||
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale;
|
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale*backwardsCompScale;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int w = 0; w < imageWidth; ++w) {
|
for (int w = 0; w < imageWidth; ++w) {
|
||||||
//int baseIndex = (h * imageWidth)+ w;
|
//int baseIndex = (h * imageWidth)+ w;
|
||||||
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
|
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
|
||||||
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale;
|
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale*backwardsCompScale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ public class HelloTerrainCollision extends SimpleApplication
|
|||||||
player.setJumpSpeed(20);
|
player.setJumpSpeed(20);
|
||||||
player.setFallSpeed(30);
|
player.setFallSpeed(30);
|
||||||
player.setGravity(30);
|
player.setGravity(30);
|
||||||
player.setPhysicsLocation(new Vector3f(0, 10, 0));
|
player.setPhysicsLocation(new Vector3f(-10, 10, 10));
|
||||||
|
|
||||||
// We attach the scene and the player to the rootnode and the physics space,
|
// We attach the scene and the player to the rootnode and the physics space,
|
||||||
// to make them appear in the game world.
|
// to make them appear in the game world.
|
||||||
|
@ -161,7 +161,7 @@ public class TerrainTest extends SimpleApplication {
|
|||||||
terrain.addControl(control);
|
terrain.addControl(control);
|
||||||
terrain.setMaterial(matRock);
|
terrain.setMaterial(matRock);
|
||||||
terrain.setLocalTranslation(0, -100, 0);
|
terrain.setLocalTranslation(0, -100, 0);
|
||||||
terrain.setLocalScale(2f, 1f, 2f);
|
terrain.setLocalScale(2f, 0.5f, 2f);
|
||||||
rootNode.attachChild(terrain);
|
rootNode.attachChild(terrain);
|
||||||
|
|
||||||
DirectionalLight light = new DirectionalLight();
|
DirectionalLight light = new DirectionalLight();
|
||||||
|
@ -142,7 +142,7 @@ public class TerrainTestAndroid extends SimpleApplication {
|
|||||||
terrain.addControl(control);
|
terrain.addControl(control);
|
||||||
terrain.setMaterial(matRock);
|
terrain.setMaterial(matRock);
|
||||||
terrain.setLocalTranslation(0, -100, 0);
|
terrain.setLocalTranslation(0, -100, 0);
|
||||||
terrain.setLocalScale(8f, 100f, 8f);
|
terrain.setLocalScale(8f, 0.5f, 8f);
|
||||||
rootNode.attachChild(terrain);
|
rootNode.attachChild(terrain);
|
||||||
|
|
||||||
DirectionalLight light = new DirectionalLight();
|
DirectionalLight light = new DirectionalLight();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user