Difference between revisions of "LlGetCameraAspect"

From Second Life Wiki
Jump to navigation Jump to search
m (Fix bad English.)
m (Removed a stray line from example script that confused someone trying to use this function)
 
(2 intermediate revisions by 2 users not shown)
Line 11: Line 11:
|caveats=Returns zero when permissions have not been granted.
|caveats=Returns zero when permissions have not been granted.
|examples=
|examples=
<source lang="lsl2">// say the camera aspect ratio and field of view (FOV)
<syntaxhighlight lang="lsl2">// say the camera aspect ratio and field of view (FOV)
integer has_perms = FALSE;
integer has_perms = FALSE;
default
default
Line 18: Line 18:
     {
     {
         llResetScript();
         llResetScript();
        has_perms = FALSE;
     }
     }
     state_entry()
     state_entry()
Line 28: Line 27:
         has_perms = (permission == PERMISSION_TRACK_CAMERA);
         has_perms = (permission == PERMISSION_TRACK_CAMERA);
     }
     }
     touch_start()
     touch_start(integer num_touches)
     {
     {
         if (has_perms)
         if (has_perms)
Line 41: Line 40:
         }
         }
     }
     }
}</source>
}</syntaxhighlight>
|helpers
|helpers
|also_functions=
|also_functions=

Latest revision as of 18:12, 23 March 2024

Summary

Function: float llGetCameraAspect( );
0.0 Forced Delay
10.0 Energy

Returns a float value for the current camera's aspect ratio (e.g. width/height) of the agent for which the task has permissions.

To run this function the script must request the PERMISSION_TRACK_CAMERA permission with llRequestPermissions.

Caveats

Permissions
Returns zero when permissions have not been granted.

Examples

// say the camera aspect ratio and field of view (FOV)
integer has_perms = FALSE;
default
{
    on_rez(integer a)
    {
        llResetScript();
    }
    state_entry()
    {
        llRequestPermissions(llGetOwner(), PERMISSION_TRACK_CAMERA);
    }
    run_time_permissions(integer permission)
    {
        has_perms = (permission == PERMISSION_TRACK_CAMERA);
    }
    touch_start(integer num_touches)
    {
        if (has_perms)
        {
            float aspect = llGetCameraAspect();
            float fov = llGetCameraFOV();
            llOwnerSay("aspect = " + (string)aspect + "  FOV = " + (string)fov);
        }
        else
        {
            llRequestPermissions(llGetOwner(), PERMISSION_TRACK_CAMERA);
        }
    }
}

See Also

Events

•  run_time_permissions Permission receiving event

Functions

•  llGetPermissions Get the permissions granted
•  llGetPermissionsKey Get the agent who granted permissions
•  llRequestPermissions Request permissions
•  llGetCameraFOV
•  llGetCameraPos
•  llGetCameraRot
•  llSetCameraParams
•  llSetCameraAtOffset
•  llSetCameraEyeOffset

Articles

•  Script permissions

Deep Notes

Signature

function float llGetCameraAspect();