Difference between revisions of "LlScaleByFactor"

From Second Life Wiki
Jump to navigation Jump to search
m
Line 28: Line 28:
<lsl>
<lsl>
float maxAbs(vector a){
float maxAbs(vector a){
return llListStatistics(LIST_STAT_MAX, [llFabs(a.x), llFabs(a.y), llFabs(a.z)]);
    return llListStatistics(LIST_STAT_MAX, [llFabs(a.x), llFabs(a.y), llFabs(a.z)]);
}
}


integer ScaleByFactor(float scale) {
integer ScaleByFactor(float scale) {
if(scale == 0) return ERR_MALFORMED_PARAMS;
    vector root = llGetScale() * scale;
    if(maxAbs(root) > 64 || scale <= 0) return ERR_MALFORMED_PARAMS;
 
    integer prims = llGetNumberOfPrims();
    list set = [PRIM_LINK_TARGET, prims > 1, PRIM_SIZE, root];
      
      
integer prims = llGetNumberOfPrims();
    if(prims > 1) {
vector root = llGetScale() * scale;
        list get = [];
if(maxAbs(root) > 64)
        int count = prims;
return ERR_MALFORMED_PARAMS;
        do {
list set = [PRIM_LINK_TARGET, prims > 1, PRIM_SIZE, root];
            get += [PRIM_LINK_TARGET, count, PRIM_POS_LOCAL, PRIM_SIZE];
        } while(--count);
if(prims > 1) {
        get = llGetPrimitiveParams(get);
list get = [];
        count = 0;
int count = prims;
        do {
do {
            vector size = llList2Vector(get, ++count) * scale;
get += [PRIM_LINK_TARGET, count, PRIM_POS_LOCAL, PRIM_SIZE];
            vector pos = llList2Vector(get, ++count) * scale;
} while(--count);
            if(maxAbs(size) > 64 || maxAbs(pos) > 54)
get = llGetPrimitiveParams(get);
                return ERR_MALFORMED_PARAMS;
count = 0;
            set += [PRIM_LINK_TARGET, prims, PRIM_POS_LOCAL, pos, PRIM_SIZE, size];
do {
        } while(--prims > 1);
vector size = llList2Vector(get, ++count) * scale;
    }
vector pos = llList2Vector(get, ++count) * scale;
    llSetPrimitiveParams(set);
if(maxAbs(size) > 64 || maxAbs(pos) > 54)
    return TRUE;
return ERR_MALFORMED_PARAMS;
set += [PRIM_LINK_TARGET, prims, PRIM_POS_LOCAL, pos, PRIM_SIZE, size];
} while(--prims > 1);
}
llSetPrimitiveParams(set);
return TRUE;
}
}
</lsl>
</lsl>

Revision as of 00:42, 6 January 2014

Emblem-important-yellow.png LSL Feature Request
The described function does not exist. This article is a feature request.

Summary

Function: integer llScaleByFactor( float scaling_factor );

Attempts to resize the entire object by scaling_factor, maintaining the size-position ratios of the prims.
Returns an integer boolean, STATUS_* flag or ERR_* flag?

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

Examples

See Also

Functions

•  llScaleByFactor
•  llGetMaxScaleFactor

Deep Notes

This function is roughly equivalent to the following: <lsl> float maxAbs(vector a){

   return llListStatistics(LIST_STAT_MAX, [llFabs(a.x), llFabs(a.y), llFabs(a.z)]);

}

integer ScaleByFactor(float scale) {

   vector root = llGetScale() * scale;
   if(maxAbs(root) > 64

History

Search JIRA for related Issues

Signature

//function integer llScaleByFactor( float scaling_factor );