Height Map Using a Text File

../_images/heightMapUsingTxt.gif

An example text file is shown below

5 5 10 10
1 1 1 1 1 1 0 0 0 1 1 0.5 0 0 1 1 0 0 0 1 1 1 1 1 1

The numbers in the first line are “xSamples”, “ySamples”, “xSize” and “ySize”, respectively. The numbers in the second line are height values.

XML Way

Try it yourself with

./xmlReader <PATH_TO_RAISIMLIB>/rsc/xmlScripts/heightMaps/heightMapUsingTxt.xml

The xml file is constructed as following:

<?xml version="1.0" ?>
<raisim version="1.0">
    <timeStep value="0.001"/>
    <objects>
        <sphere name="sphere" mass="1">
            <dim radius="0.5" />
            <inertia xx="0.1" xy="0" xz="0" yy="0.1" yz="0" zz="0.1" />
            <state pos="0 0 5" quat="1 0 0 0" linVel="0 0 0" angVel="0 0 0" />
        </sphere>
        <capsule name="capsule" mass="1">
            <dim radius="0.5" height="1" />
            <inertia xx="0.1" xy="0" xz="0" yy="0.1" yz="0" zz="0.1" />
            <state pos="1 0 5" quat="1 0 0 0" linVel="0 0 0" angVel="0 0 0" />
        </capsule>
        <box name="box" mass="1">
            <dim x="0.5" y="1" z="2"/>
            <inertia xx="0.1" xy="0" xz="0" yy="0.1" yz="0" zz="0.1" />
            <state pos="1 1 5" quat="1 0 0 0" linVel="0 0 0" angVel="0 0 0" />
        </box>
        <heightmap name="terrain" text="[THIS_DIR]/heightMapExample.txt" centerX="0" centerY="0"/>
    </objects>
</raisim>

C++ Way

auto hm = world.addHeightMap("<PATH-TO-TEXT-FILE>/heightMapExample.txt", 0, 0);