vector llWorldPosToHUD(vector world_pos// World-frame position vector to project into HUD space.
);- Returns
vector- Energy
- 10
- Permission
PERMISSION_TRACK_CAMERA
Returns the local position vector that places the center of the HUD object directly over the world coordinate world_pos as viewed by the current camera. Requires the PERMISSION_TRACK_CAMERA runtime permission.
Returns a vector position in HUD frame that would place the center of the HUD object directly over world_pos as viewed by the current camera.
vector result = llWorldPosToHUD(ZERO_VECTOR);Caveats
Section titled “Caveats”Only works for HUD attachments. The vector’s X component will be 1.0 when world_pos is in front of camera and -1.0 when it is behind. Returns zero vector when no permissions have been granted.
Examples
Section titled “Examples”Example 1
// llWorldPosToHUD() example//// Put this script on a HUD attachment (which attachment point doesn't matter).50 collapsed lines
// Touch to toggle 'tracking' on/off.// Put an object at world_pos as reference for where the HUD should move when 'tracking'.
vector not_tracking_color = <1.0, 1.0, 1.0>; // whitevector tracking_front_color = <0.5, 0.0, 0.5>; // magentavector tracking_behind_color = <0.0, 0.5, 0.5>; // cyan
vector world_pos = <32,32,24>; // change this position as necessary, put a ref object hereinteger tracking = FALSE;
default{ state_entry() { llOwnerSay("Touch HUD to toggle tracking"); llRequestPermissions(llGetOwner(), PERMISSION_TRACK_CAMERA); llSetAlpha(0.5, ALL_SIDES); // make object semi transparent llSetColor(not_tracking_color, ALL_SIDES); }
touch_start(integer total_number) { llRequestPermissions(llGetOwner(), PERMISSION_TRACK_CAMERA); tracking = !tracking; if (tracking) { llSetTimerEvent(0.01); llSetColor(tracking_front_color, ALL_SIDES); } else { llSetTimerEvent(0.0); llSetPos(<0,0,0>); llSetColor(not_tracking_color, ALL_SIDES); } }
attach(key id) { if (id != NULL_KEY) { llSetPos(<0,0,0>); tracking = FALSE; llSetTimerEvent(0.0); } }
timer() { integer attachment_point = llGetAttached(); if (attachment_point >= ATTACH_HUD_CENTER_2 && attachment_point <= ATTACH_HUD_BOTTOM_RIGHT) { vector hud_pos = llWorldPosToHUD(world_pos); if (hud_pos.x > 0.0) {13 collapsed lines
// world-pos is in front of camera llSetColor(tracking_front_color, ALL_SIDES); } else { // world_pos is behind camera llSetColor(tracking_behind_color, ALL_SIDES); } // update HUD position llSetPos(hud_pos); } }}See also
Section titled “See also”Functions
Section titled “Functions”Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.