Class TCastleTerrain
Unit
Declaration
type TCastleTerrain = class(TCastleTransform)
Description
Terrain.
Assign Data to provide some non-trivial height map, you can use there:
TCastleTerrainNoise to generate a height map using a dedicated algorithm for terrain generation, using smooth noise and special tricks to have smooth and heteregeneous terrain.
TCastleTerrainImage to generate a height map from intensities of a simple 2D image.
TCastleTerrainCombine to combine the above options in any expression (take minimum, maximum, sum, multiply).
The terrain starts as a standard mesh with a TPhysicalMaterialNode material. We apply on it a special affect to mix 4 layers, where each layer has a separate color and texture.
Each layer has a color (white by default), texture (none by default, that behaves like white) and UV scale. See TCastleTerrainLayer. Each layer is a property like Layer1, Layer2, Layer3, Layer4.
Only the RBG channels of textures matter, alpha is ignored.
Layer 1 is used for flat terrain on lower heights.
Layer 2 is used for steep terrain on lower heights.
Layer 3 is used for flat terrain on higher heights.
Layer 4 is used for steep terrain on higher heights.
The meaning of "lower" and "higher" heights is determined by Height1 and Height2. Below Height1 we show only layers 1+2, above Height2 we show only layers 3+4, between we show a smooth interpolation between them.
The meaning of "flat" and "steep" is determined by looking at terrain normals emphasized by SteepEmphasize.
The influence of this effect can be controlled by LayersInfluence.
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleTransform
- TCastleTerrain
Overview
Fields
nested const LayersCount = 4; |
|
nested const HeightsCount = 2; |
|
nested const DefaultSubdivisions = 64; |
|
nested const DefaultSize = 100; |
|
nested const DefaultHeight1 = 4.0; |
|
nested const DefaultHeight2 = 8.0; |
|
nested const DefaultHeight: array [1..HeightsCount] of Single = (
DefaultHeight1,
DefaultHeight2
); |
|
nested const DefaultLayersInfluence = 1.0; |
|
nested const DefaultSteepEmphasize = 2.0; |
Methods
procedure Loaded; override; |
|
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
Properties
property Subdivisions: TVector2 read FSubdivisions write SetSubdivisions; |
|
property Size: TVector2 read FSize write SetSize; |
|
property RenderOptions: TCastleRenderOptions read GetRenderOptions; |
|
property Layer1: TCastleTerrainLayer index 1 read GetLayer; |
|
property Layer2: TCastleTerrainLayer index 2 read GetLayer; |
|
property Layer3: TCastleTerrainLayer index 3 read GetLayer; |
|
property Layer4: TCastleTerrainLayer index 4 read GetLayer; |
|
property Data: TCastleTerrainData read FData write SetData; |
|
property Triangulate: Boolean read FTriangulate write SetTriangulate default true; |
|
property SteepEmphasize: Single read FSteepEmphasize write SetSteepEmphasize
default DefaultSteepEmphasize; |
|
property Height1: Single index 1 read GetHeight write SetHeight default DefaultHeight1; |
|
property Height2: Single index 2 read GetHeight write SetHeight default DefaultHeight2; |
|
property LayersInfluence: Single read FLayersInfluence write SetLayersInfluence
default DefaultLayersInfluence; |
|
property PreciseCollisions: Boolean read FPreciseCollisions write SetPreciseCollisions default true; |
|
property SizePersistent: TCastleVector2Persistent read FSizePersistent ; |
|
property SubdivisionsPersistent: TCastleVector2Persistent read FSubdivisionsPersistent ; |
Description
Fields
nested const LayersCount = 4; |
|
Texture layers to render this terrain. |
nested const HeightsCount = 2; |
|
nested const DefaultSubdivisions = 64; |
|
nested const DefaultSize = 100; |
|
nested const DefaultHeight1 = 4.0; |
|
nested const DefaultHeight2 = 8.0; |
|
nested const DefaultHeight: array [1..HeightsCount] of Single = (
DefaultHeight1,
DefaultHeight2
); |
|
Default values for Height1, Height2 etc. Note: This array duplicates information in constants DefaultHeight1, DefaultHeight2 etc. Unfortunately we need the simple constants too, to specify properties default values like "default DefaultHeight0". Using "default |
nested const DefaultLayersInfluence = 1.0; |
|
nested const DefaultSteepEmphasize = 2.0; |
|
Methods
procedure Loaded; override; |
|
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
Properties
property Subdivisions: TVector2 read FSubdivisions write SetSubdivisions; |
|
How dense is the mesh. By default this is (DefaultSubdivisions,DefaultSubdivisions). Changing this requires rebuild of terrain geometry, so it's costly. Avoid doing it at runtime. |
property Size: TVector2 read FSize write SetSize; |
|
Size of the generated shape and also the underlying range to query the TCastleTerrainNoise data for heights. Note that changing this does not just scale the same geometry, if TCastleTerrainNoise is used for Data. The TCastleTerrainNoise uses the size you set here to determine what heights to query from a smooth noise. This has a nice effect that increasing the size adds additional pieces of terrain adjacent to the previous terrain, and the previous terrain shape is still visible at the same place. Be sure to increase also Subdivisions when increasing this field, to keep seeing the same detail. By default this is (DefaultSize,DefaultSize). Changing this requires rebuild of terrain geometry, so it's costly. Avoid doing it at runtime. |
property RenderOptions: TCastleRenderOptions read GetRenderOptions; |
|
Options used to render the terrain. Can be used e.g. to toggle wireframe rendering. |
property Layer1: TCastleTerrainLayer index 1 read GetLayer; |
|
1st layer is displayed on lower heights and more flat terrain. See TCastleTerrain for a full description how do we mix layers. |
property Layer2: TCastleTerrainLayer index 2 read GetLayer; |
|
2nd layer is displayed on lower heights and more steep terrain. See TCastleTerrain for a full description how do we mix layers. |
property Layer3: TCastleTerrainLayer index 3 read GetLayer; |
|
3rd layer is displayed on higher heights and more flat terrain. See TCastleTerrain for a full description how do we mix layers. |
property Layer4: TCastleTerrainLayer index 4 read GetLayer; |
|
4th layer is displayed on higher heights and more steep terrain. See TCastleTerrain for a full description how do we mix layers. |
property Data: TCastleTerrainData read FData write SetData; |
|
Data for terrain heights. Changing this requires rebuild of terrain geometry, so it's costly. Avoid doing it at runtime. |
property SteepEmphasize: Single read FSteepEmphasize write SetSteepEmphasize
default DefaultSteepEmphasize; |
|
How much should we emphasize the "steep" layers (2nd and 4th layers) at the expense of "flat" layers (1st and 3rd).
|
property Height1: Single index 1 read GetHeight write SetHeight default DefaultHeight1; |
|
Below |
property Height2: Single index 2 read GetHeight write SetHeight default DefaultHeight2; |
|
Above |
property LayersInfluence: Single read FLayersInfluence write SetLayersInfluence
default DefaultLayersInfluence; |
|
How much do the layers affect the final color. 0.0 means that layes are ignored, and the terrain look is a regular mesh look with TPhysicalMaterialNode. 1.0 means maximum influence, the layers determine the base color (TODO: and normals in the future). |
property PreciseCollisions: Boolean read FPreciseCollisions write SetPreciseCollisions default true; |
|
Resolve collisions precisely with the terrain geometry. When this is |
property SizePersistent: TCastleVector2Persistent read FSizePersistent ; |
|
Size that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write Size directly. See also
|
property SubdivisionsPersistent: TCastleVector2Persistent read FSubdivisionsPersistent ; |
|
Subdivisions that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write Subdivisions directly. See also
|
Generated by PasDoc 0.16.0.