Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Stop Camera From Going Behind On Sit

Rygel Ryba
Registered User
Join date: 12 Feb 2008
Posts: 254
05-18-2008 04:30
Okay. Here's the deal on me - I'm pretty good at scripting but I suck at vector and rotation math. And this whole thing is killing me.

In essence, I have an object where when I sit on it, it spins the camera around behind me and if my object is up against a wall - I'm looking at a wall - not myself sitting.

So, okay, I can offset the camera so it's in front of the object and looking at me from the front. Which is fine and dandy until I decide to rotate the object and put it against a different wall. If it's the "opposite" wall, I'm back to where I started. And if it's a side wall, I'm looking at it from the back.


So... MY QUESTION AT LAST:

Can anyone help me with either:

a) some math so that no matter what direction my object is facing, the camera will be looking at me from the front of it?

or

b) Just stop the camera from moving altogether because before I sit, it's generally looking at the object I'm sitting on in the first place.

(I realize that if I ALT_CLICK on an object before I sit on it, my camera won't move, but I really want it to just work the way it should in the first place).

Any help, any clues, and links to examples of things that do this would be greatly appreciated. Thanks so much!

Rygel
Core Taurog
Registered User
Join date: 2 May 2007
Posts: 17
05-18-2008 14:14
this is the method I use in my poseballs.

I'm sure it can be improved, but it works for me.

CODE

set_camera()
{
vector cpos;
if (camera_pos_relative)
{
cpos = llGetPos() + camera_pos*llGetRot();
}
else
{
cpos = camera_pos;
}

// CAMERA_DISTANCE, 2.5, // ( 0.5 to 10) meters
list CAMERA_PARAMS = [
CAMERA_ACTIVE, TRUE, // TRUE is active, FALSE is inactive
CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees
CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
CAMERA_FOCUS_LAG, 0.1 , // (0 to 3) seconds
CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
CAMERA_POSITION, cpos, // region relative position
CAMERA_POSITION_LOCKED, TRUE, // (TRUE or FALSE)
CAMERA_POSITION_LAG, 0.1, // (0 to 3) seconds
CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
CAMERA_FOCUS_OFFSET, ZERO_VECTOR // <-10,-10,-10> to <10,10,10> meters
];

if (camera_focus_enable)
{
vector cfocus;
if (camera_focus_relative)
{
cfocus = llGetPos() + camera_focus*llGetRot();
}
else
{
cfocus = camera_focus;
}
CAMERA_PARAMS = CAMERA_PARAMS + [
CAMERA_FOCUS, cfocus, // region relative position
CAMERA_FOCUS_LOCKED, TRUE // (TRUE or FALSE) grr basically must be true, or camera will just pan back after moving
];
}

llSetCameraParams(CAMERA_PARAMS);
}


regards,

Core
Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
06-30-2008 16:00
In the above script, how are these variables defined / set:

camera_pos_relative
camera_pos
camera_focus_enable
camera_focus_relative
_____________________
Thread attempting to compile a list of which animations are freebies, and which are not:

http://forums.secondlife.com/showthread.php?t=265609
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-01-2008 16:46
Don't llSetCameraAtOffset() and llSetCameraEyeOffset() do what's desired? They're specified relative to the scripted object (like llSitTarget), so if the object rotates, they just rotate along too. Or am I missing something?
_____________________
Archived for Your Protection
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
07-01-2008 17:56
From: Qie Niangao
Don't llSetCameraAtOffset() and llSetCameraEyeOffset() do what's desired? They're specified relative to the scripted object (like llSitTarget), so if the object rotates, they just rotate along too. Or am I missing something?
You're not missing anything. They'd work just dandy.

I perfer llSetCameraParams over it only because you can change the camera position and focus later without having the user stand and re-sit their avatar. It's a bit more work but offers a lot more options.

For instance: I once made a chair that focused on the face of each avatar that spoke. I never put it out there because it ended up being far more annoying than useful. =^_^=