smuseus Posted August 30, 2010 Share Posted August 30, 2010 Hi, I'm new to Houdini and I'm having some trouble getting VOP_SOP doing what i want. I have a particle system with two groups. Now I want to for each particles in the first group find and random particle within an certain radius within the other group. Now through a VOP_SOP I manage to find particles within a certain radius of a point. Whats keeping me stuck is that can't figure out how to select a random point of those point within this distance. Any ideas? Quote Link to comment Share on other sites More sharing options...
Macha Posted August 31, 2010 Share Posted August 31, 2010 (edited) Uhm...tricky one. Not sure I got this right but here is my attempt. The red group goes and finds a partner in the green group. The id attribute is in blue. The partner id of that particle is in pink. If the particle has no partner (green group) then the partner id is -1. Don't understand why sometimes red group is -1. There's got to be an easier 2 node way... Actually, this should be easier in Python. I'll knock you up something if I have time today. groupme.hipnc Edited August 31, 2010 by Macha Quote Link to comment Share on other sites More sharing options...
Macha Posted August 31, 2010 Share Posted August 31, 2010 (edited) err... maybe this does what you want by using a python script. I haven't fully checked it but it should basically work. In case the python script doesn't travel along with the file, here it is. It writes to an an attribute called pairs, which contains the pair id. from random import choice geo = hou.pwd().geometry() points = geo.points() r = hou.pwd().evalParm("r") group1 = [] group2 = [] for p in points: if p.attribValue("attgroup") == 1: group1.append(p) else: group2.append(p) for p1 in group1: l1 = [] for p2 in group2: d = p1.position().distanceTo(p2.position()) if d < r: l1.append(p2.attribValue("id")) if len(l1) > 0: brother = choice(l1) p1.setAttribValue("pairs",brother) groupme.hipnc Edited August 31, 2010 by Macha 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.