Accessing terrain data

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
ben
Posts: 18
Joined: Fri May 22, 2009 4:43 pm

Accessing terrain data

Post by ben »

Hi,

I have a terrain generated from a height map. I wish to access the terrain data so I can (for example) place a scenenode (eg for a tree or something) on the corner of each quad that the map consists of.

In the 'terrain' tutorial, I have found this:

Code: Select all

scene::CDynamicMeshBuffer* buffer = new scene::CDynamicMeshBuffer(video::EVT_2TCOORDS, video::EIT_16BIT);
        terrain->getMeshBufferForLOD(*buffer, 0);
        video::S3DVertex2TCoords* data = (video::S3DVertex2TCoords*)buffer->getVertexBuffer().getData();
        // Work on data or get the IndexBuffer with a similar call.
        buffer->drop(); // When done drop the buffer again.
But once I have this buffer I do not know what to do with it! How do I actually extract or iterate through the data?

Many thanks,
Ben.
Mux
Posts: 56
Joined: Mon Feb 26, 2007 12:25 pm
Location: Stockholm

Post by Mux »

If you want the position of each vertex in the vertex buffer I think you could try something like this:

Code: Select all

for(int i=0; i<buffer->getVertexBuffer().size(); ++i)
{
   buffer->getVertexBuffer()[i].Pos;
}
It'll only take a minute or two to debug this code...
Post Reply