Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

KDC camsys: make your SL experience feel like a movie!

Kyrah Abattoir
cruelty delight
Join date: 4 Jun 2004
Posts: 2,786
03-28-2006 09:58
this is a little goodie i wrote when 1.9 came out, it is an attachment combined to volumedetect markers that will send to the attachment informations on how the camera should behave, it allow you to create buildings with fixed cameras like in resident evil for example.

the first part is a hud element with a touch to toggle behavior, when on the indicator is green and crossing a camsys marker will make the camaera change automatically, if you toggle it off the light goes green and just blink green briefly when you cross a marker (also if you decide to toggle it on, it will give you the last recorded camera setting)

code for the attachment core script:
CODE

///////////////////////////////////////////////////////////////////////////////
//KDC Camsys camera controlling system
//
//file: camsys core
//
//description: this script allow the setup of dynamic camera across a building (resident evil style)
//
//Copyright (C) 2006Kyrah Abattoir

//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//http://www.gnu.org/copyleft/gpl.html
/////////////////////////////////////////////////////////////////////////////////

integer toggle = FALSE;
list parameters = [];
integer handler;

integer Key2Channel(key given)//to compute a personal channel for every user
{
string known = (string)given;
string channel = "";
channel += (string)((integer)("0x" + llGetSubString(known,0,1)));
channel += (string)((integer)("0x" + llGetSubString(known,2,3)));
channel += (string)((integer)("0x" + llGetSubString(known,4,5)));
return -(integer)channel;
}
list formatter(list values)//this function read the parameter list and try to fnd the type of each value
{
list values2;
integer i;
for(i=0;i < llGetListLength(values);i+=2)
{
values2 += [llList2Integer(values,i)];//one value on 2 is automatically an integer
list a = llParseString2List(llList2String(values,i+1),["<",".",">"],[]);
integer b = llGetListLength(a);
if(b == 1)
values2 += [llList2Integer(values,i+1)];
else if(b == 2)
values2 += [llList2Float(values,i+1)];
else
values2 += [(vector)llList2String(values,i+1)];
}
return values2;
}
default
{
attach(key id)
{
if(id != NULL_KEY)
{
llResetScript();
}
}
run_time_permissions(integer perms)
{
if((perms | PERMISSION_CONTROL_CAMERA) == PERMISSION_CONTROL_CAMERA)
{
llOwnerSay("KDC cam ready");
llClearCameraParams();
}
}
state_entry()
{
llListenRemove(handler);
handler = llListen(Key2Channel(llGetOwner()),"","","");
llRequestPermissions(llGetOwner(),PERMISSION_CONTROL_CAMERA);
}
listen(integer channel,string name,key id,string message)
{
if(message == "off")
{
llClearCameraParams();
parameters = [];
}
else
{
parameters = llParseString2List(message,["|"],[]);
if(toggle)
llSetCameraParams(formatter(parameters));
else
llMessageLinked(LINK_SET,0,"CAM_blink","");
}
}
touch_start(integer total)
{
if(toggle == TRUE)
{
llClearCameraParams();
llMessageLinked(LINK_SET,0,"CAM_off","");
}
else
{
if(parameters != [])
llSetCameraParams(formatter(parameters));
llMessageLinked(LINK_SET,0,"CAM_on","");
}
toggle = !toggle;
}
}


code fopr the attachment blinking light (color red/green when it is toggled on and off and blink when you cross a camsys enabled zone)

CODE

///////////////////////////////////////////////////////////////////////////////
//KDC Camsys camera controlling system
//
//description: this script allow the setup of dynamic camera across a building (resident evil style)
//
//Copyright (C) 2006Kyrah Abattoir

