llScaleByFactor

From Second Life Wiki
Revision as of 16:15, 6 January 2014 by Maestro Linden (talk | contribs)
Jump to navigation Jump to search

Summary

Function: integer llScaleByFactor( float scaling_factor );

Attempts to resize the entire object by scaling_factor, maintaining the size-position ratios of the prims.

Resizing is subject to prim scale limits and linkability limits. This function can not resize the object if the linkset is physical, a pathfinding character, in a keyframed motion, or if resizing would cause the parcel to overflow.
Returns a boolean (an integer) TRUE if it succeeds, FALSE if it fails.

• float scaling_factor The multiplier to be used with the prim sizes and their local positions.

Caveats

  • Due to floating point precision issues (often, sqrt(x*x) != x), avoid rescaling by the values returned by llGetMinScaleFactor and llGetMaxScaleFactor. To guarantee successful rescaling, use values slightly within the limits returned by those functions.
All Issues ~ Search JIRA for related Bugs

Examples

<lsl>// Touching this script causes the object to double or halve in size. integer growing = FALSE;

default {

   state_entry()
   {
       llSay(0, "Touch to toggle scale");
   }

   touch_start(integer total_number)
   {
       float min_factor = llGetMinScaleFactor();
       float max_factor = llGetMaxScaleFactor();
       integer success;
       llSay(0, "min_scale_factor = " + (string)min_factor + "  max_scale_factor = " + (string)max_factor);
       growing = !growing;
       if (growing)
       {
           success = llScaleByFactor(2.0);
       }
       else
       {
           success = llScaleByFactor(0.5);
       }
       if (!success)
       {
           llSay(0, "Scaling failed!");
       }
   }
}</lsl>

See Also

Deep Notes

This function is roughly equivalent to the following: <lsl> 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

History

Search JIRA for related Issues

Signature

function integer llScaleByFactor( float scaling_factor );