netherknight Posted September 26, 2018 Share Posted September 26, 2018 (edited) 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 September 26, 2018 by netherknight Quote Link to comment Share on other sites More sharing options...
Skybar Posted September 26, 2018 Share Posted September 26, 2018 Instead of this: setprimattrib(0,"Cd",add_prim,1); Do this: setprimattrib(0,"Cd",add_prim,@Cd); Quote Link to comment Share on other sites More sharing options...
netherknight Posted September 26, 2018 Author Share Posted September 26, 2018 Yes, great, thank you! I must've been staring at it too long haha. Thanks! 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.