gimpact and deformable meshes
Posted: Fri Sep 21, 2007 12:08 pm
I've started to use GIMPACT and I thought it would be good to edit the MovingConcaveDemo replacing the bunny with my mesh. I could create the mesh using initGImpactCollision() and move my mesh around with the mouse as a rigid body. So the next step was to move the vertices coordinates to deform the mesh. I did it in this way (where wheels is a list containing all the rigid bodies created):
void ConcaveDemo::updateExtMesh()
{
for( int i = 0; i < mesh_list.size(); i++ )
tf = pde->step();
for( int i = 0; i < mesh_list.size(); i++ )
{
MeshGeometry& geometry = mesh_list->geometry();
std::cout << geometry.x(0, 1) << std::endl;
for( VertexIterator v(*bmesh_list); !v.end(); ++v )
{
uint index = vertex_map(*v);
gVertices[3 * v->index() + 0] = geometry.x(index, 0);
gVertices[3 * v->index() + 1] = geometry.x(index, 1);
gVertices[3 * v->index() + 2] = geometry.x(index, 2);
}
btCollisionShape *wheel = NULL;
if( wheels.size() > i )
wheel = wheels->getCollisionShape();
if( wheel )
wheel = m_trimeshShape;
}
}
and called this function just after stepSimulation() and before renderme(). Hence the mesh should be deformed in an arbitrary way by my external solver and then just visualized as a change in the collision shape for the rigid body (kinematic or not). However this does not happen and the mesh displayed remains unchanged in the configuration I shoot it. That is, if I shoot it at the beginning it stays undeformed, if I shoot it after some time it is displayed as deformed but it doesn't change further. And if I shoot sveral bodies, they are all in the same configuration (the configuration at the time of the first shoot). I have no clue where the problem is, should I use something different rather than a rigid body?
void ConcaveDemo::updateExtMesh()
{
for( int i = 0; i < mesh_list.size(); i++ )
tf = pde->step();
for( int i = 0; i < mesh_list.size(); i++ )
{
MeshGeometry& geometry = mesh_list->geometry();
std::cout << geometry.x(0, 1) << std::endl;
for( VertexIterator v(*bmesh_list); !v.end(); ++v )
{
uint index = vertex_map(*v);
gVertices[3 * v->index() + 0] = geometry.x(index, 0);
gVertices[3 * v->index() + 1] = geometry.x(index, 1);
gVertices[3 * v->index() + 2] = geometry.x(index, 2);
}
btCollisionShape *wheel = NULL;
if( wheels.size() > i )
wheel = wheels->getCollisionShape();
if( wheel )
wheel = m_trimeshShape;
}
}
and called this function just after stepSimulation() and before renderme(). Hence the mesh should be deformed in an arbitrary way by my external solver and then just visualized as a change in the collision shape for the rigid body (kinematic or not). However this does not happen and the mesh displayed remains unchanged in the configuration I shoot it. That is, if I shoot it at the beginning it stays undeformed, if I shoot it after some time it is displayed as deformed but it doesn't change further. And if I shoot sveral bodies, they are all in the same configuration (the configuration at the time of the first shoot). I have no clue where the problem is, should I use something different rather than a rigid body?