Class TTerrainGrid

Unit

Declaration

type TTerrainGrid = class(TTerrain)

Description

Terrain data from a grid of values with specified width * height. Used when your underlying data is a simple 2D array of GridSizeX * GridSizeY heights. The idea is that on such terrain, there are special grid points where the height data is accurate. Everything else is an interpolation derived from this data.

Hierarchy

Overview

Methods

Public constructor Create;
Public function Height(const X, Y: Single): Single; override;
Public function GridHeight(const X, Y: Cardinal): Single; virtual; abstract;
Public function GridSizeX: Cardinal; virtual; abstract;
Public function GridSizeY: Cardinal; virtual; abstract;

Properties

Public property GridX1: Single read FGridX1 write FGridX1 default 0;
Public property GridY1: Single read FGridY1 write FGridY1 default 0;
Public property GridX2: Single read FGridX2 write FGridX2 default 1;
Public property GridY2: Single read FGridY2 write FGridY2 default 1;
Public property GridHeightScale: Single read FGridHeightScale write FGridHeightScale default 1;

Description

Methods

Public constructor Create;
 
Public function Height(const X, Y: Single): Single; override;

Get height of the terrain at specified 2D point.

This is implemented in TTerrainGrid class, using the data returned by GridHeight. For float X in 0..1 range, we return grid values for grid points 0..GridSizeX - 1. Outside 0..1 range, we clamp (that is, take nearest value from 0..1 range) — this way the terrain seemingly continues into the infinity.

In comparison to GridHeight, it's (very slightly) slower, and it doesn't really present any more interesting information (in contrast to typical procedural terrain, where there can be always more and more detail at each level).

Public function GridHeight(const X, Y: Cardinal): Single; virtual; abstract;

GridSizeX, GridSizeY specify grid dimensions. Use GridHeight(0..GridSizeX - 1, 0..GridSizeY - 1) to get height at particular grid point.

Public function GridSizeX: Cardinal; virtual; abstract;
 
Public function GridSizeY: Cardinal; virtual; abstract;
 

Properties

Public property GridX1: Single read FGridX1 write FGridX1 default 0;

Specify where terrain is located, for Height method. These do not affect GridHeight method.

Public property GridY1: Single read FGridY1 write FGridY1 default 0;
 
Public property GridX2: Single read FGridX2 write FGridX2 default 1;
 
Public property GridY2: Single read FGridY2 write FGridY2 default 1;
 
Public property GridHeightScale: Single read FGridHeightScale write FGridHeightScale default 1;
 

Generated by PasDoc 0.16.0.