aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/Meshing/Extruder.cs49
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs8
2 files changed, 38 insertions, 19 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Extruder.cs b/OpenSim/Region/Physics/Meshing/Extruder.cs
index 54ef4ce..7203aaf 100644
--- a/OpenSim/Region/Physics/Meshing/Extruder.cs
+++ b/OpenSim/Region/Physics/Meshing/Extruder.cs
@@ -260,8 +260,11 @@ namespace OpenSim.Region.Physics.Meshing
260 int steps = 24; 260 int steps = 24;
261 261
262 float twistTotal = twistTop - twistBot; 262 float twistTotal = twistTop - twistBot;
263 if (System.Math.Abs(twistTotal) > (float)System.Math.PI * 1.5) steps *= 2; 263 // if the profile has a lot of twist, add more layers otherwise the layers may overlap
264 if (System.Math.Abs(twistTotal) > (float)System.Math.PI * 3.0) steps *= 2; 264 // and the resulting mesh may be quite inaccurate. This method is arbitrary and doesnt
265 // accurately match the viewer
266 if (System.Math.Abs(twistTotal) > (float)System.Math.PI * 1.5f) steps *= 2;
267 if (System.Math.Abs(twistTotal) > (float)System.Math.PI * 3.0f) steps *= 2;
265 268
266 double percentOfPathMultiplier = 1.0 / steps; 269 double percentOfPathMultiplier = 1.0 / steps;
267 double angleStepMultiplier = System.Math.PI * 2.0 / steps; 270 double angleStepMultiplier = System.Math.PI * 2.0 / steps;
@@ -271,10 +274,10 @@ namespace OpenSim.Region.Physics.Meshing
271 float totalSkew = skew * 2.0f * pathLength; 274 float totalSkew = skew * 2.0f * pathLength;
272 float skewStart = (-skew) + pathCutBegin * 2.0f * skew; 275 float skewStart = (-skew) + pathCutBegin * 2.0f * skew;
273 276
274
275 float startAngle = (float)(System.Math.PI * 2.0 * pathCutBegin * revolutions); 277 float startAngle = (float)(System.Math.PI * 2.0 * pathCutBegin * revolutions);
276 float endAngle = (float)(System.Math.PI * 2.0 * pathCutEnd * revolutions); 278 float endAngle = (float)(System.Math.PI * 2.0 * pathCutEnd * revolutions);
277 float stepSize = (float)0.2617993878; // 2*PI / 24 segments per revolution 279 float stepSize = (float)0.2617993878; // 2*PI / 24 segments per revolution
280
278 step = (int)(startAngle / stepSize); 281 step = (int)(startAngle / stepSize);
279 float angle = startAngle; 282 float angle = startAngle;
280 283
@@ -291,11 +294,11 @@ namespace OpenSim.Region.Physics.Meshing
291 294
292 295
293 bool done = false; 296 bool done = false;
294 do 297 do // loop through the length of the path and add the layers
295 { 298 {
296 float percentOfPath = 1.0f; 299 newLayer = m.Clone();
297 300
298 percentOfPath = (angle - startAngle) / (endAngle - startAngle); // endAngle should always be larger than startAngle 301 float percentOfPath = (angle - startAngle) / (endAngle - startAngle); // endAngle should always be larger than startAngle
299 302
300 if (pathTaperX > 0.001f) // can't really compare to 0.0f as the value passed is never exactly zero 303 if (pathTaperX > 0.001f) // can't really compare to 0.0f as the value passed is never exactly zero
301 xProfileScale = 1.0f - percentOfPath * pathTaperX; 304 xProfileScale = 1.0f - percentOfPath * pathTaperX;
@@ -309,6 +312,20 @@ namespace OpenSim.Region.Physics.Meshing
309 yProfileScale = 1.0f + (1.0f - percentOfPath) * pathTaperY; 312 yProfileScale = 1.0f + (1.0f - percentOfPath) * pathTaperY;
310 else yProfileScale = 1.0f; 313 else yProfileScale = 1.0f;
311 314
315#if SPAM
316 //System.Console.WriteLine("xProfileScale: " + xProfileScale.ToString() + " yProfileScale: " + yProfileScale.ToString());
317#endif
318 Vertex vTemp = new Vertex(0.0f, 0.0f, 0.0f);
319
320 // apply the taper to the profile before any rotations
321 if (xProfileScale != 1.0f || yProfileScale != 1.0f)
322 foreach (Vertex v in newLayer.vertices)
323 if ( v != null )
324 {
325 v.X *= xProfileScale;
326 v.Y *= yProfileScale;
327 }
328
312 float radiusScale; 329 float radiusScale;
313 330
314 if (radius > 0.001f) 331 if (radius > 0.001f)
@@ -317,11 +334,11 @@ namespace OpenSim.Region.Physics.Meshing
317 radiusScale = 1.0f + radius * (1.0f - percentOfPath); 334 radiusScale = 1.0f + radius * (1.0f - percentOfPath);
318 else radiusScale = 1.0f; 335 else radiusScale = 1.0f;
319 336
320 //radiusScale = 1.0f;
321 337
322#if SPAM 338#if SPAM
323 System.Console.WriteLine("Extruder: angle: " + angle.ToString() + " percentOfPath: " + percentOfPath.ToString() 339 System.Console.WriteLine("Extruder: angle: " + angle.ToString() + " percentOfPath: " + percentOfPath.ToString()
324 + " radius: " + radius.ToString() + " radiusScale: " + radiusScale.ToString()); 340 + " radius: " + radius.ToString() + " radiusScale: " + radiusScale.ToString()
341 + " xProfileScale: " + xProfileScale.ToString() + " yProfileScale: " + yProfileScale.ToString());
325#endif 342#endif
326 343
327 float twist = twistBot + (twistTotal * (float)percentOfPath); 344 float twist = twistBot + (twistTotal * (float)percentOfPath);
@@ -330,10 +347,7 @@ namespace OpenSim.Region.Physics.Meshing
330 float yOffset = (float)(System.Math.Cos(angle) * (0.5f - yPathScale)) * radiusScale; 347 float yOffset = (float)(System.Math.Cos(angle) * (0.5f - yPathScale)) * radiusScale;
331 float xOffset = 0.5f * (skewStart + totalSkew * (float)percentOfPath); 348 float xOffset = 0.5f * (skewStart + totalSkew * (float)percentOfPath);
332 349
333 newLayer = m.Clone(); 350 // next apply twist rotation to the profile
334
335 Vertex vTemp = new Vertex(0.0f, 0.0f, 0.0f);
336
337 if (twistTotal != 0.0f || twistBot != 0.0f) 351 if (twistTotal != 0.0f || twistBot != 0.0f)
338 { 352 {
339 Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, -1.0f), twist); 353 Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, -1.0f), twist);
@@ -349,19 +363,22 @@ namespace OpenSim.Region.Physics.Meshing
349 } 363 }
350 } 364 }
351 365
366 // now orient the rotation of the profile relative to it's position on the path
352 Quaternion layerRot = new Quaternion(new Vertex(-1.0f, 0.0f, 0.0f), (float)angle); 367 Quaternion layerRot = new Quaternion(new Vertex(-1.0f, 0.0f, 0.0f), (float)angle);
353 foreach (Vertex v in newLayer.vertices) 368 foreach (Vertex v in newLayer.vertices)
354 { 369 {
355 if (v != null) 370 if (v != null)
356 { 371 {
357 vTemp = v * layerRot; 372 vTemp = v * layerRot;
358 v.X = xProfileScale * vTemp.X + xOffset; 373 //v.X = xProfileScale * vTemp.X + xOffset;
359 v.Y = yProfileScale * vTemp.Y + yOffset; 374 //v.Y = yProfileScale * vTemp.Y + yOffset;
375 v.X = vTemp.X + xOffset;
376 v.Y = vTemp.Y + yOffset;
360 v.Z = vTemp.Z + zOffset; 377 v.Z = vTemp.Z + zOffset;
361 } 378 }
362 } 379 }
363 380
364 if (angle == startAngle) // last layer, invert normals 381 if (angle == startAngle) // the first layer, invert normals
365 foreach (Triangle t in newLayer.triangles) 382 foreach (Triangle t in newLayer.triangles)
366 { 383 {
367 t.invertNormal(); 384 t.invertNormal();
@@ -407,7 +424,7 @@ namespace OpenSim.Region.Physics.Meshing
407 angle = endAngle; 424 angle = endAngle;
408 } 425 }
409 426
410 } while (!done); 427 } while (!done); // loop until all the layers in the path are completed
411 428
412 // scale the mesh to the desired size 429 // scale the mesh to the desired size
413 float xScale = size.X; 430 float xScale = size.X;
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index a716d93..0c62447 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -1541,7 +1541,7 @@ namespace OpenSim.Region.Physics.Meshing
1541 } 1541 }
1542 else 1542 else
1543 { 1543 {
1544 holeHull = BuildHoleHull(primShape, primShape.ProfileShape, primShape.HollowShape, hollowFactor); 1544 holeHull = BuildHoleHull(primShape, primShape.ProfileShape, hollowShape, hollowFactor);
1545 } 1545 }
1546 1546
1547 if (holeHull != null) 1547 if (holeHull != null)
@@ -1900,6 +1900,8 @@ namespace OpenSim.Region.Physics.Meshing
1900 private static void reportPrimParams(string name, PrimitiveBaseShape primShape) 1900 private static void reportPrimParams(string name, PrimitiveBaseShape primShape)
1901 { 1901 {
1902#if SPAM 1902#if SPAM
1903 float pathShearX = primShape.PathShearX < 128 ? (float)primShape.PathShearX * 0.01f : (float)(primShape.PathShearX - 256) * 0.01f;
1904 float pathShearY = primShape.PathShearY < 128 ? (float)primShape.PathShearY * 0.01f : (float)(primShape.PathShearY - 256) * 0.01f;
1903 1905
1904 Console.WriteLine("********************* PrimitiveBaseShape Parameters *******************\n" 1906 Console.WriteLine("********************* PrimitiveBaseShape Parameters *******************\n"
1905 + "Name.............: " + name.ToString() + "\n" 1907 + "Name.............: " + name.ToString() + "\n"
@@ -1911,8 +1913,8 @@ namespace OpenSim.Region.Physics.Meshing
1911 + "PathRevolutions..: " + primShape.PathRevolutions.ToString() + "\n" 1913 + "PathRevolutions..: " + primShape.PathRevolutions.ToString() + "\n"
1912 + "PathScaleX.......: " + primShape.PathScaleX.ToString() + "\n" 1914 + "PathScaleX.......: " + primShape.PathScaleX.ToString() + "\n"
1913 + "PathScaleY.......: " + primShape.PathScaleY.ToString() + "\n" 1915 + "PathScaleY.......: " + primShape.PathScaleY.ToString() + "\n"
1914 + "PathShearX.......: " + primShape.PathShearX.ToString() + "\n" 1916 + "PathShearX.......: " + primShape.PathShearX.ToString() + " (" + pathShearX.ToString() + ")\n"
1915 + "PathShearY.......: " + primShape.PathShearY.ToString() + "\n" 1917 + "PathShearY.......: " + primShape.PathShearY.ToString() + " (" + pathShearY.ToString() + ")\n"
1916 + "PathSkew.........: " + primShape.PathSkew.ToString() + "\n" 1918 + "PathSkew.........: " + primShape.PathSkew.ToString() + "\n"
1917 + "PathTaperX.......: " + primShape.PathTaperX.ToString() + "\n" 1919 + "PathTaperX.......: " + primShape.PathTaperX.ToString() + "\n"
1918 + "PathTaperY.......: " + primShape.PathTaperY.ToString() + "\n" 1920 + "PathTaperY.......: " + primShape.PathTaperY.ToString() + "\n"