Code: Select all

```
Ogre::Vector3 offset = mTerrainInfo->getOffset();
Ogre::Vector3 scale = mTerrainInfo->getScaling();
size_t tWidth = mTerrainInfo->getWidth();
size_t tHeight = mTerrainInfo->getHeight();
//Create indices
size_t index_size = (tWidth - 1) * (tHeight - 1) * 6;
size_t* indices = new unsigned int[index_size*3];
for( size_t x = 0; x < tWidth - 1; x++)
{
for( size_t y=0; y < mTerrainInfo->getHeight() - 1; y++)
{
indices[(x+y*(tWidth-1))*6] = (x+1)+(y+1) * tWidth;
indices[(x+y*(tWidth-1))*6+1] = (x+1)+y * tWidth;
indices[(x+y*(tWidth-1))*6+2] = x+y * tWidth;
indices[(x+y*(tWidth-1))*6+3] = (x+1)+(y+1) * tWidth;
indices[(x+y*(tWidth-1))*6+4] = x+y * tWidth;
indices[(x+y*(tWidth-1))*6+5] = x+(y+1) * tWidth;
}
}
// Create vertices
size_t vertex_size = tWidth * tHeight;
float* vertices = new float[vertex_size*3];
size_t index = 0;
for(size_t z = 0; z < tHeight; z++)
{
for(size_t x = 0; x < tWidth; x++)
{
Real height = offset.y + mTerrainInfo->at(x, z)*scale.y;
vertices[index + 0] = offset.x + x * scale.x;
vertices[index + 1] = offset.y + mTerrainInfo->at(x,z)*scale.y;
vertices[index + 2] = offset.z + z*scale.z;
index += 3;
}
}
```