I've been playing with changing a terrain node dynamically, can now adjust the positions of the individual vertices with the following code (which is just a test) :
Code: Select all
scene::IMesh* pMesh = terrain->getMesh();
s32 b;
for (b=0; b<pMesh->getMeshBufferCount(); ++b){
scene::IMeshBuffer* pMeshBuffer = pMesh->getMeshBuffer(b);
// skip mesh buffers that are not the right type
if (pMeshBuffer->getVertexType() != video::EVT_2TCOORDS) continue;
video::S3DVertex2TCoords* pVertices = (video::S3DVertex2TCoords*)pMeshBuffer->getVertices();
u32 vertCount = 262144; // (512*512)
// adjust vert position
for(int i=0; i<65536; i++)
{
S3DVertex currentVert = pVertices[i];
currentVert.Pos.Y = 500;
currentVert.Normal = vector3df(0,1,0);
pVertices[i] = currentVert;
int a=1;
}
}
// force terrain render buffer to reload
terrain->setPosition(terrain->getPosition());
Need help pretty badly, have spent a couple of weeks on this and have run out of time to get it going