Archived post by toadstorm

well, i do, but it’s part of MOPs Plus so there’s a bit of proprietary stuff in there that isn’t exposed

if you have specific questions i’m happy to answer them

the code above is run in a sop solver after fetching impacts data, it’s used to generate new constraint prims. you’d have to create the polyline and get the `name` attributes of the two objects based on the impact points

oh! actually @districtnein i have an older test scene i built before i asset-ified everything. it doesn’t have nearly the same feature set but it shows how to build dynamic glue constraints (outside of a few edge cases this won’t cover)

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

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

Archived post by mattiasmalmer

sometimes xyzdist() is not really what you want when you want to get distance from the edge of a font and so on because you get all these rounded corners. i wrote a quick wrangle that gives you the same type of sharp distance that an inset would give you:

“` int numprims=nprimitives(1);
float dist=10000000000000000000; for (int i=0; ipp=v@P-p0; if (dot(normalize(-normalize(p3-p1)+normalize(p0-p1)),v@P-p1)>=0) { if (dot(normalize(-normalize(p2-p0)+normalize(p1-p0)),pp)>=0) { dist=min(dist,(length(cross(pp,dir))/length(dir))); } }
}
@dist=dist; “`

(the second input is a “convertline” of the font)

Attachments in this post:
http://fx-td.com/houdiniandchill/wp-content/uploads/discord/20233912/04/23/houdinifx_CuEDfyQLMW.gif

Archived post by mattiasmalmer

sometimes xyzdist() is not really what you want when you want to get distance from the edge of a font and so on because you get all these rounded corners. i wrote a quick wrangle that gives you the same type of sharp distance that an inset would give you:

“` int numprims=nprimitives(1);
float dist=10000000000000000000; for (int i=0; ipp=v@P-p0; if (dot(normalize(-normalize(p3-p1)+normalize(p0-p1)),v@P-p1)>=0) { if (dot(normalize(-normalize(p2-p0)+normalize(p1-p0)),pp)>=0) { dist=min(dist,(length(cross(pp,dir))/length(dir))); } }
}
@dist=dist; “`

(the second input is a “convertline” of the font)

Attachments in this post:
http://fx-td.com/houdiniandchill/wp-content/uploads/discord/20232412/04/23/houdinifx_CuEDfyQLMW.gif