Difference between revisions of "LlGetAgentSize"

From Second Life Wiki
Jump to navigation Jump to search
m (less annoying)
m (llGetAgentSize returned z is 0.2 less than llGetBoundingBox when standing. or .005 more than AgentSize.z+.195, it was put as 05 that made no sense.)
Line 9: Line 9:
|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-development|indra/llcommon/indra_constants.h|rev=0ca239e469b3|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-development|indra/llcommon/indra_constants.h|rev=0ca239e469b3|line=92|text=const F32 DEFAULT_AGENT_WIDTH = 0.60f;}}|2=const F32 DEFAULT_AGENT_WIDTH = 0.60f;}}, z is smaller than the rendered height by a fixed amount. Add .17 to z for crown to sole standing height. {{Footnote|Some applications add a higher value like .195 for crown to floor, because standing avatars are rendered slightly above the floor or ground in servers before the mesh-prep series.}}{{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-development|indra/newview/llvoavatar.cpp|rev=0ca239e469b3|line=2048|text=LLVOAvatar::computeBodySize()}}. See {{SourceLink/bitbucket|viewer-development|indra/llcommon/indra_constants.h|rev=0ca239e469b3|line=86|text=indra/llcommon/indra_constants.h}} for defaults and limits.}}
|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-development|indra/llcommon/indra_constants.h|rev=0ca239e469b3|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-development|indra/llcommon/indra_constants.h|rev=0ca239e469b3|line=92|text=const F32 DEFAULT_AGENT_WIDTH = 0.60f;}}|2=const F32 DEFAULT_AGENT_WIDTH = 0.60f;}}, z is smaller than the rendered height by a fixed amount. Add .17 to z for crown to sole standing height. {{Footnote|Some applications add a higher value like .195 for crown to floor, because standing avatars are rendered slightly above the floor or ground in servers before the mesh-prep series.}}{{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-development|indra/newview/llvoavatar.cpp|rev=0ca239e469b3|line=2048|text=LLVOAvatar::computeBodySize()}}. See {{SourceLink/bitbucket|viewer-development|indra/llcommon/indra_constants.h|rev=0ca239e469b3|line=86|text=indra/llcommon/indra_constants.h}} for defaults and limits.}}
*Some third party viewers have a "z modifier" setting that is intended to change animation heights. The modifier is also reflected in llGetAgentSize and defeats scripted height detection.
*Some third party viewers have a "z modifier" setting that is intended to change animation heights. The modifier is also reflected in llGetAgentSize and defeats scripted height detection.
*The return value is the same width and depth but 0.05 meters shorter than the avatar's reported [[llGetBoundingBox|bounding box]] when standing. An avatar's bounding box changes when an avatar sits, while llGetAgentSize is constant for as long as the shape does not change.
*The return value is the same width and depth but 0.2 meters shorter than the avatar's reported [[llGetBoundingBox|bounding box]] when standing. An avatar's bounding box changes when an avatar sits, while llGetAgentSize is constant for as long as the shape does not change.
|constants0
|constants0
|examples=
|examples=

Revision as of 19:08, 15 December 2013

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 smaller than the rendered height by a fixed amount. Add .17 to z for crown to sole standing height. [3][4]
  • Some third party viewers have a "z modifier" setting that is intended to change animation heights. The modifier is also reflected in llGetAgentSize and defeats scripted height detection.
  • The return value is the same width and depth but 0.2 meters shorter than the avatar's reported bounding box when standing. 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

<lsl>//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.z += 0.5 + agent.z / 2;//"pos" needs to be adjusted so it appears above the owner.
       if(agent)//makes sure it found the owner, a zero vector evaluates as false
           llSetPos(pos);
   }
   touch_start(integer num) {
       llResetScript();
   }
}</lsl>

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 <lsl>if(llGetAgentSize(uuid)) {

   //uuid is an avatar in the region

} else {

   //uuid is not an avatar in the region

}</lsl>

  • 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:

<lsl>vector agentSize = llGetAgentSize(uuid); if (agentSize.z == 1.9) {

   // avatar is probably Ruthed

}</lsl>

See Also

Deep Notes

Search JIRA for related Issues

Footnotes

  1. ^ Template:SourceLink/bitbucket
  2. ^ Template:SourceLink/bitbucket
  3. ^ Some applications add a higher value like .195 for crown to floor, because standing avatars are rendered slightly above the floor or ground in servers before the mesh-prep series.
  4. ^ llGetAgentSize returns the same value as Template:SourceLink/bitbucket. See Template:SourceLink/bitbucket for defaults and limits.

Signature

function vector llGetAgentSize( key avatar );