//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//http://www.gnu.org/copyleft/gpl.html
/////////////////////////////////////////////////////////////////////////////////
default
{
link_message(integer snum,integer num,string str,key id)
{
if(str == "CAM_on")
llSetColor(<0,1,0>,ALL_SIDES);
else if(str == "CAM_off")
llSetColor(<1,0,0>,ALL_SIDES);
else if(str == "CAM_blink")
{
llSetColor(<1,0,0>,ALL_SIDES);
llSleep(.1);
llSetColor(<0,1,0>,ALL_SIDES);
llSleep(.1);
llSetColor(<1,0,0>,ALL_SIDES);
llSleep(.1);
llSetColor(<0,1,0>,ALL_SIDES);
llSleep(.1);
llSetColor(<1,0,0>,ALL_SIDES);
}

}
}



now for the developper part: this is the code you will put in invisible prims palced like tripwires in your building, they detect the direction the avatar go so you can set up 2 camera behavior depending if they "enter the room" or "leave the room"
CODE

///////////////////////////////////////////////////////////////////////////////
//KDC Camsys camera controlling system
//
//description: this script allow the setup of dynamic camera across a building (resident evil style)
//
//Copyright (C) 2006Kyrah Abattoir

//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//http://www.gnu.org/copyleft/gpl.html
/////////////////////////////////////////////////////////////////////////////////


integer Key2Channel(key given)
{
string known = (string)given;
string channel = "";
channel += (string)((integer)("0x" + llGetSubString(known,0,1)));
channel += (string)((integer)("0x" + llGetSubString(known,2,3)));
channel += (string)((integer)("0x" + llGetSubString(known,4,5)));
return (integer)channel;
}
default
{
state_entry()
{
llVolumeDetect(TRUE);
}
collision_end(integer num)
{
if(llVecDist(llVecNorm(llDetectedVel(0)),(<1,0,0>*llGetRot())) < 1 ) //this trigger when the avatar cross the object alon the X axis
{
//these are simply camera parameters, check the wikki for more infos on how to set them up
//this code make a fixed cam that look at your avatar
list params =
[
CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees
CAMERA_BEHINDNESS_LAG, 0.5, // (0 to 3) seconds
CAMERA_DISTANCE, 3.0, // ( 0.5 to 10) meters
//CAMERA_FOCUS, <0,0,5>, // region relative position where the camera aim at
CAMERA_FOCUS_LAG, 0.0, // (0 to 3) seconds
CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
CAMERA_PITCH, 0.0, // (-45 to 80) degrees
CAMERA_POSITION,<183.574,24.086,204.375>, // 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, <0,0,0> // <-10,-10,-10> to <10,10,10> meters
];
llSay(- Key2Channel(llDetectedKey(0)),llDumpList2String(params,"|"));
//llSay(- Key2Channel(llDetectedKey(0)),"off"); //this code deactivate the camera system

}
else//this trigger when the avatar cross the object alon the -X axis
{
list params =
[
CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees
CAMERA_BEHINDNESS_LAG, 0.5, // (0 to 3) seconds
CAMERA_DISTANCE, 3.0, // ( 0.5 to 10) meters
//CAMERA_FOCUS, <0,0,5>, // region relative position
CAMERA_FOCUS_LAG, 0.0, // (0 to 3) seconds
CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
CAMERA_PITCH, 0.0, // (-45 to 80) degrees
CAMERA_POSITION,<182.517,28.624,204.885>, // region relative position
CAMERA_POSITION_LAG, 0.05, // (0 to 3) seconds
CAMERA_POSITION_LOCKED, TRUE, // (TRUE or FALSE)
CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
CAMERA_FOCUS_OFFSET, <0,0,0> // <-10,-10,-10> to <10,10,10> meters

];
llSay(- Key2Channel(llDetectedKey(0)),llDumpList2String(params,"|"));
//llSay(- Key2Channel(llDetectedKey(0)),"off"); //this code deactivate the camera system
}
}
}


you are free to reuse this code and modify it as long as the compatibility with the original system isn't compromised.
_____________________

tired of XStreetSL? try those!
apez http://tinyurl.com/yfm9d5b
metalife http://tinyurl.com/yzm3yvw
metaverse exchange http://tinyurl.com/yzh7j4a
slapt http://tinyurl.com/yfqah9u
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
03-28-2006 20:02
/54/bc/96791/1.html
_____________________
i've got nothing. ;)