Selecting closest object over a loop
19642 23 2- kgoossens
- Member
- 289 posts
- Joined: July 2005
- Offline
Hi Everybody,
I'd like to be able to do the following.
I have a scene of spheres(collection).
I select one sphere(start) of the collection.
The start sphere is then selecting the closest sphere in it's neighborhood(new).
I delete the start sphere from the collection
and use the new sphere as the start sphere to again select the closest neighbor.
I'm doing this in a foreach sop. But I cannot get it to work.
Cheers
I'd like to be able to do the following.
I have a scene of spheres(collection).
I select one sphere(start) of the collection.
The start sphere is then selecting the closest sphere in it's neighborhood(new).
I delete the start sphere from the collection
and use the new sphere as the start sphere to again select the closest neighbor.
I'm doing this in a foreach sop. But I cannot get it to work.
Cheers
A computer is almost human - except that it does not blame its mistakes on another computer.
- graham
- Member
- 1922 posts
- Joined: Nov. 2006
- Offline
Taking a look at your scene file I see there are a few things wrong. First I notice that the Each inside the ForEach is in a bad state. It has lost all its channel references to the parent and is behaving incorrectly. Secondly, in order to pass info from one iteration to the next you need to have Merge Results toggled off. Fixing these two things didn't actually make it work for me though.
Since debugging inside ForEach isn't the greatest thing ever I just took a general look at what you were trying to do and then vastly simplified it. Basically all the new system needs is a primitive group, start, assigned to the first sphere. Then inside the ForEach it removes it for the raying like in your scene. After that though, it just passed to a single Attribute Promote that converts it to a detail attribute ‘min_dist’, preserving the original. A group sop isolates the closest one by expression and then it cleans up the attributes. The start group is passed to the next iteration and it repeats, eventually leaving you with the proper number of spheres removed.
I'm not sure what you had going on with your elaborate color scheme so I didn't put that in there but If you want anything specific it probably isn't too difficult to add.
Hope that helps.
Since debugging inside ForEach isn't the greatest thing ever I just took a general look at what you were trying to do and then vastly simplified it. Basically all the new system needs is a primitive group, start, assigned to the first sphere. Then inside the ForEach it removes it for the raying like in your scene. After that though, it just passed to a single Attribute Promote that converts it to a detail attribute ‘min_dist’, preserving the original. A group sop isolates the closest one by expression and then it cleans up the attributes. The start group is passed to the next iteration and it repeats, eventually leaving you with the proper number of spheres removed.
I'm not sure what you had going on with your elaborate color scheme so I didn't put that in there but If you want anything specific it probably isn't too difficult to add.
Hope that helps.
Graham Thompson, Technical Artist @ Rockstar Games
- kgoossens
- Member
- 289 posts
- Joined: July 2005
- Offline
Hi Graham,
Thanks a lot for your post!! It is a much cleaner scene. As for the colors it was done in an attempt to make problems visible for me.
I did not explain myself properly.
I was able to remove the spheres, but I wanted to have the opposite result.
So that the selected objects remain. Now I need to be able to do this within the forLoop since I have to do some operations on the selected objects within that loop.
I am really struggling with this.
Cheers
Kim
Thanks a lot for your post!! It is a much cleaner scene. As for the colors it was done in an attempt to make problems visible for me.
I did not explain myself properly.
I was able to remove the spheres, but I wanted to have the opposite result.
So that the selected objects remain. Now I need to be able to do this within the forLoop since I have to do some operations on the selected objects within that loop.
I am really struggling with this.
Cheers
Kim
A computer is almost human - except that it does not blame its mistakes on another computer.
- graham
- Member
- 1922 posts
- Joined: Nov. 2006
- Offline
Ah, I see. Here's another attempt then.
Basic setup as before, except some more grouping that keeps track of what has been hit. In essence it keeps track of what objects have been hit and ignores them for future calculations. At the end of the loop you still have all your objects in the gdp, but you have the hit ones isolated. I threw in a switch at the end as well to delete all the excess info at the end of the final iteration. You should be able to put in whatever modification nodes you want to the selected objects over on the right side of the network.
Basic setup as before, except some more grouping that keeps track of what has been hit. In essence it keeps track of what objects have been hit and ignores them for future calculations. At the end of the loop you still have all your objects in the gdp, but you have the hit ones isolated. I threw in a switch at the end as well to delete all the excess info at the end of the final iteration. You should be able to put in whatever modification nodes you want to the selected objects over on the right side of the network.
Graham Thompson, Technical Artist @ Rockstar Games
- kgoossens
- Member
- 289 posts
- Joined: July 2005
- Offline
- tkluysk
- Member
- 9 posts
- Joined: May 2006
- Offline
- kgoossens
- Member
- 289 posts
- Joined: July 2005
- Offline
Hi Tom,
Thanks for your scene! Very interesting to have a look at. But I have to do the complete function within the Forloop. So I'll go for graham's solution.
The actual scene I want to use this system has a different selection method.
Cheers!!
Thanks for your scene! Very interesting to have a look at. But I have to do the complete function within the Forloop. So I'll go for graham's solution.
The actual scene I want to use this system has a different selection method.
Cheers!!
A computer is almost human - except that it does not blame its mistakes on another computer.
- asnowcappedromance
- Member
- 512 posts
- Joined: July 2009
- Offline
hey you guys
i'm very interested in this topic, as i'd like to create a similar setup.
I downloaded Grahams latest hipfile and i must admit, i'm struggeling to understand the last parts of the foreach sop!
everything is fine until he creates all those new groups, beginning with the group “new”.
It'd be awesome if you could help me comprehend those last steps of the setup. (especially the usage of the “hit” group)
with the best regards,
Manuel
i'm very interested in this topic, as i'd like to create a similar setup.
I downloaded Grahams latest hipfile and i must admit, i'm struggeling to understand the last parts of the foreach sop!
everything is fine until he creates all those new groups, beginning with the group “new”.
It'd be awesome if you could help me comprehend those last steps of the setup. (especially the usage of the “hit” group)
with the best regards,
Manuel
Edited by - Oct. 26, 2009 14:29:08
- graham
- Member
- 1922 posts
- Joined: Nov. 2006
- Offline
Here's a new version of the file that gets ride of a couple extra nodes involving the whole “new” group thing.
Basically what it is doing is we have our existing group of hit objects, and our source object that we need to add to the hit group. To do that we need to create a temp group with all the objects in it, then set the hit group to be equal to that group, then delete the new temp group. In this case I had the temp group named “new”. I adjusted the comment more to reflect this. Now it is happening just a single group sop.
Basically what it is doing is we have our existing group of hit objects, and our source object that we need to add to the hit group. To do that we need to create a temp group with all the objects in it, then set the hit group to be equal to that group, then delete the new temp group. In this case I had the temp group named “new”. I adjusted the comment more to reflect this. Now it is happening just a single group sop.
Graham Thompson, Technical Artist @ Rockstar Games
- asnowcappedromance
- Member
- 512 posts
- Joined: July 2009
- Offline
thanks a lot for this quick reply!
i think i pretty much got it. (wow that was hard!)
my last two questions:
the last stamp SOP has 2 incoming nodes. How does the expression exactly work and what is its purpose?
( in my understanding you say:
if the current processing number of one individual sphere is equal the numrange2 parameter of the foreachsop, take the input 1, otherwise the input 0)
is that right?
If the foreach SOP has run it's first iteration and the setup deletes the first (original) sphere, how is the next object getting into the original source group? because the primitve numbers rearrange themselves and the is a new primitive number “0” ?
i'm sure i already learned a lot through this hipfile, Houdini rocks
i think i pretty much got it. (wow that was hard!)
my last two questions:
the last stamp SOP has 2 incoming nodes. How does the expression exactly work and what is its purpose?
( in my understanding you say:
if the current processing number of one individual sphere is equal the numrange2 parameter of the foreachsop, take the input 1, otherwise the input 0)
is that right?
If the foreach SOP has run it's first iteration and the setup deletes the first (original) sphere, how is the next object getting into the original source group? because the primitve numbers rearrange themselves and the is a new primitive number “0” ?
i'm sure i already learned a lot through this hipfile, Houdini rocks
- graham
- Member
- 1922 posts
- Joined: Nov. 2006
- Offline
The switch basically just checks to see if the current iteration is the last iteration, and if it is, it switches to the couple of nodes that blast away the non hit faces and clean up the groups. Those operations could take place outside the For Each but I just through them in there.
The loop doesn't really “delete” the source objects. It takes the original source and removes it from the geo to ray against, but it is kept around in the other network branch.
After the ray, the closest sphere is then grouped in the “source” group and also stored into the “hit” group. The geo is then merged so that in the next iteration, the hit objects are still there, the source sphere can then be isolated and the closest found, but with the source still being in the hit group.
The loop doesn't really “delete” the source objects. It takes the original source and removes it from the geo to ray against, but it is kept around in the other network branch.
After the ray, the closest sphere is then grouped in the “source” group and also stored into the “hit” group. The geo is then merged so that in the next iteration, the hit objects are still there, the source sphere can then be isolated and the closest found, but with the source still being in the hit group.
Graham Thompson, Technical Artist @ Rockstar Games
- asnowcappedromance
- Member
- 512 posts
- Joined: July 2009
- Offline
ok, that makes sense.
Now comes the fun part:
on this website
http://3d-dave.com/ [3d-dave.com]
you can see in his showreel a project called “colopicker” (min 0:25)
oh and it's terribly streamed, you have to wait some time to be able to watch it
I intend to rebuild this setup and at the moment i'm looking for the best solution to do this. As i'm still new to houdini it would be great to get some support of you guys - for now i'm aware of the ray sop method, and of various expressions (distance, pointdist, nearpoint) and i have to find out which of those methods works best to get the desired result.
any tips or suggestions?
Now comes the fun part:
on this website
http://3d-dave.com/ [3d-dave.com]
you can see in his showreel a project called “colopicker” (min 0:25)
oh and it's terribly streamed, you have to wait some time to be able to watch it
I intend to rebuild this setup and at the moment i'm looking for the best solution to do this. As i'm still new to houdini it would be great to get some support of you guys - for now i'm aware of the ray sop method, and of various expressions (distance, pointdist, nearpoint) and i have to find out which of those methods works best to get the desired result.
any tips or suggestions?
- asnowcappedromance
- Member
- 512 posts
- Joined: July 2009
- Offline
ok here is my first attempt to the project, but there are many things i have to figure out.
i want to move the colorpicker over time, no keyframe animation and it should always travel to it's closest neighbour and be right-angled to the big sphere.
also, it should adopt the color of the sphere it's currently staying on.
I am still not sure if the ray sop method is the right thing to do this.
help would be appreciated
i want to move the colorpicker over time, no keyframe animation and it should always travel to it's closest neighbour and be right-angled to the big sphere.
also, it should adopt the color of the sphere it's currently staying on.
I am still not sure if the ray sop method is the right thing to do this.
help would be appreciated
- tamte
- Member
- 8839 posts
- Joined: July 2007
- Offline
- asnowcappedromance
- Member
- 512 posts
- Joined: July 2009
- Offline
- asnowcappedromance
- Member
- 512 posts
- Joined: July 2009
- Offline
WOW! it's amazing how much one can learn of breaking down those hip files, you never would be able to look behind the scenes of a 3DS Max File in this comples way …
Tamte it's really cool how you use the point SOP to achieve this result. But at the moment it's not 100% the way i want the needle to behave. In your file the nearest point is chosen in relation to the rotation parameters of the xform2 node, instead, i want the translation depend on the nearest point of the current point the “needle/colorpicker” is staying on.
so how could i do the translation once my neelde settled on one point?
(i hope this is understandable)
Tamte it's really cool how you use the point SOP to achieve this result. But at the moment it's not 100% the way i want the needle to behave. In your file the nearest point is chosen in relation to the rotation parameters of the xform2 node, instead, i want the translation depend on the nearest point of the current point the “needle/colorpicker” is staying on.
so how could i do the translation once my neelde settled on one point?
(i hope this is understandable)
- tamte
- Member
- 8839 posts
- Joined: July 2007
- Offline
the rotation in xform2 node is only for translating the picker point
the needle is pointing to the nearest point on the sphere to the picker point
you can use graham's example for the behavior you want
just make sure your points have normals pointing in the right direction
use graham's for each modified that it returns only isolated current nearest point
then copy your picker onto it and make it inherit the color and orient along normal
if you have any problems with it, i can post an example later
the needle is pointing to the nearest point on the sphere to the picker point
you can use graham's example for the behavior you want
just make sure your points have normals pointing in the right direction
use graham's for each modified that it returns only isolated current nearest point
then copy your picker onto it and make it inherit the color and orient along normal
if you have any problems with it, i can post an example later
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- asnowcappedromance
- Member
- 512 posts
- Joined: July 2009
- Offline
- asnowcappedromance
- Member
- 512 posts
- Joined: July 2009
- Offline
heeeeey!
I stuck to your method, Tamte and i'm pretty satisfied with the results so fas as i really know how to handle the point and nearpoint expressions now.
there are still a few questions:
is it possible to copy my colorpicker mesh to the point2 SOP without doing weird rotations and strange alignment? ( i added the correct normal to the point2 but had no success so far )
there is a new font object in my scene.
a) why isn't the text updating
b) why is the color wrong?
if you take a look at my scene you will know what i mean - and i beleave my expressions are right ^^
best regards from Munich,
Manu
I stuck to your method, Tamte and i'm pretty satisfied with the results so fas as i really know how to handle the point and nearpoint expressions now.
there are still a few questions:
is it possible to copy my colorpicker mesh to the point2 SOP without doing weird rotations and strange alignment? ( i added the correct normal to the point2 but had no success so far )
there is a new font object in my scene.
a) why isn't the text updating
b) why is the color wrong?
if you take a look at my scene you will know what i mean - and i beleave my expressions are right ^^
best regards from Munich,
Manu
- tamte
- Member
- 8839 posts
- Joined: July 2007
- Offline
asnowcappedromance
heeeeey!
…
is it possible to copy my colorpicker mesh to the point2 SOP without doing weird rotations and strange alignment? ( i added the correct normal to the point2 but had no success so far )
there is a new font object in my scene.
a) why isn't the text updating
b) why is the color wrong?
…
you can use facetSOP to compute normals on sphere and then scatter SOP will automatically create normals on scattered points
the weird rotations are made on purpose, like in video , if there is no need for them, it will simplify the network a little
just create group for current point and copy color picker to it
a) in point1 node, i used expression which is using local variables only for that node ($TX2, $TY2, $TZ2), but those are evaluated per point of the second input mesh and when the external reference is looking at the parameter, they are no longer valid
you should use point() expression to get exact position of the point for that purpose
b) the same reason
i have updated the file for those changes
i have changed a few things all over the place, so you better look at it as a whole new example and go through each node to see its purpose
the picker position is now determined as nearest point to the picker_null object, which is outside the Colorpicker_network
so you can just grab picker_null and animate it as you want
(again if you want the point picker to travel only to the nearest point on mesh, you need to use graham's method or similar, if it is too slow for you at high iterations, it can be made as simulated SOP solver )
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
-
- Quick Links