grouping in vex

   16066   13   4
User Avatar
Member
28 posts
Joined: Aug. 2013
Offline
I am working on a project building new operators for a dynamics simulation in VEX and I am to the point where I need to divide my point cloud in to groups. I would love to be able to do an n-count group case, but I haven't been able to find how to do that. I am also trying to figure out how to make an evaluation expression node that will be able to handle a $TX, $TY, or $TZ in my sopsolver network.

I know that I could just use the built in group node to run in the network, but I am not sure how to dynamically detect the group names for geometry in the code in my other nodes where grouping is going to matter. I also just realized that I could use the group section on the vex nodes themselves to work with it, but that is only one. I would need an n-dimensional parameter like the add node in SOPs.

I am sorry if that came across a little incoherant. I am a little ill, so my mind isn't the clearest right now.
User Avatar
Member
339 posts
Joined: Aug. 2007
Offline
I'm not totally following you but you might want to try using attributes instead of groups. The ‘name’ string attribute is treated much like a group in SOPs. They're much more straightforward to work with and can be turned into groups with a Partition SOP later, if need be.
Also, an example hip file would go a long way into helping us understand your question.
Jesse Erickson
Fx Animator
WDAS
User Avatar
Member
28 posts
Joined: Aug. 2013
Offline
The example file would be really convoluted, as this is one small part of a rather large simulation I am working on from scratch.

The simulation is an autonomous air combat; though at present I am really just getting the evasion and pursuit behaviors under control, so no actual combat is going on. I would like to eventually get things like firing behaviors and environmental avoidance in place, but for the time being it is just chase/avoid. The system is based on boids research and uses some of the concepts from the CMIVFX flocking simulation tutorial.

What I am trying to do now is provide an animator a methodology to pit 2+ groups of combatants against each other. I suppose I could use an attribute, but I still have the problem of how to allow the user to define who gets what value. In my targeting/evade/pursue algorithm I have this statement to select the nearest target:

int hnd = pcopen(pcloudpath, “v”, v, radius, 99999);

if(pciterate(hnd))
{
while(pciterate(hnd))
{
pcimport(hnd, “P”, arrive);
dMin = length(arrive-P);
if(dMin<length(D))
{
D = arrive-P;
pcimport(hnd, “v”, targetV);
}
}
}


So what I was planning was to have the interior if statement be

if(dMin<length(D) && not in group)
{
}

Which will cause the individual planes to ignore their allies. Eventually I want to have a behavior that will cause planes to assist allies if they end up in a stable mutual relationship.
User Avatar
Member
127 posts
Joined: Nov. 2008
Offline
As Jesse mentioned you could use attribs.

You can however group points using vex function

addgroup(string groupName, int ptnum )

