LlGetPrimitiveParams/ja

From Second Life Wiki
< LlGetPrimitiveParams
Revision as of 05:04, 25 February 2016 by SakuraNoel Fayray (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

要約

関数: list llGetPrimitiveParams( list params );

パラメータリストから指定したプリミティブのパラメータを list で返します。

• list params PRIM_* フラグ

PRIM_* フラグは 2 つのカテゴリに分類できます。面フラグとプリムフラグです。

  • プリムフラグを引数に渡すと、フラグの属性が返ってきます。
  • 面フラグはユーザが面パラメタを指定する必要があります。
フラグ 説明
LINK_ROOT 1 リンクセットの中のルートプリムに送ります
フラグ 説明
LINK_THIS -4 スクリプトの入った自プリムに送ります

パラメータ 返り値 説明
PRIM_NAME ] 27 [ string name ] プリムの名前を取得します。
PRIM_DESC ] 28 [ string description ] プリムの説明を取得します。
PRIM_TYPE ] 9 [ integer flag ] + flag_parameters プリムの形状を取得します。
フラグ定数 get
PRIM_TYPE_BOX 0 [ integer hole_shape, vector cut, float hollow, vector twist, vector top_size, vector top_shear ]
PRIM_TYPE_CYLINDER 1 [ integer hole_shape, vector cut, float hollow, vector twist, vector top_size, vector top_shear ]
PRIM_TYPE_PRISM 2 [ integer hole_shape, vector cut, float hollow, vector twist, vector top_size, vector top_shear ]
PRIM_TYPE_SPHERE 3 [ integer hole_shape, vector cut, float hollow, vector twist, vector dimple]
PRIM_TYPE_TORUS 4 [ integer hole_shape, vector cut, float hollow, vector twist, vector hole_size, vector top_shear, vector advanced_cut, vector taper, float revolutions, float radius_offset, float skew ]
PRIM_TYPE_TUBE 5 [ integer hole_shape, vector cut, float hollow, vector twist, vector hole_size, vector top_shear, vector advanced_cut, vector taper, float revolutions, float radius_offset, float skew ]
PRIM_TYPE_RING 6 [ integer hole_shape, vector cut, float hollow, vector twist, vector hole_size, vector top_shear, vector advanced_cut, vector taper, float revolutions, float radius_offset, float skew ]
PRIM_TYPE_SCULPT 7 [ string mapinteger type ] Sculpted_Prims:_FAQ
  hole_shape フラグ 形状 hole_shape フラグ 形状
PRIM_HOLE_DEFAULT 0x00 デフォルト PRIM_HOLE_SQUARE 0x20 正方形
PRIM_HOLE_CIRCLE 0x10 サークル PRIM_HOLE_TRIANGLE 0x30 三角形
type フラグ 形状 説明
PRIM_SCULPT_TYPE_SPHERE 1 球形 上端と下端で収束し、左端が右端に縫合される
PRIM_SCULPT_TYPE_TORUS 2 トーラス 上端が下端に縫合され、左端が右端に縫合される
PRIM_SCULPT_TYPE_PLANE 3 平面 収束や縫合は行われない
PRIM_SCULPT_TYPE_CYLINDER 4 シリンダー 左端が右端に縫合される
PRIM_SCULPT_FLAG_ZZZZZZZZ 63
PRIM_SCULPT_FLAG_INVERT 64 裏返し 裏返しに表示 (法線を逆転させる)
PRIM_SCULPT_FLAG_MIRROR 128 ミラー スカルプトされたプリムを X 軸上で反転する
PRIM_SLICE ] 35 [ vector slice ] プリム属性のスライスを取得します。
PRIM_PHYSICS_SHAPE_TYPE ] 30 [ integer type ] プリムの物理形状タイプを取得します。
typeフラグ 説明 ノート
PRIM_PHYSICS_SHAPE_PRIM 0 ノーマルプリム形状の物理に使います メッシュでないオブジェクトのデフォルト値です
PRIM_PHYSICS_SHAPE_CONVEX 2 プリムの凸包形状の物理に使います メッシュオブジェクトのデフォルト値です
PRIM_PHYSICS_SHAPE_NONE 1 プリムの物理形状を無視します これをルートプリム、アバターに適用することはできません

このプリムは、他のオブジェクトやアバターが衝突せずに通り抜けます("ファントム"のように)

