One Body Constrains, what do they do?

moniker
Posts: 6
Joined: Mon Oct 18, 2010 8:02 pm

One Body Constrains, what do they do?

Post by moniker »

Some constraints like btPoint2PointConstraint have a one-body constructor that looks like

Code: Select all

btPoint2PointConstraint (btRigidBody &rbA, const btVector3 &pivotInA)
In the manual, it's described as
Point to point constraint limits the translation so that the local pivot points of 2 rigidbodies match in worldspace. A chain of rigidbodies can be connected using this constraint.
If it constrains the pivot point between 2 rigid bodies, what's the meaning of a constructor that only takes on rigid body? What does it constrain between? What's its usefulness?
PeterMacGonagan
Posts: 7
Joined: Sun Dec 05, 2010 4:59 pm

Re: One Body Constrains, what do they do?

Post by PeterMacGonagan »

I think the one-body constructor is to constraint an object to rotate around a point (x,y,z).


see in http://www.bulletphysics.com/Bullet/Bul ... raint.html
moniker
Posts: 6
Joined: Mon Oct 18, 2010 8:02 pm

Re: One Body Constrains, what do they do?

Post by moniker »

of course! <hits head>

so, let's say I have an object and I want to say "object, move to a new point P", would using a one-body constructor with a motor be the best way to express such a constraint? I'd like to say things like "move here in time T or with velocity V". Which constraints are best for describing these kinds of actions?
PeterMacGonagan
Posts: 7
Joined: Sun Dec 05, 2010 4:59 pm

Re: One Body Constrains, what do they do?

Post by PeterMacGonagan »

I don't know what you want to do but if you want to move an object you could use trans.setOrigin and trans.setRotation

If body is your btRigidBody, you could say:

Code: Select all

btVector3 vNewPosition(5,51,3);
//btVector3 vAxis;
//btScalar Angle;

btTransform trans;
body->getMotionState()->getWorldTransform(trans);

trans.setOrigin(vNewPosition);
To set the velocity, you could use:

Code: Select all

fallRigidBody->setFriction(0.5);
    fallRigidBody->setLinearVelocity(btVector3(1,2,10));
and friction too.
moniker
Posts: 6
Joined: Mon Oct 18, 2010 8:02 pm

Re: One Body Constrains, what do they do?

Post by moniker »

I don't want to explicitly set the position and rotation because that messes up the continuity of the dynamics and is problematic when there are constraints on an object. Instead, I want to figure out how to apply a constraint to an object to move it to a particular point, orientation, etc. I guess the easiest is to calculate impulses and apply each frame until the target is reached, but this could easily create oscillations if the target is passed.