TomRaynor Posted May 5, 2015 Share Posted May 5, 2015 Hi, What I am trying to do is use an attribwrangle set to loop over primitives to work out the y-size of each primitive on my geometry and store that as a primitive attribute. I am trying to do it using an attribwrangle rather than using a foreach node looping over primitives and using the bbox() expression for speed purposes. Where I am stuck is working out the what to use instead of bbox in my attribwrangle that will give me the y-size of each primitive... Can anyone ofer up any suggestions? (with a snippet of example code preferably) Thanks very much Quote Link to comment Share on other sites More sharing options...
iamyog Posted May 5, 2015 Share Posted May 5, 2015 (edited) Here are 2 solutions but I can't really say they are efficient. It might still be useful for you before anybody gives a better input. First one is the easy trick to edit the parameter interface of your attribWrangle and add a float parameter. You can now type hscript in this and access the value via ch("parmname") in your VEX. Quick, efficient but I've no idea of the actual cost of calling an hscript function before using VEX. Second is probably not a good idea as it loops through all the points and annihilate any multi threading or clever computer things I'm not able to explain but here it is : float posx[] = array(); // array that will store positions for(int i=0; i<@numpt; i++) { // fill the array with X coords vector _tmp = point(0, "P", i); push(posx, _tmp[0]); } posx = sort(posx); // sort the array int msize = len(posx); // get size of array // addition of first and last elements of the array // --> min and max values on X axis @xsize = abs(posx[0]) + abs(posx[msize-1]); Edit : completely misread your question sorry... This will give the XSIZE of the whole object. But same code can probably be adapted to loop through all points from a giver primitive. Edited May 5, 2015 by iamyog 1 Quote Link to comment Share on other sites More sharing options...
TomRaynor Posted May 5, 2015 Author Share Posted May 5, 2015 Well thought was to do something like use the attribwrangle to run over each primitive, and for each of the points in each primitive, find the minimum and maximum P.y values (and hence the range). I guess I would have to store these point positions in an array for each primitive... Stil, I'm hoping that someone is going to pipe up and tell me that I can run a nice vex function to access the bbox information PER PRIMITIVE. What about primitive intrinsic attributes? Do they help me and if so how can I access them? Quote Link to comment Share on other sites More sharing options...
magneto Posted May 5, 2015 Share Posted May 5, 2015 You can loop through the points of each primitive and calculate it manually. Check out geometry traversing functions. 1 Quote Link to comment Share on other sites More sharing options...
anim Posted May 7, 2015 Share Posted May 7, 2015 (edited) ... What about primitive intrinsic attributes? Do they help me and if so how can I access them? you are on the right path here is the code (PrimitiveWrangle): float bbox[] = primintrinsic(0, "bounds", @primnum); f@ysize = bbox[3]-bbox[2]; you can as well use getbbox() to get bbox of a group, so even per prim (though much slower than the former) vector bbmin, bbmax; getbbox(0, itoa(@primnum), bbmin, bbmax); f@ysize = bbmax.y-bbmin.y; Edited May 7, 2015 by anim 2 Quote Link to comment Share on other sites More sharing options...
TomRaynor Posted May 7, 2015 Author Share Posted May 7, 2015 That is right on the money! Exactly what I needed, cheers Tomas. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.