PRIM_MATERIAL ] 2 [ integer material ] プリムの素材を取得します。素材は標準の 衝突音スプライト を決定します。 friction coefficient and restitution coefficient.
素材 フラグ 説明 摩擦 反発
PRIM_MATERIAL_STONE 0 石材 0.8 0.4
PRIM_MATERIAL_METAL 1 金属 0.3 0.4
PRIM_MATERIAL_GLASS 2 ガラス 0.2 0.7
PRIM_MATERIAL_WOOD 3 木材 0.6 0.5
PRIM_MATERIAL_FLESH 4 0.9 0.3
PRIM_MATERIAL_PLASTIC 5 プラスチック 0.4 0.7
PRIM_MATERIAL_RUBBER 6 ゴム 0.9 0.9
PRIM_MATERIAL_LIGHT 7 光, 非推奨: [ PRIM_FULLBRIGHT, ALL_SIDES, TRUE ] と同じように見えます 0.6 0.5
PRIM_PHYSICS ] 3 [ integer boolean ] 物理状態を取得します。
PRIM_TEMP_ON_REZ ] 4 [ integer boolean ] テンポラリ属性
PRIM_PHANTOM ] 5 [ integer boolean ] ファントム状態を取得します。
PRIM_POSITION ] 6 [ vector position ] 位置を取得します。
PRIM_POS_LOCAL ] 33 [ vector position ] ローカル位置を取得します。
PRIM_ROTATION ] 8 [ rotation rot ] 回転を取得します。(子プリムでは壊れています)
PRIM_ROT_LOCAL ] 29 [ rotation rot ] ローカル回転を取得します。
PRIM_SIZE ] 7 [ vector size ] 大きさを取得します。
PRIM_TEXTURE, integer face ] 17 [ string texture, vector repeats, vector offsets, float rotation_in_radians ]
テクスチャ: llGetTexture
繰り返し: llGetTextureScale
オフセット: llGetTextureOffset
回転: llGetTextureRot
PRIM_RENDER_MATERIAL, integer face ] 43 [ string render_material ]

Caveat: This parameter will be supported in the upcoming GLTF Materials project. Currently it will only work in supported testing areas with a supported test viewer.

マテリアル: llGetRenderMaterial
PRIM_TEXT ] 26 [ string text, vector color, float alpha ] Floating Text: NA
PRIM_COLOR, integer face ] 18 [ vector color, float alpha ]
透過: llGetAlpha
: llGetColor
PRIM_BUMP_SHINY, integer face ] 19 integer shiny, integer bump ]
shinybump のフラグ 説明
PRIM_SHINY_NONE 0 なし
PRIM_SHINY_LOW 1
PRIM_SHINY_MEDIUM 2
PRIM_SHINY_HIGH 3
PRIM_BUMP_NONE 0 なし: 凹凸なし
PRIM_BUMP_BRIGHT 1 明るさ:明るい光で生成されるもの
PRIM_BUMP_DARK 2 暗さ:暗い光で生成されるもの
PRIM_BUMP_WOOD 3 木目調
PRIM_BUMP_BARK 4 木の皮
PRIM_BUMP_BRICKS 5 レンガ
PRIM_BUMP_CHECKER 6 チェッカー
PRIM_BUMP_CONCRETE 7 コンクリート
PRIM_BUMP_TILE 8 クラスティ・タイル
PRIM_BUMP_STONE 9 カットストーン:ブロック
PRIM_BUMP_DISKS 10 ディスク:束ねた輪っか
PRIM_BUMP_GRAVEL 11 砂利
PRIM_BUMP_BLOBS 12 ペトリ: 簡単なアメーバのような形状
PRIM_BUMP_SIDING 13 羽目板
PRIM_BUMP_LARGETILE 14 ストーン・タイル
PRIM_BUMP_STUCCO 15 しっくい
PRIM_BUMP_SUCTION 16 吸い込み:リング
PRIM_BUMP_WEAVE 17 織目
PRIM_FULLBRIGHT, integer face ] 20 [ integer boolean ]
PRIM_FLEXIBLE ] 21 [ integer boolean, integer softness, float gravity, float friction, float wind, float tension, vector force ]
PRIM_TEXGEN, integer face ] 22 [ integer mode ]
モード定数 説明
PRIM_TEXGEN_DEFAULT 0
PRIM_TEXGEN_PLANAR 1
PRIM_POINT_LIGHT ] 23 [ integer boolean, vector linear_color, float intensity, float radius, float falloff ] linear_color param accepts color in Linear space - use llsRGB2Linear to convert regular LSL color into Linear space.
PRIM_REFLECTION_PROBE ] 44 [ integer boolean, float ambiance, float clip_distance, integer flags ] Gets the prim's reflection probe parameters.

