aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Meshing
diff options
context:
space:
mode:
authorTeravus Ovares2008-06-04 10:57:05 +0000
committerTeravus Ovares2008-06-04 10:57:05 +0000
commit99e7a2a3809716f12a3152c1f328e99946004594 (patch)
tree1ba9d0c53358e7b71674b19c64b268cf03d7b3cb /OpenSim/Region/Physics/Meshing
parentFormatting cleanup, minor refactoring, svn properties. (diff)
downloadopensim-SC_OLD-99e7a2a3809716f12a3152c1f328e99946004594.zip
opensim-SC_OLD-99e7a2a3809716f12a3152c1f328e99946004594.tar.gz
opensim-SC_OLD-99e7a2a3809716f12a3152c1f328e99946004594.tar.bz2
opensim-SC_OLD-99e7a2a3809716f12a3152c1f328e99946004594.tar.xz
* From Dahlia
* Committing : 0001449: Patch implements X and Y Top Shear parameters for torus prim physical mesh generation (PATCH attached) * The included patch implements the X and Y Top Shear parameter adjustments to the mesh generator for the torus prim physical mesh. These are approximations as I was unable to determine their exact function but they appear to generate meshes which quite closely duplicate their counterparts in the viewer. * Thanks Dahlia!!!!
Diffstat (limited to 'OpenSim/Region/Physics/Meshing')
-rw-r--r--OpenSim/Region/Physics/Meshing/Extruder.cs57
1 files changed, 36 insertions, 21 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Extruder.cs b/OpenSim/Region/Physics/Meshing/Extruder.cs
index 3941107..880a23a 100644
--- a/OpenSim/Region/Physics/Meshing/Extruder.cs
+++ b/OpenSim/Region/Physics/Meshing/Extruder.cs
@@ -255,7 +255,6 @@ namespace OpenSim.Region.Physics.Meshing
255 Mesh newLayer; 255 Mesh newLayer;
256 Mesh lastLayer = null; 256 Mesh lastLayer = null;
257 257
258 //int start = 0;
259 int step; 258 int step;
260 int steps = 24; 259 int steps = 24;
261 260
@@ -274,8 +273,17 @@ namespace OpenSim.Region.Physics.Meshing
274 float totalSkew = skew * 2.0f * pathLength; 273 float totalSkew = skew * 2.0f * pathLength;
275 float skewStart = (-skew) + pathCutBegin * 2.0f * skew; 274 float skewStart = (-skew) + pathCutBegin * 2.0f * skew;
276 275
277 float startAngle = (float)(System.Math.PI * 2.0 * pathCutBegin * revolutions); 276 // It's not quite clear what pushY (Y top shear) does, but subtracting it from the start and end
278 float endAngle = (float)(System.Math.PI * 2.0 * pathCutEnd * revolutions); 277 // angles appears to approximate it's effects on path cut. Likewise, adding it to the angle used
278 // to calculate the sine for generating the path radius appears to approximate it's effects there
279 // too, but there are some subtle differences in the radius which are noticeable as the prim size
280 // increases and it may affect megaprims quite a bit. The effect of the Y top shear parameter on
281 // the meshes generated with this technique appear nearly identical in shape to the same prims when
282 // displayed by the viewer.
283
284
285 float startAngle = (float)(System.Math.PI * 2.0 * pathCutBegin * revolutions) - pushY * 0.9f;
286 float endAngle = (float)(System.Math.PI * 2.0 * pathCutEnd * revolutions) - pushY * 0.9f;
279 float stepSize = (float)0.2617993878; // 2*PI / 24 segments per revolution 287 float stepSize = (float)0.2617993878; // 2*PI / 24 segments per revolution
280 288
281 step = (int)(startAngle / stepSize); 289 step = (int)(startAngle / stepSize);
@@ -284,6 +292,7 @@ namespace OpenSim.Region.Physics.Meshing
284 float xProfileScale = 1.0f; 292 float xProfileScale = 1.0f;
285 float yProfileScale = 1.0f; 293 float yProfileScale = 1.0f;
286 294
295
287#if SPAM 296#if SPAM
288 System.Console.WriteLine("Extruder: twistTop: " + twistTop.ToString() + " twistbot: " + twistBot.ToString() + " twisttotal: " + twistTotal.ToString()); 297 System.Console.WriteLine("Extruder: twistTop: " + twistTop.ToString() + " twistbot: " + twistBot.ToString() + " twisttotal: " + twistTotal.ToString());
289 System.Console.WriteLine("Extruder: startAngle: " + startAngle.ToString() + " endAngle: " + endAngle.ToString() + " step: " + step.ToString()); 298 System.Console.WriteLine("Extruder: startAngle: " + startAngle.ToString() + " endAngle: " + endAngle.ToString() + " step: " + step.ToString());
@@ -346,35 +355,41 @@ namespace OpenSim.Region.Physics.Meshing
346 355
347 float twist = twistBot + (twistTotal * (float)percentOfPath); 356 float twist = twistBot + (twistTotal * (float)percentOfPath);
348 357
349 float zOffset = (float)(System.Math.Sin(angle) * (0.5f - yPathScale)) * radiusScale; 358 float xOffset;
350 float yOffset = (float)(System.Math.Cos(angle) * (0.5f - yPathScale)) * radiusScale; 359 float yOffset;
351 float xOffset = 0.5f * (skewStart + totalSkew * (float)percentOfPath); 360 float zOffset;
352 361
353 // next apply twist rotation to the profile 362
354 if (twistTotal != 0.0f || twistBot != 0.0f) 363 xOffset = 0.5f * (skewStart + totalSkew * (float)percentOfPath);
355 { 364 xOffset += (float) System.Math.Sin(angle) * pushX * 0.45f;
356 Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, -1.0f), twist); 365 yOffset = (float)(System.Math.Cos(angle) * (0.5f - yPathScale)) * radiusScale;
357 foreach (Vertex v in newLayer.vertices) 366 zOffset = (float)(System.Math.Sin(angle + pushY * 0.9f) * (0.5f - yPathScale)) * radiusScale;
367
368
369 // next apply twist rotation to the profile layer
370 if (twistTotal != 0.0f || twistBot != 0.0f)
358 { 371 {
359 if (v != null) 372 Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, -1.0f), twist);
373 foreach (Vertex v in newLayer.vertices)
360 { 374 {
361 vTemp = v * profileRot; 375 if (v != null)
362 v.X = vTemp.X; 376 {
363 v.Y = vTemp.Y; 377 vTemp = v * profileRot;
364 v.Z = vTemp.Z; 378 v.X = vTemp.X;
379 v.Y = vTemp.Y;
380 v.Z = vTemp.Z;
381 }
365 } 382 }
366 } 383 }
367 }
368 384
369 // now orient the rotation of the profile relative to it's position on the path 385 // now orient the rotation of the profile layer relative to it's position on the path
370 Quaternion layerRot = new Quaternion(new Vertex(-1.0f, 0.0f, 0.0f), (float)angle); 386 // adding pushY to the angle used to generate the quat appears to approximate the viewer
387 Quaternion layerRot = new Quaternion(new Vertex(-1.0f, 0.0f, 0.0f), (float)angle + pushY * 0.9f);
371 foreach (Vertex v in newLayer.vertices) 388 foreach (Vertex v in newLayer.vertices)
372 { 389 {
373 if (v != null) 390 if (v != null)
374 { 391 {
375 vTemp = v * layerRot; 392 vTemp = v * layerRot;
376 //v.X = xProfileScale * vTemp.X + xOffset;
377 //v.Y = yProfileScale * vTemp.Y + yOffset;
378 v.X = vTemp.X + xOffset; 393 v.X = vTemp.X + xOffset;
379 v.Y = vTemp.Y + yOffset; 394 v.Y = vTemp.Y + yOffset;
380 v.Z = vTemp.Z + zOffset; 395 v.Z = vTemp.Z + zOffset;