Jump to content
vi_rus

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 this post


Link to post
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
  • Like 1

Share this post


Link to post
Share on other sites

Hi Tomas,

 

Thank you for your respond!

 

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 this post


Link to post
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"

  • Like 2

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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

  • Like 1

Share this post


Link to post
Share on other sites

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 this post


Link to post
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
  • Like 1

Share this post


Link to post
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
  • Like 1

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×