Topic: how deform a mesh?
hello, i see the documentation but not found how make this, i need deform a mesh (vertex) in runtime, thanks.
You are not logged in. Please login or register.
hello, i see the documentation but not found how make this, i need deform a mesh (vertex) in runtime, thanks.
In c++, you can access the mesh of an entity (or the meshs of a scene).
From an entity :
// mesh
MMesh * mesh = entity->getMesh();
if(! mesh)
return;
// sub-meshs
unsigned int s, sSize = mesh->getSubMeshsNumber();
for(s=0; s<sSize; s++)
{
MSubMesh * subMesh = &mesh->getSubMeshs()[s];
// vertices
MVector3 * vertices = subMesh->getVertices();
if(! vertices)
continue;
unsigned int v, vSize = subMesh->getVerticesSize();
for(v=0; v<vSize; v++)
vertices[v] += MVector3(1, 0, 0); // ex : translate
}
mesh->updateBoundingBox();
Also, depending on what you want to do, you can just use a vertex shader.
i want change a terrain in realtime, i will be try this code, thankyou very much.
Powered by PunBB, supported by Informer Technologies, Inc.
Currently installed 3 official extensions. Copyright © 2003–2009 PunBB.