Difference between revisions of "LlSetCameraParams"

From Second Life Wiki
Jump to navigation Jump to search
m (Replaced old <LSL> block with <source lang="lsl2">)
(21 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|inject-2={{Issues/SCR-325}}{{Issues/SCR-326}}{{Issues/SCR-327}}{{LSL_Function/permission|PERMISSION_CONTROL_CAMERA}}
|func_id=313|func_sleep=0.0|func_energy=10.0
|func_id=313|func_sleep=0.0|func_energy=10.0
|func=llSetCameraParams
|func=llSetCameraParams
|p1_type=list|p1_name=rules|p1_desc=Format is [ rule1, data1, rule2, data2 . . . rulen, datan ]
|p1_type=list|p1_subtype=instructions|p1_name=rules|p1_desc=Format is [ rule1, data1, rule2, data2 . . . rulen, datan ]
|func_footnote
|func_footnote
|func_desc=Sets multiple camera parameters at once.
|func_desc=Sets multiple camera parameters at once.
|return_text
|return_text
|spec
|spec
|caveats
|caveats=*Camera control currently (server 1.38) only supported for attachments and objects on which you are sitting. An attempt otherwise will result in an error being shouted on [[DEBUG_CHANNEL]].
|constants={{{!}} {{Prettytable}}
*Scripted camera parameters will not set for the agent if the last controls they used were their camera controls. Manual camera control will override set parameters too.
{{!}}-  
|examples=
 
You can either set the camera in region relative coordinates or you can make the camera follow your avatar.
 
'''Region relative coordinates, an example:'''
 
<source lang="lsl2">lookAtMe( integer perms )
{
    if ( perms & PERMISSION_CONTROL_CAMERA )
    {
        vector camPos = llGetPos() + (relCamP * llGetRot() * turnOnChair) ;
        vector camFocus = llGetPos() ;
        llClearCameraParams(); // reset camera to default
        llSetCameraParams([
            CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
            CAMERA_FOCUS, camFocus, // region relative position
            CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE)
            CAMERA_POSITION, camPos, // region relative position
            CAMERA_POSITION_LOCKED, TRUE // (TRUE or FALSE)
        ]);
    }
}</source>
Note that Focus and Position are both locked. This first example makes the camera look at ''camFocus'' from ''camPos''.
 
'''Camera follow avatar, an example:'''
 
<source lang="lsl2">lookAtMe( integer perms )
{
    if ( perms & PERMISSION_CONTROL_CAMERA )
    {
        llClearCameraParams(); // reset camera to default
        llSetCameraParams([
            CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
            CAMERA_BEHINDNESS_ANGLE, 30.0, // (0 to 180) degrees
            CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
            CAMERA_DISTANCE, 10.0, // ( 0.5 to 10) meters
          //CAMERA_FOCUS, <0,0,5>, // region relative position
            CAMERA_FOCUS_LAG, 0.05 , // (0 to 3) seconds
            CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
            CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
            CAMERA_PITCH, 10.0, // (-45 to 80) degrees
          //CAMERA_POSITION, <0,0,0>, // region relative position
            CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
            CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
            CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
            CAMERA_FOCUS_OFFSET, <2.0, 0.0, 0.0> // <-10,-10,-10> to <10,10,10> meters
        ]);
    }
}
</source>
Note that in this second example Focus and Position are NOT locked and not even set. This is appropriate for making the camera follow a pilot on a vehicle.
|helpers
|also_functions=
{{LSL DefineRow||[[llClearCameraParams]]}}
{{LSL DefineRow||[[llGetCameraPos]]}}
{{LSL DefineRow||[[llGetCameraRot]]}}
|also_events
|also_tests=
{{LSL DefineRow||[[llSetCameraParams Test]]}}
|also_articles=
{{LSL DefineRow||[[FollowCam]]}}
|notes
|cat1=Camera
|cat2
|cat3
|cat4
|constants={{{!}} class="sortable" {{Prettytable|style=margin-top:0;}}
{{!}}- {{Hl2}}
! Rule
! Rule
! Value
!
! Parameter
! Parameter
! Default
!class="unsortable"{{!}} Default
! Value Range
!class="unsortable"{{!}} Value Range
! Description
!class="unsortable"{{!}} Description
{{!}}-  
{{!}}-  
{{!}} {{LSLG|CAMERA_ACTIVE}}
{{!}} {{LSL Const|CAMERA_ACTIVE|integer|12}}
{{!}} 12
{{!}} {{#var:cvalue}}&nbsp;&nbsp;
{{!}} {{LSLG|integer}} isActive
{{!}} [[integer]]&nbsp;isActive
{{!}} {{LSLG|FALSE}}
{{!}} {{LSL Const|FALSE|integer|0}}
{{!}} {{LSLG|TRUE}} or {{LSLG|FALSE}}
{{!}} {{LSL Const|TRUE|integer|1}} or {{LSL Const|FALSE|integer|0}}
{{!}} Turns on or off {{LSLG|script|scripted}} control of the camera.
{{!}} Turns on or off [[script|scripted]] control of the camera.
{{!}}-  
{{!}}-  
{{!}} {{LSLG|CAMERA_BEHINDNESS_ANGLE}}
{{!}} {{LSL Const|CAMERA_BEHINDNESS_ANGLE|integer|8}}
{{!}} 8
{{!}} {{#var:cvalue}}
{{!}} {{LSLG|float}} degrees
{{!}} [[float]]&nbsp;degrees
{{!}} 10.0
{{!}} 10.0
{{!}} 0 to 180
{{!}} 0 to 180
{{!}} Sets the angle in degrees within which the camera is not constrained by changes in target rotation.
{{!}} Sets the angle in degrees within which the camera is not constrained by changes in target rotation.
{{!}}-  
{{!}}-  
{{!}} {{LSLG|CAMERA_BEHINDNESS_LAG}}
{{!}} {{LSL Const|CAMERA_BEHINDNESS_LAG|integer|9}}
{{!}} 9
{{!}} {{#var:cvalue}}
{{!}} {{LSLG|float}} seconds
{{!}} [[float]]&nbsp;seconds
{{!}} 0.0
{{!}} 0.0
{{!}} 0 to 3
{{!}} 0 to 3
{{!}} Sets how strongly the camera is forced to stay behind the target if outside of behindness angle.
{{!}} Sets how strongly the camera is forced to stay behind the target if outside of behindness angle.
{{!}}-  
{{!}}-  
{{!}} {{LSLG|CAMERA_DISTANCE}}
{{!}} {{LSL Const|CAMERA_DISTANCE|integer|7}}
{{!}} 7
{{!}} {{#var:cvalue}}
{{!}} {{LSLG|float}} meters
{{!}} [[float]]&nbsp;meters
{{!}} 3.0
{{!}} 3.0
{{!}} 0.5 to 10
{{!}} 0.5 to 50
{{!}} Sets how far away the camera wants to be from its target.
{{!}} Sets how far away the camera wants to be from its target.
{{!}}-  
{{!}}-  
{{!}} {{LSLG|CAMERA_FOCUS}}
{{!}} {{LSL Const|CAMERA_FOCUS|integer|17}}
{{!}} 17
{{!}} {{#var:cvalue}}
{{!}} {{LSLG|vector}} position
{{!}} [[vector]]&nbsp;position
{{!}} n/a
{{!}} n/a
{{!}} n/a
{{!}} n/a
{{!}} Sets camera focus (target position) in {{LSLG|Region Coordinate|region coordinates}}.
{{!}} Sets camera focus (target position) in [[Viewer coordinate frames#Region|region coordinates]].
{{!}}-  
{{!}}-  
{{!}} {{LSLG|CAMERA_FOCUS_LAG}}
{{!}} {{LSL Const|CAMERA_FOCUS_LAG|integer|6}}
{{!}} 6
{{!}} {{#var:cvalue}}
{{!}} {{LSLG|float}} seconds
{{!}} [[float]]&nbsp;seconds
{{!}} 0.1
{{!}} 0.1
{{!}} 0 to 3
{{!}} 0 to 3
{{!}} How much the camera lags as it tries to aim towards the target.
{{!}} How much the camera lags as it tries to aim towards the target.
{{!}}-  
{{!}}-  
{{!}} {{LSLG|CAMERA_FOCUS_LOCKED}}
{{!}} {{LSL Const|CAMERA_FOCUS_LOCKED|integer|22}}
{{!}} 22
{{!}} {{#var:cvalue}}
{{!}} {{LSLG|integer}} isLocked
{{!}} [[integer]]&nbsp;isLocked
{{!}} {{LSLG|FALSE}}
{{!}} {{LSL Const|FALSE|integer|0}}
{{!}} {{LSLG|TRUE}} or {{LSLG|FALSE}}
{{!}} {{LSL Const|TRUE|integer|1}} or {{LSL Const|FALSE|integer|0}}
{{!}} Locks the camera focus so it will not move.
{{!}} Locks the camera focus so it will not move.
{{!}}-  
{{!}}-  
{{!}} {{LSLG|CAMERA_FOCUS_OFFSET}}
{{!}} {{LSL Const|CAMERA_FOCUS_OFFSET|integer|1}}
{{!}} 1
{{!}} {{#var:cvalue}}
{{!}} {{LSLG|vector}} [[meter|meters]]
{{!}} [[vector]]&nbsp;[[meter|meters]]
{{!}} <0.0, 0.0, 0.0>
{{!}} <0.0,0.0,0.0>
{{!}} <-10,-10,-10> to <10,10,10>
{{!}} <-10,-10,-10> to <10,10,10>
{{!}} Adjusts the camera focus [[position]] relative to the target.
{{!}} Adjusts the camera focus [[position]] relative to the target.
{{!}}-  
{{!}}-  
{{!}} {{LSLG|CAMERA_FOCUS_THRESHOLD}}
{{!}} {{LSL Const|CAMERA_FOCUS_THRESHOLD|integer|11}}
{{!}} 11
{{!}} {{#var:cvalue}}
{{!}} {{LSLG|float}} meters
{{!}} [[float]]&nbsp;meters
{{!}} 1.0
{{!}} 1.0
{{!}} 0 to 4
{{!}} 0 to 4
{{!}} Sets the radius of a sphere around the camera's target position within which its focus is not affected by target motion.
{{!}} Sets the radius of a sphere around the camera's target position within which its focus is not affected by target motion.
{{!}}-  
{{!}}-  
{{!}} {{LSLG|CAMERA_PITCH}}
{{!}} {{LSL Const|CAMERA_PITCH|integer|0}}
{{!}} 0
{{!}} {{#var:cvalue}}
{{!}} {{LSLG|float}} degrees
{{!}} [[float]]&nbsp;degrees
{{!}} 0.0
{{!}} 0.0
{{!}} -45 to 80
{{!}} -45 to 80
{{!}} Adjusts the angular amount that the camera aims straight ahead vs. straight down, maintaining the same distance; analogous to 'incidence'."
{{!}} Adjusts the angular amount that the camera aims straight ahead vs. straight down, maintaining the same distance; analogous to 'incidence'."
{{!}}-  
{{!}}-  
{{!}} {{LSLG|CAMERA_POSITION}}
{{!}} {{LSL Const|CAMERA_POSITION|integer|13}}
{{!}} 13
{{!}} {{#var:cvalue}}
{{!}} {{LSLG|vector}} position
{{!}} [[vector]]&nbsp;position
{{!}} n/a
{{!}} n/a
{{!}} n/a
{{!}} n/a
{{!}} Sets camera position in {{LSLG|Region Coordinate|region coordinates}}.
{{!}} Sets camera position in [[Viewer coordinate frames#Region|region coordinates]].
{{!}}-  
{{!}}-  
{{!}} {{LSLG|CAMERA_POSITION_LAG}}
{{!}} {{LSL Const|CAMERA_POSITION_LAG|integer|5}}
{{!}} 5
{{!}} {{#var:cvalue}}
{{!}} {{LSLG|float}} seconds
{{!}} [[float]]&nbsp;seconds
{{!}} 0.1
{{!}} 0.1
{{!}} 0 to 3
{{!}} 0 to 3
{{!}} How much the camera lags as it tries to move towards its 'ideal' position.
{{!}} How much the camera lags as it tries to move towards its 'ideal' position.
{{!}}-  
{{!}}-  
{{!}} {{LSLG|CAMERA_POSITION_LOCKED}}
{{!}} {{LSL Const|CAMERA_POSITION_LOCKED|integer|21}}
{{!}} 21
{{!}} {{#var:cvalue}}
{{!}} {{LSLG|integer}} isLocked
{{!}} [[integer]]&nbsp;isLocked
{{!}} {{LSLG|FALSE}}
{{!}} {{LSL Const|FALSE|integer|0}}
{{!}} {{LSLG|TRUE}} or {{LSLG|FALSE}}
{{!}} {{LSL Const|TRUE|integer|1}} or {{LSL Const|FALSE|integer|0}}
{{!}} Locks the camera position so it will not move.
{{!}} Locks the camera position so it will not move.
{{!}}-  
{{!}}-  
{{!}} {{LSLG|CAMERA_POSITION_THRESHOLD}}
{{!}} {{LSL Const|CAMERA_POSITION_THRESHOLD|integer|10}}
{{!}} 10
{{!}} {{#var:cvalue}}
{{!}} {{LSLG|float}} meters
{{!}} [[float]]&nbsp;meters
{{!}} 1.0
{{!}} 1.0
{{!}} 0 to 4
{{!}} 0 to 4
{{!}} Sets the radius of a sphere around the camera's ideal position within which it is not affected by target motion.
{{!}} Sets the radius of a sphere around the camera's ideal position within which it is not affected by target motion.
{{!}}}
{{!}}}
|examples=<pre>llSetCameraParams([
|}}
        CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
        CAMERA_BEHINDNESS_ANGLE, 10.0, // (0 to 180) degrees
        CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
        CAMERA_DISTANCE, 3.0, // ( 0.5 to 10) meters
        // CAMERA_FOCUS, <0,0,0>, // region-relative position
        CAMERA_FOCUS_LAG, 0.1 , // (0 to 3) seconds
        CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
        CAMERA_FOCUS_THRESHOLD, 1.0, // (0 to 4) meters
        CAMERA_PITCH, 0.0, // (-45 to 80) degrees
        // CAMERA_POSITION, <0,0,0>, // region-relative position
        CAMERA_POSITION_LAG, 0.1, // (0 to 3) seconds
        CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
        CAMERA_POSITION_THRESHOLD, 1.0, // (0 to 4) meters
        CAMERA_FOCUS_OFFSET, ZERO_VECTOR // <-10,-10,-10> to <10,10,10> meters
    ]);</pre>
|helpers
|also_functions
|also_events
|also_tests
|also_articles
|notes
|permission=PERMISSION_CONTROL_CAMERA
|negative_index
|sort=SetCameraParams
|cat1=Camera
|cat2
|cat3
|cat4
}}

Revision as of 15:00, 22 January 2015

Summary

Function: llSetCameraParams( list rules );

Sets multiple camera parameters at once.

• list rules Format is [ rule1, data1, rule2, data2 . . . rulen, datan ]

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

Rule Parameter Default Value Range Description
CAMERA_ACTIVE 12   integer isActive FALSE TRUE or FALSE Turns on or off scripted control of the camera.
CAMERA_BEHINDNESS_ANGLE 8 float degrees 10.0 0 to 180 Sets the angle in degrees within which the camera is not constrained by changes in target rotation.
CAMERA_BEHINDNESS_LAG 9 float seconds 0.0 0 to 3 Sets how strongly the camera is forced to stay behind the target if outside of behindness angle.
CAMERA_DISTANCE 7 float meters 3.0 0.5 to 50 Sets how far away the camera wants to be from its target.
CAMERA_FOCUS 17 vector position n/a n/a Sets camera focus (target position) in region coordinates.
CAMERA_FOCUS_LAG 6 float seconds 0.1 0 to 3 How much the camera lags as it tries to aim towards the target.
CAMERA_FOCUS_LOCKED 22 integer isLocked FALSE TRUE or FALSE Locks the camera focus so it will not move.
CAMERA_FOCUS_OFFSET 1 vector meters <0.0,0.0,0.0> <-10,-10,-10> to <10,10,10> Adjusts the camera focus position relative to the target.
CAMERA_FOCUS_THRESHOLD 11 float meters 1.0 0 to 4 Sets the radius of a sphere around the camera's target position within which its focus is not affected by target motion.
CAMERA_PITCH 0 float degrees 0.0 -45 to 80 Adjusts the angular amount that the camera aims straight ahead vs. straight down, maintaining the same distance; analogous to 'incidence'."
CAMERA_POSITION 13 vector position n/a n/a Sets camera position in region coordinates.
CAMERA_POSITION_LAG 5 float seconds 0.1 0 to 3 How much the camera lags as it tries to move towards its 'ideal' position.
CAMERA_POSITION_LOCKED 21 integer isLocked FALSE TRUE or FALSE Locks the camera position so it will not move.
CAMERA_POSITION_THRESHOLD 10 float meters 1.0 0 to 4 Sets the radius of a sphere around the camera's ideal position within which it is not affected by target motion.

Caveats

Permissions
  • The PERMISSION_CONTROL_CAMERA permission is automatically revoked when the avatar stands up from or detaches the object, and any scripted camera parameters are automatically cleared.
  • Camera control currently (server 1.38) only supported for attachments and objects on which you are sitting. An attempt otherwise will result in an error being shouted on DEBUG_CHANNEL.
  • Scripted camera parameters will not set for the agent if the last controls they used were their camera controls. Manual camera control will override set parameters too.
All Issues ~ Search JIRA for related Bugs

Examples

You can either set the camera in region relative coordinates or you can make the camera follow your avatar.

Region relative coordinates, an example:

lookAtMe( integer perms )
{
    if ( perms & PERMISSION_CONTROL_CAMERA )
    {
        vector camPos = llGetPos() + (relCamP * llGetRot() * turnOnChair) ;
        vector camFocus = llGetPos() ;
        llClearCameraParams(); // reset camera to default
        llSetCameraParams([
            CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
            CAMERA_FOCUS, camFocus, // region relative position
            CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE)
            CAMERA_POSITION, camPos, // region relative position
            CAMERA_POSITION_LOCKED, TRUE // (TRUE or FALSE)
        ]);
    }
}

Note that Focus and Position are both locked. This first example makes the camera look at camFocus from camPos.

Camera follow avatar, an example:

lookAtMe( integer perms )
{
    if ( perms & PERMISSION_CONTROL_CAMERA )
    {
        llClearCameraParams(); // reset camera to default
        llSetCameraParams([
            CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
            CAMERA_BEHINDNESS_ANGLE, 30.0, // (0 to 180) degrees
            CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
            CAMERA_DISTANCE, 10.0, // ( 0.5 to 10) meters
          //CAMERA_FOCUS, <0,0,5>, // region relative position
            CAMERA_FOCUS_LAG, 0.05 , // (0 to 3) seconds
            CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
            CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
            CAMERA_PITCH, 10.0, // (-45 to 80) degrees
          //CAMERA_POSITION, <0,0,0>, // region relative position
            CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
            CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
            CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
            CAMERA_FOCUS_OFFSET, <2.0, 0.0, 0.0> // <-10,-10,-10> to <10,10,10> meters
        ]);
    }
}
Note that in this second example Focus and Position are NOT locked and not even set. This is appropriate for making the camera follow a pilot on a vehicle.

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
•  llClearCameraParams
•  llGetCameraPos
•  llGetCameraRot

Articles

•  Script permissions
•  FollowCam

Deep Notes

All Issues

~ Search JIRA for related Issues
   Damping Parameters for llSetCameraParams()
   CAMERA_FOCUS_TARGET and CAMERA_POSITION_TARGET parameters for llSetCameraParams()
   Improvements to llSetCameraParams()

Tests

•  llSetCameraParams Test

Signature

function void llSetCameraParams( list rules );