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
Building Geodesic_Dome_Builder  

Geodesic_Dome_Builder

This code makes Geodesic Domes and was given to the Open Source Scripting group by Shine Renoir.
You can read about the math here, http://www.geometer.org/mathcircles/geodesic.pdf

The Dome Builder uses 3 scripts. One in the builder object and two simple scale/scale and shear scripts in the component parts.

You can pick up a complete Dome Builder tool for free in Chessport, near the telehub.

First - this script goes in the builder object.

BUILDER

Category: Building
By : Shine Renoir
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Geodesic_Dome_Builder
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Geodesic_Dome_Builder_1.lsl
Get file # 2. Geodesic_Dome_Builder_2.lsl
Get file # 3. Geodesic_Dome_Builder_3.lsl
1
2 // Dome Builder
3 // 2007 Copyright by Shine Renoir (fb@frank-buss.de)
4 // Use it for whatever you want, but keep this copyright notice
5 // and credit my name in notecards etc., if you use it in
6 // closed source objects
7
8 integer subdivision = 2;
9 float length = 3.0;
10
11 vector base;
12 float r;
13
14 move(vector destination)
15 {
16 // llSetPos is limited to 10m distances,
17 // so it is called until the target is reached
19 while(p.z != destination.z) {
20 llSetPos(destination);
21 p = llGetPos();
22 }
23 }
24
25 drawLine(vector v1, vector v2)
26 {
27 vector line = v2 - v1;
28 vector pos = base + line / 2 + v1;
29 float len = llVecMag(line);
30 vector size = <0.1, 0.1, len>;
31 vector up = <0, 0, 1>;
32 rotation rot = llRotBetween(up, llVecNorm(line));
33 move(pos);
34 llRezObject("Line", pos, ZERO_VECTOR, rot, 0);
35 llSay(-42, (string) size);
36 }
37
38 drawTriangle(vector v1, vector v2, vector v3)
39 {
40 // assuming a normal triangle: no zero area
41
42 // make v1-v3 the longest side
43 integer i = 0;
44 for (i = 0; i < 2; i++) {
45 float a = llVecDist(v2, v3);
46 float b = llVecDist(v1, v3);
47 float c = llVecDist(v1, v2);
48 if(a > b || c > b) {
49 vector tmp = v1;
50 v1 = v2;
51 v2 = v3;
52 v3 = tmp;
53 }
54 }
55
56 // calculate side lengths
57 float a = llVecDist(v2, v3);
58 float b = llVecDist(v1, v3);
59 float c = llVecDist(v1, v2);
60
61 // b=b1+b2, a^2=h^2+b2^2, c^2=b1^2+h^2, solving:
62 float b2 = (a*a + b*b - c*c)/2.0/b;
63 float b1 = b - b2;
64 float h = llSqrt(a*a - b2*b2); // triangle height
65
66 // calculate triangle height vector and shear value
67 float hPosition = b1 / b;
68 vector vb1 = (v3 - v1) * hPosition;
69 vector vh = v2 - (v1 + vb1);
70 float shear = hPosition - 0.5;
71
72 // calculate position and rotation
73 vector pos = base + v1 + (v3 - v1) / 2 + vh / 2;
74 vector size = <b, 0.05, h>;
75 vector up = <0.0, 0.0, 1.0>;
76 rotation rot = llRotBetween(up, llVecNorm(vh));
77 vector fwd = llVecNorm(v3 - v1); // fwd is the base
78 vector left = llVecNorm(vh);
79 left = llVecNorm(left % fwd); // "left" is cross product (orthogonal to base and left)
80 rot = llAxes2Rot(fwd, left, fwd % left); // calculate the needed rotation
81
82 // create object
83 llRezObject("Triangle", pos, ZERO_VECTOR, rot, 0);
84
85 // set size and shear value
86 list send = [size, shear ] ;
87 llSay(-42, llList2CSV(send));
88 }
89
90 vector scaleToSphere(vector v)
91 {
92 float l = llVecMag(v);
93 return r / l * v;
94 }
95
96 drawSide(vector bottomLeft, vector top, vector bottomRight)
97 {
98 integer i;
99 integer segments = subdivision + 1;
100 vector dx = (bottomRight - bottomLeft) / segments;
101 vector dy = (top - bottomLeft) / segments;
102 for (i = 0; i < segments; i++) {
103 integer j;
104 for (j = 0; j < subdivision * 2 + 1 - 2 * i; j++) {
105 if((j % 2) == 0) {
106 // even, draw left and bottom line
107 integer l = j / 2;
108 vector v1 = scaleToSphere(bottomLeft + l * dx + i * dy);
109 vector v2 = scaleToSphere(bottomLeft + l * dx + (i+1) * dy);
110 vector v3 = scaleToSphere(bottomLeft + (l+1) * dx + i * dy);
111 drawLine(v1, v2);
112 drawLine(v1, v3);
113 drawTriangle(v1, v2, v3);
114 } else {
115 // odd, draw right line
116 integer l = (j - 1) / 2;
117 vector v1 = scaleToSphere(bottomLeft + l * dx + (i+1) * dy);
118 vector v2 = scaleToSphere(bottomLeft + (l+1) * dx + i * dy);
119 vector v3 = scaleToSphere(bottomLeft + (l+1) * dx + (i+1) * dy);
120 drawLine(v1, v2);
121 drawTriangle(v1, v2, v3);
122 }
123 }
124 }
125 }
126
127 drawDome()
128 {
129 float l2 = length / 2.0;
130 vector bottomLeft = <-l2, -l2, 0.0>;
131 vector topLeft = <-l2, l2, 0.0>;
132 vector topRight = <l2, l2, 0.0>;
133 vector bottomRight = <l2, -l2, 0.0>;
134 vector top = <0, 0, length * llSqrt(6.0) / 3.0>;
135 r = llVecMag(bottomLeft - topRight) / 2.0;
136 drawSide(bottomLeft, top, bottomRight);
137 drawSide(topLeft, top, bottomLeft);
138 drawSide(topRight, top, topLeft);
139 drawSide(bottomRight, top, topRight);
140 }
141
142 initialize()
143 {
144 llSetSitText("Build");
145 llSetText("Right click and 'Build'", <1, 0, 0>, 1.0);
146 llSitTarget(<0.5, 0.0, 0.7>, ZERO_ROTATION);
147 base = llGetPos();
148 }
149
150 default
151 {
152 touch_start(integer total_number)
153 {
154 llSay(0, "Right click me and choose 'Build' to start build");
155 }
156
157 on_rez(integer start_param)
158 {
159 initialize();
160 }
161
163 {
164 initialize();
165 }
166
167 changed(integer change)
168 {
169 // sitdown or standup
170 if(change & CHANGED_LINK) {
172 if(av) {
173 // sitdown
174 initialize();
175 drawDome();
176 base.z += length + 1.0;
177 move(base);
178 }
179 }
180 }
181 }

