Gorilla.Terrain.Sphere
Unit Gorilla.Terrain.Sphere.pasClasses
- TGorillaSphereTerrain = class ( TGorillaMesh )
TGorillaSphereTerrain
Simple sphere terrain component for rendering from heightmaps or procedural algorithms. The sphere terrain model contains by default a sub-mesh which contains all necessary mesh data.
Ancestors
Members
Fields
- protected FTwoFace :
Boolean
- protected FHeightMap :
TBitmap
- protected FHeightScale :
Single
- protected FSmoothing :
Integer
- protected FShowVertices :
Boolean
- protected FShowGrid :
Boolean
- protected FDotMaterial :
TColorMaterial
- protected FSubdivisionsWidth :
Integer
- protected FSubdivisionsHeight :
Integer
- protected FStaticBuffering :
Boolean
- protected FAutoDecimate :
Boolean
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected procedure SetTwoFace ( const AValue : Boolean ) ; virtual;
- protected function GetResolutionX ( ) : Integer ; virtual;
- protected procedure SetResolutionX ( const AValue : Integer ) ; virtual;
- protected function GetResolutionY ( ) : Integer ; virtual;
- protected procedure SetResolutionY ( const AValue : Integer ) ; virtual;
- protected function GetResolution ( ) : TPoint ; virtual;
- protected procedure SetResolution ( const AValue : TPoint ) ; virtual;
- protected procedure SetHeightMap ( const AValue : TBitmap ) ; virtual;
- protected procedure SetHeightScale ( const AValue : Single ) ; virtual;
- protected procedure SetSmoothing ( const AValue : Integer ) ; virtual;
- protected function GetVerticeColor ( ) : TAlphaColor ; virtual;
- protected procedure SetVerticeColor ( AValue : TAlphaColor ) ; virtual;
- protected procedure SetStaticBuffering ( const AValue : Boolean ) ; virtual;
- protected procedure SetAutoDecimate ( const AValue : Boolean ) ; virtual;
- protected procedure Loaded ( ) ; override;
- protected procedure DoOnHeightMapChanged ( ASender : TObject ) ; virtual;
- protected procedure DoOnRenderControls ( ASender : TObject; AContext : TContext3D ) ; override;
- protected procedure UpdateTerrain
(
)
;
virtual;
Executes the Setup() and RebuildTerrain() methods
- public function GetMeshMatrix
(
)
: TMatrix3D
;
override;
Returns the mesh matrix of the terrain vertices inside the sub-mesh. This method calls the GetMeshMatrix() method of the integrated sub-mesh.
- public procedure SetXYResolution
(
const
X :
Integer; const
Y :
Integer
)
;
Sets the resolution used by the terrain build routine. By "resolution" is meant the rows and columns of the terrain grid. By default the grid is set to 64 x 64. The larger you choose the number of rows and columns the more memory is needed, because the more vertices need to be created.
- public procedure RebuildTerrain
(
const
AStaticBuffering :
Boolean
=
True
; const
ADecimate :
Boolean
=
False
)
;
Clears the previous terrain and rebuilds it from given heightmap. Procedural algorithms will also use this method, after building their heightmap.
Parameters
- const AStaticBuffering : Boolean = True - Activate static buffering of vertices and indices. Mesh data will be uploaded directly to GPU memory and handled a static buffer. The routine will automatically decimate the mesh data. If you like to decimate with individual parameters, set this parameter to false and use the Decimate() function.
- const ADecimate : Boolean = False - Activate static buffering of vertices and indices. Mesh data will be uploaded directly to GPU memory and handled a static buffer. The routine will automatically decimate the mesh data. If you like to decimate with individual parameters, set this parameter to false and use the Decimate() function.
- public procedure RandomTerrain
(
const
AAlgorithm :
TRandomTerrainAlgorithmType; const
AStaticBuffering :
Boolean
=
True
; const
ADecimate :
Boolean
=
False
)
;
overload;
Execute this method to build a heightmap by a specific procedural terrain algorithm. The method will automatically execute the RebuildTerrain() method.
- public procedure RandomTerrain
(
const
AAlgorithm :
TRandomTerrainAlgorithm; const
AStaticBuffering :
Boolean
=
True
; const
ADecimate :
Boolean
=
False
)
;
overload;
Execute this method to build a heightmap by a specific procedural terrain algorithm. The method will automatically execute the RebuildTerrain() method.
- public procedure Decimate
(
const
ARatio :
Single
=
0.2
; const
AAgression :
Single
=
3
; const
ATolerance :
Single
=
0.0001
)
;
virtual;
Decimates the terrain mesh data depending on the supplied parameters.
Parameters
- const ARatio : Single = 0.2 - An expected ratio of reduction. Aggression used to decimate vertices. The higher the value, the more radical vertices are going to be removed/unified. Tolerance used to decide if a vertices should be removed / unified.
- const AAgression : Single = 3 - An expected ratio of reduction. Aggression used to decimate vertices. The higher the value, the more radical vertices are going to be removed/unified. Tolerance used to decide if a vertices should be removed / unified.
- const ATolerance : Single = 0.0001 - An expected ratio of reduction. Aggression used to decimate vertices. The higher the value, the more radical vertices are going to be removed/unified. Tolerance used to decide if a vertices should be removed / unified.
- public procedure BeginUpdate ( ) ; override;
- public procedure EndUpdate ( ) ; override;
Properties
- published TwoFace : Boolean
Defines if front and back of triangles will be rendered. By default this property is set to FALSE to gain performance.
read FTwoFace
write SetTwoFace - published ResolutionX : Integer
Defines the columns of the grid. The larger you set this value, the more vertices will be created and the more memory is needed.
read GetResolutionX
write SetResolutionX - published ResolutionY : Integer
Defines the rows of the grid. The larger you set this value, the more vertices will be created and the more memory is needed.
read GetResolutionY
write SetResolutionY - published Resolution : TPoint
Defines the rows and columns of the grid. The larger you set this value, the more vertices will be created and the more memory is needed.
read GetResolution
write SetResolution - published HeightMap : TBitmap
The heightmap bitmap is used to compute the y-value of every vertex in the terrain grid.
read FHeightMap
write SetHeightMap - published HeightScale : Single
Describes the y-multiplicator on applying the heightmap on the terrain grid.
read FHeightScale
write SetHeightScale - published Smoothing : Integer
Defines if heightmap getting smoothed before translating to vertex positions. The higher this value is, the more smoothing iterations will be executed. To deactivate smoothing, set the value to 0.
read FSmoothing
write SetSmoothing - published ShowVertices : Boolean
Displays the vertices as dots after rendering. Use this property only at debug time and deactivate at release. It reduces rendering speed a lot.
read FShowVertices
write FShowVertices - published ShowGrid : Boolean
- published VerticeColor : TAlphaColor
Defines the vertex color for each vertex drawn by the post-renderer. This property is only useful if ShowVertices is activated.
read GetVerticeColor
write SetVerticeColor - published StaticBuffering : Boolean
Get or set if the vertex data should be stored in a framebufferobject for fast rendering.
read FStaticBuffering
write SetStaticBuffering - published AutoDecimate : Boolean
Get or set if vertex data will automatically be reduced by the integrated algorithm.
read FAutoDecimate
write SetAutoDecimate