Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Camera SitCameraSetter  

SitCameraSetter

When you sit on an object your camera is set to a default view. If you want to change this and look elsewhere, zoomed in close in or even a couple of sims away, you can use this to do it.

You just sit on the prim with this script in it and move your camera into position. One click and its done.

You can leave the script in place or use the cam offsets from your chat window in your own.

All sorts of uses from telescopes to microscopes.
Hope you have fun with it!

Category: Camera
By : Heb Dexler
Created: 2010-08-14 Edited: 2010-08-14
Worlds: Second Life

the Zip file

Download all files for SitCameraSetter
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. SitCameraSetter_1.lsl
1 //~^~^~^~^~^~^~^ SitCameraSetter v3 by Heb Dexler, SL August 2010 ~^~^~^~^~^~^~^~
2 // Setup camera offsets for seated avatars using your current camera position.
3 // Script licence IfYouWinTheLottoGiveUsAfewQuidWare. Please keep open source.
4
5 //1. Put this in a prim and sit. (Sets a default sit target if there isnt one already)
6 //2. Move your camera to a viewpoint you like
7 //3. Press the button or chat '/517 setcam'
8 //4. Press 'ESC' key once or twice to reset your camera If you dont see it on first sit.
9
10 // Has worked viewing 2 sims away. Give it a try!
11 //~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~
12
13 // listen chanel- change this if you like
14 integer dialogChannel = 517;
15 integer menuTimeOut = 300;
16
17 // dialog vars - leave this
18 integer setup = FALSE;
19 integer listenId;
20 key sitterId;
21
22 // position vars
23 rotation startRot;
24 vector startPos;
25 vector eyeOffPos;
26 vector camOffPos;
27
28 // set the camera offsets
29 setCamOffsets(){
30 llSetCameraEyeOffset(eyeOffPos);
31 llSetCameraAtOffset(camOffPos);
32 if(!setup){
33 llOwnerSay("Please sit to set a camera position.");
34 }
35 }
36
37 // Default state - set cam offsets or run setup
38 default{
39 on_rez(integer r){
40 setCamOffsets();
41 }
43 setCamOffsets();
44 }
45
47 if(perm & PERMISSION_TRACK_CAMERA){
48 state camsetup;
49 }
50 }
51
52 changed(integer change){
53 //convoluted way of getting sitter==owner test without an llAvatarOnSitTarget
55
56 // set a default sittarget if none
57 if(numAv > 0 && llAvatarOnSitTarget() == NULL_KEY){
58 llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
59 llOwnerSay("There was no sittarget. A default has been set");
60 }
61
62 if(change & CHANGED_LINK){
63 if(numAv == 1){
65 sitterId = llGetLinkKey(lnkNumAv);
66 // check sitter is owner and change state
67 if(sitterId == llGetOwner() && !setup){
69 // missfeature use 'if' to change state not 'if else'
70 if(perm & PERMISSION_TRACK_CAMERA){
71 state camsetup;
72 }
73 if(!(perm & PERMISSION_TRACK_CAMERA)) {
74 llRequestPermissions(llGetOwner(), PERMISSION_TRACK_CAMERA);
75 }
76 }
77 }
78 }
79 }
80
81 }
82
83 // Change state - run camera setup dialog to get offsets
84 state camsetup{
85
87
88 // get current prim pos
89 startPos = llGetPos();
90 startRot = llGetRot();
91
92 listenId = llListen(dialogChannel, "",sitterId, "");
93
94 string msg = "\n\nPosition your camera then press 'setcam'";
95 msg += "\n\n(in mouselook chat: /517 setcam)";
96 llDialog(sitterId, msg,["setcam"],dialogChannel);
97
98 llSetTimerEvent(menuTimeOut);
99 }
100
101
102 listen(integer _channel, string _name, key _id, string _message) {
103
104 // handle dialog replies and calc offsets
105 if(_message == "setcam"){
106
107 // this does the work
108 eyeOffPos = (llGetCameraPos()-startPos)/startRot;
109 camOffPos = (llGetCameraPos()-startPos)/startRot + llRot2Fwd(llGetCameraRot()/llGetRot());
110
111 string msgOut =" Camera position setup!\n\t\t\t (ESC key twice on sit if necessary)";
112 msgOut +="\n Leave the script in place or use the following code in your own:";
113 msgOut +="\n//SitCamSetter \ndefault{\n\t state_entry(){";
114 msgOut +="\n\t\t llSetCameraEyeOffset(" + (string)eyeOffPos + ");";
115 msgOut +="\n\t\t llSetCameraAtOffset(" + (string)camOffPos + ");\n\t}\n}//end";
116
117 llOwnerSay(msgOut);
118
119 //remove listens and change state
120 llListenRemove(listenId);
122 setup = TRUE;
124 llUnSit(sitterId);
125 state default;
126 }
127 }
128
129 // timeout on the menu
130 timer(){
131 llOwnerSay("Menu timeout..");
132 llListenRemove(listenId);
134 setup = FALSE;
135 state default;
136 }
137 }//end

Back to the Best Free Tools in Second Life and OpenSim.