User:Ezian Ecksol

From Second Life Wiki
Revision as of 05:23, 20 September 2008 by Ezian Ecksol (talk | contribs)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Cam Lock/Follow <lsl> // Camstyle, (c) Ezian Ecksol, feel free to copy, steal, modify

// Put script into prim, attach it. // usage: position your camera where you like. // enter in chan: // /1 camstyle follow <-- camera is fixed, but follows your av // /1 camstyle lock <-- camera is completly locked // /1 camstyle <-- releases cam again

integer chan = 1;

key owner; list keywords = ["lock", "follow"];

cam_style(integer cs) {

   llRequestPermissions(owner, PERMISSION_CONTROL_CAMERA | PERMISSION_TRACK_CAMERA);
   llClearCameraParams(); 
       
   if (!cs)
       return;
       
   vector cpos = llGetCameraPos();
   list params = [CAMERA_ACTIVE, TRUE, CAMERA_POSITION_LOCKED, TRUE, CAMERA_POSITION_THRESHOLD, 0.5,
                   CAMERA_FOCUS_THRESHOLD, 0.5, CAMERA_POSITION, cpos];
       
   if (cs == 1) 
       params += [
           CAMERA_DISTANCE, .5, // ( 0.5 to 10) meters
           CAMERA_BEHINDNESS_LAG, 0.1, // (0 to 3) seconds
           CAMERA_PITCH, 10.0, // (-45 to 80) degrees
           CAMERA_FOCUS, cpos + llRot2Fwd(llGetCameraRot()), // region-relative position
           CAMERA_FOCUS_LAG, 0.1, // (0 to 3) seconds
           CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE)
           CAMERA_POSITION_LAG, 1.0 // (0 to 3) seconds
       ];
       
   else if (cs == 2) 
       params += [
           CAMERA_FOCUS_LAG, 0.0, // (0 to 3) seconds
           CAMERA_BEHINDNESS_LAG, 0.5 // (0 to 3) seconds
       ];
       
   llSetCameraParams(params);

}


default {

   state_entry() {
       owner = llGetOwner();
       llListen(chan, "", owner, "");
   }
   
   listen(integer channel, string name, key id, string msg) {
       msg = llToLower(msg);
       list m = llParseString2List(msg, [" "], []);
       
       if (llList2String(m, 0) == "camstyle") 
           cam_style(llListFindList(keywords, [llList2String(m, 1)]) + 1);
   }
   changed(integer c) {
       if (c & CHANGED_OWNER)
           llResetScript();
   }

} </lsl>