aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Meshing/Extruder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/Meshing/Extruder.cs')
-rw-r--r--OpenSim/Region/Physics/Meshing/Extruder.cs193
1 files changed, 3 insertions, 190 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Extruder.cs b/OpenSim/Region/Physics/Meshing/Extruder.cs
index 77bd9a4..b14deeb 100644
--- a/OpenSim/Region/Physics/Meshing/Extruder.cs
+++ b/OpenSim/Region/Physics/Meshing/Extruder.cs
@@ -64,193 +64,6 @@ namespace OpenSim.Region.Physics.Meshing
64 public float pathTaperY = 0.0f; 64 public float pathTaperY = 0.0f;
65 65
66 /// <summary> 66 /// <summary>
67 /// (deprecated) creates a 3 layer extruded mesh of a profile hull
68 /// </summary>
69 /// <param name="m"></param>
70 /// <returns></returns>
71 public Mesh Extrude(Mesh m)
72 {
73 startParameter = float.MinValue;
74 stopParameter = float.MaxValue;
75 // Currently only works for iSteps=1;
76 Mesh result = new Mesh();
77
78 Mesh workingPlus = m.Clone();
79 Mesh workingMiddle = m.Clone();
80 Mesh workingMinus = m.Clone();
81
82 Quaternion tt = new Quaternion();
83 Vertex v2 = new Vertex(0, 0, 0);
84
85 foreach (Vertex v in workingPlus.vertices)
86 {
87 if (v == null)
88 continue;
89
90 // This is the top
91 // Set the Z + .5 to match the rest of the scale of the mesh
92 // Scale it by Size, and Taper the scaling
93 v.Z = +.5f;
94 v.X *= (size.X * taperTopFactorX);
95 v.Y *= (size.Y * taperTopFactorY);
96 v.Z *= size.Z;
97
98 //Push the top of the object over by the Top Shear amount
99 v.X += pushX * size.X;
100 v.Y += pushY * size.Y;
101
102 if (twistTop != 0)
103 {
104 // twist and shout
105 tt = new Quaternion(new Vertex(0, 0, 1), twistTop);
106 v2 = v * tt;
107 v.X = v2.X;
108 v.Y = v2.Y;
109 v.Z = v2.Z;
110 }
111 }
112
113 foreach (Vertex v in workingMiddle.vertices)
114 {
115 if (v == null)
116 continue;
117
118 // This is the top
119 // Set the Z + .5 to match the rest of the scale of the mesh
120 // Scale it by Size, and Taper the scaling
121 v.Z *= size.Z;
122 v.X *= (size.X * ((taperTopFactorX + taperBotFactorX) /2));
123 v.Y *= (size.Y * ((taperTopFactorY + taperBotFactorY) / 2));
124
125 v.X += (pushX / 2) * size.X;
126 v.Y += (pushY / 2) * size.Y;
127 //Push the top of the object over by the Top Shear amount
128 if (twistMid != 0)
129 {
130 // twist and shout
131 tt = new Quaternion(new Vertex(0, 0, 1), twistMid);
132 v2 = v * tt;
133 v.X = v2.X;
134 v.Y = v2.Y;
135 v.Z = v2.Z;
136 }
137 }
138
139 foreach (Vertex v in workingMinus.vertices)
140 {
141 if (v == null)
142 continue;
143
144 // This is the bottom
145 v.Z = -.5f;
146 v.X *= (size.X * taperBotFactorX);
147 v.Y *= (size.Y * taperBotFactorY);
148 v.Z *= size.Z;
149
150 if (twistBot != 0)
151 {
152 // twist and shout
153 tt = new Quaternion(new Vertex(0, 0, 1), twistBot);
154 v2 = v * tt;
155 v.X = v2.X;
156 v.Y = v2.Y;
157 v.Z = v2.Z;
158 }
159 }
160
161 foreach (Triangle t in workingMinus.triangles)
162 {
163 t.invertNormal();
164 }
165
166 result.Append(workingMinus);
167 result.Append(workingMiddle);
168
169 int iLastNull = 0;
170
171 for (int i = 0; i < workingMiddle.vertices.Count; i++)
172 {
173 int iNext = i + 1;
174
175 if (workingMiddle.vertices[i] == null) // Can't make a simplex here
176 {
177 iLastNull = i + 1;
178 continue;
179 }
180
181 if (i == workingMiddle.vertices.Count - 1) // End of list
182 {
183 iNext = iLastNull;
184 }
185
186 if (workingMiddle.vertices[iNext] == null) // Null means wrap to begin of last segment
187 {
188 iNext = iLastNull;
189 }
190
191 Triangle tSide;
192 tSide = new Triangle(workingMiddle.vertices[i], workingMinus.vertices[i], workingMiddle.vertices[iNext]);
193 result.Add(tSide);
194
195 tSide =
196 new Triangle(workingMiddle.vertices[iNext], workingMinus.vertices[i], workingMinus.vertices[iNext]);
197 result.Add(tSide);
198 }
199 //foreach (Triangle t in workingPlus.triangles)
200 //{
201 //t.invertNormal();
202 // }
203 result.Append(workingPlus);
204
205 iLastNull = 0;
206 for (int i = 0; i < workingPlus.vertices.Count; i++)
207 {
208 int iNext = i + 1;
209
210 if (workingPlus.vertices[i] == null) // Can't make a simplex here
211 {
212 iLastNull = i + 1;
213 continue;
214 }
215
216 if (i == workingPlus.vertices.Count - 1) // End of list
217 {
218 iNext = iLastNull;
219 }
220
221 if (workingPlus.vertices[iNext] == null) // Null means wrap to begin of last segment
222 {
223 iNext = iLastNull;
224 }
225
226 Triangle tSide;
227 tSide = new Triangle(workingPlus.vertices[i], workingMiddle.vertices[i], workingPlus.vertices[iNext]);
228 result.Add(tSide);
229
230 tSide =
231 new Triangle(workingPlus.vertices[iNext], workingMiddle.vertices[i], workingMiddle.vertices[iNext]);
232 result.Add(tSide);
233 }
234
235 if (twistMid != 0)
236 {
237 foreach (Vertex v in result.vertices)
238 {
239 // twist and shout
240 if (v != null)
241 {
242 tt = new Quaternion(new Vertex(0, 0, -1), twistMid*2);
243 v2 = v * tt;
244 v.X = v2.X;
245 v.Y = v2.Y;
246 v.Z = v2.Z;
247 }
248 }
249 }
250 return result;
251 }
252
253 /// <summary>
254 /// Creates an extrusion of a profile along a linear path. Used to create prim types box, cylinder, and prism. 67 /// Creates an extrusion of a profile along a linear path. Used to create prim types box, cylinder, and prism.
255 /// </summary> 68 /// </summary>
256 /// <param name="m"></param> 69 /// <param name="m"></param>
@@ -350,7 +163,7 @@ namespace OpenSim.Region.Physics.Meshing
350 163
351 // apply twist rotation to the profile layer and position the layer in the prim 164 // apply twist rotation to the profile layer and position the layer in the prim
352 165
353 Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, -1.0f), twist); 166 Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, 1.0f), twist);
354 foreach (Vertex v in newLayer.vertices) 167 foreach (Vertex v in newLayer.vertices)
355 { 168 {
356 if (v != null) 169 if (v != null)
@@ -566,7 +379,7 @@ namespace OpenSim.Region.Physics.Meshing
566 // next apply twist rotation to the profile layer 379 // next apply twist rotation to the profile layer
567 if (twistTotal != 0.0f || twistBot != 0.0f) 380 if (twistTotal != 0.0f || twistBot != 0.0f)
568 { 381 {
569 Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, -1.0f), twist); 382 Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, 1.0f), twist);
570 foreach (Vertex v in newLayer.vertices) 383 foreach (Vertex v in newLayer.vertices)
571 { 384 {
572 if (v != null) 385 if (v != null)
@@ -581,7 +394,7 @@ namespace OpenSim.Region.Physics.Meshing
581 394
582 // now orient the rotation of the profile layer relative to it's position on the path 395 // now orient the rotation of the profile layer relative to it's position on the path
583 // adding pushY to the angle used to generate the quat appears to approximate the viewer 396 // adding pushY to the angle used to generate the quat appears to approximate the viewer
584 Quaternion layerRot = new Quaternion(new Vertex(-1.0f, 0.0f, 0.0f), (float)angle + pushY * 0.9f); 397 Quaternion layerRot = new Quaternion(new Vertex(1.0f, 0.0f, 0.0f), (float)angle + pushY * 0.9f);
585 foreach (Vertex v in newLayer.vertices) 398 foreach (Vertex v in newLayer.vertices)
586 { 399 {
587 if (v != null) 400 if (v != null)