Geodesic_Dome_Builder

LINE


Put this scale script into a rod object called 'Line' and put that inside the builder, alongside the script above.

The rod object is a Cylinder with size <0.1,0.1,1.0>.

Category: Building
By : Shine Renoir
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

1
2
3 // One time scale script
4 // 2007 Copyright by Shine Renoir (fb@frank-buss.de)
5 // Use it for whatever you want, but keep this copyright notice
6 // and credit my name in notecards etc., if you use it in
7 // closed source objects
8
9 integer handle;
10
11 default
12 {
14 {
15 handle = llListen(-42, "", NULL_KEY, "" );
16 }
17
18 listen(integer channel, string name, key id, string message)
19 {
20 llSetScale((vector) message);
21 llListenRemove(handle);
22 }
23
24 on_rez(integer param) {
26 }
27 }

Geodesic_Dome_Builder

TRIANGLE

Category: Building
By : Shine Renoir
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

1
2 // One time scale and shear script
3 // 2007 Copyright by Shine Renoir (fb@frank-buss.de)
4 // Use it for whatever you want, but keep this copyright notice
5 // and credit my name in notecards etc., if you use it in
6 // closed source objects
7
8 integer handle;
9
10 default
11 {
13 {
14 handle = llListen(-42, "", NULL_KEY, "" );
15 }
16
17 listen(integer channel, string name, key id, string message)
18 {
19 list tokens = llCSV2List(message);
20 vector size = (vector) llList2String(tokens, 0);
21 float shear = (float) llList2String(tokens, 1);
24 0, // hollow shape
25 <0.0, 1.0, 0.0>, // cut
26 0.0, // hollow
27 <0.0, 0.0, 0.0>, // twist
28 <0.0, 1.0, 0.0>, // taper
29 <shear, 0.0, 0.0>, // top shear
30 PRIM_SIZE, size
31 ]);
32 llListenRemove(handle);
33 }
34
35 on_rez(integer param) {
37 }
38 }

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