Jump to content
amin.khormaei

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

Recommended Posts

Posted (edited)

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

best regards.

Edited by amin.khormaei

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×