Browse Source

Dev cmd updated

magicbox-1.5.2
MagicBot 1 year ago
parent
commit
11664a9218
  1. 31
      src/engine/devcmd/cmds/GetHeightCmd.java
  2. 10
      src/engine/gameManager/ZoneManager.java

31
src/engine/devcmd/cmds/GetHeightCmd.java

@ -35,30 +35,35 @@ public class GetHeightCmd extends AbstractDevCmd {
heightmapZone = Terrain.getNextZoneWithTerrain(currentZone); heightmapZone = Terrain.getNextZoneWithTerrain(currentZone);
parentZone = Terrain.getNextZoneWithTerrain(currentZone.parent); parentZone = Terrain.getNextZoneWithTerrain(currentZone.parent);
float currentHeight = Terrain.getWorldHeight(currentZone, playerCharacter.getLoc()); Vector2f childZoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), heightmapZone);
float parentHeight = Terrain.getWorldHeight(parentZone, playerCharacter.getLoc()); Vector2f childZoneOffset = ZoneManager.worldToZoneOffset(playerCharacter.getLoc(), heightmapZone);
Vector2f normalizedOffset = new Vector2f(Math.abs(childZoneOffset.x) / heightmapZone.major_radius,
Math.abs(childZoneOffset.y) / heightmapZone.minor_radius);
Vector2f parentZoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), parentZone);
Vector2f zoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), heightmapZone); float childHeight = heightmapZone.terrain.getInterpolatedTerrainHeight(childZoneLoc);
Vector2f zoneOffset = ZoneManager.worldToZoneOffset(playerCharacter.getLoc(), heightmapZone); childHeight = childHeight + heightmapZone.global_height;
Vector2f normalizedOffset = new Vector2f(Math.abs(zoneOffset.x) / heightmapZone.major_radius,
Math.abs(zoneOffset.y) / heightmapZone.minor_radius);
Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(zoneLoc); float parentHeight = parentZone.terrain.getInterpolatedTerrainHeight(parentZoneLoc);
parentHeight += parentZone.global_height;
Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(childZoneLoc);
gridSquare.x = (float) Math.floor(gridSquare.x); gridSquare.x = (float) Math.floor(gridSquare.x);
gridSquare.y = (float) Math.floor(gridSquare.y); gridSquare.y = (float) Math.floor(gridSquare.y);
this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName); this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName);
this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName); this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName);
this.throwbackInfo(playerCharacter, "Global Height: " + heightmapZone.global_height); this.throwbackInfo(playerCharacter, "Parent Zone: " + parentZone.zoneName);
this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.seaLevel);
this.throwbackInfo(playerCharacter, "Grid : " + "[" + gridSquare.x + "]" + "[" + gridSquare.y + "]"); this.throwbackInfo(playerCharacter, "Grid : " + "[" + gridSquare.x + "]" + "[" + gridSquare.y + "]");
this.throwbackInfo(playerCharacter, "Offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]"); this.throwbackInfo(playerCharacter, "Offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]");
this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(zoneOffset)); this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(childZoneOffset));
this.throwbackInfo(playerCharacter, "Height returned: " + Math.ceil(currentHeight)); this.throwbackInfo(playerCharacter, "Height returned: " + Math.ceil(childHeight));
this.throwbackInfo(playerCharacter, "------------"); this.throwbackInfo(playerCharacter, "------------");
this.throwbackInfo(playerCharacter, "Parent : " + parentZone.zoneName);
this.throwbackInfo(playerCharacter, "Height returned : " + Math.ceil(parentHeight)); this.throwbackInfo(playerCharacter, "Child Height: " + Math.ceil(childHeight));
this.throwbackInfo(playerCharacter, "Parent Height : " + Math.ceil(parentHeight));
this.throwbackInfo(playerCharacter, "------------"); this.throwbackInfo(playerCharacter, "------------");
} }

10
src/engine/gameManager/ZoneManager.java

@ -291,14 +291,12 @@ public enum ZoneManager {
public static Vector2f worldToZoneOffset(Vector3fImmutable worldLoc, public static Vector2f worldToZoneOffset(Vector3fImmutable worldLoc,
Zone zone) { Zone zone) {
Vector2f localCoords; Vector2f zoneLoc;
Vector2f zoneOrigin;
zoneOrigin = new Vector2f(zone.getLoc().x, zone.getLoc().z); zoneLoc = new Vector2f(worldLoc.x, worldLoc.z).subtract(zone.getLoc().x, zone.getLoc().z);
localCoords = new Vector2f(worldLoc.x, worldLoc.z); zoneLoc.y *= -1;
localCoords = localCoords.subtract(zoneOrigin);
return localCoords; return zoneLoc;
} }

Loading…
Cancel
Save