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; |
|
nested const DefaultTriangulationIgnoreHeights = false; |
Methods
procedure Loaded; override; |
|
function InternalBuildNodeInside: TObject; override; |
|
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
function HasColliderMesh: Boolean; override; |
|
procedure ColliderMesh(const TriangleEvent: TTriangleEvent); override; |
Properties
property Subdivisions: TVector2 read FSubdivisions write SetSubdivisions; |
|
property Size: TVector2 read FSize write SetSize; |
|
property QueryOffset: TVector2 read FQueryOffset write SetQueryOffset; |
|
property Triangulate: Boolean read FTriangulationIgnoreHeights write SetTriangulationIgnoreHeights; deprecated 'use TriangulationIgnoreHeights'; |
|
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 TriangulationIgnoreHeights: Boolean
read FTriangulationIgnoreHeights write SetTriangulationIgnoreHeights
default DefaultTriangulationIgnoreHeights; |
|
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 QueryOffsetPersistent: TCastleVector2Persistent read FQueryOffsetPersistent ; |
|
property SubdivisionsPersistent: TCastleVector2Persistent read FSubdivisionsPersistent ; |
Description
Fields
nested const LayersCount = 4; |
|
Texture layers to render this terrain. |
nested const HeightsCount = 2; |
|
This item has no description. |
nested const DefaultSubdivisions = 64; |
|
This item has no description. |
nested const DefaultSize = 100; |
|
This item has no description. |
nested const DefaultHeight1 = 4.0; |
|
This item has no description. |
nested const DefaultHeight2 = 8.0; |
|
This item has no description. |
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; |
|
This item has no description. |
nested const DefaultSteepEmphasize = 2.0; |
|
This item has no description. |
nested const DefaultTriangulationIgnoreHeights = false; |
|
This item has no description. |
Methods
procedure Loaded; override; |
|
This item has no description. |
function InternalBuildNodeInside: TObject; override; |
|
This item has no description. Showing description inherited from TCastleTransform.InternalBuildNodeInside.
Helper for InternalBuildNode. Result must be TAbstractChildNode or |
constructor Create(AOwner: TComponent); override; |
|
This item has no description. |
destructor Destroy; override; |
|
This item has no description. |
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
This item has no description. Showing description inherited from TCastleComponent.PropertySections. Section where to show property in the editor. |
function HasColliderMesh: Boolean; override; |
|
This item has no description. Showing description inherited from TCastleTransform.HasColliderMesh.
Does this transform have a collision mesh that TCastleMeshCollider can use. Default implementation returns |
procedure ColliderMesh(const TriangleEvent: TTriangleEvent); override; |
|
This item has no description. Showing description inherited from TCastleTransform.ColliderMesh.
Enumerate triangles for a collision mesh that TCastleMeshCollider can use. Always the front side of triangles is CCW (this matters for TCastleMeshCollider with TCastleMeshCollider.DoubleSided = |
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 QueryOffset: TVector2 read FQueryOffset write SetQueryOffset; |
|
Offset the range of input values used to query the Data. By default (when this is zero) we query the TCastleTerrainData.Height using This vector offsets the range of queried values. It can be used to display a terrain noise matching neighboring terrain noise. |
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 TriangulationIgnoreHeights: Boolean
read FTriangulationIgnoreHeights write SetTriangulationIgnoreHeights
default DefaultTriangulationIgnoreHeights; |
|
Triangulate each terrain quad the same way. When When 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 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 QueryOffsetPersistent: TCastleVector2Persistent read FQueryOffsetPersistent ; |
|
QueryOffset 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 QueryOffset 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-snapshot.