# CreateObjectFromHeightMap

## Description

Creates an object from a specified height map, useful for making terrain. The image should be PNG 8-bit greyscale or RGB, if it is RGB then only the red channel is read. 16-bit greyscale support may be added in future. The object will have a single UV channel with the range 0 to 1 mapped to the entire terrain. If you wish to modify this then you can use SetObjectUVOffset and SetObjectUVScale, or use a shader that multiplies the UV coordinates by a specified amount. A shader can also be used to create multiple UV channels from this single channel by applying different scale factors to each. A smoothing value of 1 is recommended to remove stepping artifacts, adjust as necessary. The split value lets you create multiple meshes which can improve performance, as unseen meshes will not be drawn. The split value specifies how many meshes to create along each edge, for example a split value of 5 will create 5x5 = 25 meshes in total. Unlike other objects collision data is not generated by default on this object as it can consume a lot of memory, use SetObjectCollisionMode if you want to turn it on. For terrains greater than 1024x1024 this is not recommended on mobile devices, and you should use GetObjectHeightMapHeight instead if possible. Turning on physics for this object will use even more memory and is not recommended on terrains greater than 1024x1024 on any platform.

## Definition

CreateObjectFromHeightMap( objID, szImageFile, width, height, length, smoothing, split )

void agk::CreateObjectFromHeightMap( UINT objID, const char* szImageFile, float width, float height, float length, int smoothing, int split )

integer CreateObjectFromHeightMap( szImageFile, width, height, length, smoothing, split )

UINT agk::CreateObjectFromHeightMap( const char* szImageFile, float width, float height, float length, int smoothing, int split )

## Parameters

- objID - The ID of the object to create
- szImageFile - The filename of the image to use as a height map, PNG preferred, also supports JPEG
- width - The desired width of the new object in the X direction
- height - The desired height of the new object in the Y direction
- length - The desired length of the new object in the Z direction
- smoothing - The amount of smoothing to apply to the height values, 0=none, 1=one pass, 2=two passes, etc
- split - 1=single mesh, 2=four meshes, 3=nine meshes, 4=sixteen meshes, etc