aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDahlia Trimble2008-08-24 01:23:04 +0000
committerDahlia Trimble2008-08-24 01:23:04 +0000
commit29407a43f5a544c9b540ddd29c3e6111ff9c6427 (patch)
tree902d5ef9492896e645b29d929b43da43513106ef /OpenSim/Region
parentImplements 80% of object buy (prim vendor). You can't buy the object yet, (diff)
downloadopensim-SC-29407a43f5a544c9b540ddd29c3e6111ff9c6427.zip
opensim-SC-29407a43f5a544c9b540ddd29c3e6111ff9c6427.tar.gz
opensim-SC-29407a43f5a544c9b540ddd29c3e6111ff9c6427.tar.bz2
opensim-SC-29407a43f5a544c9b540ddd29c3e6111ff9c6427.tar.xz
more progress on new meshing routines
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/Meshing/PrimMesher.cs215
1 files changed, 189 insertions, 26 deletions
diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs
index 8679f65..d7621d3 100644
--- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs
+++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs
@@ -151,26 +151,20 @@ namespace OpenSim.Region.Physics.Meshing
151 internal class makeProfile 151 internal class makeProfile
152 { 152 {
153 private float twoPi = 2.0f * (float)Math.PI; 153 private float twoPi = 2.0f * (float)Math.PI;
154
154 internal List<vertex> coords; 155 internal List<vertex> coords;
155 internal List<vertex> hollowCoords;
156 internal List<face> faces; 156 internal List<face> faces;
157 157
158 internal int sides = 4; 158 internal makeProfile(int sides, float profileStart, float profileEnd, float hollow, int hollowSides)
159 internal int hollowSides = 7;
160 internal vertex center = new vertex(0.0f, 0.0f, 0.0f);
161
162 makeProfile(int sides, float profileStart, float profileEnd, float hollow, int hollowSides)
163 { 159 {
164 coords = new List<vertex>(); 160 this.coords = new List<vertex>();
165 hollowCoords = new List<vertex>(); 161 List<vertex> hollowCoords = new List<vertex>();
166 faces = new List<face>(); 162 this.faces = new List<face>();
163 vertex center = new vertex(0.0f, 0.0f, 0.0f);
167 164
168 AngleList angles = new AngleList(); 165 AngleList angles = new AngleList();
169 AngleList hollowAngles = new AngleList(); 166 AngleList hollowAngles = new AngleList();
170 167
171 this.sides = sides;
172 this.hollowSides = hollowSides;
173
174 float xScale = 0.5f; 168 float xScale = 0.5f;
175 float yScale = 0.5f; 169 float yScale = 0.5f;
176 if (sides == 4) // corners of a square are sqrt(2) from center 170 if (sides == 4) // corners of a square are sqrt(2) from center
@@ -181,18 +175,18 @@ namespace OpenSim.Region.Physics.Meshing
181 175
182 float startAngle = profileStart * twoPi; 176 float startAngle = profileStart * twoPi;
183 float stopAngle = profileEnd * twoPi; 177 float stopAngle = profileEnd * twoPi;
184 float stepSize = twoPi / this.sides; 178 float stepSize = twoPi / sides;
185 179
186 angles.makeAngles(this.sides, startAngle, stopAngle); 180 angles.makeAngles(sides, startAngle, stopAngle);
187 181
188 if (hollow > 0.001f) 182 if (hollow > 0.001f)
189 { 183 {
190 if (this.sides == this.hollowSides) 184 if (sides == hollowSides)
191 hollowAngles = angles; 185 hollowAngles = angles;
192 else 186 else
193 { 187 {
194 hollowAngles = new AngleList(); 188 hollowAngles = new AngleList();
195 hollowAngles.makeAngles(this.hollowSides, startAngle, stopAngle); 189 hollowAngles.makeAngles(hollowSides, startAngle, stopAngle);
196 } 190 }
197 } 191 }
198 else 192 else
@@ -201,7 +195,7 @@ namespace OpenSim.Region.Physics.Meshing
201 Angle angle; 195 Angle angle;
202 vertex newVert = new vertex(); 196 vertex newVert = new vertex();
203 197
204 if ( hollow > 0.001f && this.hollowSides != this.sides) 198 if (hollow > 0.001f && hollowSides != sides)
205 { 199 {
206 int numHollowAngles = hollowAngles.angles.Count; 200 int numHollowAngles = hollowAngles.angles.Count;
207 for (int i = 0; i < numHollowAngles; i++) 201 for (int i = 0; i < numHollowAngles; i++)
@@ -210,25 +204,194 @@ namespace OpenSim.Region.Physics.Meshing
210 newVert.X = hollow * xScale * angle.X; 204 newVert.X = hollow * xScale * angle.X;
211 newVert.Y = hollow * yScale * angle.Y; 205 newVert.Y = hollow * yScale * angle.Y;
212 newVert.Z = 0.0f; 206 newVert.Z = 0.0f;
213 this.hollowCoords.Add(newVert); 207
208 hollowCoords.Add(newVert);
214 } 209 }
215 } 210 }
216 211
217 int numAngles = angles.angles.Count; 212 int numAngles = angles.angles.Count;
218 for (int i = 0; i < numAngles; i++) 213 int index;
214 for (index = 0; index < numAngles; index++)
219 { 215 {
220 angle = angles.angles[i]; 216 angle = angles.angles[index];
221 newVert.X = angle.X * xScale; 217 newVert.X = angle.X * xScale;
222 newVert.Y = angle.Y * yScale; 218 newVert.Y = angle.Y * yScale;
223 newVert.Z = 0.0f; 219 newVert.Z = 0.0f;
224 this.coords.Add(newVert); 220 this.coords.Add(newVert);
221
222 if (hollow > 0.0f)
223 {
224 newVert.X = angle.X *= hollow;
225 newVert.Y = angle.Y *= hollow;
226 newVert.Z = 0.0f;
227 hollowCoords.Add(newVert);
228 }
229 else if (angle.angle > 0.0001f)
230 {
231 face newFace = new face();
232 newFace.v1 = 0;
233 newFace.v2 = index;
234 newFace.v3 = index;
235 this.faces.Add(newFace);
236 }
225 } 237 }
226
227 /*
228 continue at python source line 174
229
230 */
231 238
239 if (hollow > 0.0)
240 {
241 hollowCoords.Reverse();
242
243 int numOuterVerts = this.coords.Count;
244 int numHollowVerts = hollowCoords.Count;
245 int numTotalVerts = numOuterVerts + numHollowVerts;
246
247 if (numOuterVerts == numHollowVerts)
248 {
249 face newFace = new face();
250
251 for (int coordIndex = 0; coordIndex < numOuterVerts - 1; coordIndex++)
252 {
253 newFace.v1 = coordIndex;
254 newFace.v2 = coordIndex + 1;
255 newFace.v3 = numTotalVerts - coordIndex - 1;
256
257 this.faces.Add(newFace);
258
259 newFace.v1 = coordIndex + 1;
260 newFace.v2 = numTotalVerts - coordIndex - 2;
261 newFace.v3 = numTotalVerts - coordIndex - 1;
262
263 this.faces.Add(newFace);
264 }
265 }
266
267 else
268 {
269 if (numOuterVerts < numHollowVerts)
270 {
271 face newFace = new face();
272 int j = 0; // j is the index for outer vertices
273 int maxJ = numOuterVerts - 1;
274 for (int i = 0; i < numHollowVerts; i++) // i is the index for inner vertices
275 {
276 if (j < maxJ)
277 if (angles.angles[j + 1].angle - hollowAngles.angles[i].angle <= hollowAngles.angles[i].angle - angles.angles[j].angle)
278 {
279 newFace.v1 = numTotalVerts - i - 2;
280 newFace.v2 = j;
281 newFace.v3 = j + 1;
282
283 this.faces.Add(newFace);
284 j += 1;
285 }
286
287 newFace.v1 = j;
288 newFace.v2 = numTotalVerts - i - 2;
289 newFace.v3 = numTotalVerts - i - 1;
290
291 this.faces.Add(newFace);
292 }
293 }
294 else // numHollowVerts < numOuterVerts
295 {
296 face newFace = new face();
297 int j = 0; // j is the index for inner vertices
298 int maxJ = numHollowVerts - 1;
299 for (int i = 0; i < numOuterVerts; i++)
300 {
301 if (j < maxJ)
302 if (hollowAngles.angles[j + 1].angle - angles.angles[i].angle <= angles.angles[i].angle - hollowAngles.angles[j].angle)
303 {
304 newFace.v1 = i;
305 newFace.v2 = numTotalVerts - j - 2;
306 newFace.v3 = numTotalVerts - j - 1;
307
308 this.faces.Add(newFace);
309 j += 1;
310 }
311
312 newFace.v1 = numTotalVerts - j - 1;
313 newFace.v2 = i;
314 newFace.v3 = i + 1;
315
316 this.faces.Add(newFace);
317 }
318 }
319
320 }
321
322 this.coords.AddRange(hollowCoords);
323 }
324 }
325
326 internal void addPos(vertex v)
327 {
328 this.addPos(v.X, v.Y, v.Z);
329 }
330
331 internal void addPos(float x, float y, float z)
332 {
333 int i;
334 int numVerts = this.coords.Count;
335 vertex vert;
336
337 for (i = 0; i < numVerts; i++)
338 {
339 vert = this.coords[i];
340 vert.X += x;
341 vert.Y += y;
342 vert.Z += z;
343 }
344 }
345
346 internal void addRot(Quaternion q)
347 {
348 int i;
349 int numVerts = this.coords.Count;
350 vertex vert;
351
352 for (i = 0; i < numVerts; i++)
353 {
354 vert = this.coords[i];
355 Vertex v = new Vertex(vert.X, vert.Y, vert.Z);
356
357 v = v * q;
358
359 vert.X = v.X;
360 vert.Y = v.Y;
361 vert.Z = v.Z;
362 }
363 }
364
365 internal void scale(float x, float y, float z)
366 {
367 int i;
368 int numVerts = this.coords.Count;
369 vertex vert;
370
371 for (i = 0; i < numVerts; i++)
372 {
373 vert = this.coords[i];
374
375 vert.X *= x;
376 vert.Y *= y;
377 vert.Z *= z;
378 }
379 }
380
381 internal void flipNormals()
382 {
383 int i;
384 int numFaces = this.faces.Count;
385 face tmpFace;
386 int tmp;
387
388 for (i = 0; i < numFaces; i++)
389 {
390 tmpFace = this.faces[i];
391 tmp = tmpFace.v3;
392 tmpFace.v3 = tmpFace.v1;
393 tmpFace.v1 = tmp;
394 }
232 } 395 }
233 } 396 }
234 397