Jump to content

[VEX] Stacking points one above the other using atrrib size


esnaacho

Recommended Posts

Hello wizards, i have a little problem, and im not able to understand why my code doesnt work.

I have:

-a couple of points,

-each with a vector attrib "size".

-some code in a wrangle to order the points one above/under(direction shouldnt matter because im taking the absolut value, right?) the other without modifying the first point (0):

if(@ptnum > 0){
    vector last_point_size = point(0, "size", @ptnum-1);
    vector last_point_pos = point(0, "P", @ptnum-1);
    @P.y += ( abs(last_point_size[1]) + abs(last_point_pos[1]) );
}

hip.jpg.64374b201fc8476433c545924f99c659.jpg

Here before/after the wrangle. Tint in blue everything that doesnt change.

beforeAfterWrangle.jpg.fb0ca3c62aeeb96e182812be68f02a70.jpg

What am i doing wrong?

Thanks in advance for your time.

mylogic.jpg

Link to comment
Share on other sites

1 hour ago, fencer said:

How about calculate real size of every letter and shift based on it? Looks like you are trying to do the same but I am not sure about you idea.

ltower_v01.hipnc

ltower.jpg

Thank you . i would look into it.

1 hour ago, Noobini said:

I'm not really contributing anything but just FYI there's Labs Align and distribute which does in all 3 axis (with spacing)...just in case you wanna dissect its innards.

thanks man! i was looking for that, i saw it in a video a long time ago, but i couldnt remember the node name, and i dont remember the video either. lool thanks !


I think i found out the problem.
In the loop inside the wrangle:

if(@ptnum > 0){
    vector last_point_size = point(0, "size", @ptnum-1);
    vector last_point_pos = point(0, "P", @ptnum-1);
    @P.y += ( abs(last_point_size[1]) + abs(last_point_pos[1]) );
}

when its in Point(0) - nothing happen

when its in Point(1) - last_point_pos = Point(0)'s position. apply new pos. OK

but when its in Point(2) - last_point_pos = Point(1) without the previous modification, so point 1 and 2 end up overlapping.

 

:/

 

Link to comment
Share on other sites

2 hours ago, fencer said:

How about calculate real size of every letter and shift based on it? Looks like you are trying to do the same but I am not sure about you idea.

ltower_v01.hipnc

ltower.jpg

 

finally, problem solved. With just one wrangle. Your hip file was very useful. thanks !

I had to calculate the total size of all previous points, then adding the current size. 

float total;
for(int i=0;i<@ptnum;i++){
    vector last_point_size = point( 0, "size", i );
    total += last_point_size[1];
}
@P.y = ( total + ( v@size[1]/2) );

 

Thanks everyone :)

Edited by esnaacho
changed variable name for easy understanding
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...