Netvudu Posted December 19, 2007 Share Posted December 19, 2007 (edited) Hi there. I Edited December 19, 2007 by Netvudu Quote Link to comment Share on other sites More sharing options...
Jason Posted December 19, 2007 Share Posted December 19, 2007 Hi there. I resolve_interpenetrations.hipnc Quote Link to comment Share on other sites More sharing options...
Netvudu Posted December 20, 2007 Author Share Posted December 20, 2007 Ok, even if I don Quote Link to comment Share on other sites More sharing options...
Jason Posted December 20, 2007 Share Posted December 20, 2007 Alrighty, how about this: Solve for ONE box being stacked on something else. Rinse and Repeat. So: Add a single point on the floor. Use the Ray SOP to shoot the point upwards moving the point to "Farthest Collision" - or make a ground plane and add a point high in the air and ray it downward to the nearest collision. (This first point will strike the floor in either solution.) Copy your box to the point location. One crate, on top of the tallest thing. Now repeat in a ForEach SOP (with "Merge Results" ON). .. This is a rudimentary solution so far.... You could improve the stacking logic from there... like sending four corner points instead of one point and so be able to have tilted boxes. Now you might be ready to stack arbitrary objects, not just boxes... perhaps scatter the points on (the underside of) the geometry and and project these points up, take the oriented bounding box of the transformed points (in the Box SOP) and use the button poly as target transform. You might be able to built a little StackAnObject HDA which can stack one of any object vertically on another. This HDA would be able to go inside a ForEach. Sounds fun to try out! But I gotta go... if you have trouble trying something like this, write in here! Jason. Quote Link to comment Share on other sites More sharing options...
Netvudu Posted December 20, 2007 Author Share Posted December 20, 2007 (edited) mrrrmmm...some stuff looks doable and some other looked like greek to me Will have to try it. I Edited December 20, 2007 by Netvudu Quote Link to comment Share on other sites More sharing options...
Jason Posted December 20, 2007 Share Posted December 20, 2007 Ah the Ray SOP, a fearsome engine in the Houdini toolset. Fiddle with those concepts, perhaps when you see it in action the dreams will come. Quote Link to comment Share on other sites More sharing options...
petz Posted December 20, 2007 Share Posted December 20, 2007 you can also use the nearpoint expression together with a foreach sop. file is atached! petz non_overlapping.hipnc 2 Quote Link to comment Share on other sites More sharing options...
symek Posted December 23, 2007 Share Posted December 23, 2007 (edited) Nice one petz! Very smartly! This is actually very common question: about non-overlapping copies. There are some ways to do it with particles collision detection. Also Chops could be possibly helpful here. Here is a brief code for Vex Sop. It generally does the same what petz did with foreach loop but in code thus it's x times faster. That does matter for a big geometry. (Maybe someone can fix it. Don't treat it as a VEX reference ). sop nearestPoint() { float dist; int i; // Get the longest possible distance: vector min, max; getbbox(min, max); dist = distance(min, max); // Loop through all other points to check if // there are no closer than that: for (i = 0; i < Npt; i++) { // Compute distance to next point: vector neighbour; import("P", neighbour, 0, i); // If not the same point compute distance: if ( neighbour != P ) { float tmpdist = distance(P, neighbour); // If found point closer than before, // overwrite distance attribute: if ( tmpdist < dist ) { dist = tmpdist; addattribute("distance", dist); } } } } Using point cloud method would speed up it even more, because of search radius of that. Code is also nicer: sop nearestPointPC(string pointcloud="") { vector tmpdist; vector min, max; getbbox(min, max); float dist = distance(min, max); int handle = pcopen(pointcloud, "P", P, dist, 2); while (pciterate(handle) ) { vector pos; pcimport(handle, "P", pos); if ( P != pos ) { pcimport(handle, "point.distance", tmpdist); addattribute("distance", tmpdist); } } } "pointcloud" parameter can be pointed to the input SOP with a syntax like: op:/`opinputpath(".",0)` Hope this could be helpful for someone on that trip! cheers, sy. Edited April 23, 2008 by SYmek 2 Quote Link to comment Share on other sites More sharing options...
fxrod Posted January 28, 2019 Share Posted January 28, 2019 I know this is an old post, but I wanted to thank Symek. I updated the code to be used in a vex wrangle, in case this helps anyone. vector tmpdist; vector min; vector max; getbbox(min, max); float dist = distance(min, max); int handle = pcopen(geoself(), "P", @P, 1, chi("max_pts")); while (pciterate(handle)){ vector pos; pcimport(handle, "P", pos); if (@P != pos) { pcimport(handle, "point.distance", f@distance); } } f@pscale = f@distance / 2; 1 Quote Link to comment Share on other sites More sharing options...
probiner Posted January 29, 2019 Share Posted January 29, 2019 @fxrod Maybe this is of interest: Quote Link to comment Share on other sites More sharing options...
Atom Posted January 29, 2019 Share Posted January 29, 2019 Here is another thread on the topic leveraging the found_overlap attribute for RBDs. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.