Domanda

Is it possible, and if yes, how do I apply force in Bullet, if I have two objects connected with a hinge constraint and something is making them to open up a bit more? So is it possible to give some kind of resistance force to the hinge constraint?

  1. example: a clip
  2. example: I have a V like shape, to which from the open part I push something that makes the V wider. But now I need to apply force on the object from the two legs of V.

(If relevant: Bullet version: bullet-2.82-r2704)

È stato utile?

Soluzione

Bullet has a function to apply force to rigid bodies:
void btRigidBody::applyForce(const btVector3 &force, const btVector3 &rel_pos)

Reference:
http://bulletphysics.org/Bullet/BulletFull/classbtRigidBody.html#af016720c45cf7ccaf8701d81a28319d9

First, to achieve the clip like hinge constraint, you have to create a hinge constraint.

Reference:
http://bulletphysics.org/mediawiki-1.5.8/index.php/Constraints#Hinge

Next, you have to apply an angular force to both legs with opposite direction. So the force that pulls the clips together depends on the angle between the two "legs".

(In addition, you can set a limit for the hinge constraint to stop it at a specified angle).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top