aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorTeravus Ovares2008-02-08 11:32:56 +0000
committerTeravus Ovares2008-02-08 11:32:56 +0000
commit50acb8e634cfb85c6e6c76e72b99bea459bfe746 (patch)
tree0235c28e7dbb600a48295efd68bfb1ce43941444 /OpenSim/Region
parent* Fix: Send Parcel data on region crossing. (diff)
downloadopensim-SC_OLD-50acb8e634cfb85c6e6c76e72b99bea459bfe746.zip
opensim-SC_OLD-50acb8e634cfb85c6e6c76e72b99bea459bfe746.tar.gz
opensim-SC_OLD-50acb8e634cfb85c6e6c76e72b99bea459bfe746.tar.bz2
opensim-SC_OLD-50acb8e634cfb85c6e6c76e72b99bea459bfe746.tar.xz
* This update adds limited support for Cylinder meshed prim in the Meshmerizer plugin. (Limited because path cut is wrongly offset and while Hollowing works, you can walk through the inside wall.)
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs298
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs12
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs3
3 files changed, 312 insertions, 1 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index d4c9926..e9997a0 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Physics.Meshing
58 // Setting baseDir to a path will enable the dumping of raw files 58 // Setting baseDir to a path will enable the dumping of raw files
59 // raw files can be imported by blender so a visual inspection of the results can be done 59 // raw files can be imported by blender so a visual inspection of the results can be done
60 // const string baseDir = "rawFiles"; 60 // const string baseDir = "rawFiles";
61 private const string baseDir = null; 61 private const string baseDir = "rawFiles";
62 62
63 private static void IntersectionParameterPD(PhysicsVector p1, PhysicsVector r1, PhysicsVector p2, 63 private static void IntersectionParameterPD(PhysicsVector p1, PhysicsVector r1, PhysicsVector p2,
64 PhysicsVector r2, ref float lambda, ref float mu) 64 PhysicsVector r2, ref float lambda, ref float mu)
@@ -302,7 +302,296 @@ namespace OpenSim.Region.Physics.Meshing
302 result.DumpRaw(baseDir, primName, "Z extruded"); 302 result.DumpRaw(baseDir, primName, "Z extruded");
303 return result; 303 return result;
304 } 304 }
305 private static Mesh CreateCyllinderMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size)
306 // Builds the z (+ and -) surfaces of a box shaped prim
307 {
308 UInt16 hollowFactor = primShape.ProfileHollow;
309 UInt16 profileBegin = primShape.ProfileBegin;
310 UInt16 profileEnd = primShape.ProfileEnd;
311
312 // Procedure: This is based on the fact that the upper (plus) and lower (minus) Z-surface
313 // of a block are basically the same
314 // They may be warped differently but the shape is identical
315 // So we only create one surface as a model and derive both plus and minus surface of the block from it
316 // This is done in a model space where the block spans from -.5 to +.5 in X and Y
317 // The mapping to Scene space is done later during the "extrusion" phase
318
319 // Base
320 // Q1Q15 = Quadrant 1, Quadrant1, Vertex 5
321 Vertex Q1Q15 = new Vertex(-0.35f, -0.35f, 0.0f);
322 Vertex Q1Q16 = new Vertex(-0.30f, -0.40f, 0.0f);
323 Vertex Q1Q17 = new Vertex(-0.24f, -0.43f, 0.0f);
324 Vertex Q1Q18 = new Vertex(-0.18f, -0.46f, 0.0f);
325 Vertex Q1Q19 = new Vertex(-0.11f, -0.48f, 0.0f);
326
327 Vertex Q2Q10 = new Vertex(+0.0f, -0.50f, 0.0f);
328 Vertex Q2Q11 = new Vertex(+0.11f, -0.48f, 0.0f);
329 Vertex Q2Q12 = new Vertex(+0.18f, -0.46f, 0.0f);
330 Vertex Q2Q13 = new Vertex(+0.24f, -0.43f, 0.0f);
331 Vertex Q2Q14 = new Vertex(+0.30f, -0.40f, 0.0f);
332 Vertex Q2Q15 = new Vertex(+0.35f, -0.35f, 0.0f);
333 Vertex Q2Q16 = new Vertex(+0.40f, -0.30f, 0.0f);
334 Vertex Q2Q17 = new Vertex(+0.43f, -0.24f, 0.0f);
335 Vertex Q2Q18 = new Vertex(+0.46f, -0.18f, 0.0f);
336 Vertex Q2Q19 = new Vertex(+0.48f, -0.11f, 0.0f);
337
338 Vertex Q2Q20 = new Vertex(+0.50f, +0.0f, 0.0f);
339 Vertex Q2Q21 = new Vertex(+0.48f, +0.11f, 0.0f);
340 Vertex Q2Q22 = new Vertex(+0.46f, +0.18f, 0.0f);
341 Vertex Q2Q23 = new Vertex(+0.43f, +0.24f, 0.0f);
342 Vertex Q2Q24 = new Vertex(+0.40f, +0.30f, 0.0f);
343 Vertex Q2Q25 = new Vertex(+0.35f, +0.35f, 0.0f);
344 Vertex Q2Q26 = new Vertex(+0.30f, +0.40f, 0.0f);
345 Vertex Q2Q27 = new Vertex(+0.24f, +0.43f, 0.0f);
346 Vertex Q2Q28 = new Vertex(+0.18f, +0.46f, 0.0f);
347 Vertex Q2Q29 = new Vertex(+0.11f, +0.48f, 0.0f);
348
349 Vertex Q1Q20 = new Vertex(+0.0f, +0.50f, 0.0f);
350 Vertex Q1Q21 = new Vertex(-0.11f, +0.48f, 0.0f);
351 Vertex Q1Q22 = new Vertex(-0.18f, +0.46f, 0.0f);
352 Vertex Q1Q23 = new Vertex(-0.24f, +0.43f, 0.0f);
353 Vertex Q1Q24 = new Vertex(-0.30f, +0.40f, 0.0f);
354 Vertex Q1Q25 = new Vertex(-0.35f, +0.35f, 0.0f);
355 Vertex Q1Q26 = new Vertex(-0.40f, +0.30f, 0.0f);
356 Vertex Q1Q27 = new Vertex(-0.43f, +0.24f, 0.0f);
357 Vertex Q1Q28 = new Vertex(-0.46f, +0.18f, 0.0f);
358 Vertex Q1Q29 = new Vertex(-0.48f, +0.11f, 0.0f);
359
360 Vertex Q1Q10 = new Vertex(-0.50f, +0.0f, 0.0f);
361 Vertex Q1Q11 = new Vertex(-0.48f, -0.11f, 0.0f);
362 Vertex Q1Q12 = new Vertex(-0.46f, -0.18f, 0.0f);
363 Vertex Q1Q13 = new Vertex(-0.43f, -0.24f, 0.0f);
364 Vertex Q1Q14 = new Vertex(-0.40f, -0.30f, 0.0f);
365
366
367 SimpleHull outerHull = new SimpleHull();
368 outerHull.AddVertex(Q1Q15);
369 outerHull.AddVertex(Q1Q16);
370 outerHull.AddVertex(Q1Q17);
371 outerHull.AddVertex(Q1Q18);
372 outerHull.AddVertex(Q1Q19);
373
374 outerHull.AddVertex(Q2Q10);
375 outerHull.AddVertex(Q2Q11);
376 outerHull.AddVertex(Q2Q12);
377 outerHull.AddVertex(Q2Q13);
378 outerHull.AddVertex(Q2Q14);
379 outerHull.AddVertex(Q2Q15);
380 outerHull.AddVertex(Q2Q16);
381 outerHull.AddVertex(Q2Q17);
382 outerHull.AddVertex(Q2Q18);
383 outerHull.AddVertex(Q2Q19);
384
385 outerHull.AddVertex(Q2Q20);
386 outerHull.AddVertex(Q2Q21);
387 outerHull.AddVertex(Q2Q22);
388 outerHull.AddVertex(Q2Q23);
389 outerHull.AddVertex(Q2Q24);
390 outerHull.AddVertex(Q2Q25);
391 outerHull.AddVertex(Q2Q26);
392 outerHull.AddVertex(Q2Q27);
393 outerHull.AddVertex(Q2Q28);
394 outerHull.AddVertex(Q2Q29);
395
396 outerHull.AddVertex(Q1Q20);
397 outerHull.AddVertex(Q1Q21);
398 outerHull.AddVertex(Q1Q22);
399 outerHull.AddVertex(Q1Q23);
400 outerHull.AddVertex(Q1Q24);
401 outerHull.AddVertex(Q1Q25);
402 outerHull.AddVertex(Q1Q26);
403 outerHull.AddVertex(Q1Q27);
404 outerHull.AddVertex(Q1Q28);
405 outerHull.AddVertex(Q1Q29);
406
407 outerHull.AddVertex(Q1Q10);
408 outerHull.AddVertex(Q1Q11);
409 outerHull.AddVertex(Q1Q12);
410 outerHull.AddVertex(Q1Q13);
411 outerHull.AddVertex(Q1Q14);
412
413 // Deal with cuts now
414 if ((profileBegin != 0) || (profileEnd != 0))
415 {
416 double fProfileBeginAngle = profileBegin / 50000.0 * 360.0;
417 // In degree, for easier debugging and understanding
418 fProfileBeginAngle -= (90.0 + 45.0); // for some reasons, the SL client counts from the corner -X/-Y
419 double fProfileEndAngle = 360.0 - profileEnd / 50000.0 * 360.0; // Pathend comes as complement to 1.0
420 fProfileEndAngle -= (90.0 + 45.0);
421 if (fProfileBeginAngle < fProfileEndAngle)
422 fProfileEndAngle -= 360.0;
423
424 // Note, that we don't want to cut out a triangle, even if this is a
425 // good approximation for small cuts. Indeed we want to cut out an arc
426 // and we approximate this arc by a polygon chain
427 // Also note, that these vectors are of length 1.0 and thus their endpoints lay outside the model space
428 // So it can easily be subtracted from the outer hull
429 int iSteps = (int)(((fProfileBeginAngle - fProfileEndAngle) / 45.0) + .5);
430 // how many steps do we need with approximately 45 degree
431 double dStepWidth = (fProfileBeginAngle - fProfileEndAngle) / iSteps;
432
433 Vertex origin = new Vertex(0.0f, 0.0f, 0.0f);
434
435 // Note the sequence of vertices here. It's important to have the other rotational sense than in outerHull
436 SimpleHull cutHull = new SimpleHull();
437 cutHull.AddVertex(origin);
438 for (int i = 0; i < iSteps; i++)
439 {
440 double angle = fProfileBeginAngle - i * dStepWidth; // we count against the angle orientation!!!!
441 Vertex v = Vertex.FromAngle(angle * Math.PI / 180.0);
442 cutHull.AddVertex(v);
443 }
444 Vertex legEnd = Vertex.FromAngle(fProfileEndAngle * Math.PI / 180.0);
445 // Calculated separately to avoid errors
446 cutHull.AddVertex(legEnd);
447
448 m_log.Debug(String.Format("Starting cutting of the hollow shape from the prim {1}", 0, primName));
449 SimpleHull cuttedHull = SimpleHull.SubtractHull(outerHull, cutHull);
450
451 outerHull = cuttedHull;
452 }
453
454 // Deal with the hole here
455 if (hollowFactor > 0)
456 {
457 float hollowFactorF = (float)hollowFactor / (float)50000;
458
459 Vertex IQ1Q15 = new Vertex(-0.35f * hollowFactorF, -0.35f * hollowFactorF, 0.0f);
460 Vertex IQ1Q16 = new Vertex(-0.30f * hollowFactorF, -0.40f * hollowFactorF, 0.0f);
461 Vertex IQ1Q17 = new Vertex(-0.24f * hollowFactorF, -0.43f * hollowFactorF, 0.0f);
462 Vertex IQ1Q18 = new Vertex(-0.18f * hollowFactorF, -0.46f * hollowFactorF, 0.0f);
463 Vertex IQ1Q19 = new Vertex(-0.11f * hollowFactorF, -0.48f * hollowFactorF, 0.0f);
464
465 Vertex IQ2Q10 = new Vertex(+0.0f * hollowFactorF, -0.50f * hollowFactorF, 0.0f);
466 Vertex IQ2Q11 = new Vertex(+0.11f * hollowFactorF, -0.48f * hollowFactorF, 0.0f);
467 Vertex IQ2Q12 = new Vertex(+0.18f * hollowFactorF, -0.46f * hollowFactorF, 0.0f);
468 Vertex IQ2Q13 = new Vertex(+0.24f * hollowFactorF, -0.43f * hollowFactorF, 0.0f);
469 Vertex IQ2Q14 = new Vertex(+0.30f * hollowFactorF, -0.40f * hollowFactorF, 0.0f);
470 Vertex IQ2Q15 = new Vertex(+0.35f * hollowFactorF, -0.35f * hollowFactorF, 0.0f);
471 Vertex IQ2Q16 = new Vertex(+0.40f * hollowFactorF, -0.30f * hollowFactorF, 0.0f);
472 Vertex IQ2Q17 = new Vertex(+0.43f * hollowFactorF, -0.24f * hollowFactorF, 0.0f);
473 Vertex IQ2Q18 = new Vertex(+0.46f * hollowFactorF, -0.18f * hollowFactorF, 0.0f);
474 Vertex IQ2Q19 = new Vertex(+0.48f * hollowFactorF, -0.11f * hollowFactorF, 0.0f);
475
476 Vertex IQ2Q20 = new Vertex(+0.50f * hollowFactorF, +0.0f * hollowFactorF, 0.0f);
477 Vertex IQ2Q21 = new Vertex(+0.48f * hollowFactorF, +0.11f * hollowFactorF, 0.0f);
478 Vertex IQ2Q22 = new Vertex(+0.46f * hollowFactorF, +0.18f * hollowFactorF, 0.0f);
479 Vertex IQ2Q23 = new Vertex(+0.43f * hollowFactorF, +0.24f * hollowFactorF, 0.0f);
480 Vertex IQ2Q24 = new Vertex(+0.40f * hollowFactorF, +0.30f * hollowFactorF, 0.0f);
481 Vertex IQ2Q25 = new Vertex(+0.35f * hollowFactorF, +0.35f * hollowFactorF, 0.0f);
482 Vertex IQ2Q26 = new Vertex(+0.30f * hollowFactorF, +0.40f * hollowFactorF, 0.0f);
483 Vertex IQ2Q27 = new Vertex(+0.24f * hollowFactorF, +0.43f * hollowFactorF, 0.0f);
484 Vertex IQ2Q28 = new Vertex(+0.18f * hollowFactorF, +0.46f * hollowFactorF, 0.0f);
485 Vertex IQ2Q29 = new Vertex(+0.11f * hollowFactorF, +0.48f * hollowFactorF, 0.0f);
486
487 Vertex IQ1Q20 = new Vertex(+0.0f * hollowFactorF, +0.50f * hollowFactorF, 0.0f);
488 Vertex IQ1Q21 = new Vertex(-0.11f * hollowFactorF, +0.48f * hollowFactorF, 0.0f);
489 Vertex IQ1Q22 = new Vertex(-0.18f * hollowFactorF, +0.46f * hollowFactorF, 0.0f);
490 Vertex IQ1Q23 = new Vertex(-0.24f * hollowFactorF, +0.43f * hollowFactorF, 0.0f);
491 Vertex IQ1Q24 = new Vertex(-0.30f * hollowFactorF, +0.40f * hollowFactorF, 0.0f);
492 Vertex IQ1Q25 = new Vertex(-0.35f * hollowFactorF, +0.35f * hollowFactorF, 0.0f);
493 Vertex IQ1Q26 = new Vertex(-0.40f * hollowFactorF, +0.30f * hollowFactorF, 0.0f);
494 Vertex IQ1Q27 = new Vertex(-0.43f * hollowFactorF, +0.24f * hollowFactorF, 0.0f);
495 Vertex IQ1Q28 = new Vertex(-0.46f * hollowFactorF, +0.18f * hollowFactorF, 0.0f);
496 Vertex IQ1Q29 = new Vertex(-0.48f * hollowFactorF, +0.11f * hollowFactorF, 0.0f);
497
498 Vertex IQ1Q10 = new Vertex(-0.50f * hollowFactorF, +0.0f * hollowFactorF, 0.0f);
499 Vertex IQ1Q11 = new Vertex(-0.48f * hollowFactorF, -0.11f * hollowFactorF, 0.0f);
500 Vertex IQ1Q12 = new Vertex(-0.46f * hollowFactorF, -0.18f * hollowFactorF, 0.0f);
501 Vertex IQ1Q13 = new Vertex(-0.43f * hollowFactorF, -0.24f * hollowFactorF, 0.0f);
502 Vertex IQ1Q14 = new Vertex(-0.40f * hollowFactorF, -0.30f * hollowFactorF, 0.0f);
305 503
504 SimpleHull holeHull = new SimpleHull();
505 holeHull.AddVertex(Q1Q15);
506 holeHull.AddVertex(Q1Q16);
507 holeHull.AddVertex(Q1Q17);
508 holeHull.AddVertex(Q1Q18);
509 holeHull.AddVertex(Q1Q19);
510
511 holeHull.AddVertex(IQ2Q10);
512 holeHull.AddVertex(IQ2Q11);
513 holeHull.AddVertex(IQ2Q12);
514 holeHull.AddVertex(IQ2Q13);
515 holeHull.AddVertex(IQ2Q14);
516 holeHull.AddVertex(IQ2Q15);
517 holeHull.AddVertex(IQ2Q16);
518 holeHull.AddVertex(IQ2Q17);
519 holeHull.AddVertex(IQ2Q18);
520 holeHull.AddVertex(IQ2Q19);
521
522 holeHull.AddVertex(IQ2Q20);
523 holeHull.AddVertex(IQ2Q21);
524 holeHull.AddVertex(IQ2Q22);
525 holeHull.AddVertex(IQ2Q23);
526 holeHull.AddVertex(IQ2Q24);
527 holeHull.AddVertex(IQ2Q25);
528 holeHull.AddVertex(IQ2Q26);
529 holeHull.AddVertex(IQ2Q27);
530 holeHull.AddVertex(IQ2Q28);
531 holeHull.AddVertex(IQ2Q29);
532
533 holeHull.AddVertex(IQ1Q20);
534 holeHull.AddVertex(IQ1Q21);
535 holeHull.AddVertex(IQ1Q22);
536 holeHull.AddVertex(IQ1Q23);
537 holeHull.AddVertex(IQ1Q24);
538 holeHull.AddVertex(IQ1Q25);
539 holeHull.AddVertex(IQ1Q26);
540 holeHull.AddVertex(IQ1Q27);
541 holeHull.AddVertex(IQ1Q28);
542 holeHull.AddVertex(IQ1Q29);
543
544 holeHull.AddVertex(IQ1Q10);
545 holeHull.AddVertex(IQ1Q11);
546 holeHull.AddVertex(IQ1Q12);
547 holeHull.AddVertex(IQ1Q13);
548 holeHull.AddVertex(IQ1Q14);
549
550
551 SimpleHull hollowedHull = SimpleHull.SubtractHull(outerHull, holeHull);
552
553 outerHull = hollowedHull;
554 }
555
556 Mesh m = new Mesh();
557
558 Vertex Seed1 = new Vertex(0.0f, -10.0f, 0.0f);
559 Vertex Seed2 = new Vertex(-10.0f, 10.0f, 0.0f);
560 Vertex Seed3 = new Vertex(10.0f, 10.0f, 0.0f);
561
562 m.Add(Seed1);
563 m.Add(Seed2);
564 m.Add(Seed3);
565
566 m.Add(new Triangle(Seed1, Seed2, Seed3));
567 m.Add(outerHull.getVertices());
568
569 InsertVertices(m.vertices, 3, m.triangles);
570 m.DumpRaw(baseDir, primName, "Proto first Mesh");
571
572 m.Remove(Seed1);
573 m.Remove(Seed2);
574 m.Remove(Seed3);
575 m.DumpRaw(baseDir, primName, "Proto seeds removed");
576
577 m.RemoveTrianglesOutside(outerHull);
578 m.DumpRaw(baseDir, primName, "Proto outsides removed");
579
580 foreach (Triangle t in m.triangles)
581 {
582 PhysicsVector n = t.getNormal();
583 if (n.Z < 0.0)
584 t.invertNormal();
585 }
586
587 Extruder extr = new Extruder();
588
589 extr.size = size;
590
591 Mesh result = extr.Extrude(m);
592 result.DumpRaw(baseDir, primName, "Z extruded");
593 return result;
594 }
306 public static void CalcNormals(Mesh mesh) 595 public static void CalcNormals(Mesh mesh)
307 { 596 {
308 int iTriangles = mesh.triangles.Count; 597 int iTriangles = mesh.triangles.Count;
@@ -374,6 +663,13 @@ namespace OpenSim.Region.Physics.Meshing
374 mesh = CreateBoxMesh(primName, primShape, size); 663 mesh = CreateBoxMesh(primName, primShape, size);
375 CalcNormals(mesh); 664 CalcNormals(mesh);
376 break; 665 break;
666 case ProfileShape.Circle:
667 if (primShape.PathCurve == (byte)Extrusion.Straight)
668 {
669 mesh = CreateCyllinderMesh(primName, primShape, size);
670 CalcNormals(mesh);
671 }
672 break;
377 default: 673 default:
378 mesh = CreateBoxMesh(primName, primShape, size); 674 mesh = CreateBoxMesh(primName, primShape, size);
379 CalcNormals(mesh); 675 CalcNormals(mesh);
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 690e9d3..aa80a84 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -127,6 +127,18 @@ namespace OpenSim.Region.Physics.OdePlugin
127 m_targetSpace = _parent_scene.space; 127 m_targetSpace = _parent_scene.space;
128 } 128 }
129 m_primName = primName; 129 m_primName = primName;
130 if (mesh != null)
131 {
132 }
133 else
134 {
135 if (_parent_scene.needsMeshing(_pbs))
136 {
137 // Don't need to re-enable body.. it's done in SetMesh
138 mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size);
139 // createmesh returns null when it's a shape that isn't a cube.
140 }
141 }
130 142
131 lock (OdeScene.OdeLock) 143 lock (OdeScene.OdeLock)
132 { 144 {
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 9cf6d50..37b8fb9 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -1011,6 +1011,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1011 if ((pbs.ProfileBegin != 0) || pbs.ProfileEnd != 0) 1011 if ((pbs.ProfileBegin != 0) || pbs.ProfileEnd != 0)
1012 return true; 1012 return true;
1013 1013
1014 if (pbs.ProfileShape == ProfileShape.Circle && pbs.PathCurve == (byte)Extrusion.Straight)
1015 return true;
1016
1014 return false; 1017 return false;
1015 } 1018 }
1016 1019