LlScaleByFactor
De DigiWiki.
(Différences entre les versions)
(Page créée avec « <lsl>// Touching this script causes the object to double or halve in size. integer growing; default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to toggl… ») |
|||
Ligne 29 : | Ligne 29 : | ||
}</lsl> | }</lsl> | ||
- | + | ==== Deep Notes ==== | |
This function is roughly equivalent to the following: | This function is roughly equivalent to the following: | ||
<lsl> | <lsl> |
Version actuelle en date du 11 janvier 2014 à 23:48
// Touching this script causes the object to double or halve in size. integer growing; default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to toggle scale."); } touch_start(integer num_detected) { growing = !growing; float min_factor = llGetMinScaleFactor(); float max_factor = llGetMaxScaleFactor(); llSay(PUBLIC_CHANNEL, "min_scale_factor = " + (string)min_factor + "\nmax_scale_factor = " + (string)max_factor); integer success; if (growing) success = llScaleByFactor(2.0); else success = llScaleByFactor(0.5); if (!success) llSay(PUBLIC_CHANNEL, "Scaling failed!"); } }
Deep Notes
This function is roughly equivalent to the following:
float VectorAbsStatistics(integer flag, vector a){ return llListStatistics(flag, [llFabs(a.x), llFabs(a.y), llFabs(a.z)]); } integer ScaleByFactor(float scale) { vector root = llGetScale() * scale; if (VectorAbsStatistics(LIST_STAT_MAX, root) > 64 || VectorAbsStatistics(LIST_STAT_MIN, root) < 0.01 || scale <= 0) { return ERR_MALFORMED_PARAMS; } integer prims = llGetNumberOfPrims(); list set = [PRIM_LINK_TARGET, prims > 1, PRIM_SIZE, root]; if (prims > 1) { list get = []; integer count = prims; do { get += [PRIM_LINK_TARGET, count, PRIM_SIZE, PRIM_POS_LOCAL]; } while(--count); get = llGetPrimitiveParams(get); count = 0; do { vector size = llList2Vector(get, ++count) * scale; vector pos = llList2Vector(get, ++count) * scale; if (VectorAbsStatistics(LIST_STAT_MAX, size) > 64 || VectorAbsStatistics(LIST_STAT_MIN, size) < 0.01 || VectorAbsStatistics(LIST_STAT_MAX, pos) > 54 ) { return ERR_MALFORMED_PARAMS; } set += [PRIM_LINK_TARGET, prims, PRIM_POS_LOCAL, pos, PRIM_SIZE, size]; } while(--prims > 1); } llSetPrimitiveParams(set); return TRUE; }