|
Steve Patel
Registered User
Join date: 4 May 2004
Posts: 39
|
06-29-2008 12:03
Hi, just wondering if anyone has the answer to this problem.
What I'd like to do is allow the user to give a command to remember their camera position, using llGetCameraPos() and llGetCameraRot(). Then the script should be able to use llSetCameraParams() to recall this previous camera position.
llSetCameraParams() has CAMERA_POSITION, so that should take care of the position, but I can't figure out how to translate the rotation into anything usable by llSetCameraParams(). Is there a way to get the focus position, or anything other way to do this? Using the position only I can get it close, but its not looking in the right direction.
Thanks.
|
|
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
|
06-29-2008 12:24
i dont belive you can acculy set a rotation to the cam but you can set a angle
CAMERA_BEHINDNESS_ANGLE
|
|
Steve Patel
Registered User
Join date: 4 May 2004
Posts: 39
|
06-29-2008 14:09
I'm not sure about that. According to the wiki, CAMERA_BEHINDNESS_ANGLE "Sets the angle in degrees within which the camera is not constrained by changes in target rotation." To me that means it's not directly positioning it, but can anyone clarify?
I think I need either focus or maybe pitch, but I'm not sure. Is there a way to take the rotation from llGetCameraRot() and convert it to pitch/focus position/anything useful ?
|
|
Nexii Malthus
[Cubitar]Mothership
Join date: 24 Apr 2006
Posts: 400
|
06-29-2008 14:50
You can set the focus position like this: CameraPos + llRot2Fwd(CameraRot)
_____________________
 Geometric Library, for all your 3D maths needs. https://wiki.secondlife.com/wiki/Geometric Creator of the Vertical Life Client
|
|
Steve Patel
Registered User
Join date: 4 May 2004
Posts: 39
|
06-29-2008 16:14
From: Nexii Malthus You can set the focus position like this: CameraPos + llRot2Fwd(CameraRot) I had tried that before, but it was still always focusing on my avatar when reset. So I put it back and experimented with the settings. I've made some progress by setting CAMERA_FOCUS_THRESHOLD to 4.0 and CAMERA_BEHINDNESS_ANGLE to 180.0, which seems to unlock it from being focused on me. This wasn't enough though, objects farther away seemed to still lose the correct position/angle, so I tried using CAMERA_POSITION_LOCKED and CAMERA_FOCUS_LOCKED and that did the trick. Here's my final testing code, it seems to get the job done. Thanks for the help! From: someone vector pos = ZERO_VECTOR; rotation rot; updateCamera() { if(pos == ZERO_VECTOR) return; if(llAvatarOnSitTarget() != NULL_KEY) { llSetCameraParams([ CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive CAMERA_FOCUS, pos + llRot2Fwd(rot), CAMERA_POSITION_LOCKED, TRUE, CAMERA_FOCUS_LOCKED, TRUE, CAMERA_POSITION, pos // region relative position ]); } } requestPermissions() { key id = llAvatarOnSitTarget(); if(id != NULL_KEY) llRequestPermissions(id, PERMISSION_CONTROL_CAMERA|PERMISSION_TRACK_CAMERA); } default { state_entry() { llSitTarget(<0,0,0.1>, ZERO_ROTATION); llListen(0, "", llGetOwner(), "store"  ; requestPermissions(); } changed(integer change) { requestPermissions(); } listen(integer chan, string name, key id, string msg) { pos = llGetCameraPos(); rot = llGetCameraRot(); llOwnerSay("Stored"  ; updateCamera(); } run_time_permissions(integer permissions) { llClearCameraParams(); llOwnerSay("Ready"  ; updateCamera(); } }
|