Difference between revisions of "LlGetAgentSize"

From Second Life Wiki
Jump to navigation Jump to search
(It's a great example but at this point in time it's antiquated. Much easier to use llGetObjectDetails, probably should use it instead of llGetAgentSize too but that would spoil all the fun.)
m
(44 intermediate revisions by 18 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|inject-2={{LSL Function/avatar|avatar|sim=*}}
|func_id=218|func_sleep=0.0|func_energy=10.0
|func_id=218|func_sleep=0.0|func_energy=10.0
|func=llGetAgentSize|return_type=vector|p1_type=key|p1_name=id
|func=llGetAgentSize|return_type=vector|p1_type=key|p1_name=avatar
|func_footnote=The agent '''id''' must be in the same region as the requesting object, {{LSL Const|ZERO_VECTOR|vector|{{LSL VR|0.0|0.0|0.0}}}} is returned if not.
|func_footnote={{LSL Const|ZERO_VECTOR|vector|{{LSL VR|0.0|0.0|0.0}}}} is returned if {{LSLP|avatar}} is not in the region or if it is not an avatar.
|func_desc
|func_desc
|return_text=that is the size of the requested avatar by '''id'''.
|return_text=that is an estimated size of the requested {{LSLP|avatar}}.
|spec
|spec
|caveats
|caveats=* The returned vector is an estimate calculated from the avatar's current shape including shoes. x is a constant 0.45{{Footnote|1={{SourceLink/bitbucket|viewer-release|indra/llcommon/indra_constants.h|rev=bc61d5ad9162bd461c17d77728090fe5d8ead59e|line=88|text=const F32 DEFAULT_AGENT_DEPTH = 0.45f;}}|2=const F32 DEFAULT_AGENT_DEPTH = 0.45f;}}, y is a constant 0.60{{Footnote|1={{SourceLink/bitbucket|viewer-release|indra/llcommon/indra_constants.h|rev=bc61d5ad9162bd461c17d77728090fe5d8ead59e|line=92|text=const F32 DEFAULT_AGENT_WIDTH = 0.60f;}}|2=const F32 DEFAULT_AGENT_WIDTH = 0.60f;}}, z is the approximate total height of all avatar's bones, with an arbitrary amount added or subtracted based on the current shape's "Hover" setting. Reported height is constrained to the range 1.1 to 2.45 meters, and does not include animation or mesh bone offsets. {{Footnote|2=llGetAgentSize returns the same value as LLVOAvatar::computeBodySize(). See llcommon/indra_constants.h for defaults and limits.|1=llGetAgentSize returns the same value as {{SourceLink/bitbucket|viewer-release|indra/llappearance/llavatarappearance.cpp|rev=bc61d5ad9162bd461c17d77728090fe5d8ead59e|line=433|text=LLVOAvatar::computeBodySize()}}. See {{SourceLink/bitbucket|viewer-release|indra/llcommon/indra_constants.h|rev=bc61d5ad9162bd461c17d77728090fe5d8ead59e|line=86|text=indra/llcommon/indra_constants.h}} for defaults and limits.}}
|constants
** Due to the shape Hover setting, and mesh and animation offsets, it is not possible to use this function to determine the rendered height of an avatar with any degree of confidence.
*As of Second Life Server 13.11.19.284082, the return value is the avatar's reported [[llGetBoundingBox|bounding box]] - <0.1, 0.1, 0.2> when standing. (Avatar bounding boxes have historically been redefined with major physics upgrades.) An avatar's bounding box changes when an avatar sits, while [[llGetAgentSize]] is constant for as long as the shape does not change.
|constants0
|examples=
|examples=
<pre>
<source lang="lsl2">
//A simple script that makes a box hover above the owner's head.
//A simple script that makes a box hover above the owner's head.
default {
default
     state_entry(integer i) {
{
         key owner = llGetOwner();
     state_entry()
         vector pos = llList2Vector(llGetObjectDetails(owner, [OBJECT_POSITION]),0);
    {
         key   owner = llGetOwner();
         vector pos   = llList2Vector(llGetObjectDetails(owner, [OBJECT_POS]), 0);
         vector agent = llGetAgentSize(owner);
         vector agent = llGetAgentSize(owner);
    //  "pos" needs to be adjusted so it appears above the owner.
         pos.z += 0.5 + agent.z / 2;
         pos.z += 0.5 + agent.z / 2;
        llSetPos(pos);
 
     }
     //  makes sure it found the owner, a zero vector evaluates as false
    touch_start(integer num)
        if(agent)
    {
            llSetPos(pos);
        llResetScript();
     }
     }
}
</pre>


Corrected Code, Comments welcomed.
--[[User:Mr Lovenkraft|Mr Lovenkraft]] 05:49, 12 November 2007 (PST)
<pre>
//This code was edited by Mr Lovenkraft for errors, comments are below.
vector size;
default
{
    on_rez(integer i)
    {
        llSensor("", llGetOwner(), AGENT, 96, PI); //I reversed the "96" and the "PI" because-
    }                                              //PI defines the Arc. and 96 Defines the meters.
    sensor(integer num)                            //Not the other way around.
    {
        vector where = llDetectedPos(0);
        vector agent = llGetAgentSize(llGetOwner())/2;
        size += agent + <0,0,.5>; //"size" Has to be defined in some way, I made it a Global
        llSetPos(where + size); //In order for "size" to effect this code it must be added in
    }                          //some way, which is why it says "llSetPos(where + size);"
     touch_start(integer num)
     touch_start(integer num)
     {
     {
Line 50: Line 35:
     }
     }
}
}
</pre>
</source>
|helpers
|helpers
|also_functions=
|also_functions=
{{LSL DefineRow||[[llGetObjectDetails]]|}}
{{LSL DefineRow||[[llGetBoundingBox]]|}}
{{LSL DefineRow||[[llGetBoundingBox]]|}}
{{LSL DefineRow||[[llGetAgentInfo]]|}}
{{LSL DefineRow||[[llGetAgentInfo]]|}}
Line 58: Line 44:
|also_events
|also_events
|also_tests
|also_tests
|also_articles
|also_articles=
|notes=This is a good way to test if an av is in the same region.
{{LSL DefineRow||[[Avatar body size]]|}}
|permission
|notes=
|negative_index
* This function is a good way to quickly test...
** if an avatar is in the same region.
** if a UUID known to be in the region is an avatar.
 
To use this function to test either case use as follows
<source lang="lsl2">if(llGetAgentSize(uuid)) {
    //uuid is an avatar in the region
} else {
    //uuid is not an avatar in the region
}</source>
 
* <code>DEFAULT_AGENT_HEIGHT</code> in {{SourceLink/bitbucket|viewer-development|indra/llcommon/indra_constants.h|rev=0ca239e469b3|line=96|text=indra/llcommon/indra_constants.h}} is 1.9. This will be the z value if an avatar's shape has [[Ruth|not loaded yet]]. It is possible but extremely rare to see a fully loaded avatar with this exact size, so:
<source lang="lsl2">vector agentSize = llGetAgentSize(uuid);
if (agentSize.z == 1.9) {
    // avatar is probably Ruthed
}</source>
|cat1
|cat1
|cat2=Avatar
|cat2=Avatar
|haiku={{Haiku|For height (minus head)|Or to tell if you're not there.|Do not hope for "size".}}
{{Haiku|I just wanted size.|It gave me something useless.|How hard can it be?}}
|cat3
|cat3
|cat4
|cat4
}}
}}

