Jump to content

Transfering colors in attribute wrangler


netherknight

Recommended Posts

So I'm working with this attribute wrangler that makes a twisting braid around any curves I slot into it. However I am running into an issue where the original curves have a color but I can't seem to have the new twist inherit the color from the curve. Of course I can add a color node afterwards but that will only give it one color. Whereas my curves have multiple colors (each primitive has a different color).  

float rad = ch('radius');
float pi = 3.1415926;
float t = 2.0 * pi  * ch('winding');
int copies = chi('strands');

int prim_pts[] = primpoints(0, @primnum);

for(int i = 0; i < copies; i++){
    int add_prim = addprim(0, "polyline");
    setprimintrinsic(0,"closed",add_prim,"toggle");
    setprimgroup(0,"twisted"+itoa(i+1),add_prim,1);
    setprimattrib(0,"Cd",add_prim,1);
    foreach(int pt; prim_pts){
        vector pt_p = point(0, "P", pt);
        vector pt_n = point(0, "Nloc", pt);
        vector pt_b = point(0, "Bloc", pt); 
        vector uv = point(0,"uv",pt);
        float s =uv.x;
        float phase = 2*pi / copies * i;
        vector pt_pos = pt_p + pt_n * sin(s*t+phase)*rad + pt_b * cos(s*t+phase)*rad;
        int add_pt = addpoint(0, pt_pos); 
        addvertex(0, add_prim, add_pt);
    }

removeprim(0,@primnum,1);

Twist.hip

Edited by netherknight
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...