jinko
2007年08月24日 06:03
//================================================
// [fixed_camera.lsl]
// Fixed the camera position & focus.
// ver 1.0 Aug 23, 2007 by Jinko Spitteler
//================================================
// Ref http://miz.slmame.com/e16983.html
integer isReady;
key keyOwner;
control_init () {
isReady = FALSE;
keyOwner = llGetOwner();
llRequestPermissions(keyOwner, PERMISSION_CONTROL_CAMERA);
llListen(1,"",keyOwner,"");
}
focus_lock_typeA () {
//Fixed position & forcus
llSetCameraParams([
CAMERA_ACTIVE, TRUE,
CAMERA_FOCUS_LOCKED, TRUE,
CAMERA_POSITION_LOCKED, TRUE
]);
}
focus_lock_typeB () {
//Fixed position & Follow target
llSetCameraParams([
CAMERA_ACTIVE, TRUE,
CAMERA_FOCUS_LAG, 0.0,
CAMERA_POSITION_LOCKED, TRUE
]);
}
focus_lock_typeC () {
//Follow taget, Overlook
llSetCameraParams([
CAMERA_ACTIVE, TRUE,
CAMERA_BEHINDNESS_ANGLE, 180.0,
CAMERA_DISTANCE, 10.0,
CAMERA_PITCH, 180.0
]);
}
focus_unlock () {
llClearCameraParams();
llReleaseCamera(llGetPermissionsKey());
}
default {
state_entry() {
if (llGetAttached() != 0) {
control_init ();
}
}
attach(key agent) {
if (agent != NULL_KEY) {
control_init ();
}
else {
integer perm = llGetPermissions();
if (perm & PERMISSION_CONTROL_CAMERA) {
focus_unlock();
llOwnerSay("thanks!!");
}
}
}
run_time_permissions(integer perm) {
if (perm & PERMISSION_CONTROL_CAMERA) {
llOwnerSay("Camera Control is ready!!");
isReady = TRUE;
}
}
listen(integer channel,string name, key id, string message) {
if (id == keyOwner && isReady) {
if(message == "c1") {
focus_lock_typeA ();
llOwnerSay("ok, Fixed Camera!!");
}
else if(message == "c2") {
focus_lock_typeB ();
llOwnerSay("ok, Lock on Target!!");
}
else if(message == "c3") {
focus_lock_typeC ();
llOwnerSay("ok, Follow Target!!");
}
else if(message == "r") {
focus_unlock();
llOwnerSay("ok, Release Target!!");
}
}
}
}