Function _IrrAddTerrain

au3Irr2

au3Irr2 Function Reference

_IrrAddTerrain

Creates a terrain object from a gray scale bitmap.

#Include <au3Irrlicht2.au3>
_IrrAddTerrain($s_Path, $f_PosX = 0.0, $f_PosY = 0.0, $f_PosZ = 0.0, $f_RotX = 0.0, $f_RotY = 0.0, $f_RotZ = 0.0, $f_ScaleX = 1.0, $f_ScaleY = 1.0, $f_ScaleZ = 1.0, $i_VertexAlpha = 255, $i_VertexRed = 255, $i_VertexGreen = 255, $i_VertexBlue = 255, $i_Smoothing = 0, $i_MaxLOD = 5, $i_PatchSize = $ETPS_17)

 

Parameters

$s_Path Filename of a gray scale image used to define the contours of the surface
$f_PosX, $f_PosY, $f_PosZ [optional] Define position of the terrain
$f_RotX, $f_RotY, $f_RotZ [optional] Define rotation of the terrain
$f_ScaleX, $f_ScaleY, $f_ScaleZ [optional] Define scaling of the terrain
$i_VertexAlpha [optional] Alpha value for the vertex colour from 0 to 255.
$i_VertexRed, $i_VertexGreen, $i_VertexBlue [optional] Define the vertex colour of all points in the terrain (values from 0 to 255)
$i_Smoothing [optional] True or false defines whether the contours of the surface of the terrain are smoothed over.
$i_MaxLOD, $i_PatchSize [optional] Control the properties of the level of detail calculations applied to the terrain.
It is recommended that these are left at default values.

Valid values for $i_PatchSize:
$ETPS_9 (patch size of 9, at most, use 4 levels of detail with this patch size)
$ETPS_17 (patch size of 17, at most, use 5 levels of detail with this patch size)
$ETPS_33 (patch size of 33, at most, use 6 levels of detail with this patch size)
$ETPS_65 (patch size of 65, at most, use 7 levels of detail with this patch size)
$ETPS_129 (patch size of 129, at most, use 8 levels of detail with this patch size)

 

Return Value

success: Handle of the terrain object
failure: false

 

Remarks

The terrain is created from a gray scale bitmap where bright pixels are high points on the terrain and black pixels are low points.
You will inevitablly have to rescale the terrain during the call or after it is created.
The Terrain object is a special dynamic mesh whose resoloution is reduced in the distance to reduce the number of triangles it consumes.

 

Related

_IrrScaleTexture

 

Example


#include "au3Irrlicht2.au3"

_IrrStart()

local $nodeTerrain = _IrrAddTerrain( "./media/terrain-heightmap.bmp" )
_IrrSetNodeScale( $nodeTerrain, 40.0, 4.4, 40.0 )

_IrrSetNodeMaterialTexture( $nodeTerrain, _IrrGetTexture( "./media/terrain-texture.jpg" ), 0 )
_IrrSetNodeMaterialTexture( $nodeTerrain, _IrrGetTexture( "./media/detailmap3.jpg" ), 1 )

_IrrScaleTexture( $nodeTerrain, 1.0, 60.0 )

_IrrSetNodeMaterialFlag( $nodeTerrain, $IRR_EMF_LIGHTING, $IRR_OFF )
_IrrSetNodeMaterialType ( $nodeTerrain, $IRR_EMT_DETAIL_MAP )

local $nodeCamera = _IrrAddFPSCamera()
_IrrSetNodePosition( $nodeCamera, 3942.8, 1102.7, 5113.9 )

_IrrSetCameraClipDistance( $nodeCamera, 12000 )

WHILE _IrrRunning()
    _IrrBeginScene( 240, 255, 255 )
    _IrrDrawScene()
    _IrrEndScene()
WEND

_IrrStop()