Description | Hierarchy | Fields | Methods | Properties |
type TTerrainSceneNode = class(TSceneNode)
A scene node for displaying terrain using the geo mip map algorithm.
The code for the TerrainSceneNode is based on the Terrain renderer by Soconne and the GeoMipMapSceneNode developed by Spintz. They made their code available for Irrlicht and allowed it to be distributed under this licence. I only modified some parts. A lot of thanks go to them.
This scene node is capable of very quickly loading terrains and updating the indices at runtime to enable viewing very large terrains. It uses a CLOD (Continuous Level of Detail) algorithm which updates the indices for each patch based on a LOD (Level of Detail) which is determined based on a patch's distance from the camera.
The Patch Size of the terrain must always be a size of ( 2ˆN+1, i.e. 8+1(9), 16+1(17), etc. ). The MaxLOD available is directly dependent on the patch size of the terrain. LOD 0 contains all of the indices to draw all the triangles at the max detail for a patch. As each LOD goes up by 1 the step taken, in generating indices increases by - 2ˆLOD, so for LOD 1, the step taken is 2, for LOD 2, the step taken is 4, LOD 3 - 8, etc. The step can be no larger than the size of the patch, so having a LOD of 8, with a patch size of 17, is asking the algoritm to generate indices every 2ˆ8 ( 256 ) vertices, which is not possible with a patch size of 17. The maximum LOD for a patch size of 17 is 2ˆ4 ( 16 ). So, with a MaxLOD of 5, you'll have LOD 0 ( full detail ), LOD 1 ( every 2 vertices ), LOD 2 ( every 4 vertices ), LOD 3 ( every 8 vertices ) and LOD 4 ( every 16 vertices ).
![]() |
function GetBoundingBox(PatchX, PatchZ: LongInt): TBoundingBox; inline; |
![]() |
function GetCurrentLODOfPatches: TLongIntArray; inline; |
![]() |
function GetHeight(X, Z: Single): Single; inline; |
![]() |
function GetIndicesForPatch(PatchX, PatchZ, LOD: LongInt): TLongWordArray; inline; |
![]() |
function GetMesh: TMesh; inline; |
![]() |
function GetRenderBuffer: TMeshBuffer; inline; |
![]() |
function LoadHeightMap(RFile: TReadFile; VertexColor: TARGBColor = $ffffffff; SmoothFactor: LongInt = 0): Boolean; inline; |
![]() |
function LoadHeightMapRaw(RFile: TReadFile; BitsPerPixel: LongInt = 16; SignedData: Boolean = False; FloatVals: Boolean = False; Width: LongInt = 0; VertexColor: TARGBColor = $ffffffff; SmoothFactor: LongInt = 0): Boolean; inline; |
![]() |
function OverrideLODDistance(LOD: LongInt; NewDistance: Double): Boolean; inline; |
![]() |
procedure GetMeshBufferForLOD(Buffer: TDynamicMeshBuffer; LOD: LongInt); inline; |
![]() |
procedure ScaleTexture(Scale: Single = 1; Scale2: Single = 0); inline; |
![]() |
procedure SetCameraMovementDelta(Delta: Single); inline; |
![]() |
procedure SetCameraRotationDelta(Delta: Single); inline; |
![]() |
procedure SetDynamicSelectorUpdate(Update: Boolean); inline; |
![]() |
procedure SetLODOfPatch(PatchX, PatchZ, LOD: LongInt); inline; |
![]() |
property IndexCount: LongWord read GetIndexCount; |
![]() |
property TerrainCenter: TVector3D read GetTerrainCenter; |
![]() |
function GetBoundingBox(PatchX, PatchZ: LongInt): TBoundingBox; inline; |
Gets the bounding box of a patch. Parameters
ReturnsThe bounding box. |
![]() |
function GetCurrentLODOfPatches: TLongIntArray; inline; |
Returns an array containing the current LOD of each patch. |
![]() |
function GetHeight(X, Z: Single): Single; inline; |
Returns the height of a point in the terrain. |
![]() |
function GetIndicesForPatch(PatchX, PatchZ, LOD: LongInt): TLongWordArray; inline; |
Returns the indices for a specified patch at a specified Level of Detail. Parameters
|
![]() |
function GetMesh: TMesh; inline; |
Returns the terrain mesh. |
![]() |
function GetRenderBuffer: TMeshBuffer; inline; |
Returns the buffer used by the terrain. Usually used internally. |
![]() |
function LoadHeightMap(RFile: TReadFile; VertexColor: TARGBColor = $ffffffff; SmoothFactor: LongInt = 0): Boolean; inline; |
Initializes the terrain data. Loads the vertices from the RFile. Parameters
|
![]() |
function LoadHeightMapRaw(RFile: TReadFile; BitsPerPixel: LongInt = 16; SignedData: Boolean = False; FloatVals: Boolean = False; Width: LongInt = 0; VertexColor: TARGBColor = $ffffffff; SmoothFactor: LongInt = 0): Boolean; inline; |
Initializes the terrain data. Loads the vertices from the RFile. Parameters
|
![]() |
function OverrideLODDistance(LOD: LongInt; NewDistance: Double): Boolean; inline; |
Override the default generation of distance thresholds. |
![]() |
procedure GetMeshBufferForLOD(Buffer: TDynamicMeshBuffer; LOD: LongInt); inline; |
Fetches the meshbuffer data based on a specified level of detail. Parameters
|
![]() |
procedure ScaleTexture(Scale: Single = 1; Scale2: Single = 0); inline; |
Scales the base texture, similar to makePlanarTextureMapping. Parameters
|
![]() |
procedure SetCameraMovementDelta(Delta: Single); inline; |
Sets the movement camera threshold. |
![]() |
procedure SetCameraRotationDelta(Delta: Single); inline; |
Sets the rotation camera threshold. |
![]() |
property IndexCount: LongWord read GetIndexCount; |
The number of indices currently in the mesh buffer. |
![]() |
property TerrainCenter: TVector3D read GetTerrainCenter; |
The terrain's center. |