LlSetPrimitiveParams

De DigiWiki.

// To color all sides of a prim black, except side 3 white
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <0.0,0.0,0.0>, 1.0]);
llSetPrimitiveParams([PRIM_COLOR, 3, <1.0,1.0,1.0>, 1.0]);
 
// To render on side 3 
// the picture with the UUID... 
// and the repeats per face as vector, 
// the texture offset as second vector, 
// and the texture rotation as float
llSetPrimitiveParams([PRIM_TEXTURE, 3, "4d304955-2b01-c6c6-f545-c1ae1e618288",
                          <1.0,1.0,0.0>, <0.0,0.0,0.0>, 0.0]);
 
// To set the prim "Full Bright" on sides 3
llSetPrimitiveParams([PRIM_FULLBRIGHT,3,TRUE]);
 
// And to make it all in one breath,
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <0.0,0.0,0.0>, 1.0,
                      PRIM_COLOR, 3, <1.0,1.0,1.0>, 1.0,
                      PRIM_TEXTURE, 3, "4d304955-2b01-c6c6-f545-c1ae1e618288",
                          <1.0,1.0,0.0>, <0.0,0.0,0.0>, 0.0,
                      PRIM_FULLBRIGHT, 3, TRUE]);
 
//And If you want to place it above you bed, to make you sleep well, and the coords
// of that place are for example <x, y, z>
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <0.0,0.0,0.0>, 1.0, 
                      PRIM_COLOR, 3, <1.0,1.0,1.0>, 1.0,
                      PRIM_TEXTURE, 3, "4d304955-2b01-c6c6-f545-c1ae1e618288",
                          <1.0,1.0,0.0>, <0.0,0.0,0.0>,0.0,
                      PRIM_FULLBRIGHT, 3, TRUE, 
                      PRIM_POSITION, <x, y, z>]);
 
//You can set the texture of several sides at once, with no time penalty,
//just by repeating the param for that:
llSetPrimitiveParams([
        PRIM_TEXTURE, 3, "4d304955-2b01-c6c6-f545-c1ae1e618288",
            <1.0,1.0,0.0>, <0.0,0.0,0.0>, 0.0,
        PRIM_TEXTURE, 4, "4d304955-2b01-c6c6-f545-c1ae1e618288",
            <1.0,1.0,0.0>, <0.0,0.0,0.0>, 0.0
    ]);

Top-size (taper)

default
{
    state_entry()
    {
        vector XYZ = llGetScale();
        float X = XYZ.x;
        float Y = XYZ.y;     
        llSetPrimitiveParams([PRIM_SIZE, <X,Y,0.1>, // keep the prim thin
                              PRIM_TYPE, PRIM_TYPE_BOX, 0, <0.0,1.0,0.0>, 0.0, ZERO_VECTOR, 
                              <1.0 - (0.4 / X), 1.0 - (0.4 / Y), 0.0>,
                              ZERO_VECTOR]); //We use the equation "answer = 1 - desired_taper"
        //The proportions of the top-size (taper) will be maintained (as close as possible)
        // whenever the prim is resized. The proportion above will produce a reasonably
        // pleasing picture frame kinda thing.
    }
    changed(integer change)
    {
        if(change & CHANGED_SCALE)
        {
            llResetScript();
        }
    }
}

Useful Snippets

 //-- PRIM_ROTATION workaround for child prims (works in unattached objects only)
llSetPrimitiveParams( [PRIM_ROT_LOCAL, rot * llGetRootRotation()] )
 
 //-- PRIM_ROTATION workaround for child prims (works in linked objects only)
llSetPrimitiveParams( [PRIM_ROT_LOCAL, rot * llList2Rot( llGetLinkPrimitiveParams( LINK_ROOT, [PRIM_ROT_LOCAL] ), 0 )] )
 
 //-- PRIM_ROTATION workaround for child prims (works in all scenarios)
llSetPrimitiveParams( [PRIM_ROT_LOCAL, rot * llList2Rot( llGetLinkPrimitiveParams( !!llGetLinkNumber(), [PRIM_ROT_LOCAL] ), 0 )] )

Notes

Link Numbers

Each prim that makes up an object has an address, a link number. To access a specific prim in the object, the prim's link number must be known. In addition to prims having link numbers, avatars seated upon the object do as well.

If an object consists of only one prim, and there are no avatars seated upon it, the (root) prim's link number is zero. However, if the object is made up of multiple prims or there is an avatar seated upon the object, the root prim's link number is one. When an avatar sits on an object, it is added to the end of the link set and will have the largest link number. In addition to this, while an avatar is seated upon an object, the object is unable to link or unlink prims without unseating the avatars first.

Counting Prims & Avatars

There are two functions of interest when trying to find the number of prims and avatars on an object.

llGetNumberOfPrims() - Returns the number of prims and seated avatars. llGetObjectPrimCount(llGetKey()) - Returns only the number of prims in the object but will return zero for attachments.

integer GetPrimCount() { //always returns only the number of prims
    if(llGetAttached())//Is it attached?
        return llGetNumberOfPrims();//returns avatars and prims but attachments can't be sat on.
    return llGetObjectPrimCount(llGetKey());//returns only prims but won't work on attachments.
}

The old PRIM_TYPE interface (labeled PRIM_TYPE_LEGACY) while technically retired can still be used.

Outils personnels
  • Cette page a été consultée 1 690 fois.
donate
Google Ads