Petal simulation

Post Reply
m_iDev_792
Posts: 3
Joined: Fri Apr 12, 2019 12:07 pm

Petal simulation

Post by m_iDev_792 »

Hi, I'm new to Bullet physics. I'm working on plant modeling and I want to use Bullet physics to simulate petal material and handle the collisions between petals of different flowers. In my program petals are represented by triangle faces and they have no volume just like cloth and paper, but I want them to be harder than cloth and be able to keep their overall shape in a small collision.
Here are what I have done to do this(simulate petals with btSoftBody), the problem is that petals turn out to be too soft. I want them to be harder.
But I really have no idea which attribute of btSoftBody and btSoftBody::Material I should adjust to do this.

Code: Select all

  pSoftBody=btSoftBodyHelpers::CreateFromTriMesh(*worldInfo,pVertices,pTriangles,triangleNum);
  btSoftBody::Material *pMat=pSoftBody->appendMaterial();
  pMat->m_kLST = 0.5;
  pMat->m_kAST=1.0;
  pMat->m_kVST=1.0;
  pSoftBody->generateBendingConstraints(2,pMat);
  pSoftBody->m_cfg.kDF=0.5;
  pSoftBody->m_cfg.piterations=2;
  pSoftBody->m_cfg.kDP = 0.005;
  pSoftBody->m_cfg.kCHR = 0.1;
  pSoftBody->setTotalMass(10);
 
  pSoftBody->setMass(rootIndex,0);//set static nodes
  pSoftBody->setMass(farIndex,0);
I copied these parameters from Bullet SoftBody Demo, how to adjust them to make soft body harder(stronger shape preserve ability)?
thanks!
steven
Posts: 83
Joined: Mon Nov 05, 2018 8:16 am
Location: China

Re: Petal simulation

Post by steven »

Could you try these two interfaces? i still think it is hard to implement your feature. the point is what will be used to overcome the gravity.
psb->setPose(false, true)
psb->generateClusters(8)
steven
Posts: 83
Joined: Mon Nov 05, 2018 8:16 am
Location: China

Re: Petal simulation

Post by steven »

maybe the psb->setWindVelocity() can be used to overcome the gravity.
m_iDev_792
Posts: 3
Joined: Fri Apr 12, 2019 12:07 pm

Re: Petal simulation

Post by m_iDev_792 »

steven wrote: Fri Apr 12, 2019 1:56 pm Could you try these two interfaces? i still think it is hard to implement your feature. the point is what will be used to overcome the gravity.
psb->setPose(false, true)
psb->generateClusters(8)
Hi steven, thanks for your reply. I set the mass of top node and bottom node of petal to zero to overcome gravity and it works. I also tried setWindVelocity() which also works fine.
But now I have another problem that btSoftBody can't collide with btSoftBody. When two btSoftBody contact, they just penetrate each other while a btRigidBody does collide with a btSoftBody and bounces off.
I set the collisions flag of btSoftBody as

Code: Select all

pSoftBody->m_cfg.collisions = btSoftBody::fCollision::CL_SS | btSoftBody::fCollision::CL_RS;
but not working
steven
Posts: 83
Joined: Mon Nov 05, 2018 8:16 am
Location: China

Re: Petal simulation

Post by steven »

hi, can you try this interface btSoftBody::generateClusters(int k,int maxiterations) and ajust the parameter k to see if can get the expected result.
m_iDev_792
Posts: 3
Joined: Fri Apr 12, 2019 12:07 pm

Re: Petal simulation

Post by m_iDev_792 »

steven wrote: Sat Apr 13, 2019 8:56 am hi, can you try this interface btSoftBody::generateClusters(int k,int maxiterations) and ajust the parameter k to see if can get the expected result.
that's exactly what I forgot. I called pSoftBody->generateClusters(16) and pSoftBody->setMargin(0.01) and it worked great.
But larger margin value like 0.5 leads to a strange result.
thank you steven , have a good day! :mrgreen:
Post Reply