Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Request Camera Control

Robins Hermano
Registered User
Join date: 20 Oct 2006
Posts: 18
03-10-2007 06:16
I am trying to request the camera controls from an avi sitting on an object. I'm not getting any error messages with the following script, but don't get any message that the script has taken control of the camera and the camera control changes don't seem to have any effect.

Here's the script (and oh, this is driving me crazy!)

default
{
state_entry()
{

}

touch_start(integer total_number)
{
llSay(0, "Touched.";);
key owner = llAvatarOnSitTarget();
llRequestPermissions(owner, PERMISSION_CONTROL_CAMERA);
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, .75, // ( 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, 20.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
]);
llOwnerSay((string) owner);
}
}
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
03-10-2007 06:24
If you put the request in the changed event (check for CHANGED_LINK and llAvatarOnSitTarget()) they'll be automatically granted when an avatar sits on the object.
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
03-10-2007 08:25
The problem is that permissions requests aren't granted instantaneously. You have to wait until the user has time to respond to the dialog BEFORE actually attempting to use the permissions you've requested. This means you need to call llRequestPermissions(), then stop what you're doing and wait for a run_time_permissions() event before continuing on and calling llSetCameraParams().

It's true that a sitting avatar will always grant a variety of permissions without getting a dialog, but it's still a good idea to wait to use the permissions you request until run_time_permissions is called.
Robins Hermano
Registered User
Join date: 20 Oct 2006
Posts: 18
Have Permission
03-10-2007 10:09
OK, thanks, now I have permissions, but when I change the camera settings I don't see the camera moving around to the new settings. Is there some trigger that has to happen before the camera moves?
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
03-10-2007 10:10
Have you set the camera back to it's default position by pressing escape?
Robins Hermano
Registered User
Join date: 20 Oct 2006
Posts: 18
ClearCameraParms
03-10-2007 10:28
Well I inserted a llClearCameraParams() before I changed the params (and I tried hitting ESC as suggested). Sometimes (it seems random) the camera moves to right behind me - that must be the default, but then none of my actual parameter changes can be seen. The camera doesn't move again. I've been in First Viewer and am changing to the regular client to see if that does anything.

Changing to the old viewer seemed to do the trick, First Viewer must be a bit buggie.
Ed Gobo
ed44's alt
Join date: 20 Jun 2006
Posts: 220
03-10-2007 16:39
Hi Robins

Tried your code. Trying to give my bulldozer some decent camera angles. But it tels me camera control permissions are not set. Do you get this error message too?

Called from changed event:
CODE

initCamera () {
gOwner = llAvatarOnSitTarget();
llRequestPermissions(gOwner, PERMISSION_CONTROL_CAMERA | PERMISSION_TRACK_CAMERA );
}


CODE

setCamera () {
llOwnerSay((string) gOwner + " is going to set camera parameters");
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, .75, // ( 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, 20.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
]);
llOwnerSay((string) gOwner + " has set camera parameters");
}

in my default:
CODE

run_time_permissions(integer perms)
{
if (debug)
llOwnerSay ("perms=" + (string) perms);
if (perms & PERMISSION_CONTROL_CAMERA) {
setCamera ();
}
//integer gPC = llGetParcelPrimCount (llGetPos (), PARCEL_COUNT_TOTAL, FALSE);
//llOwnerSay ("bobcat mm prim count = " + (string) gPC);
if (perms & PERMISSION_TAKE_CONTROLS) {
integer desired_controls =
CONTROL_FWD |
CONTROL_BACK |
CONTROL_UP |
CONTROL_DOWN |
CONTROL_LEFT |
CONTROL_RIGHT |
CONTROL_ROT_LEFT |
CONTROL_ROT_RIGHT;
llTakeControls(desired_controls, TRUE, FALSE);
doInit ();
}
}


From: someone


[16:26] Bobcat Ver 2.55: perms=3072
[16:26] Bobcat Ver 2.55: 15efb08d-e555-4131-977f-e6a0024e27be is going to set camera parameters
[16:26] Bobcat Ver 2.55: Script trying to set camera parameters but PERMISSION_CONTROL_CAMERA permission not set!
[16:26] Bobcat Ver 2.55: 15efb08d-e555-4131-977f-e6a0024e27be has set camera parameters

PERMISSION_CONTROL_CAMERA = 2048 so it is definitely set with 3072 (2048 + 1024)
Robins Hermano
Registered User
Join date: 20 Oct 2006
Posts: 18
Try Follow Cam
03-11-2007 04:47
Ed,

My scripting isn't up to your level, but yes, I was getting those error messages. All is now working, but I just have the simple script in one prim. For getting different camera angles on your bulldowser I would use the Follow-Cam Code posted by Dan Linden, on this list and you can find it here: http://rpgstats.com/wiki/index.php?title=FollowCam

There is also a video of using this code by Torley Linden, I think in the Knowledge Base.


Good Luck, Robins
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
03-11-2007 06:09
Thanks Robins, will give that a go.