How to calculate the transforms for a...[SOLVED]

StephenLynx
Posts: 9
Joined: Tue May 10, 2016 1:42 am

How to calculate the transforms for a...[SOLVED]

Post by StephenLynx »

I am trying to fix rigid bodies to each other using btFixedConstraint, but the constraint isn't working as it should when the bodies have rotated.

I tried this:

Code: Select all


 btVector3 delta = hitTransform.getOrigin()
        - spawned->rigidBody->getWorldTransform().getOrigin();

    delta *= 0.5;

    btTransform temp1;
    temp1.setIdentity();

    btTransform temp2;
    temp2.setIdentity();

    temp1.setOrigin(delta);
    temp2.setOrigin(-delta);

    btTypedConstraint* p2p = new btFixedConstraint(*spawned->rigidBody,
        *hitRigidBody, temp1, temp2);

And it works, as long as the rotation is zero.

I tried adding

Code: Select all


    temp1.setRotation(hitTransform.getRotation());
    temp2.setRotation(hitTransform.getRotation());

too, but it changed nothing.

Basically, I am failing to understand what should the transforms taken by btFixedConstraint represent.

How do I calculate those transforms so the constraint will keep both where they are right now relative to each other?
Last edited by StephenLynx on Fri May 13, 2016 1:06 am, edited 1 time in total.
StephenLynx
Posts: 9
Joined: Tue May 10, 2016 1:42 am

Re: How to calculate the transforms for a btFixedConstraint?

Post by StephenLynx »

benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland

Re: How to calculate the transforms for a btFixedConstraint?

Post by benelot »

Nice that you found a solution. Can you quickly summarize your solution by providing a small explanation or code you are using now? This might help other users with the same problem. Also, edit your first post's title to add the [SOLVED] tag to it makes it easier to identify this thread as solved.