Search Unity

Access terrain data

Discussion in 'Made With Unity' started by Rob Ho, Apr 7, 2008.

  1. Rob Ho

    Rob Ho

    Joined:
    Oct 21, 2007
    Posts:
    6
    Just a small example how to deal with terrain height data.

    Has anybody an idea how to get the terrain wizzard script ?

    /Users/unity-build/Desktop/automatic-build-2/unity/Editor/Mono/TerrainEditor/TerrainWizards.cs

    Rob
     

    Attached Files:

  2. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    What's that, exactly?
     
  3. Rob Ho

    Rob Ho

    Joined:
    Oct 21, 2007
    Posts:
    6
    Hi Gaston,

    First example (WrapMeshToTerrain scene) shows two scripts:

    a) ModifyTerrainData script
    b) WrapMeshToTerrain script

    The WrapToMeshScript reads heightmap samples via the ModifyTerrainData script and creates a mesh which uses the height informations to copy the terrain shape. The mesh size depends on heightmap resolution.

    Second example (ModifyTerrainHeight) shows also two scripts:

    a) ModifyTerrainData script (again)
    b) ModifyTerrainHeight script

    The ModifyTerrainHeight script detects wether and where you mouseclick at your active terrain. Draws a primitive plane at this place and changes at mouseup the height data at this place e.g. to an average niveau of minimum and maximum height. The ModifyTerrainData script supplies diffrent functions, e.g. to modify the terrain data to the minimum, maximum or explicit height etc.

    To this showcase see also discussion at

    http://forum.unity3d.com//viewtopic.php?t=8249

    I think it's quite easy to work with the height data of terrains by script like shown here. But unfortunately the script API is not to much documented. For example which effects have all the settings of the 'Set Resolution wizzard' tho terrain data model. Or is it possible to interact with terrain objects like trees while runtime. For example delete a terrain tree by script. The terrain wizzard can !

    If you know more about the terrain engine let me know, please.

    Thanks Rob
     
  4. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Sorry, but I can't help you in such things... :?