private void add4ChildNodes(int lod){ if (isleaf){ isleaf = false; } if(getChildren().size() == 0){ for (int i=0; i<2; i++){ for (int j=0; j<2; j++){ addChild(new TerrainNode(getComponents(), location.add(new Vec2f(i*gap/2f,j*gap/2f)), lod, new Vec2f(i,j))); } } } }
for (int j=0; j<2; j++){ Vec2f newLocation = location.add(new Vec2f(i*gap/2f,j*gap/2f)); Vec2f newIndex = new Vec2f(i,j); String key = getQuadtreeCacheKey(lod, newLocation, newIndex);
protected void computeWorldPos(){ Vec2f chunkCenter = location.add(gap/2f); Vec4f worldPosition = getWorldTransform().getWorldMatrixRTS().mul( new Vec4f(chunkCenter.getX(),0,chunkCenter.getY(),1)); worldPosition = worldPosition.normalize(); worldPosition = worldPosition.mul(terrainProperties.getHorizontalScaling()); // TODO displacment // Vec3f displacement = TerrainHelper.getTerrainHeight(terrainProperties, loc.getX(), loc.getY()); // System.out.println(worldPosition); worldPos = worldPosition.xyz(); }
public void computeWorldPos(){ Vec2f loc = location.add(gap/2f).mul(config.getScaleXZ()).sub(config.getScaleXZ()/2f); float height = getTerrainHeight(loc.getX(), loc.getY()); this.worldPos = new Vec3f(loc.getX(),height,loc.getY()); }
pos.setX(x); pos.setY(z); pos = pos.add(config.getHorizontalScaling()/2f); pos = pos.div(config.getHorizontalScaling()); Vec2f floor = new Vec2f((int) Math.floor(pos.getX()), (int) Math.floor(pos.getY()));
pos.setX(x); pos.setY(z); pos = pos.add(config.getScaleXZ()/2f); pos = pos.div(config.getScaleXZ()); Vec2f floor = new Vec2f((int) Math.floor(pos.getX()), (int) Math.floor(pos.getY()));
pos.setX(x); pos.setY(z); pos = pos.add(config.getScaleXZ()/2f); pos = pos.div(config.getScaleXZ()); Vec2f floor = new Vec2f((int) Math.floor(pos.getX()), (int) Math.floor(pos.getY()));