Jump to content

bossbitxh

Resident
  • Posts

    1
  • Joined

  • Last visited

Everything posted by bossbitxh

  1. 0 vector cubic_curve(float t, list points) { float tt = t * t; float ttt = tt * t; float u = 1 - t; float uu = u * u; float uuu = uu * u; vector p0 = llList2Vector(points, 0); vector p1 = llList2Vector(points, 1); vector p2 = llList2Vector(points, 2); vector p3 = llList2Vector(points, 3); return (uuu * p0) + (3 * uu * t * p1) + (3 * u * tt * p2) + (ttt * p3); } vector get_vector(integer link, integer type) { list data = llGetLinkPrimitiveParams(link, (list)type); return llList2Vector(data, 0); } float radius = 7; vector radius_by_2; default { state_entry() { // Set stuff up radius_by_2 = <radius/2, radius/2, radius/2>; list points = []; // Generate random points for each link besides the root. integer link = 2; integer prims = llGetNumberOfPrims(); while (link <= prims) { llSetLinkPrimitiveParamsFast(link, [PRIM_TEXT, (string)["link", link], <1,1,1>, 1]); vector p = get_vector(link, PRIM_POS_LOCAL); points += p; // start points += <llFrand(radius), llFrand(radius), llFrand(radius)> - radius_by_2; points += <llFrand(radius), llFrand(radius), llFrand(radius)> - radius_by_2; points += p; // end ++link; } // Start updating link positions. while (TRUE) { // Get time and adjust its speed float t = llGetTime() * 0.2; // And make sure we stay in the 0:1 range. if (t > 1) t = 1; // This list will contain all of the PrimParams we'll apply to each prim. list params = []; link = 2; while (link <= prims) { // Get the 4 points that belong to the current link. integer index = (link - 2) * 4; list stride = llList2ListStrided(points, index, index + 3, 0); // Calculate its position based on current time. params += [PRIM_LINK_TARGET, link, PRIM_POS_LOCAL, cubic_curve(t, stride)]; ++link; } // Apply all of the positions at once. llSetLinkPrimitiveParamsFast(1, params); llSetText((string)["Time: ", t], <1,1,1>, 1); if (t >= 1) llResetTime(); } } } That's about 40 significant lines of code. Edited October 13, 2020 by Wulfie Reanimator 3 Quote
×
×
  • Create New...