Criando uma saia flex
Autor: Marson Montekuri | Publicado: 2011-04-28T12:21:00-07:00

Nessa parte da aula iremos aprender a criar uma saia flex usando o prim flex da outra aula.Vamos precisar também do script looprez, encontrado nesse blog.Looprez script otimizado para a aula:////////////////////////////////////////////////////////////////////////////////// LoopRez v0.6, by Ged Larsen, 20 December 2006//// - rez a number of objects in an ellipse, whose size is determined by xRadius and yRadius// - all facing "outwards", along a tangent to the ellipse// - can set how much the objects flare outwards// - properly handles object rotation corrections (for example, X-axis 180 degree rotation helps for flexi-prim skirts)// - can also get a 'saddle' bend, to generate a bend that might help for necklaces (from Ariane Brodie)//// To use:// 1) create a prim that will contain this script and the object to use// 2) put the script into the prim// 3) create an object that will be used, and name it "Object"// 4) put "Object" into the prim containing the script, by dragging it from your inventory// 5) get out of Edit Mode, and touch the prim//// Random note:// - this version does NOT insure equal spacing of objects along the perimeter of the ellipse// - i.e., objects "bunch up" at the long ends of an ellipse; the effect should be acceptable for non-extreme ellipses// - even spacing of objects can be accomplished, but requires simulation of integral calculus, which slows down the script//// References:// - tangent formulas from: http://mathworld.wolfram.com/Ellipse.html////////////////////////////////////////////////////////////////////////////////// CONFIGURATION PARAMETERS, change these to your likingstring objectName = "saia"; // objeto a ser copiadointeger numObjects = 12; // quantidade de objetosfloat xRadius = 0.23;  // elipse eixo-xfloat yRadius = 0.17;  // elipse eixo-yfloat flareAngle = 40.0; // grau de inclinacaofloat bendCoefficient = 0.0; // coeficiente de dobramentovector rotOffset = &lt;0.0, 180.0, 0.0&gt;; // rotacaovector posOffset = &lt;0.0, 0.0, 0.6&gt;; // posicao////////////////////////////////////////////////////////////////////////////////// No need to mess with anything below heremakeLoop(){integer n; // which object is being placedfloat theta; // angle in radiansvector pos; // positionrotation rot; // rotation in quaternion formatfor(n = 0; n &lt; numObjects; n++) {theta = TWO_PI * ( (float)n / (float)numObjects );pos.x = xRadius * llCos(theta); // ellipse: 2x xRadius meters widepos.y = yRadius * llSin(theta); // ellipse: 2x yRadius meters widepos.z = -bendCoefficient*llCos(theta)*llCos(theta); // saddle shape, bending downwards on X-axispos = pos + llGetPos() + posOffset;rot = llEuler2Rot(&lt;rotOffset.x*DEG_TO_RAD, rotOffset.y*DEG_TO_RAD, rotOffset.z*DEG_TO_RAD&gt;); // user-chosen rotation offset correctionrot = rot * llEuler2Rot(&lt;0, -1*flareAngle*DEG_TO_RAD, 0&gt;); // flare generation (poof)// the following make the objects face outwards properly for an ellipse; using theta alone is only correct for a circle// the scary formula calculates a unit vector TANGENTIAL to the ellipse, and llRotBetween is used to figure out how much the object needs to rotate to lie parallel to the tangentrot = rot * llRotBetween(&lt;0.0,1.0,0.0&gt;, &lt;-1.0 * xRadius * llSin(theta) / ( llSqrt ( (yRadius*yRadius * llCos(theta) * llCos(theta)) + (xRadius*xRadius * llSin(theta) * llSin(theta))) ),yRadius * llCos(theta) / ( llSqrt ( (yRadius*yRadius * llCos(theta) * llCos(theta)) + (xRadius*xRadius * llSin(theta) * llSin(theta))) ),0.0&gt;);if ( n== (numObjects/2) ) // LSL's implementation of llRotBetween at theta = pi radians is reversed at 180 degrees, so this manually corrects itrot = rot * llEuler2Rot( &lt;0,PI,0&gt; );llRezObject(objectName, pos, ZERO_VECTOR, rot, 0);}}default{touch_start(integer total_number){if (llDetectedOwner(0) == llGetOwner()){makeLoop();}}}