Gorilla.Terrain.Algorithm
Unit Gorilla.Terrain.Algorithm.pasClasses
- TRandomTerrainAlgorithm = class ( TObject )
- THillRandomTerrain = class ( TRandomTerrainAlgorithm )
- TDiamondSquareTerrain = class ( TRandomTerrainAlgorithm )
- TMandelbrotTerrain = class ( TRandomTerrainAlgorithm )
- TDiamondSquareBasedTerrain = class ( TRandomTerrainAlgorithm )
- TPerlinNoiseTerrain = class ( TDiamondSquareBasedTerrain )
- TPlateauTerrain = class ( TDiamondSquareTerrain )
- TBrownianTerrain = class ( TDiamondSquareBasedTerrain )
Enumerations
- enum TRandomTerrainAlgorithmType = ( Hill, DiamondSquare, Mandelbrot, PerlinNoise, Plateau, Brownian ) ;
- enum TPerlinNoiseInterpolation = ( Linear, Cosine, Cubic ) ;
Constants
- const GORILLA_TERRAIN_SMOOTHING_MIN : Integer = $0;
- const GORILLA_TERRAIN_SMOOTHING_MAX : Integer = $14;
TRandomTerrainAlgorithmType
Defines the procedural terrain algorithm: Hill, DiamondSquare, Mandelbrot, PerlinNoise, Plateau, Brownian.
TRandomTerrainAlgorithm
Custom procedural terrain algorithm class. Extend this class to create your individual terrain algorithm. Data is stored temporarily as Array of Array of Single. On GetHeightMap() call, the class will create a TBitmap from the raw data.
Ancestors
Members
Fields
- protected FSize :
Integer
- protected FWidth :
Integer
- protected FHeight :
Integer
- protected FData :
TArray<System.TArray<System.Single>>
Methods
- public constructor Create ( ) ;
- public destructor Destroy ( ) ;
- public function GetHeightMap
(
)
: TBitmap
;
virtual;
The method returns a new TBitmap instance where pixels represent the computed height information from internal data array. This method is automatically called by the TGorillaTerrain component while execution.
Properties
THillRandomTerrain
A basic procedural hill algorithm. The algorithm will produce smooth hills by radius settings and a given count.
Ancestors
Members
Fields
Methods
- public constructor Create ( ) ;
- public destructor Destroy ( ) ;
- protected procedure Generate ( const N : Integer = $9 ) ;
- public function GetHeightMap ( ) : TBitmap ; override;
Properties
- published Hills : Integer
- published MinRadius : Integer
Minimum radius used for generated hills. The algorithm will interpolate a value between min and max radius.
read FMinRadius
write FMinRadius - published MaxRadius : Integer
Maximum radius used for generated hills. The algorithm will interpolate a value between min and max radius.
read FMaxRadius
write FMaxRadius
TDiamondSquareTerrain
A very popular algorithm to build random terrain. The algorithm creates randomly lows and highs for a realisic terrain.
Ancestors
Members
TMandelbrotTerrain
Creates the typical mandelbrot pattern: https://en.wikipedia.org/wiki/Mandelbrot_set This is a fixed result, but you could use this as basis for further computation.
Ancestors
Members
TDiamondSquareBasedTerrain
A very popular algorithm to build random terrain. The algorithm creates randomly lows and highs for a realisic terrain. This component is similar, but more flexible than TDiamondSquareTerrain.
Ancestors
Members
Fields
- protected FMSeed :
Integer
- protected FDiamondSquareFactor :
Single
- protected FDiamondSquareEnabled :
Boolean
Methods
- public constructor Create ( ) ;
- public destructor Destroy ( ) ;
- protected procedure GenerateDiamondSquare ( const N : Integer ) ;
Properties
- published MSeed : Integer
- published DiamondSquareFactor : Single
Change this factor to manipulate coordinate values. By default this value is set to 1. If DiamondSquareFactor is zero, the algorithm will compute nothing.
read FDiamondSquareFactor
write FDiamondSquareFactor - published DiamondSquareEnabled : Boolean
Enables the diamond square factor usage. By default this value is set to true. If DiamondSquareEnabled is set to false the algorithm will compute nothing.
read FDiamondSquareEnabled
write FDiamondSquareEnabled
TPerlinNoiseTerrain
Perlin noise terrains are a good choice for random terrain. The component provides different mathmatical interpolation methods (linear, cosine, cubic).
Ancestors
Members
Fields
- protected FMSeed :
Integer
- protected FIntensity :
Single
- protected FInterpolation :
TPerlinNoiseInterpolation
Methods
- public constructor Create ( ) ;
- public destructor Destroy ( ) ;
- protected function LinearInterpolate ( a : Double; b : Double; fraction : Double ) : Double ;
- protected function CosineInterpolate ( const a : Double; const b : Double; const fraction : Double ) : Double ;
- protected function CubicInterpolate ( const v0 : Double; const v1 : Double; const v2 : Double; const v3 : Double; const x : Double ) : Double ;
- protected function Noise ( const x : Double; const y : Double ) : Double ;
- protected function SmoothedNoise ( const x : Double; const y : Double ) : Double ;
- protected function InterpolatedNoise ( const x : Double; const y : Double ) : Double ;
- protected function PerlinNoise2D ( const x : Double; const y : Double ) : Double ;
- protected procedure Generate ( const N : Integer = $7 ) ;
- public function GetHeightMap ( ) : TBitmap ; override;
Properties
- published Intensity : Single
Defines the intensity of computation. The more intense, the higher the peaks get. By default this value is set to 0.25.
read FIntensity
write FIntensity - published Interpolation : TPerlinNoiseInterpolation
Defines the used interpolation method: Linear, Cosine, Cubic. By default this value is set to Cosine interpolation.
read FInterpolation
write FInterpolation
TPlateauTerrain
A plateau terrain is described by a specific number of high and flat areas, while the rest is much lower. The algorithm extends the TDiamondSquareTerrain.
Ancestors
Members
Fields
- protected FPlateaus :
Integer
- protected FMinSize :
Integer
- protected FMaxSize :
Integer
- protected FMinHeight :
Single
- protected FMaxHeight :
Single
- protected FInverted :
Boolean
Methods
- public constructor Create ( ) ;
- public destructor Destroy ( ) ;
- protected procedure Generate ( const N : Integer = $9 ) ; override;
- protected procedure GeneratePlateau
(
)
;
Build a specific number of plateaus after the algorithm already applied the diamond square terrain algorithm.
Properties
- published Plateaus : Integer
- published MinSize : Integer
- published MaxSize : Integer
- published MinHeight : Single
Defines the minimum height of the plateaus. By default this value is set to 0.25.
read FMinHeight
write FMinHeight - published MaxHeight : Single
Defines the maximum height of the plateaus. By default this value is set to 1.0.
read FMaxHeight
write FMaxHeight - published Inverted : Boolean
TBrownianTerrain
Brownian terrains or brownian surface is based on the diamond square based terrain algorithm: https://en.wikipedia.org/wiki/Brownian_surface The component computes peaks by a specific number of random particles. Afterwards the complete terrain will be smooth to create a realistic landscape.
Ancestors
Members
Fields
Methods
- public constructor Create ( ) ;
- public destructor Destroy ( ) ;
- protected procedure Generate ( const N : Integer = $9 ) ; virtual;
- public function GetHeightMap ( ) : TBitmap ; override;
Properties
- published Particles : Integer
Number of particles used for terrain computation. The larger, the slower the algorithm, but the more random the terrain looks like. By default this value is set to 3000.
read FParticles
write FParticles - published MinHeight : Single
Minimum height factor for computed peaks. By default this value is set to 0.01.
read FMinHeight
write FMinHeight - published MaxHeight : Single
Maximum height factor for computed peaks. By default this value is set to 0.05.
read FMaxHeight
write FMaxHeight