Class DiamondSquareTerrain

java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.base.AbstractCompositeShape
eu.svjatoslav.sixth.e3d.examples.terrain_demo.DiamondSquareTerrain

public class DiamondSquareTerrain extends eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.base.AbstractCompositeShape
A procedurally generated terrain mesh using the diamond-square algorithm. Creates a grid of triangular polygons with height variation for mountains.
  • Field Summary

    Fields inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape

    cachedBoundingBox, mouseInteractionController
  • Constructor Summary

    Constructors
    Constructor
    Description
    DiamondSquareTerrain(int gridSize, double minHeight, double maxHeight, long seed)
    Creates a diamond-square terrain with the specified parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    getHeightAt(double worldX, double worldZ)
    Returns the terrain height at the specified world XZ coordinates.

    Methods inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.base.AbstractCompositeShape

    addShape, addShape, beforeTransformHook, extractSolidPolygons, getBoundingBox, getGroup, getLocation, getSubShapesRegistry, getTransform, getViewSpaceTracker, hideGroup, intersect, removeGroup, setBackfaceCulling, setCacheNeedsRebuild, setColor, setGroupForUngrouped, setMouseInteractionController, setRootComposite, setShadingEnabled, setTransform, showGroup, subtract, transform, union

    Methods inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape

    invalidateBounds

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DiamondSquareTerrain

      public DiamondSquareTerrain(int gridSize, double minHeight, double maxHeight, long seed)
      Creates a diamond-square terrain with the specified parameters.
      Parameters:
      gridSize - the size of the heightmap grid (must be 2^n + 1)
      minHeight - the minimum terrain height
      maxHeight - the maximum terrain height
      seed - random seed for reproducible terrain
  • Method Details

    • getHeightAt

      public double getHeightAt(double worldX, double worldZ)
      Returns the terrain height at the specified world XZ coordinates.
      Parameters:
      worldX - the world X coordinate
      worldZ - the world Z coordinate
      Returns:
      the terrain height at that position, or 0 if outside terrain bounds