LlGetPrimitiveParams

De DigiWiki.

To test whether an object is a point light source, and if so get its parameters:

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

Useful Snippets

// Contributed by Strife Onizuka
 
list GetPrimitiveParams(list input)
{ // Returns a list that can be fed to 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)//pop the stack
                output += flag + side + llGetPrimitiveParams( flag + side );
            else
            {
                side = llGetNumberOfSides();
                do //we return the sides in reverse order, easier to code; runs faster.
                    output += flag + side + llGetPrimitiveParams( flag + (side = ~ -side) );
                while(side);
            }
        }
        else
            output += flag + llGetPrimitiveParams( flag );
    }
    return output;
}

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.

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