However this will only work inside Point Wrangler nodes or inline vop sops
(Pretty much anything that doesn't use Attrib Wrangler vop).

Edit: Another thing to bear in mind is this will obviously be a point group.
You can convert it to primitive group using a group SOP.
Bhavesh Pandey.

https://bhaveshpandey.io [bhaveshpandey.io]
User Avatar
Member
28 posts
Joined: Aug. 2013
Offline
I would be interested in using attribs, but how would I go about it for this purpose?

Also I did find the add addgroup() vex function, but I still need a way to delineate the points between separate groups. It would be fairly easy to do if i could just get a parameter that would be able to be evaluated based on things like point position for just the first frame, which
if(Frame == 1)
{
}
does, but then I have to get a second if statement based off of user input to figure out what groups. If there are any other ways, please let me know, but that is what I am seeing for a method.

Ideally, I would like to have external groups be able to be used, then passed down the line to my other nodes so they can behave properly with regards to the groups.

As to the point groups, that is exactly what I need, since this is a DOPs simulation, it is all worked on points, then geometry is copied onto them. The rest of the simulation works beautifully, and this is a new piece I am adding into it.
User Avatar
Member
339 posts
Joined: Aug. 2007
Offline
Yeah I would defintely use attribs for this. A point can be in multiple groups at once, but they can only have one attrib value. If you use an int to define each side in the pc loop you can iterate until currentSide!=foundSide, that'll find each points nearest opponent and you can terminate the while loop. Also (not that you need it) but this would support an arbitrary number of teams.
Jesse Erickson
Fx Animator
WDAS
User Avatar
Member
28 posts
Joined: Aug. 2013
Offline
tjeeds:
Ok, you sold me on using attribs. Now I just need a way develop the descriptions of the groups and name them dynamically. I need a UI method for it. I was trying to use an int parameter, but for whatever reason I was unable to use $TX in it. The problem isn't really how to use the attribs, I have that figured out. The problem is how to define who gets what attrib.
User Avatar
Member
339 posts
Joined: Aug. 2007
Offline
Check out the Cluster Points SOP, it does k-means clustering on a point cloud and returns a cluster number. Set the Clusters parm to 2 and you'll end up with 2 teams.
Jesse Erickson
Fx Animator
WDAS
User Avatar
Member
28 posts
Joined: Aug. 2013
Offline
tjeeds
Check out the Cluster Points SOP, it does k-means clustering on a point cloud and returns a cluster number. Set the Clusters parm to 2 and you'll end up with 2 teams.

Thank you so much. This worked better than I could have ever hoped! You are a life saver. My project just got so much better. I am going to have to start figuring out some more complicated things to do so I can continue getting paid through the end of the semester. This is for an undergrad research assistanceship, so I need to be continuing work on it to keep getting paid.

I believe the next step should be environmental avoidance, but I am trying to figure out the best way to probe the scene and detect near collisions.
User Avatar
Member
339 posts
Joined: Aug. 2007
Offline
If you convert your environment to a VDB levelset you can sample that each timestep and have your particles turn away as they get closer. Turn on ‘Use World Space for Band’ and make your exterior bandwidth equal to the max detection distance. Then you can do a 1-smoothstep between 0 and the max distance to get a smooth, normalized bias value to run your rotation off of. The normalized cross product of normalized gradient and normalized velocity will give you a good rotation axis.
Jesse Erickson
Fx Animator
WDAS
User Avatar
Member
28 posts
Joined: Aug. 2013
Offline
I am trying to work with the VDB stuff, but I have 0 experience with it. Do you have any tutorials that I could look at to get my feet wet with it?

I am also not entirely positive that this will satisfy the requirements being placed on my research by the math department at my school. I am pretty sure that this is more to do with my lack of understanding on the topic than the system not fitting.

Also, how are you doing surface gradients? I was looking for that in an earlier part of the project and was unable to find it.
User Avatar
Member
678 posts
Joined: July 2005
Offline
I don't know why, but when I see title of this topic I read “group sex” instead of “grouping in vex”.

Sorry for offtop
Edited by - Nov. 8, 2013 17:01:55
User Avatar
Member
339 posts
Joined: Aug. 2007
Offline
Download the Houdini Examples zip from http://www.openvdb.org/download/ [openvdb.org]
It goes over everything and it's mostly built from native Houdini nodes.

For a gradient, you would use VDB Analysis or just do a Volume Gradient from File in VOPs, both are covered in the example.
Jesse Erickson
Fx Animator
WDAS
User Avatar
Member
127 posts
Joined: Nov. 2008
Offline
Came across an entry in the help docs and though this is relevant
to this thread.
In Houdini13+ versions you can decide group memberships dynamically using this syntax (Bear in mind this works only in Attrib Wranglers) :
@group_foo = 1 ;
This will create a point/primitive group called “foo” and
all the points/prims with value of 1 will be members of that group.

FROM THE DOCS:
http://www.sidefx.com/docs/houdini13.0/news/13/geometry [sidefx.com]
You can set the membership of groups in VEX snippets. In nodes that allow VEX/VOPs to edit geometry – such as Attrib VOP SOP, Geometry VOP DOP, and geometry “wrangler” nodes that have VEX snippet fields – you can set whether the current point/edge/primitive is a member of a group by setting the @group_name attribute. Setting the attribute to 1 (or any non-zero value) puts the current element in that group. Setting the attribute to 0 removes the current element from that group.

While I do prefer using attribs over groups
I appreciate groups because they help keep things a bit more
clear. While skimming thorugh someone else's setup/file or handover's
being able to see if there are any groups, prepares me for
expecting different behaviours based on group memebrships.
Using attribs is a bit more involved and needs more restrictive
naming requirements.
Bhavesh Pandey.

https://bhaveshpandey.io [bhaveshpandey.io]
  • Quick Links