Jump to content

Point Collection Iterations with VEX


SubjectEgo

Recommended Posts

I'm having trouble finding a solution to a problem. I have a point group in my file, which I need to behave in a particular manner. To get the behavior I need, the points need to be aware of neighboring points, and act accordingly. For example, for each point in the group, the positions of all points within a certain distance will have their relative positions fed into an algorithm. The result from this will be used to move the current point through space in relation to that result, and, in effect, in relation to the neighboring points.

However, I'm not sure how to achieve that. Within a VEX POP, I don't know how to bring in the positions of points other than the one currently being evaluated, let alone isolate the points that fall within a certain distance from that point. It's been recommended that I use a Point Cloud, but I have found ZERO reference for how Point Clouds are used. The local Houdini Help Documentation does not contain the relevant information, and the Wiki here has not yielded anything useful (some of the would-be useful links are broken).

Link to comment
Share on other sites

I'm having trouble finding a solution to a problem. I have a point group in my file, which I need to behave in a particular manner. To get the behavior I need, the points need to be aware of neighboring points, and act accordingly. For example, for each point in the group, the positions of all points within a certain distance will have their relative positions fed into an algorithm. The result from this will be used to move the current point through space in relation to that result, and, in effect, in relation to the neighboring points.

However, I'm not sure how to achieve that. Within a VEX POP, I don't know how to bring in the positions of points other than the one currently being evaluated, let alone isolate the points that fall within a certain distance from that point. It's been recommended that I use a Point Cloud, but I have found ZERO reference for how Point Clouds are used. The local Houdini Help Documentation does not contain the relevant information, and the Wiki here has not yielded anything useful (some of the would-be useful links are broken).

I'm ashamed for myself, I'm selling this code twice a week, although it's really trivial. Look at the very bottom here: http://forums.odforce.net/index.php?showto...non-overlapping

This is a sop VEX code, but to turn in into a pop VEX, I think it's enough to change declaration, so:

// We need at least one variable, point cloud map. In SOPs and POPs this can be preceding 
// operator (not a file on disk), specified with a trick:" op:/`opinputpath(".", 0)` " in a string 
// parameter.

 pop
  nearestPointPC(string pointcloud="")
  { 
	  // Here I assumed that farthest possible distance between points is a bbox: 
	  vector min, max;
	 float tmpdist;
	  getbbox(min, max);
	  float dist = distance(min, max);

	 // Open a PC "around" current P coordinates, and retrieve 2 closest neighbours:
	 // again: point cloud doesn't have to exist on disk...
	  int handle = pcopen(pointcloud, "P", P, dist, 2);  

	 // Iterate through points returned by pcopen()
	  while (pciterate(handle) ) {

		  vector pos;

		   // import position of a point. I also suspect (?) that the first one 
		   // will be *our point, so I'm trying to omit first match:
		  pcimport(handle, "P", pos);

		  if ( P != pos ) {

				 // There are two spacial attribs: point.distance and point.number 
				 //  you can import besides any other owned by a point in query:

			  pcimport(handle, "point.distance", tmpdist);

			   //  I needed only to save the shortest distance to a point attribute:
			  // Perhaps this is a place for your fancy, rocket science  algorithm:

			  addattribute("distance", tmpdist);
		  }
	  }			
  }

I think there are some examples how to deal with PC in Help. Did you search for a pcopen?

Hope this helps,

Simon.

Edited by SYmek
  • Like 1
Link to comment
Share on other sites

How might I achieve the same results using a node-based approach? I'd like to understand how the same information would flow through a VOP Network / POP Type setup.

Don't ask me to do this :ph34r: . It's fully doable In VOPs. You need nodes like: Point Cloud Open, Point Cloud Iterate, While, Compare, Point Cloud Import and a few others. Good luck ;). After all this snippet has ~8 lines of workable code. Rest are {} or comments.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...