Archived post by toadstorm

there’s some local space fuckery involved with where you put constraint points and what orientation they’re in. they have to be generated in the rest space of the rbd objects, even if the rbd objects aren’t in rest space when the constraint is made

i built a tool for this in MOPs+, it generates constraints on the fly from collisions. it works roughly like this: “` // get position, orientation, and rest xform of impact prims vector P1 = point(1, “P”, i@impactprimnum); vector P2 = point(1, “P”, i@parentprimnum); vector rest1 = point(1, “rest”, i@impactprimnum); vector rest2 = point(1, “rest”, i@parentprimnum); vector4 orient1 = point(1, “orient”, i@impactprimnum); vector4 orient2 = point(1, “orient”, i@parentprimnum);
vector deltaP1 = @P – P1; vector deltaP2 = @P – P2;
// rotate these vectors into the local space of the impacting objects. deltaP1 = qrotate(qinvert(orient1), deltaP1); deltaP2 = qrotate(qinvert(orient2), deltaP2);
// shift by rest position. these are the local space constraint points. P1 = rest1 + deltaP1; P2 = rest2 + deltaP2;
// generate a polyline from P1 and P2 and set name attributes to match the two RBD objects being constrained… “`

the attributes will be different if you’re not generating stuff from collision points, but the math should be similar

Attachments in this post:
http://fx-td.com/houdiniandchill/wp-content/uploads/discord/20231312/05/23/rbd_runtime_constraints.gif