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 Pose_Ball_camera_Control  

Pose_Ball_camera_Control

Pose_Ball_camera_Control

Category: Camera
By : Ferd Frederix
Created: 2012-03-10 Edited: 2012-03-10
Worlds: Second Life

the Zip file

Download all files for Pose_Ball_camera_Control
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Pose_Ball_camera_Control_1.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 //Original idea by Linden Lab's Dan Linden
2 // Mods by Ferd Frederix
3
4 key agent;
5
6 integer CHANNEL; // dialog channel
7 list MENU_MAIN = ["Default", "Overhead Cam", "Spin Cam", "Spaz Cam", "Drop Cam",
8 "Worm Cam", "Top Cam","Cam ON", "Cam OFF"]; // the main menu
9
10
11 integer on = FALSE;
12
13 integer spaz = 0;
14 take_camera_control(key agent)
15 {
17 llSetCameraParams([CAMERA_ACTIVE, 1]); // 1 is active, 0 is inactive
18 on = TRUE;
19 }
20
21 release_camera_control(key agent)
22 {
23
24 llSetCameraParams([CAMERA_ACTIVE, 0]); // 1 is active, 0 is inactive
25 llReleaseCamera(agent);
26 on = FALSE;
27 }
28
29 focus_on_me()
30 {
31 vector here = llGetPos();
33 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
34 CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees
35 CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
36 CAMERA_DISTANCE, 0.0, // ( 0.5 to 10) meters
37 CAMERA_FOCUS, here, // region relative position
38 CAMERA_FOCUS_LAG, 0.0 , // (0 to 3) seconds
39 CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE)
40 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
41 // PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 80.0, // (-45 to 80) degrees
42 CAMERA_POSITION, here + <4.0,4.0,4.0>, // region relative position
43 CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
44 CAMERA_POSITION_LOCKED, TRUE, // (TRUE or FALSE)
45 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
46 CAMERA_FOCUS_OFFSET, ZERO_VECTOR // <-10,-10,-10> to <10,10,10> meters
47 ]);
48 }
49
50 default_cam()
51 {
52
53 llClearCameraParams(); // reset camera to default
54 llSetCameraParams([CAMERA_ACTIVE, 1]);
55 }
56
57
58 driving_cam()
59 {
60
61 default_cam();
63 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
64 CAMERA_BEHINDNESS_ANGLE, 45.0, // (0 to 180) degrees
65 CAMERA_BEHINDNESS_LAG, 0.5, // (0 to 3) seconds
66 CAMERA_DISTANCE, 8.0, // ( 0.5 to 10) meters
67 //CAMERA_FOCUS, <0.0,0.0,5.0>, // region relative position
68 CAMERA_FOCUS_LAG, 0.05 , // (0 to 3) seconds
69 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
70 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
71 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 20.0, // (-45 to 80) degrees
72 //CAMERA_POSITION, <0.0,0.0,0.0>, // region relative position
73 CAMERA_POSITION_LAG, 0.1, // (0 to 3) seconds
74 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
75 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
76 CAMERA_FOCUS_OFFSET, <3.0,0.0,2.0> // <-10,-10,-10> to <10,10,10> meters
77 ]);
78 }
79
80
81 side_cam()
82 {
83
84 llClearCameraParams(); // reset camera to default
86 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
87 CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees
88 CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
89 CAMERA_DISTANCE, 0.0, // ( 0.5 to 10) meters
90 //CAMERA_FOCUS, <0.0,0.0,5.0>, // region relative position
91 CAMERA_FOCUS_LAG, 0.0 , // (0 to 3) seconds
92 // CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
93 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
94 // PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 80.0, // (-45 to 80) degrees
95 //CAMERA_POSITION, <0.0,0.0,0.0>, // region relative position
96 CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
97 // CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
98 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
99 CAMERA_FOCUS_OFFSET, <0.0,6.0,0.0> // <-10,-10,-10> to <10,10,10> meters
100 ]);
101 }
102
103 rearview_cam()
104 {
105
107 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
108 CAMERA_BEHINDNESS_ANGLE, 180.0, // (0 to 180) degrees
109 CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
110 // CAMERA_DISTANCE, 10.0, // ( 0.5 to 10) meters
111 //CAMERA_FOCUS, <0.0,0.0,5.0>, // region relative position
112 CAMERA_FOCUS_LAG, 3.0 , // (0 to 3) seconds
113 // CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
114 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
115 // PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 80.0, // (-45 to 80) degrees
116 //CAMERA_POSITION, <0.0,0.0,0.0>, // region relative position
117 // CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
118 // CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
119 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
120 CAMERA_FOCUS_OFFSET, <5.0,2.0,-2.0> // <-10,-10,-10> to <10,10,10> meters
121 ]);
122 }
123
124 overhead_cam()
125 {
126
127 default_cam();
129 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
130 CAMERA_BEHINDNESS_ANGLE, 180.0, // (0 to 180) degrees
131 CAMERA_BEHINDNESS_LAG, 0.5, // (0 to 3) seconds
132 CAMERA_DISTANCE, 10.0, // ( 0.5 to 10) meters
133 //CAMERA_FOCUS, <0.0,0.0,5.0>, // region relative position
134 CAMERA_FOCUS_LAG, 0.05 , // (0 to 3) seconds
135 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
136 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
137 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 80.0, // (-45 to 80) degrees
138 //CAMERA_POSITION, <0.0,0.0,0.0>, // region relative position
139 CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
140 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
141 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
142 CAMERA_FOCUS_OFFSET, <0.0,0.0,0.0> // <-10,-10,-10> to <10,10,10> meters
143 ]);
144 }
145
146 drop_camera_5_seconds()
147 {
148
150 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
151 CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees
152 CAMERA_BEHINDNESS_LAG, 0.5, // (0 to 3) seconds
153 CAMERA_DISTANCE, 3.0, // ( 0.5 to 10) meters
154 //CAMERA_FOCUS, <0.0,0.0,5.0>, // region relative position
155 CAMERA_FOCUS_LAG, 2.0, // (0 to 3) seconds
156 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
157 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
158 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 0.0, // (-45 to 80) degrees
159 //CAMERA_POSITION, <0.0,0.0,0.0>, // region relative position
160 CAMERA_POSITION_LAG, 0.05, // (0 to 3) seconds
161 CAMERA_POSITION_LOCKED, TRUE, // (TRUE or FALSE)
162 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
163 CAMERA_FOCUS_OFFSET, <0.0,0.0,0.0> // <-10,-10,-10> to <10,10,10> meters
164 ]);
165
166 }
167
168
169
170 worm_cam()
171 {
172
174 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
175 CAMERA_BEHINDNESS_ANGLE, 180.0, // (0 to 180) degrees
176 CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
177 CAMERA_DISTANCE, 8.0, // ( 0.5 to 10) meters
178 //CAMERA_FOCUS, <0.0,0.0,5.0>, // region relative position
179 CAMERA_FOCUS_LAG, 0.0 , // (0 to 3) seconds
180 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
181 CAMERA_FOCUS_THRESHOLD, 4.0, // (0 to 4) meters
182 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, -45.0, // (-45 to 80) degrees
183 //CAMERA_POSITION, <0.0,0.0,0.0>, // region relative position
184 CAMERA_POSITION_LAG, 1.0, // (0 to 3) seconds
185 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
186 CAMERA_POSITION_THRESHOLD, 1.0, // (0 to 4) meters
187 CAMERA_FOCUS_OFFSET, <0.0,0.0,0.0> // <-10,-10,-10> to <10,10,10> meters
188 ]);
189 }
190
191 spaz_cam()
192 {
193 float i;
194 for (i=0; i< 50; i+=1)
195 {
196 vector xyz = llGetPos() + <llFrand(80.0) - 40, llFrand(80.0) - 40, llFrand(10.0)>;
197 // llOwnerSay((string)xyz);
198 vector xyz2 = llGetPos() + <llFrand(80.0) - 40, llFrand(80.0) - 40, llFrand(10.0)>;
200 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
201 CAMERA_BEHINDNESS_ANGLE, 180.0, // (0 to 180) degrees
202 CAMERA_BEHINDNESS_LAG, llFrand(3.0), // (0 to 3) seconds
203 CAMERA_DISTANCE, llFrand(10.0), // ( 0.5 to 10) meters
204 //CAMERA_FOCUS, xyz, // region relative position
205 CAMERA_FOCUS_LAG, llFrand(3.0), // (0 to 3) seconds
206 CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE)
207 CAMERA_FOCUS_THRESHOLD, llFrand(4.0), // (0 to 4) meters
208 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, llFrand(125.0) - 45, // (-45 to 80) degrees
209 CAMERA_POSITION, xyz2, // region relative position
210 CAMERA_POSITION_LAG, llFrand(3.0), // (0 to 3) seconds
211 CAMERA_POSITION_LOCKED, TRUE, // (TRUE or FALSE)
212 CAMERA_POSITION_THRESHOLD, llFrand(4.0), // (0 to 4) meters
213 CAMERA_FOCUS_OFFSET, <llFrand(20.0) - 10, llFrand(20.0) - 10, llFrand(20) - 10> // <-10,-10,-10> to <10,10,10> meters
214 ]);
215 llSleep(0.2);
216 }
217 default_cam();
218 }
219
220 spin_cam()
221 {
223 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
224 CAMERA_BEHINDNESS_ANGLE, 180.0, // (0 to 180) degrees
225 CAMERA_BEHINDNESS_LAG, 0.5, // (0 to 3) seconds
226 //CAMERA_DISTANCE, 10.0, // ( 0.5 to 10) meters
227 //CAMERA_FOCUS, <0.0,0.0,5.0>, // region relative position
228 CAMERA_FOCUS_LAG, 0.05 , // (0 to 3) seconds
229 CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
230 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
231 PITCH" title="View Definition" class="tooltip">CAMERA_PITCH, 30.0, // (-45 to 80) degrees
232 //CAMERA_POSITION, <0.0,0.0,0.0>, // region relative position
233 CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
234 CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
235 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
236 CAMERA_FOCUS_OFFSET, <0.0,0.0,0.0> // <-10,-10,-10> to <10,10,10> meters
237 ]);
238
239 float i;
240 vector camera_position;
241 for (i=0; i< 6*TWO_PI; i+=.05)
242 {
243 camera_position = llGetPos() + <0.0, 6.0, 0.0> * llEuler2Rot(<0.0, 0.0, i>);
244 llSetCameraParams([CAMERA_POSITION, camera_position]);
245 }
246 default_cam();
247 }
248
249 setup_listen()
250 {
252 CHANNEL = llRound(llFrand(1) * 100000);
253 integer x = llListen(CHANNEL, "", "", ""); // listen for dialog answers
254 }
255
256 default
257 {
259 {
260 setup_listen();
261 }
262
263 listen(integer channel, string name, key id, string message)
264 {
265 if(~llListFindList(MENU_MAIN, [message])) // verify dialog choice
266 {
267 if(message == "Cam ON")
268 {
269 take_camera_control(id);
270 }
271
272 else if(message == "Cam OFF")
273 {
274 release_camera_control(id);
275 }
276
277 else if(message == "Default")
278 {
279 default_cam();
280 }
281
282 else if(message == "Top Cam")
283 {
284 driving_cam();
285 }
286
287 else if(message == "Worm Cam")
288 {
289 worm_cam();
290 }
291
292 else if(message == "Overhead Cam")
293 {
294 overhead_cam();
295 }
296
297 else if(message == "Spaz Cam")
298 {
299 spaz_cam();
300 }
301
302 else if(message == "Side Cam")
303 {
304 side_cam();
305 }
306
307 else if(message == "Drop Cam")
308 {
309 drop_camera_5_seconds();
310 }
311
312 else if(message == "Spin Cam")
313 {
314 spin_cam();
315 }
316
317 }
318
319 llDialog(agent, "What do you want to do?", MENU_MAIN, CHANNEL); // present dialog on click
320
321 }
322
325 llSetCameraParams([CAMERA_ACTIVE, 1]); // 1 is active, 0 is inactive
326 //llOwnerSay("Camera permissions have been taken");
327 }
328 }
329
330 changed(integer change)
331 {
332 if(change & CHANGED_LINK)
333 {
334 agent = llAvatarOnSitTarget();
335
336 if(agent)
337 {
338
339 setup_listen();
340 llDialog(agent, "What do you want to do?", MENU_MAIN, CHANNEL); // present dialog on click
342 }
343 }
344 }
345
346 attach(key agent)
347 {
348 if(agent)
349 {
350 setup_listen();
352 }
353 }
354
355
356 }

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