Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Camera rotation

Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
10-24-2008 05:03
how dose one make the camera rotation look at the av's face when then sit down?
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
10-24-2008 06:57
From: Jenn Yoshikawa
how dose one make the camera rotation look at the av's face when then sit down?

For free:
CODE

// Studio Dora: camara position and 'Sit right' with Teleport, Dora Gustafson d.2007-10-26, 2008
// v2.42 rotation given as rotation ( not euler )
// specific for pod shape
// relative cam focus introduced

// vectors that may change with a changed prim/object to sit on

vector sitPos = <-0.04880, -0.01642, 1.12499>; // sit position relative to the prim
rotation turnOnChair = <-0.00000, -0.00000, -0.00486, 0.99999>; // the amount the avatar is rotated relative to the prim when seated
vector relCamP = <2.5, 0.0, 4.0>; // relative camera to prim position
vector relCamF = < 0.0, 0.0, 1.2 >; // relative focus to prim position

string wantedAnim = "hover_up"; // what animation to play? ( "hover_up" is a build-in used as default )

////

lookAtMe( integer perms )
{
if ( perms & PERMISSION_CONTROL_CAMERA )
{
vector camPos = llGetPos() + (relCamP * llGetRot() * turnOnChair) ;
vector camFocus = llGetPos() + relCamF ;
llClearCameraParams(); // reset camera to default
llSetCameraParams([
CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees
CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
CAMERA_DISTANCE, 0.0, // ( 0.5 to 10) meters
CAMERA_FOCUS, camFocus, // region relative position
CAMERA_FOCUS_LAG, 0.0 , // (0 to 3) seconds
CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE)
CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
// CAMERA_PITCH, 80.0, // (-45 to 80) degrees
CAMERA_POSITION, camPos, // region relative position
CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
CAMERA_POSITION_LOCKED, TRUE, // (TRUE or FALSE)
CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
CAMERA_FOCUS_OFFSET, ZERO_VECTOR // <-10,-10,-10> to <10,10,10> meters
]);
}
}

resetCamera( integer perms )
{
if ( perms & PERMISSION_CONTROL_CAMERA )
{
llClearCameraParams(); // reset camera to default
llSetCameraParams([ CAMERA_ACTIVE, FALSE ]);
}
}

default
{
state_entry()
{
llSitTarget( sitPos, turnOnChair ); //specific for object you sit on
resetCamera( llGetPermissions() );
}

link_message(integer sender_num, integer flag, string str, key id)
{
if ( flag ) lookAtMe( llGetPermissions());
else resetCamera( llGetPermissions() );
}

changed(integer change)
{
if (change & CHANGED_LINK)
{
key sitter = llAvatarOnSitTarget();
if(sitter != NULL_KEY)
{
llRequestPermissions( sitter, PERMISSION_TRIGGER_ANIMATION | PERMISSION_CONTROL_CAMERA );
}
else resetCamera( llGetPermissions() );
}
}

run_time_permissions(integer perm)
{
if ( perm & PERMISSION_TRIGGER_ANIMATION )
{
llStartAnimation( wantedAnim );
llStopAnimation("sit");
llStopAnimation("sit_female");
llStopAnimation("sit_generic");
}
if ( perm & PERMISSION_CONTROL_CAMERA ) lookAtMe( perm );
}
}

You will probably want to change the values in the variables: sitPos, turnOnChair, relCamP, relCamF and wantedAnim.
The 'link_message' event you can delete. It is used to control the camera from another prim in the link set.
Happy scipting:)
_____________________
From Studio Dora