Caveat: This parameter will be supported in the upcoming GLTF Materials project. Currently it will only work in supported testing areas with a supported test viewer.

type Flags V Description Notes
PRIM_REFLECTION_PROBE_BOX/ja 1 Determines if the reflection probe is a box or a sphere. Unset by default (probe is a sphere)
PRIM_REFLECTION_PROBE_DYNAMIC/ja 2 Determines if avatars are included by the probe for imaging. Unset by default (probe does not image avatars). Imaging avatars in probes has a performance cost.
PRIM_GLOW, integer face ] 25 [ float intensity ]
PRIM_OMEGA ] 32 vector axis, float spinrate, float gain ] llTargetOmega
PRIM_NORMAL, integer face ] 37 string texture, vector repeats, vector offsets, float rotation_in_radians ]
PRIM_SPECULAR, integer face ] 36 string texture, vector repeats, vector offsets, float rotation_in_radians, vector color, integer glossiness integer environment ]
PRIM_ALPHA_MODE, integer face ] 38 integer alpha_mode, integer mask_cutoff ]
34 [] 複数のllGetLinkPrimitiveParamsを呼び出します。
PRIM_CAST_SHADOWS ] 24 [ integer boolean ] 廃止予定: プリミティブに影を割り付ける
PRIM_ALLOW_UNSIT ] 39 [ integer boolean ]
PRIM_SCRIPTED_SIT_ONLY ] 40 [ integer boolean ]
PRIM_SIT_TARGET ] 41 [ integer boolean , vector offset, rotation rot ] Sit target, llSitTarget. The position can be ZERO_VECTOR.
PRIM_PROJECTOR ] 42 [ string texture, float fov, float focus, float ambiance ] Light projector settings, the texture may be NULL_KEY. (Write only, for now. See here)
PRIM_GLTF_BASE_COLOR, integer face ] 48 string texture, vector repeats, vector offsets, float rotation_in_radians, vector color, float alpha, integer alpha_mode, float alpha_mask_cutoff, integer double_sided ] linear_color param accepts color in Linear space - use llsRGB2Linear/ja to convert regular LSL color into Linear space.

This parameter's arguments are GLTF overrides.
Caveat: This parameter will be supported in the upcoming GLTF Materials project. Currently it will only work in supported testing areas with a supported test viewer.

PRIM_GLTF_NORMAL, integer face ] 45 string texture, vector repeats, vector offsets, float rotation_in_radians ] This parameter's arguments are GLTF overrides.


Caveat: This parameter will be supported in the upcoming GLTF Materials project. Currently it will only work in supported testing areas with a supported test viewer.

PRIM_GLTF_METALLIC_ROUGHNESS, integer face ] 47 string texture, vector repeats, vector offsets, float rotation_in_radians, float metallic_factor, float roughness_factor ] This parameter's arguments are GLTF overrides.


Caveat: This parameter will be supported in the upcoming GLTF Materials project. Currently it will only work in supported testing areas with a supported test viewer.

PRIM_GLTF_EMISSIVE, integer face ] 46 string texture, vector repeats, vector offsets, float rotation_in_radians, vector emissive_tint ] emissive_tint param accepts color in Linear space - use llsRGB2Linear/ja to convert regular LSL color into Linear space.

This parameter's arguments are GLTF overrides.
Caveat: This parameter will be supported in the upcoming GLTF Materials project. Currently it will only work in supported testing areas with a supported test viewer.

