# CreateObjectFromRawHeightMap

## Description

Creates an object from a specified .raw or .dat height map, useful for making terrain. The file should be in raw 16-bit data. If you use extension ".dat" in szFilename it will expect that this is a GameGuru 32-bit raw height map and convert that to 16-bit. If the file is not a GameGuru height map then you must change the extension to ".raw". If you convert a GameGuru height map (.dat) file, rawWidth and rawHeight should always be set to 1024. 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. Normally when using 16-bit data you don't need to set a smoothing value, but if its not already been smoothed 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

integer CreateObjectFromRawHeightMap( szFilename, width, height, length, smoothing, split, rawWidth, rawHeight)

UINT agk::CreateObjectFromRawHeightMap( const char* szFilename, float width, float height, float length, int smoothing, int split, int rawWidth, int rawHeight)

CreateObjectFromRawHeightMap( objID, szFilename, width, height, length, smoothing, split, rawWidth, rawHeight )

void agk::CreateObjectFromRawHeightMap( UINT objID, const char* szFilename, float width, float height, float length, int smoothing, int split, int rawWidth, int rawHeight )

## Parameters

- szFilename - The filename of the height map, must end in .raw or .dat
- 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
- rawWidth - The width of the height map data
- rawHeight - The height of the height map data
- objID - The ID of the object to create