Search code examples
c++ogre3d

Mesh from heightmap in Ogre3D


Using the Ogre3D engine (C++), I would like to generate a mesh from a grayscale heightmap. I know that the Terrain tools can do that but I just want a simple mesh. What would be the best way to do that? This sounds pretty basic but I can't find my way in the Ogre3d doc.

Thanks!


Solution

  • One way to do it is extract all the height values and pump them into an Ogre::ManualObject.

    Then call ManualObject::convertToMesh(...) for the conversion.

    Fire up a MeshSerializer and use it to save the mesh out to a file.

    MeshPtr pmo = mo.convertToMesh( "GrassBladesMesh" );
    MeshSerializer ser;
    ser.exportMesh( pmo.getPointer(), "grass.mesh" );
    

    See Ogre::ManualObject link above for more info. HTH