警告

  • この関数は 0.2 秒間、スクリプトを停止します。
  • With render_material as with llGetRenderMaterial, NULL_KEY is returned when the owner does not have full permissions to the object and the material is not in the prim's inventory.
  • ストレージ媒体として フローティングテキスト の機能が使えると思わないでください。これは不完全ですし、安全なものでもありません。
    • フローティングテキストはサーバの更新時に変更になったことが過去にあり、その際に既に設定されている内容は消去されていました。将来も変更が発生する可能性があります。
    • 「不可視」[2] のフローティングテキストもクライアントに送信されます。
      • 不可視にしているテキストを表示することのできるクライアントを持っている人が見れてしまう可能性があります。
      • テキストが含まれている通信パケットが盗聴され、テキストが読まれる可能性があります。
  • top_size とクライアントの値は異なります。範囲は一致しておらず、変換が必要です。シンプルな計算式は、結果 = 1.0 - value です。詳細は top_size Explained をご覧ください。
  • position は常に リージョン座標 です。プリムが子プリムでも アタッチメント でも同様です。
  • rot は常に グローバルな回転値 です。プリムが子プリムでもアタッチメントのルートプリムでも同様です。
  • rot は常に グローバルな回転値 です。プリムが子プリムでもアタッチメントのルートプリムでも同様です。
  • PRIM_OMEGA/ja on nonphysical objects, and child prims of physical objects, is only a client side effect; the object or prim will collide as non-moving geometry.
  • PRIM_OMEGA/ja cannot be used on avatars sitting on the object. It will emit the error message "PRIM_OMEGA disallowed on agent".
  • If PRIM_OMEGA/ja does not appear to be working, make sure that that Develop > Network > Velocity Interpolate Objects is enabled on the viewer.
  • In the parameters returned by llGetPrimitiveParams([PRIM_OMEGA/ja]), the vector is normalized, and the spinrate is multiplied by the magnitude of the original vector.
  • repeats is not only used to get the number of repeats but the sign of the individual components indicate if "Flip" is set.
  • With texture as with llGetTexture, NULL_KEY is returned when the owner does not have full permissions to the object and the texture is not in the prim's inventory.
  • If face indicates a face that exists but does not contain a material, the PRIM_NORMAL return is [ NULL_KEY, <1,1,0>, ZERO_VECTOR, 0.0 ]
  • In the default texture mapping mode the texture repeats units are in texture repeats per face. In the planar texture mapping mode the texture repeats units are in texture repeats per half meter. This is in contrast to the in-world editing tool, in which the planar texture scaling units are repeats per meter.
  • repeats is not only used to get the number of repeats but the sign of the individual components indicate if "Flip" is set.
  • With texture as with llGetTexture, NULL_KEY is returned when the owner does not have full permissions to the object and the texture is not in the prim's inventory.
  • If face indicates a face that exists but does not contain a material, the PRIM_SPECULAR return is [ NULL_KEY, <1,1,0>, ZERO_VECTOR, 0.0 <1,1,1>, 51, 0]
  • In the default texture mapping mode the texture repeats units are in texture repeats per face. In the planar texture mapping mode the texture repeats units are in texture repeats per half meter. This is in contrast to the in-world editing tool, in which the planar texture scaling units are repeats per meter.
  • If PRIM_LINK_TARGET's link_target describes a seated avatar...
  • faceALL_SIDES であれば flag は全ての面に作用します。
  • face が存在しない面を指している場合、 flag の結果は nothing. です。
  • PRIM_TYPE のレガシーな値 1 はこの関数ではフラグとしてサポートされません。[4].

Important Issues

~ All Issues ~ Search JIRA for related Bugs
   We need PRIM_ALPHA_MODE_DEFAULT to revert alpha to old "if the texture has an alpha mask, use alpha. If not, don't" behavior.

サンプル

オブジェクトが部分の光源であるかテストして、もしそうであればパラメータを取得します。

string msg = "Object is ";
integer isLight;
vector colour;
float intensity;
float radius;
float falloff;
list params = llGetPrimitiveParams([PRIM_POINT_LIGHT]);
isLight = llList2Integer(params, 0);
if (isLight == FALSE)
    msg += "not a light source.";
else
{
    colour = llList2Vector(params, 1);
    intensity = llList2Float(params, 2);
    radius = llList2Float(params, 3);
    falloff = llList2Float(params, 4);
    msg += "a point light source.\nColour = "+(string)colour;
    msg += "\nIntensity = "+(string)intensity;
    msg += "\nRadius = "+(string)radius;
    msg += "\nFalloff = "+(string)falloff;
}
llSay(0, msg);

便利なスニペット

list GetPrimitiveParams(list input)
{//llSetPrimitiveParams の引数に渡せるリストを返します。
    list output;
    integer c = ~llGetListLength(input);
    while(0x80000000 & (c = - ~c))
    {
        list flag = (list)llList2Integer(input, c);
        if(~llListFindList([PRIM_BUMP_SHINY, PRIM_COLOR, PRIM_TEXTURE, 
                            PRIM_FULLBRIGHT, PRIM_TEXGEN, PRIM_GLOW], flag ))
        {
            integer side = llList2Integer(input, (c = - ~c));
            if(~side)//スタックから取得
                output += flag + side + llGetPrimitiveParams( flag + side );
            else
            {
                side = llGetNumberOfSides();
                do //面は逆順で返ってくるようにします。コードが早く実行されやすくするために。
                    output += flag + side + llGetPrimitiveParams( flag + (side = ~ -side) );
                while(side);
            }
        }
        else
            output += flag + llGetPrimitiveParams( flag );
    }
    return output;
}
//Contributed by Strife Onizuka

