# Bullet - dynamic constraint creation

## Recommended Posts

Hi everybody,

I'm looking for a way how to create dynamic constraints with Bullet. The basic way doesn't work. Take a look at hip file please to see the problem.

Any help would be appreciated!

Thanks!

bullet_dynamic_con_issue_v01.hip

##### Share on other sites

your constraint has to have correct anchor positions relative to initial pose of the rbds

and since you are creating constraints between already simulated positions of the pieces, you need to transfer found anchors back to initial pose yourself

here is the file (13.0.401)

bullet_dynamic_con_issue_v01_fix.hip

Edited by anim
##### Share on other sites

Hi Tomas,

Actually, I had similar thoughts, but I couldn't solve an orientation issue. So I didn't change your setup, just replaced spheres on boxes and changed initial velocity.

As we can see, constraint takes direction from an initial orientation.

bullet_dynamic_con_issue_v02.hip

##### Share on other sites

Seems like I solved this issue!

Thanks again, Tomas! You really helped me!

bullet_dynamic_con_issue_v02_fix.hip

##### Share on other sites

Awseome!

You can also simplify this setup using only one pointwrangle:

```matrix tr = invert( primintrinsic(1,"packedfulltransform",@ptnum) );
vector pt0 = point(1,"P",0);
vector pt1 = point(1,"P",1);
vector pos = (pt0+pt1)*.5;
@P = pos*tr;
v@r=cracktransform(0, 0, 1, { 0, 0, 0 }, tr);```

hook "add1" to input0 and "dopimport1" to input1.

then connect this node to "attribwrangle1"

##### Share on other sites

Awseome!

You can also simplify this setup using only one pointwrangle:

```matrix tr = invert( primintrinsic(1,"packedfulltransform",@ptnum) );
vector pt0 = point(1,"P",0);
vector pt1 = point(1,"P",1);
vector pos = (pt0+pt1)*.5;
@P = pos*tr;
v@r=cracktransform(0, 0, 1, { 0, 0, 0 }, tr);```

hook "add1" to input0 and "dopimport1" to input1.

then connect this node to "attribwrangle1"

thanks, I'll try it

##### Share on other sites

Seems like I solved this issue!

...

good catch, didn't know about the r attrib, sometimes it's a good idea to read the help pages I guess

it's a little disturbing that it's defined as euler, but I guess that can have some advantages as well

##### Share on other sites

good catch, didn't know about the r attrib, sometimes it's a good idea to read the help pages I guess

it's a little disturbing that it's defined as euler, but I guess that can have some advantages as well

From what I recall, the reasoning for that was to match the interface of the old-style constraints (like the RBD Angular Constraint DOP). It gets converted to a quaternion internally, though.

##### Share on other sites

that's understandable and not a big deal

it's just that the current workflow is to modify these attributes through wrangle nodes or VOPs and so it'd be much easier to pass quaternion to r than extracting euler angles, as we usually work with matrices and quaternions

##### Share on other sites

• 4 weeks later...

hey

I am trying to apply this to more than a pair of objects, and can't get it to work.

live_constraints01.hip

##### Share on other sites

got it!

what I am not getting how we are supose to read the prim force or torque attribute. without altering the type.. when I fetch that into an attribwrangle sop the type switches to vector.

live_constraints03.hip

##### Share on other sites

and finally an example for more than one "wire" element ;p

must say I've learned a lot by your examples. thanks a bunch!

ps. of course I have to cast force as float...

live_constraints04.hip

##### Share on other sites

• 11 months later...

I don't understand the idea of scaling the primitives to 0 and then running all this code:

```vector com = v@pivot+v@trans;
@P = v@pivot+(@P-com)*invert(qconvert(p@orient));```
Anyone can please tell me why these steps have to be done?
##### Share on other sites

the idea is to bring anchor points of all new constraints generated from simmed RBDs to the initial pose of your RBDs as that's the space where bullet is looking up their attributes

the code above will only work if you have copied trans and pivot attrib from corespoinding RBD to constraint anchors

however in H14 trans attrib was deprecated, so this may not work the same way anymore, you need to be careful

Edited by anim
##### Share on other sites

Thanks anim. What's the established way to do this in H14?

##### Share on other sites

not sure if established

help says that instead of trans, P is used for com

so it's about to figure out how pivot comes in the place, just to reverse transform to initial pose as in H13

I can have a look at it once I have time, which is sadly not right now

EDIT:

but, you would probably use RBD's intrinsic transform directly as rayman suggested:

http://forums.odforce.net/topic/20640-bullet-dynamic-constraint-creation/?p=123106

Edited by anim
##### Share on other sites

Thanks anim appreciate your help I will check out rayman's method.

##### Share on other sites

• 1 month later...

Just got Sergei-Tomas-Pavel example working in H14, if someone need this.

dynamic_constraint.hipnc

Edited by f1480187
• 8
• 1
##### Share on other sites

• 2 years later...

Played with this.

Hate switches, love multiple, so I did this.

dynamic_constraint.hipnc

Edited by Druidl
##### Share on other sites

This can be achieved also with the setup

• 1
• 1

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×