dxCreateTerrain%(grid_size%,parent%)

Parameters

grid_size - no of grid squares along each side of terrain, and must be a power of 2 value, e.g. 32, 64, 128, 256, 512, 1024.
parent (optional) - parent entity of terrain

Description

Creates a terrain entity and returns its handle.

The terrain extends from 0,0,0 to grid_size,1,grid_size.

A terrain is a special type of polygon object that uses real-time level of detail (LOD) to display landscapes which should theoretically consist of over a million polygons with only a few thousand. The way it does this is by constantly rearranging a certain amount of polygons to display high levels of detail close to the viewer and low levels further away.

This constant rearrangement of polygons is occasionally noticeable however, and is a well-known side-effect of all LOD landscapes. This 'pop-in' effect can be reduced in lots of ways though, as the other terrain help files will go on to explain.

The optional parent parameter allows you to specify a parent entity for the terrain so that when the parent is moved the child terrain will move with it. However, this relationship is one way; applying movement commands to the child will not affect the parent.

Specifying a parent entity will still result in the terrain being created at position 0,0,0 rather than at the parent entity's position.

See also: dxLoadTerrain.

Example

; dxCreateTerrain Example
; ---------------------

dxGraphics3D 640,480
dxSetBuffer dxBackBuffer()

camera=dxCreateCamera()
dxPositionEntity camera,0,1,0

light=dxCreateLight()
dxRotateEntity light,90,0,0

; Create terrain
terrain=dxCreateTerrain(128)

; Texture terrain
grass_tex=dxLoadTexture( "media/mossyground.bmp" )
dxEntityTexture terrain,grass_tex

While Not dxKeyDown( 1 )

If dxKeyDown( 205 )=True Then dxTurnEntity camera,0,-1,0
If dxKeyDown( 203 )=True Then dxTurnEntity camera,0,1,0
If dxKeyDown( 208 )=True Then dxMoveEntity camera,0,0,-0.05
If dxKeyDown( 200 )=True Then dxMoveEntity camera,0,0,0.05

dxRenderWorld

dxText 0,0,"Use cursor keys to move about the terrain"

dxFlip

Wend

End

Index