Difference between revisions of "LlGetCameraAspect"

From Second Life Wiki
Jump to navigation Jump to search
(Add llGetCameraAspect() which is in Gingerbread update scheduled for late Jan or early Feb 2024.)
 
 
(8 intermediate revisions by 5 users not shown)
Line 7: Line 7:
|return_type=float
|return_type=float
|func_desc
|func_desc
|return_text=value for the current camera's aspect ratio (e.g. width/height) for which the agent the task has permissions.
|return_text=value for the current camera's aspect ratio (e.g. width/height) of the agent for which the task has permissions.
|spec
|spec
|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>
 
<syntaxhighlight lang="lsl2">// Scale an object to fit the aspect ratio of the viewer.
fit_to_screen()
{
    // The X axis from the left to  the right edge of the screen is 0.0 to width value.
    // The Y axis is always 1.
    float x = llGetCameraAspect();
    float y = 1;
    llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_SIZE, <0, x, y>]);
}
</syntaxhighlight>
 
|helpers
|helpers
|also_functions=
|also_functions=
Line 50: Line 61:
{{LSL DefineRow||{{LSLG|llSetCameraAtOffset}}|}}
{{LSL DefineRow||{{LSLG|llSetCameraAtOffset}}|}}
{{LSL DefineRow||{{LSLG|llSetCameraEyeOffset}}|}}
{{LSL DefineRow||{{LSLG|llSetCameraEyeOffset}}|}}
|notes
|notes=
The reported aspect ratio is based on values provided by the viewer to the simulator. This may cause visual oddities if there's a discrepancy between the viewer's reported camera and what the viewer actually displays to the user. For example: entering mouselook may cause portions of the viewer interface to disappear, which alters the amount of space available to the HUD, which can lead to misaligned positioning or slightly-off aspect ratio. (This is currently considered a viewer-bug.)
|cat1=Camera
|cat1=Camera
|cat2
|cat2

Latest revision as of 05:40, 28 December 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);
        }
    }
}
// Scale an object to fit the aspect ratio of the viewer.
fit_to_screen()
{
    // The X axis from the left to  the right edge of the screen is 0.0 to width value.
    // The Y axis is always 1.
    float x = llGetCameraAspect();
    float y = 1;
    llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_SIZE, <0, x, y>]);
}

Notes

The reported aspect ratio is based on values provided by the viewer to the simulator. This may cause visual oddities if there's a discrepancy between the viewer's reported camera and what the viewer actually displays to the user. For example: entering mouselook may cause portions of the viewer interface to disappear, which alters the amount of space available to the HUD, which can lead to misaligned positioning or slightly-off aspect ratio. (This is currently considered a viewer-bug.)

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