Camera Sync
Camera sync allows for multiple users to synchronize their cameras, for use by builders in joint projects or in tutorials and demonstrations.
Camera Tween - Smoothly adjusts the position and rotation of the camera over a given number of steps (eight works well):
camTween(rotation camRot_origin, vector camPos_origin, rotation camRot_target, vector camPos_target, float steps)
{
//Keep steps a float, but make sure its rounded of to the nearest 1.0
steps = (float)llRound(steps);
//Calculate camera position increments
vector posStep = (camPos_target - camPos_origin) / steps;
//Calculate camera rotation increments
rotation rotStep = (camRot_target - camRot_origin);
rotStep = <rotStep.x / steps, rotStep.y / steps, rotStep.z / steps, rotStep.s / steps>;
float cStep; //Loop through motion for cStep = current step, while cStep <= Total steps
for(cStep = 0.0; cStep <= steps; cStep++)
{
//Set next position in tween
vector camPos_next = camPos_origin + (posStep * cStep);
rotation camRot_next = camRot_origin + <rotStep.x * cStep, rotStep.y * cStep, rotStep.z * cStep, rotStep.s * cStep>;
//Set camera parameters
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, camPos_next + llRot2Fwd(camRot_next), //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_POSITION, camPos_next, //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
]);
}
}
Camera Default - Sets the camera parameters back to their defaults:
camDefault()
{
llSetCameraParams([
CAMERA_ACTIVE, FALSE, //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_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_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
]);
}
Camera Match - Sets a prim's position and rotation to that of the user's (the one we have permissions for) camera:
warpPos(vector destpos)
{
integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
list rules = [PRIM_POSITION, destpos];
integer count = 1;
while (( count = count << 1 ) < jumps)
{
rules = (rules=[]) + rules + rules;
}
llSetPrimitiveParams(rules + llList2List(rules, (count - jumps) << 1, count));
}
camMatch()
{
warpPos(llGetCameraPos());
llSetRot(llGetCameraRot());
}
Script Library|
WarpPos