Jump to content

what's the Geometry traversal's application in houdini?


amin.khormaei

Recommended Posts

why not :P

you could do something like (creating a prim attribute from points data):

//run this over primitives, to calculate the perimeter using the point data.
//note that this is not the most efficient way to do this, but as an example to what options this gives you:

int pts[] = primpoints(0, @primnum);
float sumOfTheDistances = 0; 

for(int i=0; i < (@numvtx-1); i++){
	vector pos0 = point(0, "P", pts[i]);
	vector pos1 = point(0, "P", pts[i+1]);
	sumOfTheDistances += distance(pos0, pos1);
}
                             
f@perimeter = sumOfTheDistances; // create a primitive attribute

or the other way (creating a vertex attribute while processing prims):

//run this over primitives to calculate the same thing a polyframe would, but as a vertex attribute, so you do not have to make the points unique:

int verts[] = primvertices(0, @primnum);
vector forwardDir;

for(i = 0; i < (@numvtx-1); i++){
	vector pos0 = point(0, "P", vertexpoint(0, verts[i])); //get the point data, from the vertex (just to demo the conversion, 
	vector pos1 = point(0, "P", vertexpoint(0, verts[i])); //the "P" data should also be fetchable here using vertex() instead of point()
	forwardDir = normalize(pos1 - pos0);
	setvertexattrib(0, "N", verts[i], -1, forwardDir);
}

setvertexattrib(0, "N", verts[-1], -1, forwardDir); //put the same data on the last vertex, as the second to last one

note that I have coded this "blind" (did not test it) so hopefully the code runs, but there could be a typo somewhere

  • Thanks 1
Link to comment
Share on other sites

My favorite "traversal" adds primitive objects to points.
Unfortunately there is very little types to choose from.

prim_types.jpg.bb77a6521f1af1524beac987490823a6.jpg

// Choose random primitive types from list
string types[] = {'sphere', 'circle', 'tube'};
int index = int(rand(i@ptnum) * len(types));
int prim_add = addprim(0, types[index], i@ptnum);

// apply point orientation from polyframe node
matrix3 xform = set(v@tangentv, v@N, v@tangentu);
scale(xform, 0.05);
setprimintrinsic(geoself(), "transform", prim_add, xform);

 

add_prims.hipnc

  • Thanks 1
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...