Difference between revisions of "LlScaleByFactor/ja"

From Second Life Wiki
Jump to navigation Jump to search
m
m
Line 4: Line 4:
|func=llScaleByFactor|sort=ScaleByFactor
|func=llScaleByFactor|sort=ScaleByFactor
|return_type=integer
|return_type=integer
|p1_type=float|p1_name=scaling_factor|p1_desc=The multiplier to be used with the prim sizes and their local positions.
|p1_type=float|p1_name=scaling_factor|p1_desc=プリムサイズおよびそれらのローカル位置と一致するように使用される乗数。
|func_desc=Attempts to resize the entire object by {{LSLP|scaling_factor}}, maintaining the size-position ratios of the prims.
|func_desc=プリムのサイズと位置の比率を保持しつつ、全体のオブジェクトを{{LSLP|scaling_factor}}で再サイズしようとします。


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.
再サイズはプリムスケールの制限とリンク可能性の制限が適用されます。リンクセットが物理的である、パスファインディングキャラクターである、キーフレーム化されたモーションの一部である、またはサイズ変更によってパーセルがオーバーフローする場合、この関数はオブジェクトのサイズを変更できません。
|return_type=integer
|return_type=integer
|return_subtype=boolean
|return_subtype=boolean
|return_text=[[TRUE]] if it succeeds, [[FALSE]] if it fails.
|return_text=成功すると[[TRUE]]、失敗すると[[FALSE]]
|spec
|spec
|caveats=
|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.
*浮動小数点の精度の問題により(しばしば、sqrt(x*x) != x)、[[llGetMinScaleFactor]]および[[llGetMaxScaleFactor]]で返される値を使用して再スケーリングしないようにしてください。成功した再スケーリングを保証するには、これらの関数によって返される範囲内の値をわずかに使用してください。
|constants
|constants
|examples=
|examples=
Line 47: Line 47:
|helpers
|helpers
|also_functions=
|also_functions=
{{LSL DefineRow||[[llScaleByFactor]]|}}
{{LSL DefineRow||[[llScaleByFactor/ja]]|}}
{{LSL DefineRow||[[llGetMaxScaleFactor]]|}}
{{LSL DefineRow||[[llGetMaxScaleFactor/ja]]|}}
{{LSL DefineRow||[[llGetMinScaleFactor]]|}}
{{LSL DefineRow||[[llGetMinScaleFactor/ja]]|}}
|also_tests
|also_tests
|also_events
|also_events

Revision as of 15:29, 22 November 2023

要約

関数: integer llScaleByFactor( float scaling_factor );

プリムのサイズと位置の比率を保持しつつ、全体のオブジェクトをscaling_factorで再サイズしようとします。

再サイズはプリムスケールの制限とリンク可能性の制限が適用されます。リンクセットが物理的である、パスファインディングキャラクターである、キーフレーム化されたモーションの一部である、またはサイズ変更によってパーセルがオーバーフローする場合、この関数はオブジェクトのサイズを変更できません。
成功するとTRUE、失敗するとFALSE。を integer で返します。

• float scaling_factor プリムサイズおよびそれらのローカル位置と一致するように使用される乗数。

警告

  • 浮動小数点の精度の問題により(しばしば、sqrt(x*x) != x)、llGetMinScaleFactorおよびllGetMaxScaleFactorで返される値を使用して再スケーリングしないようにしてください。成功した再スケーリングを保証するには、これらの関数によって返される範囲内の値をわずかに使用してください。
All Issues ~ Search JIRA for related Bugs

サンプル

//  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!");
    }
}

関連項目

特記事項

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;
}

経緯

Search JIRA for related Issues

Signature

function integer llScaleByFactor( float scaling_factor );
この翻訳は 原文 と比べて古いですか?間違いがありますか?読みにくいですか?みんなで 修正 していきましょう! (手順はこちら)
この項目はあなたにとって参考にならない項目ですか?もしかしたらLSL Wikiの関連した項目が参考になるかもしれません。