Anylyn Hax作のSetPrimitiveParams-Example はプリミティブのパラメータを読みやすくします。

注意点

リンク番号

オブジェクトを構成するそれぞれのプリムにはアドレスがあります。それがリンク番号です。オブジェクトの特定のプリムにアクセスするには、そのプリムのリンク番号を知らなければなりません。リンク番号はプリムに振られますが、オブジェクトに座っているアバターにも振られます。

  • オブジェクトが単一のプリムで構成されていて、アバターが座っていないとき、(ルート)プリムのリンク番号は 0 です。
  • しかし、オブジェクトが複数のプリムで構成されていたり、オブジェクトに座っているアバターがいたりすると、ルートプリムのリンク番号は 1 となります。

アバターがオブジェクトに座ると、リンクセットの末尾に追加され、いちばん大きなリンク番号が振られることになります。さらに、アバターがオブジェクトに座っている場合、アバターを立たせないと、プリムのリンク・リンク解除ができません。

プリムやアバターの数え方

オブジェクトのプリムや、プリムに座っているアバターの数を調べるのに、2つの関数があります。

  • llGetNumberOfPrims() - プリムと座っているアバターの数を返します。
  • llGetObjectPrimCount(llGetKey()) - オブジェクトのプリムの数だけを返しますが、アタッチメントとなっている場合は 0 を返します。
integer GetPrimCount() { //常にプリムの数だけを返します。
    if(llGetAttached())//装着されているか?
        return llGetNumberOfPrims();//アバターとプリムの数を返しますが、アタッチメントの上には座れないのでこれでいいです。
    return llGetObjectPrimCount(llGetKey());//プリムの数だけを返しますが、アタッチメントの場合ここは通りません。
}

関連項目

関数

•  llGetLinkNumber スクリプトが入っているプリムのリンク番号を取得します。
•  llSetPrimitiveParams 複数のプリミティブのパラメータを設定します
•  llSetLinkPrimitiveParams
•  llGetLinkPrimitiveParams
•  llGetObjectDetails

記事

•  各種制限 SL の制限と制約
•  LSL での色
•  透明度
•  LSL での色
•  透明度

特記事項

PRIM_TYPE の top_size とクライアントのテーパー変換
範囲 尖る 尖らない 底が尖る
クライアント [-1, 1] 1.0 0.0 -1.0
PRIM_TYPE [0, 2] 0.0 1.0 2.0
LEGACY [0, 1] 0.0 1.0 なし
1.11 以前 [0, 1] 0.0 1.0 なし

top_size について解説

もともとの PRIM_TYPE のインターフェースが廃止されたとき (PRIM_TYPE_LEGACY, SL 1.5)、新しい PRIM_TYPE インターフェースはプリムの底を尖らせる機能がまだサポートされておらず、SL 1.11 (2年後) になってようやく導入されました。これが導入され新しい PRIM_TYPE が廃止されたときに、top_size の範囲が拡張されました。 それまでの間、クライアントの中で属性とその定義値が再定義されていました。この再定義と範囲の拡張により、異なる値で同じことをする2つのインターフェースが存在することになりました。それまでの間 PRIM_TYPE_LEGACY のインターフェースは更新されず、プリムの底を尖らせるのはサポートされないままでした。その結果、3つのインターフェースがそれぞれ異なる範囲をもつことになり、いじわるな警告をつけるはめになってしまいました。

All Issues

~ Search JIRA for related Issues
   We need PRIM_ALPHA_MODE_DEFAULT to revert alpha to old "if the texture has an alpha mask, use alpha. If not, don't" behavior.

脚注

  1. ^ When LL deprecated this flag they stripped it of it's name, however they did not remove the functionality. To aid in documenting the functionality, the value was given a new name in the documentation only. That is why PRIM_TYPE_LEGACY is not recognized by the compiler.
  2. ^ フローティングテキストの alpha を 1.0 に設定すると「不可視」になります。
  3. ^ 記事中の範囲は、 実数空間 に記載されているものです。
  4. ^ llGetPrimitiveParams は PRIM_TYPE_LEGACY が廃止された後に導入されました。

Signature

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