asnowcappedromance Posted October 10, 2011 Share Posted October 10, 2011 hi, I got a sphere which I scattered points upon. Now I want to take each single point that I scattered and find its closest primitive of the sphere. Using xyzdist expression only gets me one primitive, I got to feed that into a foreach sop somehow to run multiple iterations. How does that work? happy thanksgiving, Manu find_closest_prim.hipnc Quote Link to comment Share on other sites More sharing options...
sam.h Posted October 10, 2011 Share Posted October 10, 2011 Your scene didn't really make sense, you were running the expression on the spere and the points, and you were using $PT on a primitive group .... not sure what $PT returns when you are looping over primitives .... :/ Anyway, I have attached a scene. Just doing an attrib create on the points to record the nearest prim. find_closest_prim.hipnc Quote Link to comment Share on other sites More sharing options...
asnowcappedromance Posted October 11, 2011 Author Share Posted October 11, 2011 uhmm yeah, that makes sense ok so now I copy stamped the primitives to the scattered points, but their positions get screwed up. Computed their center of mass which I'm applying in a transform sop but the copy sop doesn't want to take that. Can you check that out? Thanks, Manuel find_closest_prim_v2.hipnc Quote Link to comment Share on other sites More sharing options...
sam.h Posted October 11, 2011 Share Posted October 11, 2011 what are you trying to do? Quote Link to comment Share on other sites More sharing options...
graham Posted October 11, 2011 Share Posted October 11, 2011 (edited) If you're just trying to copy the primitives back onto the points, you don't need to transform by the COM of the primitives: you need to transform by the negative position of the point you are trying to copy onto. Since you are copying geometry off center, you can get the same result by essentially copying onto points at the origin. However, since your points might be moving around (also in attached file), we can just move the primitives in the opposite way the copy will move them instead. This results in the primitives having no net transform and happily in the correct place. In this case (my file), since the points are driven by a particle simulation, we transform based on the scattered point location, not the moving one. Finally, disabling Transform Using Template Point Attributes prevents the copy from transforming the primitives based on the particles normal and/or velocity. Also, instead of the complicated xyzdist expression, I used 3 SOPs to do the job instead. If we generate unique points on the primitives we can still get the same scatter result and then attribute promote the primitive number to the points on each face so when points are scattered on them, they automatically pick up the primitive number. find_closest_prim_v2.hipnc Edited October 11, 2011 by graham Quote Link to comment Share on other sites More sharing options...
Alexander Weide Posted October 11, 2011 Share Posted October 11, 2011 Only watch this TUTORIAL you will find what you need inside Quote Link to comment Share on other sites More sharing options...
asnowcappedromance Posted October 11, 2011 Author Share Posted October 11, 2011 Only watch this TUTORIAL you will find what you need inside haha, good one Thanks for that file Graham, I like that workflow! Subtracting the pivot in the xform's position parameters did the trick for me, though! cheers! 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.