fixed terrain scale bug
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8314 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
210e4ad17b
commit
ca628fe5d6
@ -922,8 +922,8 @@ public class TerrainQuad extends Node implements Terrain {
|
|||||||
public float getHeightmapHeight(Vector2f xz) {
|
public float getHeightmapHeight(Vector2f xz) {
|
||||||
// offset
|
// offset
|
||||||
int halfSize = totalSize / 2;
|
int halfSize = totalSize / 2;
|
||||||
int x = Math.round((xz.x / getLocalScale().x) + halfSize);
|
int x = Math.round((xz.x / getWorldScale().x) + halfSize);
|
||||||
int z = Math.round((xz.y / getLocalScale().z) + halfSize);
|
int z = Math.round((xz.y / getWorldScale().z) + halfSize);
|
||||||
|
|
||||||
return getHeightmapHeight(x, z);
|
return getHeightmapHeight(x, z);
|
||||||
}
|
}
|
||||||
@ -1024,10 +1024,10 @@ public class TerrainQuad extends Node implements Terrain {
|
|||||||
|
|
||||||
public float getHeight(Vector2f xz) {
|
public float getHeight(Vector2f xz) {
|
||||||
// offset
|
// offset
|
||||||
float x = (float)(((xz.x - getLocalTranslation().x) / getLocalScale().x) + (float)totalSize / 2f);
|
float x = (float)(((xz.x - getLocalTranslation().x) / getWorldScale().x) + (float)totalSize / 2f);
|
||||||
float z = (float)(((xz.y - getLocalTranslation().z) / getLocalScale().z) + (float)totalSize / 2f);
|
float z = (float)(((xz.y - getLocalTranslation().z) / getWorldScale().z) + (float)totalSize / 2f);
|
||||||
float height = getHeight(x, z);
|
float height = getHeight(x, z);
|
||||||
height *= getLocalScale().y;
|
height *= getWorldScale().y;
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1064,8 +1064,8 @@ public class TerrainQuad extends Node implements Terrain {
|
|||||||
|
|
||||||
public Vector3f getNormal(Vector2f xz) {
|
public Vector3f getNormal(Vector2f xz) {
|
||||||
// offset
|
// offset
|
||||||
float x = (float)(((xz.x - getLocalTranslation().x) / getLocalScale().x) + (float)totalSize / 2f);
|
float x = (float)(((xz.x - getLocalTranslation().x) / getWorldScale().x) + (float)totalSize / 2f);
|
||||||
float z = (float)(((xz.y - getLocalTranslation().z) / getLocalScale().z) + (float)totalSize / 2f);
|
float z = (float)(((xz.y - getLocalTranslation().z) / getWorldScale().z) + (float)totalSize / 2f);
|
||||||
Vector3f normal = getNormal(x, z, xz);
|
Vector3f normal = getNormal(x, z, xz);
|
||||||
|
|
||||||
return normal;
|
return normal;
|
||||||
@ -1130,8 +1130,8 @@ public class TerrainQuad extends Node implements Terrain {
|
|||||||
|
|
||||||
// offset
|
// offset
|
||||||
for (int i=0; i<xz.size(); i++) {
|
for (int i=0; i<xz.size(); i++) {
|
||||||
int x = Math.round((xz.get(i).x / getLocalScale().x) + halfSize);
|
int x = Math.round((xz.get(i).x / getWorldScale().x) + halfSize);
|
||||||
int z = Math.round((xz.get(i).y / getLocalScale().z) + halfSize);
|
int z = Math.round((xz.get(i).y / getWorldScale().z) + halfSize);
|
||||||
locations.add(new LocationHeight(x,z,height.get(i)));
|
locations.add(new LocationHeight(x,z,height.get(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ public class PaintTerrainToolAction extends AbstractTerrainToolAction {
|
|||||||
Vector2f uv = new Vector2f(worldLoc.x,-worldLoc.z);
|
Vector2f uv = new Vector2f(worldLoc.x,-worldLoc.z);
|
||||||
float scale = ((Node)terrain).getLocalScale().x;
|
float scale = ((Node)terrain).getLocalScale().x;
|
||||||
|
|
||||||
uv.subtractLocal(((Node)terrain).getLocalTranslation().x*scale, ((Node)terrain).getLocalTranslation().z*scale); // center it on 0,0
|
uv.subtractLocal(((Node)terrain).getWorldTranslation().x*scale, ((Node)terrain).getWorldTranslation().z*scale); // center it on 0,0
|
||||||
float scaledSize = terrain.getTerrainSize()*scale;
|
float scaledSize = terrain.getTerrainSize()*scale;
|
||||||
uv.addLocal(scaledSize/2, scaledSize/2); // shift the bottom left corner up to 0,0
|
uv.addLocal(scaledSize/2, scaledSize/2); // shift the bottom left corner up to 0,0
|
||||||
uv.divideLocal(scaledSize); // get the location as a percentage
|
uv.divideLocal(scaledSize); // get the location as a percentage
|
||||||
|
@ -76,11 +76,11 @@ public class RaiseTerrainToolAction extends AbstractTerrainToolAction {
|
|||||||
|
|
||||||
private void modifyHeight(Terrain terrain, float radius, float heightDir) {
|
private void modifyHeight(Terrain terrain, float radius, float heightDir) {
|
||||||
|
|
||||||
int radiusStepsX = (int) (radius / ((Node)terrain).getLocalScale().x);
|
int radiusStepsX = (int) (radius / ((Node)terrain).getWorldScale().x);
|
||||||
int radiusStepsZ = (int) (radius / ((Node)terrain).getLocalScale().z);
|
int radiusStepsZ = (int) (radius / ((Node)terrain).getWorldScale().z);
|
||||||
|
|
||||||
float xStepAmount = ((Node)terrain).getLocalScale().x;
|
float xStepAmount = ((Node)terrain).getWorldScale().x;
|
||||||
float zStepAmount = ((Node)terrain).getLocalScale().z;
|
float zStepAmount = ((Node)terrain).getWorldScale().z;
|
||||||
|
|
||||||
List<Vector2f> locs = new ArrayList<Vector2f>();
|
List<Vector2f> locs = new ArrayList<Vector2f>();
|
||||||
List<Float> heights = new ArrayList<Float>();
|
List<Float> heights = new ArrayList<Float>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user