forked from MagicBane/Server
Offset support for blend.
This commit is contained in:
@@ -104,7 +104,7 @@ public class Terrain {
|
|||||||
|
|
||||||
// Transform world loc into zone space coordinate system
|
// Transform world loc into zone space coordinate system
|
||||||
|
|
||||||
Vector2f terrainLoc = ZoneManager.worldToZoneSpace(worldLoc, terrainZone);
|
Vector2f terrainLoc = ZoneManager.worldToTerrainSpace(worldLoc, terrainZone);
|
||||||
|
|
||||||
// Interpolate height for this position in terrain
|
// Interpolate height for this position in terrain
|
||||||
|
|
||||||
@@ -178,12 +178,12 @@ public class Terrain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float terrainBlend(Vector2f terrainLoc) {
|
public float terrainBlend(Vector2f zoneOffset) {
|
||||||
|
|
||||||
// Normalize terrain loc
|
// Normalize terrain loc
|
||||||
|
|
||||||
Vector2f normalizedLoc = new Vector2f(terrainLoc.x / this.terrain_size.x,
|
Vector2f normalizedLoc = new Vector2f(zoneOffset.x / this.terrain_size.x,
|
||||||
terrainLoc.y / terrain_size.y);
|
zoneOffset.y / terrain_size.y);
|
||||||
|
|
||||||
float minp = this.zone.min_blend / this.zone.major_radius;
|
float minp = this.zone.min_blend / this.zone.major_radius;
|
||||||
float maxp = this.zone.max_blend / this.zone.major_radius;
|
float maxp = this.zone.max_blend / this.zone.major_radius;
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ public class GetHeightCmd extends AbstractDevCmd {
|
|||||||
float currentHeight = Terrain.getWorldHeight(currentZone, playerCharacter.getLoc());
|
float currentHeight = Terrain.getWorldHeight(currentZone, playerCharacter.getLoc());
|
||||||
float parentHeight = Terrain.getWorldHeight(parentZone, playerCharacter.getLoc());
|
float parentHeight = Terrain.getWorldHeight(parentZone, playerCharacter.getLoc());
|
||||||
|
|
||||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(playerCharacter.getLoc(), heightmapZone);
|
Vector2f zoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), heightmapZone);
|
||||||
|
Vector2f zoneOffset = ZoneManager.worldToZoneOffset(playerCharacter.getLoc(), heightmapZone);
|
||||||
Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(zoneLoc);
|
Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(zoneLoc);
|
||||||
|
|
||||||
this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName);
|
this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName);
|
||||||
@@ -47,7 +47,7 @@ public class GetHeightCmd extends AbstractDevCmd {
|
|||||||
this.throwbackInfo(playerCharacter, "Global Height: " + heightmapZone.worldAltitude);
|
this.throwbackInfo(playerCharacter, "Global Height: " + heightmapZone.worldAltitude);
|
||||||
this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.seaLevel);
|
this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.seaLevel);
|
||||||
this.throwbackInfo(playerCharacter, "Grid : " + Math.floor(gridSquare.x) + "x" + Math.floor(gridSquare.y));
|
this.throwbackInfo(playerCharacter, "Grid : " + Math.floor(gridSquare.x) + "x" + Math.floor(gridSquare.y));
|
||||||
this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(zoneLoc));
|
this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(zoneOffset));
|
||||||
this.throwbackInfo(playerCharacter, "Height returned: " + Math.ceil(currentHeight));
|
this.throwbackInfo(playerCharacter, "Height returned: " + Math.ceil(currentHeight));
|
||||||
|
|
||||||
this.throwbackInfo(playerCharacter, "------------");
|
this.throwbackInfo(playerCharacter, "------------");
|
||||||
|
|||||||
@@ -288,8 +288,22 @@ public enum ZoneManager {
|
|||||||
return localCoords;
|
return localCoords;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2f worldToZoneSpace(Vector3fImmutable worldVector,
|
public static Vector2f worldToZoneOffset(Vector3fImmutable worldLoc,
|
||||||
Zone serverZone) {
|
Zone serverZone) {
|
||||||
|
|
||||||
|
Vector2f localCoords;
|
||||||
|
Vector2f zoneOrigin;
|
||||||
|
|
||||||
|
zoneOrigin = new Vector2f(serverZone.getLoc().x, serverZone.getLoc().z);
|
||||||
|
localCoords = new Vector2f(worldLoc.x, worldLoc.z);
|
||||||
|
localCoords = localCoords.subtract(zoneOrigin);
|
||||||
|
|
||||||
|
return localCoords;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector2f worldToTerrainSpace(Vector3fImmutable worldLoc,
|
||||||
|
Zone serverZone) {
|
||||||
|
|
||||||
Vector2f localCoords;
|
Vector2f localCoords;
|
||||||
Vector2f zoneOrigin;
|
Vector2f zoneOrigin;
|
||||||
@@ -301,7 +315,7 @@ public enum ZoneManager {
|
|||||||
|
|
||||||
// Local coordinate in world space translated to an offset from the calculated zone origin.
|
// Local coordinate in world space translated to an offset from the calculated zone origin.
|
||||||
|
|
||||||
localCoords = new Vector2f(worldVector.x, worldVector.z);
|
localCoords = new Vector2f(worldLoc.x, worldLoc.z);
|
||||||
localCoords = localCoords.subtract(zoneOrigin);
|
localCoords = localCoords.subtract(zoneOrigin);
|
||||||
|
|
||||||
// TODO : Make sure this value does not go outside the zone's bounds.
|
// TODO : Make sure this value does not go outside the zone's bounds.
|
||||||
@@ -311,18 +325,6 @@ public enum ZoneManager {
|
|||||||
|
|
||||||
// Converts local zone coordinates to world coordinates
|
// Converts local zone coordinates to world coordinates
|
||||||
|
|
||||||
public static Vector3fImmutable localToWorld(Vector3fImmutable worldVector,
|
|
||||||
Zone serverZone) {
|
|
||||||
|
|
||||||
Vector3fImmutable worldCoords;
|
|
||||||
|
|
||||||
worldCoords = new Vector3fImmutable(worldVector.x + serverZone.absX,
|
|
||||||
worldVector.y + serverZone.absY, worldVector.z
|
|
||||||
+ serverZone.absZ);
|
|
||||||
|
|
||||||
return worldCoords;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts from local (relative to this building) to world.
|
* Converts from local (relative to this building) to world.
|
||||||
|
|||||||
Reference in New Issue
Block a user