Difference between revisions of "LlScaleByFactor"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "{{LSL_Function|mode=request |inject-2= |func_id=|func_sleep=0.0|func_energy= |func=llScaleByFactor|sort=ScaleByFactor |return_type=float |p1_type=float |p1_name=scaling_factor |f…")
 
Line 4: Line 4:
|func=llScaleByFactor|sort=ScaleByFactor
|func=llScaleByFactor|sort=ScaleByFactor
|return_type=float
|return_type=float
|p1_type=float
|p1_type=float|p1_name=scaling_factor|p1_desc=The multiplier to be used with the prim sizes and their local positions.
|p1_name=scaling_factor
|func_desc=Attempts to resize the entire object by {{LSLP|scaling_factor}}, maintaining the size-position ratios of the prims.
|func_desc=Attempts to resize the entire object by {{LSLP|scaling_factor}}, maintaining the size-position ratios of the prims.
|return_type=integer
|return_type=integer
Line 26: Line 25:
|cat4
|cat4
|cat5
|cat5
|deepnotes=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) {
if(scale == 0) return ERR_MALFORMED_PARAMS;
   
integer prims = llGetNumberOfPrims();
vector root = llGetScale() * scale;
if(maxAbs(root) > 64)
return ERR_MALFORMED_PARAMS;
list set = [PRIM_LINK_TARGET, prims > 1, PRIM_SIZE, root];
if(prims > 1) {
list get = [];
int count = prims;
do {
get += [PRIM_LINK_TARGET, count, PRIM_POS_LOCAL, PRIM_SIZE];
} while(--count);
get = llGetPrimitiveParams(get);
count = 0;
do {
vector size = llList2Vector(get, ++count) * scale;
vector pos = llList2Vector(get, ++count) * scale;
if(maxAbs(size) > 64 || maxAbs(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;
}
</lsl>
|history=
|history=
*Mentioned in [[Simulator_User_Group/Transcripts/2013.12.10]]
*Mentioned in [[Simulator_User_Group/Transcripts/2013.12.10]]
*Mentioned in [[Simulator_User_Group/Transcripts/2013.12.17]]
*Mentioned in [[Simulator_User_Group/Transcripts/2013.12.17]]
}}
}}

Revision as of 00:15, 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) { if(scale == 0) return ERR_MALFORMED_PARAMS;

integer prims = llGetNumberOfPrims(); vector root = llGetScale() * scale; if(maxAbs(root) > 64) return ERR_MALFORMED_PARAMS; list set = [PRIM_LINK_TARGET, prims > 1, PRIM_SIZE, root];

if(prims > 1) { list get = []; int count = prims; do { get += [PRIM_LINK_TARGET, count, PRIM_POS_LOCAL, PRIM_SIZE]; } while(--count); get = llGetPrimitiveParams(get); count = 0; do { vector size = llList2Vector(get, ++count) * scale; vector pos = llList2Vector(get, ++count) * scale; if(maxAbs(size) > 64

History

Search JIRA for related Issues

Signature

//function integer llScaleByFactor( float scaling_factor );