0

I have two cubs in a bullet softbody simulation (example of how I make such a cube below). How can I constrain them so that is it like the two cubes were 'glued' together on a face?

const btVector3 c[]={
                btVector3(-1,-1,-1),
            btVector3(+1,-1,-1),
        btVector3(-1,+1,-1),
        btVector3(+1,+1,-1),
        btVector3(-1,-1,+1),
        btVector3(+1,-1,+1),
        btVector3(-1,+1,+1),
        btVector3(+1,+1,+1)
        };
    btSoftBody* psb=btSoftBodyHelpers::CreateFromConvexHull(pdemo->m_softBodyWorldInfo,c,8, true);

I found this thread where the OP asks about a "one-way vertex-to-vertex joint". I'm looking for a similar (but two-way) joint.

ipburbank
  • 151
  • 1
  • 8
  • Why don't you create an array that represents the combined shape (minus the hidden "glued" edges) before passing to the helper? – weston Jun 25 '14 at 18:04
  • Each of the objects being glued together has different properties. E.g, one cube is very squishy, the other is firm. I believe that in order to do that, I have to create separate `btSoftBody` objects. – ipburbank Jun 25 '14 at 22:06

1 Answers1

1

What kind of interaction do you want between the two objects? Different approaches will likely lead to different results. Also keep in mind that you're going to need a very high iteration number and small time step for the solver to be able to always keep the objects glued.

I suggest you build a single, heterogeneous, soft body by using different masses for the nodes and stiffness values for the links.

const btVector3 c[] = 
{
    btVector3(+1,-1,-1),
    btVector3(+1,+1,-1),
    btVector3(+1,-1,+1),
    btVector3(+1,+1,+1),
    btVector3(-1,-1,-1),
    btVector3(-1,-1,+1),
    btVector3(-1,+1,+1),
    btVector3(-1,+1,-1),
    btVector3(+2,-1,-1), // "Other" cube starts here
    btVector3(+2,+1,-1),
    btVector3(+2,-1,+1),
    btVector3(+2,+1,+1)
};

// Masses, should be tuned depending on gravity/timestep
const btScalar m[] = 
{
    0.1f,
    0.1f,
    0.1f,
    0.1f,
    0.1f,
    0.1f,
    0.1f,
    0.1f,
    0.1f,
    0.1f,
    0.1f,
    0.1f
};

btSoftBody* psb = new btSoftBody(pdemo->m_softBodyWorldInfo,12,c,m);

// VERY stiff material
btSoftBody::Material aMat;
aMat.m_kLST = 1; // Linear stiffness coefficient [0,1]
aMat.m_kAST = 0; // Area/Angular stiffness coefficient [0,1]
aMat.m_kVST = 1; // Volume stiffness coefficient [0,1]

// Softer material
btSoftBody::Material bMat;
bMat.m_kLST = 0.5f; // Linear stiffness coefficient [0,1]
bMat.m_kAST = 0; // Area/Angular stiffness coefficient [0,1]
bMat.m_kVST = 0.5f; // Volume stiffness coefficient [0,1]

for(int i=0; i < 12; ++i)
{
    for(int j = i + 1; j < 12; ++j)
    {
        // If either node has x==+2, use softer material
        psb->appendLink(i,j, (i > 7 || j > 7) ? &bMat : &aMat, false);
    }
}   

This should get you started. Good luck!

Shank
  • 330
  • 2
  • 4