Revision as of 02:56, 15 September 2016

Summary

Function: vector llGetAgentSize( key avatar );

Returns a vector that is an estimated size of the requested avatar.

• key avatar avatar UUID that is in the same region

ZERO_VECTOR is returned if avatar is not in the region or if it is not an avatar.

Caveats

  • The returned vector is an estimate calculated from the avatar's current shape including shoes. x is a constant 0.45[1], y is a constant 0.60[2], z is the approximate total height of all avatar's bones, with an arbitrary amount added or subtracted based on the current shape's "Hover" setting. Reported height is constrained to the range 1.1 to 2.45 meters, and does not include animation or mesh bone offsets. [3]
    • Due to the shape Hover setting, and mesh and animation offsets, it is not possible to use this function to determine the rendered height of an avatar with any degree of confidence.
  • As of Second Life Server 13.11.19.284082, the return value is the avatar's reported bounding box - <0.1, 0.1, 0.2> when standing. (Avatar bounding boxes have historically been redefined with major physics upgrades.) An avatar's bounding box changes when an avatar sits, while llGetAgentSize is constant for as long as the shape does not change.
All Issues ~ Search JIRA for related Bugs

Examples

//A simple script that makes a box hover above the owner's head.
default
{
    state_entry()
    {
        key    owner = llGetOwner();
        vector pos   = llList2Vector(llGetObjectDetails(owner, [OBJECT_POS]), 0);
        vector agent = llGetAgentSize(owner);

    //  "pos" needs to be adjusted so it appears above the owner.
        pos.z += 0.5 + agent.z / 2;

    //  makes sure it found the owner, a zero vector evaluates as false
        if(agent)
            llSetPos(pos);
    }

    touch_start(integer num)
    {
        llResetScript();
    }
}

Notes

  • This function is a good way to quickly test...
    • if an avatar is in the same region.
    • if a UUID known to be in the region is an avatar.

To use this function to test either case use as follows

if(llGetAgentSize(uuid)) {
    //uuid is an avatar in the region
} else {
    //uuid is not an avatar in the region
}
  • DEFAULT_AGENT_HEIGHT in Template:SourceLink/bitbucket is 1.9. This will be the z value if an avatar's shape has not loaded yet. It is possible but extremely rare to see a fully loaded avatar with this exact size, so:
vector agentSize = llGetAgentSize(uuid);
if (agentSize.z == 1.9) {
    // avatar is probably Ruthed
}

See Also

Functions

•  llGetObjectDetails
•  llGetBoundingBox
•  llGetAgentInfo
•  llRequestAgentData

Articles

•  Avatar body size

Deep Notes

Search JIRA for related Issues

Footnotes

Signature

function vector llGetAgentSize( key avatar );

Haiku

For height (minus head)
Or to tell if you're not there.
Do not hope for "size".

I just wanted size.
It gave me something useless.
How hard can it be?