From fdf238cc081f959f2630b2a3f5f629c2b6fe0101 Mon Sep 17 00:00:00 2001 From: "bre..om" Date: Fri, 14 Dec 2012 15:37:21 +0000 Subject: [PATCH] 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 --- .../terrain/heightmap/ImageBasedHeightMap.java | 14 +++++--------- .../jme3test/helloworld/HelloTerrainCollision.java | 2 +- engine/src/test/jme3test/terrain/TerrainTest.java | 2 +- .../test/jme3test/terrain/TerrainTestAndroid.java | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/engine/src/terrain/com/jme3/terrain/heightmap/ImageBasedHeightMap.java b/engine/src/terrain/com/jme3/terrain/heightmap/ImageBasedHeightMap.java index 893ca06a3..d4e9b22c8 100644 --- a/engine/src/terrain/com/jme3/terrain/heightmap/ImageBasedHeightMap.java +++ b/engine/src/terrain/com/jme3/terrain/heightmap/ImageBasedHeightMap.java @@ -32,13 +32,8 @@ package com.jme3.terrain.heightmap; import com.jme3.math.ColorRGBA; -import com.jme3.system.JmeSystem; import com.jme3.texture.Image; -import com.jme3.texture.image.DefaultImageRaster; import com.jme3.texture.image.ImageRaster; -import com.jme3.util.NativeObject; -import java.nio.ByteBuffer; -import java.nio.ShortBuffer; /** * ImageBasedHeightMap is a height map created from the grayscale @@ -53,6 +48,7 @@ public class ImageBasedHeightMap extends AbstractHeightMap implements ImageHeigh protected Image colorImage; + private float backwardsCompScale = 255f; public void setImage(Image image) { @@ -124,13 +120,13 @@ public class ImageBasedHeightMap extends AbstractHeightMap implements ImageHeigh for (int w = imageWidth - 1; w >= 0; --w) { //int baseIndex = (h * imageWidth)+ w; //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 { for (int w = 0; w < imageWidth; ++w) { //int baseIndex = (h * imageWidth)+ w; //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) { //int baseIndex = (h * imageWidth)+ w; //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 { for (int w = 0; w < imageWidth; ++w) { //int baseIndex = (h * imageWidth)+ w; //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; } } } diff --git a/engine/src/test/jme3test/helloworld/HelloTerrainCollision.java b/engine/src/test/jme3test/helloworld/HelloTerrainCollision.java index 75478cdad..051e68adb 100644 --- a/engine/src/test/jme3test/helloworld/HelloTerrainCollision.java +++ b/engine/src/test/jme3test/helloworld/HelloTerrainCollision.java @@ -162,7 +162,7 @@ public class HelloTerrainCollision extends SimpleApplication player.setJumpSpeed(20); player.setFallSpeed(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, // to make them appear in the game world. diff --git a/engine/src/test/jme3test/terrain/TerrainTest.java b/engine/src/test/jme3test/terrain/TerrainTest.java index 122a7fc58..7eff18b8f 100644 --- a/engine/src/test/jme3test/terrain/TerrainTest.java +++ b/engine/src/test/jme3test/terrain/TerrainTest.java @@ -161,7 +161,7 @@ public class TerrainTest extends SimpleApplication { terrain.addControl(control); terrain.setMaterial(matRock); terrain.setLocalTranslation(0, -100, 0); - terrain.setLocalScale(2f, 1f, 2f); + terrain.setLocalScale(2f, 0.5f, 2f); rootNode.attachChild(terrain); DirectionalLight light = new DirectionalLight(); diff --git a/engine/src/test/jme3test/terrain/TerrainTestAndroid.java b/engine/src/test/jme3test/terrain/TerrainTestAndroid.java index b5c225e30..d5b74b291 100644 --- a/engine/src/test/jme3test/terrain/TerrainTestAndroid.java +++ b/engine/src/test/jme3test/terrain/TerrainTestAndroid.java @@ -142,7 +142,7 @@ public class TerrainTestAndroid extends SimpleApplication { terrain.addControl(control); terrain.setMaterial(matRock); terrain.setLocalTranslation(0, -100, 0); - terrain.setLocalScale(8f, 100f, 8f); + terrain.setLocalScale(8f, 0.5f, 8f); rootNode.attachChild(terrain); DirectionalLight light = new DirectionalLight();