diff options
author | Dahlia Trimble | 2008-10-10 09:00:52 +0000 |
---|---|---|
committer | Dahlia Trimble | 2008-10-10 09:00:52 +0000 |
commit | 726e0045d93a08a0f4ebb380b1dcc781c8da7da3 (patch) | |
tree | 6b34dc83144f854007761bdf53c73633ac41c6dd /OpenSim | |
parent | refactoring PrimMesher to add viewer compatable features and some code cleanup (diff) | |
download | opensim-SC-726e0045d93a08a0f4ebb380b1dcc781c8da7da3.zip opensim-SC-726e0045d93a08a0f4ebb380b1dcc781c8da7da3.tar.gz opensim-SC-726e0045d93a08a0f4ebb380b1dcc781c8da7da3.tar.bz2 opensim-SC-726e0045d93a08a0f4ebb380b1dcc781c8da7da3.tar.xz |
Some decrufting
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 274 |
1 files changed, 46 insertions, 228 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index b11efd8..8a43fa5 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs | |||
@@ -601,17 +601,14 @@ namespace OpenSim.Region.Physics.Meshing | |||
601 | 601 | ||
602 | if (pathShearX != 0) | 602 | if (pathShearX != 0) |
603 | { | 603 | { |
604 | //System.Console.WriteLine("pushX: " + pathShearX.ToString()); | ||
605 | if (pathShearX > 50) | 604 | if (pathShearX > 50) |
606 | { | 605 | { |
607 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 | 606 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 |
608 | extr.pushX = (((float)(256 - pathShearX) / 100) * -1f); | 607 | extr.pushX = (((float)(256 - pathShearX) / 100) * -1f); |
609 | //System.Console.WriteLine("pushX: " + extr.pushX); | ||
610 | } | 608 | } |
611 | else | 609 | else |
612 | { | 610 | { |
613 | extr.pushX = (float)pathShearX / 100; | 611 | extr.pushX = (float)pathShearX / 100; |
614 | //System.Console.WriteLine("pushX: " + extr.pushX); | ||
615 | } | 612 | } |
616 | } | 613 | } |
617 | 614 | ||
@@ -621,56 +618,18 @@ namespace OpenSim.Region.Physics.Meshing | |||
621 | { | 618 | { |
622 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 | 619 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 |
623 | extr.pushY = (((float)(256 - pathShearY) / 100) * -1f); | 620 | extr.pushY = (((float)(256 - pathShearY) / 100) * -1f); |
624 | //System.Console.WriteLine("pushY: " + extr.pushY); | ||
625 | } | 621 | } |
626 | else | 622 | else |
627 | { | 623 | { |
628 | extr.pushY = (float)pathShearY / 100; | 624 | extr.pushY = (float)pathShearY / 100; |
629 | //System.Console.WriteLine("pushY: " + extr.pushY); | ||
630 | } | 625 | } |
631 | } | 626 | } |
632 | 627 | ||
633 | //if (twistTop != 0) | ||
634 | //{ | ||
635 | // extr.twistTop = 180 * ((float)twistTop / 100); | ||
636 | // if (extr.twistTop > 0) | ||
637 | // { | ||
638 | // extr.twistTop = 360 - (-1 * extr.twistTop); | ||
639 | |||
640 | // } | ||
641 | |||
642 | |||
643 | // extr.twistTop = (float)(extr.twistTop * DEG_TO_RAD); | ||
644 | //} | ||
645 | |||
646 | //float twistMid = ((twistTop + twistBot) * 0.5f); | ||
647 | |||
648 | //if (twistMid != 0) | ||
649 | //{ | ||
650 | // extr.twistMid = 180 * ((float)twistMid / 100); | ||
651 | // if (extr.twistMid > 0) | ||
652 | // { | ||
653 | // extr.twistMid = 360 - (-1 * extr.twistMid); | ||
654 | // } | ||
655 | // extr.twistMid = (float)(extr.twistMid * DEG_TO_RAD); | ||
656 | //} | ||
657 | |||
658 | //if (twistBot != 0) | ||
659 | //{ | ||
660 | // extr.twistBot = 180 * ((float)twistBot / 100); | ||
661 | // if (extr.twistBot > 0) | ||
662 | // { | ||
663 | // extr.twistBot = 360 - (-1 * extr.twistBot); | ||
664 | // } | ||
665 | // extr.twistBot = (float)(extr.twistBot * DEG_TO_RAD); | ||
666 | //} | ||
667 | |||
668 | extr.twistTop = (float)primShape.PathTwist * (float)Math.PI * 0.01f; | 628 | extr.twistTop = (float)primShape.PathTwist * (float)Math.PI * 0.01f; |
669 | extr.twistBot = (float)primShape.PathTwistBegin * (float)Math.PI * 0.01f; | 629 | extr.twistBot = (float)primShape.PathTwistBegin * (float)Math.PI * 0.01f; |
670 | extr.pathBegin = primShape.PathBegin; | 630 | extr.pathBegin = primShape.PathBegin; |
671 | extr.pathEnd = primShape.PathEnd; | 631 | extr.pathEnd = primShape.PathEnd; |
672 | 632 | ||
673 | //Mesh result = extr.Extrude(m); | ||
674 | Mesh result = extr.ExtrudeLinearPath(m); | 633 | Mesh result = extr.ExtrudeLinearPath(m); |
675 | result.DumpRaw(baseDir, primName, "Z extruded"); | 634 | result.DumpRaw(baseDir, primName, "Z extruded"); |
676 | #if SPAM | 635 | #if SPAM |
@@ -695,8 +654,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
695 | UInt16 taperY = primShape.PathScaleY; | 654 | UInt16 taperY = primShape.PathScaleY; |
696 | UInt16 pathShearX = primShape.PathShearX; | 655 | UInt16 pathShearX = primShape.PathShearX; |
697 | UInt16 pathShearY = primShape.PathShearY; | 656 | UInt16 pathShearY = primShape.PathShearY; |
698 | // Int16 twistBot = primShape.PathTwist; | ||
699 | // Int16 twistTop = primShape.PathTwistBegin; | ||
700 | 657 | ||
701 | #if SPAM | 658 | #if SPAM |
702 | reportPrimParams("[CYLINDER] " + primName, primShape); | 659 | reportPrimParams("[CYLINDER] " + primName, primShape); |
@@ -748,9 +705,8 @@ namespace OpenSim.Region.Physics.Meshing | |||
748 | { | 705 | { |
749 | double fProfileBeginAngle = profileBegin / 50000.0 * 360.0; | 706 | double fProfileBeginAngle = profileBegin / 50000.0 * 360.0; |
750 | // In degree, for easier debugging and understanding | 707 | // In degree, for easier debugging and understanding |
751 | //fProfileBeginAngle -= (90.0 + 45.0); // for some reasons, the SL client counts from the corner -X/-Y | ||
752 | double fProfileEndAngle = 360.0 - profileEnd / 50000.0 * 360.0; // Pathend comes as complement to 1.0 | 708 | double fProfileEndAngle = 360.0 - profileEnd / 50000.0 * 360.0; // Pathend comes as complement to 1.0 |
753 | //fProfileEndAngle -= (90.0 + 45.0); | 709 | |
754 | #if SPAM | 710 | #if SPAM |
755 | Console.WriteLine("Extruder: Cylinder fProfileBeginAngle: " + fProfileBeginAngle.ToString() + " fProfileEndAngle: " + fProfileEndAngle.ToString()); | 711 | Console.WriteLine("Extruder: Cylinder fProfileBeginAngle: " + fProfileBeginAngle.ToString() + " fProfileEndAngle: " + fProfileEndAngle.ToString()); |
756 | #endif | 712 | #endif |
@@ -787,7 +743,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
787 | // Calculated separately to avoid errors | 743 | // Calculated separately to avoid errors |
788 | cutHull.AddVertex(legEnd); | 744 | cutHull.AddVertex(legEnd); |
789 | 745 | ||
790 | // m_log.DebugFormat("Starting cutting of the hollow shape from the prim {1}", 0, primName); | ||
791 | SimpleHull cuttedHull = SimpleHull.SubtractHull(outerHull, cutHull); | 746 | SimpleHull cuttedHull = SimpleHull.SubtractHull(outerHull, cutHull); |
792 | 747 | ||
793 | outerHull = cuttedHull; | 748 | outerHull = cuttedHull; |
@@ -843,20 +798,14 @@ namespace OpenSim.Region.Physics.Meshing | |||
843 | 798 | ||
844 | extr.size = size; | 799 | extr.size = size; |
845 | 800 | ||
846 | //System.Console.WriteLine("taperFactorX: " + taperX.ToString()); | ||
847 | //System.Console.WriteLine("taperFactorY: " + taperY.ToString()); | ||
848 | |||
849 | if (taperX != 100) | 801 | if (taperX != 100) |
850 | { | 802 | { |
851 | if (taperX > 100) | 803 | if (taperX > 100) |
852 | { | 804 | { |
853 | extr.taperTopFactorX = 1.0f - ((float)(taperX - 100) / 100); | 805 | extr.taperTopFactorX = 1.0f - ((float)(taperX - 100) / 100); } |
854 | //System.Console.WriteLine("taperTopFactorX: " + extr.taperTopFactorX.ToString()); | ||
855 | } | ||
856 | else | 806 | else |
857 | { | 807 | { |
858 | extr.taperBotFactorX = 1.0f - ((100 - (float)taperX) / 100); | 808 | extr.taperBotFactorX = 1.0f - ((100 - (float)taperX) / 100); |
859 | //System.Console.WriteLine("taperBotFactorX: " + extr.taperBotFactorX.ToString()); | ||
860 | } | 809 | } |
861 | 810 | ||
862 | } | 811 | } |
@@ -866,12 +815,10 @@ namespace OpenSim.Region.Physics.Meshing | |||
866 | if (taperY > 100) | 815 | if (taperY > 100) |
867 | { | 816 | { |
868 | extr.taperTopFactorY = 1.0f - ((float)(taperY - 100) / 100); | 817 | extr.taperTopFactorY = 1.0f - ((float)(taperY - 100) / 100); |
869 | // System.Console.WriteLine("taperTopFactorY: " + extr.taperTopFactorY.ToString()); | ||
870 | } | 818 | } |
871 | else | 819 | else |
872 | { | 820 | { |
873 | extr.taperBotFactorY = 1.0f - ((100 - (float)taperY) / 100); | 821 | extr.taperBotFactorY = 1.0f - ((100 - (float)taperY) / 100); |
874 | //System.Console.WriteLine("taperBotFactorY: " + extr.taperBotFactorY.ToString()); | ||
875 | } | 822 | } |
876 | } | 823 | } |
877 | 824 | ||
@@ -881,12 +828,10 @@ namespace OpenSim.Region.Physics.Meshing | |||
881 | { | 828 | { |
882 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 | 829 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 |
883 | extr.pushX = (((float)(256 - pathShearX) / 100) * -1f); | 830 | extr.pushX = (((float)(256 - pathShearX) / 100) * -1f); |
884 | //m_log.Warn("pushX: " + extr.pushX); | ||
885 | } | 831 | } |
886 | else | 832 | else |
887 | { | 833 | { |
888 | extr.pushX = (float)pathShearX / 100; | 834 | extr.pushX = (float)pathShearX / 100; |
889 | //m_log.Warn("pushX: " + extr.pushX); | ||
890 | } | 835 | } |
891 | } | 836 | } |
892 | 837 | ||
@@ -896,58 +841,19 @@ namespace OpenSim.Region.Physics.Meshing | |||
896 | { | 841 | { |
897 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 | 842 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 |
898 | extr.pushY = (((float)(256 - pathShearY) / 100) * -1f); | 843 | extr.pushY = (((float)(256 - pathShearY) / 100) * -1f); |
899 | //m_log.Warn("pushY: " + extr.pushY); | ||
900 | } | 844 | } |
901 | else | 845 | else |
902 | { | 846 | { |
903 | extr.pushY = (float)pathShearY / 100; | 847 | extr.pushY = (float)pathShearY / 100; |
904 | //m_log.Warn("pushY: " + extr.pushY); | ||
905 | } | 848 | } |
906 | 849 | ||
907 | } | 850 | } |
908 | 851 | ||
909 | //if (twistTop != 0) | ||
910 | //{ | ||
911 | // extr.twistTop = 180 * ((float)twistTop / 100); | ||
912 | // if (extr.twistTop > 0) | ||
913 | // { | ||
914 | // extr.twistTop = 360 - (-1 * extr.twistTop); | ||
915 | |||
916 | // } | ||
917 | |||
918 | |||
919 | // extr.twistTop = (float)(extr.twistTop * DEG_TO_RAD); | ||
920 | //} | ||
921 | |||
922 | //float twistMid = ((twistTop + twistBot) * 0.5f); | ||
923 | |||
924 | //if (twistMid != 0) | ||
925 | //{ | ||
926 | // extr.twistMid = 180 * ((float)twistMid / 100); | ||
927 | // if (extr.twistMid > 0) | ||
928 | // { | ||
929 | // extr.twistMid = 360 - (-1 * extr.twistMid); | ||
930 | // } | ||
931 | // extr.twistMid = (float)(extr.twistMid * DEG_TO_RAD); | ||
932 | //} | ||
933 | |||
934 | //if (twistBot != 0) | ||
935 | //{ | ||
936 | // extr.twistBot = 180 * ((float)twistBot / 100); | ||
937 | // if (extr.twistBot > 0) | ||
938 | // { | ||
939 | // extr.twistBot = 360 - (-1 * extr.twistBot); | ||
940 | // } | ||
941 | // extr.twistBot = (float)(extr.twistBot * DEG_TO_RAD); | ||
942 | //} | ||
943 | |||
944 | extr.twistTop = (float)primShape.PathTwist * (float)Math.PI * 0.01f; | 852 | extr.twistTop = (float)primShape.PathTwist * (float)Math.PI * 0.01f; |
945 | extr.twistBot = (float)primShape.PathTwistBegin * (float)Math.PI * 0.01f; | 853 | extr.twistBot = (float)primShape.PathTwistBegin * (float)Math.PI * 0.01f; |
946 | extr.pathBegin = primShape.PathBegin; | 854 | extr.pathBegin = primShape.PathBegin; |
947 | extr.pathEnd = primShape.PathEnd; | 855 | extr.pathEnd = primShape.PathEnd; |
948 | 856 | ||
949 | //System.Console.WriteLine("[MESH]: twistTop = " + twistTop.ToString() + "|" + extr.twistTop.ToString() + ", twistMid = " + twistMid.ToString() + "|" + extr.twistMid.ToString() + ", twistbot = " + twistBot.ToString() + "|" + extr.twistBot.ToString()); | ||
950 | //Mesh result = extr.Extrude(m); | ||
951 | Mesh result = extr.ExtrudeLinearPath(m); | 857 | Mesh result = extr.ExtrudeLinearPath(m); |
952 | result.DumpRaw(baseDir, primName, "Z extruded"); | 858 | result.DumpRaw(baseDir, primName, "Z extruded"); |
953 | #if SPAM | 859 | #if SPAM |
@@ -972,18 +878,10 @@ namespace OpenSim.Region.Physics.Meshing | |||
972 | UInt16 pathShearX = primShape.PathShearX; | 878 | UInt16 pathShearX = primShape.PathShearX; |
973 | UInt16 pathShearY = primShape.PathShearY; | 879 | UInt16 pathShearY = primShape.PathShearY; |
974 | 880 | ||
975 | // Int16 twistTop = primShape.PathTwistBegin; | ||
976 | // Int16 twistBot = primShape.PathTwist; | ||
977 | 881 | ||
978 | #if SPAM | 882 | #if SPAM |
979 | reportPrimParams("[PRISM] " + primName, primShape); | 883 | reportPrimParams("[PRISM] " + primName, primShape); |
980 | #endif | 884 | #endif |
981 | |||
982 | //m_log.Error("pathShear:" + primShape.PathShearX.ToString() + "," + primShape.PathShearY.ToString()); | ||
983 | //m_log.Error("pathTaper:" + primShape.PathTaperX.ToString() + "," + primShape.PathTaperY.ToString()); | ||
984 | //m_log.Error("ProfileBegin:" + primShape.ProfileBegin.ToString() + "," + primShape.ProfileBegin.ToString()); | ||
985 | //m_log.Error("PathScale:" + primShape.PathScaleX.ToString() + "," + primShape.PathScaleY.ToString()); | ||
986 | |||
987 | // Procedure: This is based on the fact that the upper (plus) and lower (minus) Z-surface | 885 | // Procedure: This is based on the fact that the upper (plus) and lower (minus) Z-surface |
988 | // of a block are basically the same | 886 | // of a block are basically the same |
989 | // They may be warped differently but the shape is identical | 887 | // They may be warped differently but the shape is identical |
@@ -1008,9 +906,8 @@ namespace OpenSim.Region.Physics.Meshing | |||
1008 | { | 906 | { |
1009 | double fProfileBeginAngle = profileBegin / 50000.0 * 360.0; | 907 | double fProfileBeginAngle = profileBegin / 50000.0 * 360.0; |
1010 | // In degree, for easier debugging and understanding | 908 | // In degree, for easier debugging and understanding |
1011 | //fProfileBeginAngle -= (90.0 + 45.0); // for some reasons, the SL client counts from the corner -X/-Y | ||
1012 | double fProfileEndAngle = 360.0 - profileEnd / 50000.0 * 360.0; // Pathend comes as complement to 1.0 | 909 | double fProfileEndAngle = 360.0 - profileEnd / 50000.0 * 360.0; // Pathend comes as complement to 1.0 |
1013 | //fProfileEndAngle -= (90.0 + 45.0); | 910 | |
1014 | if (fProfileBeginAngle < fProfileEndAngle) | 911 | if (fProfileBeginAngle < fProfileEndAngle) |
1015 | fProfileEndAngle -= 360.0; | 912 | fProfileEndAngle -= 360.0; |
1016 | 913 | ||
@@ -1038,7 +935,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
1038 | // Calculated separately to avoid errors | 935 | // Calculated separately to avoid errors |
1039 | cutHull.AddVertex(legEnd); | 936 | cutHull.AddVertex(legEnd); |
1040 | 937 | ||
1041 | //m_log.DebugFormat("Starting cutting of the hollow shape from the prim {1}", 0, primName); | ||
1042 | SimpleHull cuttedHull = SimpleHull.SubtractHull(outerHull, cutHull); | 938 | SimpleHull cuttedHull = SimpleHull.SubtractHull(outerHull, cutHull); |
1043 | 939 | ||
1044 | outerHull = cuttedHull; | 940 | outerHull = cuttedHull; |
@@ -1099,12 +995,10 @@ namespace OpenSim.Region.Physics.Meshing | |||
1099 | if (taperX > 100) | 995 | if (taperX > 100) |
1100 | { | 996 | { |
1101 | extr.taperTopFactorX = 1.0f - ((float)(taperX - 100) / 100); | 997 | extr.taperTopFactorX = 1.0f - ((float)(taperX - 100) / 100); |
1102 | //System.Console.WriteLine("taperTopFactorX: " + extr.taperTopFactorX.ToString()); | ||
1103 | } | 998 | } |
1104 | else | 999 | else |
1105 | { | 1000 | { |
1106 | extr.taperBotFactorX = 1.0f - ((100 - (float)taperX) / 100); | 1001 | extr.taperBotFactorX = 1.0f - ((100 - (float)taperX) / 100); |
1107 | //System.Console.WriteLine("taperBotFactorX: " + extr.taperBotFactorX.ToString()); | ||
1108 | } | 1002 | } |
1109 | 1003 | ||
1110 | } | 1004 | } |
@@ -1114,12 +1008,10 @@ namespace OpenSim.Region.Physics.Meshing | |||
1114 | if (taperY > 100) | 1008 | if (taperY > 100) |
1115 | { | 1009 | { |
1116 | extr.taperTopFactorY = 1.0f - ((float)(taperY - 100) / 100); | 1010 | extr.taperTopFactorY = 1.0f - ((float)(taperY - 100) / 100); |
1117 | // System.Console.WriteLine("taperTopFactorY: " + extr.taperTopFactorY.ToString()); | ||
1118 | } | 1011 | } |
1119 | else | 1012 | else |
1120 | { | 1013 | { |
1121 | extr.taperBotFactorY = 1.0f - ((100 - (float)taperY) / 100); | 1014 | extr.taperBotFactorY = 1.0f - ((100 - (float)taperY) / 100); |
1122 | //System.Console.WriteLine("taperBotFactorY: " + extr.taperBotFactorY.ToString()); | ||
1123 | } | 1015 | } |
1124 | } | 1016 | } |
1125 | 1017 | ||
@@ -1129,12 +1021,10 @@ namespace OpenSim.Region.Physics.Meshing | |||
1129 | { | 1021 | { |
1130 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 | 1022 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 |
1131 | extr.pushX = (((float)(256 - pathShearX) / 100) * -1f); | 1023 | extr.pushX = (((float)(256 - pathShearX) / 100) * -1f); |
1132 | // m_log.Warn("pushX: " + extr.pushX); | ||
1133 | } | 1024 | } |
1134 | else | 1025 | else |
1135 | { | 1026 | { |
1136 | extr.pushX = (float)pathShearX / 100; | 1027 | extr.pushX = (float)pathShearX / 100; |
1137 | // m_log.Warn("pushX: " + extr.pushX); | ||
1138 | } | 1028 | } |
1139 | } | 1029 | } |
1140 | 1030 | ||
@@ -1144,57 +1034,18 @@ namespace OpenSim.Region.Physics.Meshing | |||
1144 | { | 1034 | { |
1145 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 | 1035 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 |
1146 | extr.pushY = (((float)(256 - pathShearY) / 100) * -1f); | 1036 | extr.pushY = (((float)(256 - pathShearY) / 100) * -1f); |
1147 | //m_log.Warn("pushY: " + extr.pushY); | ||
1148 | } | 1037 | } |
1149 | else | 1038 | else |
1150 | { | 1039 | { |
1151 | extr.pushY = (float)pathShearY / 100; | 1040 | extr.pushY = (float)pathShearY / 100; |
1152 | //m_log.Warn("pushY: " + extr.pushY); | ||
1153 | } | 1041 | } |
1154 | } | 1042 | } |
1155 | 1043 | ||
1156 | //if (twistTop != 0) | ||
1157 | //{ | ||
1158 | // extr.twistTop = 180 * ((float)twistTop / 100); | ||
1159 | // if (extr.twistTop > 0) | ||
1160 | // { | ||
1161 | // extr.twistTop = 360 - (-1 * extr.twistTop); | ||
1162 | |||
1163 | // } | ||
1164 | |||
1165 | |||
1166 | // extr.twistTop = (float)(extr.twistTop * DEG_TO_RAD); | ||
1167 | //} | ||
1168 | |||
1169 | //float twistMid = ((twistTop + twistBot) * 0.5f); | ||
1170 | |||
1171 | //if (twistMid != 0) | ||
1172 | //{ | ||
1173 | // extr.twistMid = 180 * ((float)twistMid / 100); | ||
1174 | // if (extr.twistMid > 0) | ||
1175 | // { | ||
1176 | // extr.twistMid = 360 - (-1 * extr.twistMid); | ||
1177 | // } | ||
1178 | // extr.twistMid = (float)(extr.twistMid * DEG_TO_RAD); | ||
1179 | //} | ||
1180 | |||
1181 | //if (twistBot != 0) | ||
1182 | //{ | ||
1183 | // extr.twistBot = 180 * ((float)twistBot / 100); | ||
1184 | // if (extr.twistBot > 0) | ||
1185 | // { | ||
1186 | // extr.twistBot = 360 - (-1 * extr.twistBot); | ||
1187 | // } | ||
1188 | // extr.twistBot = (float)(extr.twistBot * DEG_TO_RAD); | ||
1189 | //} | ||
1190 | |||
1191 | extr.twistTop = (float)primShape.PathTwist * (float)Math.PI * 0.01f; | 1044 | extr.twistTop = (float)primShape.PathTwist * (float)Math.PI * 0.01f; |
1192 | extr.twistBot = (float)primShape.PathTwistBegin * (float)Math.PI * 0.01f; | 1045 | extr.twistBot = (float)primShape.PathTwistBegin * (float)Math.PI * 0.01f; |
1193 | extr.pathBegin = primShape.PathBegin; | 1046 | extr.pathBegin = primShape.PathBegin; |
1194 | extr.pathEnd = primShape.PathEnd; | 1047 | extr.pathEnd = primShape.PathEnd; |
1195 | 1048 | ||
1196 | //System.Console.WriteLine("[MESH]: twistTop = " + twistTop.ToString() + "|" + extr.twistTop.ToString() + ", twistMid = " + twistMid.ToString() + "|" + extr.twistMid.ToString() + ", twistbot = " + twistBot.ToString() + "|" + extr.twistBot.ToString()); | ||
1197 | //Mesh result = extr.Extrude(m); | ||
1198 | Mesh result = extr.ExtrudeLinearPath(m); | 1049 | Mesh result = extr.ExtrudeLinearPath(m); |
1199 | result.DumpRaw(baseDir, primName, "Z extruded"); | 1050 | result.DumpRaw(baseDir, primName, "Z extruded"); |
1200 | #if SPAM | 1051 | #if SPAM |
@@ -1227,13 +1078,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
1227 | 1078 | ||
1228 | // Still have more to do here. | 1079 | // Still have more to do here. |
1229 | 1080 | ||
1230 | // UInt16 hollowFactor = primShape.ProfileHollow; | ||
1231 | // UInt16 profileBegin = primShape.ProfileBegin; | ||
1232 | // UInt16 profileEnd = primShape.ProfileEnd; | ||
1233 | // UInt16 taperX = primShape.PathScaleX; | ||
1234 | // UInt16 taperY = primShape.PathScaleY; | ||
1235 | // UInt16 pathShearX = primShape.PathShearX; | ||
1236 | // UInt16 pathShearY = primShape.PathShearY; | ||
1237 | Mesh m = new Mesh(); | 1081 | Mesh m = new Mesh(); |
1238 | 1082 | ||
1239 | #if SPAM | 1083 | #if SPAM |
@@ -1356,12 +1200,8 @@ namespace OpenSim.Region.Physics.Meshing | |||
1356 | UInt16 hollowFactor = primShape.ProfileHollow; | 1200 | UInt16 hollowFactor = primShape.ProfileHollow; |
1357 | UInt16 profileBegin = primShape.ProfileBegin; | 1201 | UInt16 profileBegin = primShape.ProfileBegin; |
1358 | UInt16 profileEnd = primShape.ProfileEnd; | 1202 | UInt16 profileEnd = primShape.ProfileEnd; |
1359 | // UInt16 taperX = primShape.PathScaleX; | ||
1360 | // UInt16 taperY = primShape.PathScaleY; | ||
1361 | UInt16 pathShearX = primShape.PathShearX; | 1203 | UInt16 pathShearX = primShape.PathShearX; |
1362 | UInt16 pathShearY = primShape.PathShearY; | 1204 | UInt16 pathShearY = primShape.PathShearY; |
1363 | // Int16 twistBot = primShape.PathTwist; | ||
1364 | // Int16 twistTop = primShape.PathTwistBegin; | ||
1365 | HollowShape hollowShape = primShape.HollowShape; | 1205 | HollowShape hollowShape = primShape.HollowShape; |
1366 | 1206 | ||
1367 | #if SPAM | 1207 | #if SPAM |
@@ -1497,9 +1337,8 @@ namespace OpenSim.Region.Physics.Meshing | |||
1497 | { | 1337 | { |
1498 | double fProfileBeginAngle = profileBegin / 50000.0 * 360.0; | 1338 | double fProfileBeginAngle = profileBegin / 50000.0 * 360.0; |
1499 | // In degree, for easier debugging and understanding | 1339 | // In degree, for easier debugging and understanding |
1500 | //fProfileBeginAngle -= (90.0 + 45.0); // for some reasons, the SL client counts from the corner -X/-Y | ||
1501 | double fProfileEndAngle = 360.0 - profileEnd / 50000.0 * 360.0; // Pathend comes as complement to 1.0 | 1340 | double fProfileEndAngle = 360.0 - profileEnd / 50000.0 * 360.0; // Pathend comes as complement to 1.0 |
1502 | //fProfileEndAngle -= (90.0 + 45.0); | 1341 | |
1503 | if (fProfileBeginAngle < fProfileEndAngle) | 1342 | if (fProfileBeginAngle < fProfileEndAngle) |
1504 | fProfileEndAngle -= 360.0; | 1343 | fProfileEndAngle -= 360.0; |
1505 | 1344 | ||
@@ -1657,8 +1496,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
1657 | foreach (Triangle t in m.triangles) | 1496 | foreach (Triangle t in m.triangles) |
1658 | t.invertNormal(); | 1497 | t.invertNormal(); |
1659 | 1498 | ||
1660 | // Vertex vTemp = new Vertex(0.0f, 0.0f, 0.0f); | ||
1661 | |||
1662 | 1499 | ||
1663 | float skew = primShape.PathSkew * 0.01f; | 1500 | float skew = primShape.PathSkew * 0.01f; |
1664 | float pathScaleX = (float)(200 - primShape.PathScaleX) * 0.01f; | 1501 | float pathScaleX = (float)(200 - primShape.PathScaleX) * 0.01f; |
@@ -1677,7 +1514,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
1677 | { | 1514 | { |
1678 | v.X *= profileXComp; | 1515 | v.X *= profileXComp; |
1679 | v.Y *= pathScaleY; | 1516 | v.Y *= pathScaleY; |
1680 | //v.Y *= 0.5f; // torus profile is scaled in y axis | ||
1681 | } | 1517 | } |
1682 | 1518 | ||
1683 | Extruder extr = new Extruder(); | 1519 | Extruder extr = new Extruder(); |
@@ -1717,12 +1553,10 @@ namespace OpenSim.Region.Physics.Meshing | |||
1717 | { | 1553 | { |
1718 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 | 1554 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 |
1719 | extr.pushX = (((float)(256 - pathShearX) / 100) * -1f); | 1555 | extr.pushX = (((float)(256 - pathShearX) / 100) * -1f); |
1720 | //m_log.Warn("pushX: " + extr.pushX); | ||
1721 | } | 1556 | } |
1722 | else | 1557 | else |
1723 | { | 1558 | { |
1724 | extr.pushX = (float)pathShearX / 100; | 1559 | extr.pushX = (float)pathShearX / 100; |
1725 | //m_log.Warn("pushX: " + extr.pushX); | ||
1726 | } | 1560 | } |
1727 | } | 1561 | } |
1728 | 1562 | ||
@@ -1732,12 +1566,10 @@ namespace OpenSim.Region.Physics.Meshing | |||
1732 | { | 1566 | { |
1733 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 | 1567 | // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 |
1734 | extr.pushY = (((float)(256 - pathShearY) / 100) * -1f); | 1568 | extr.pushY = (((float)(256 - pathShearY) / 100) * -1f); |
1735 | //m_log.Warn("pushY: " + extr.pushY); | ||
1736 | } | 1569 | } |
1737 | else | 1570 | else |
1738 | { | 1571 | { |
1739 | extr.pushY = (float)pathShearY / 100; | 1572 | extr.pushY = (float)pathShearY / 100; |
1740 | //m_log.Warn("pushY: " + extr.pushY); | ||
1741 | } | 1573 | } |
1742 | 1574 | ||
1743 | } | 1575 | } |
@@ -1745,7 +1577,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
1745 | extr.twistTop = (float)primShape.PathTwist * (float)Math.PI * 0.02f; | 1577 | extr.twistTop = (float)primShape.PathTwist * (float)Math.PI * 0.02f; |
1746 | extr.twistBot = (float)primShape.PathTwistBegin * (float)Math.PI * 0.02f; | 1578 | extr.twistBot = (float)primShape.PathTwistBegin * (float)Math.PI * 0.02f; |
1747 | 1579 | ||
1748 | //System.Console.WriteLine("[MESH]: twistTop = " + twistTop.ToString() + "|" + extr.twistTop.ToString() + ", twistMid = " + twistMid.ToString() + "|" + extr.twistMid.ToString() + ", twistbot = " + twistBot.ToString() + "|" + extr.twistBot.ToString()); | ||
1749 | Mesh result = extr.ExtrudeCircularPath(m); | 1580 | Mesh result = extr.ExtrudeCircularPath(m); |
1750 | result.DumpRaw(baseDir, primName, "Z extruded"); | 1581 | result.DumpRaw(baseDir, primName, "Z extruded"); |
1751 | 1582 | ||
@@ -1764,66 +1595,62 @@ namespace OpenSim.Region.Physics.Meshing | |||
1764 | return result; | 1595 | return result; |
1765 | } | 1596 | } |
1766 | 1597 | ||
1767 | //public static void CalcNormals(Mesh mesh) | 1598 | public static void CalcNormals(Mesh mesh) |
1768 | //{ | 1599 | { |
1769 | // int iTriangles = mesh.triangles.Count; | 1600 | int iTriangles = mesh.triangles.Count; |
1770 | |||
1771 | // mesh.normals = new float[iTriangles*3]; | ||
1772 | 1601 | ||
1773 | // int i = 0; | 1602 | mesh.normals = new float[iTriangles * 3]; |
1774 | // foreach (Triangle t in mesh.triangles) | ||
1775 | // { | ||
1776 | // float ux, uy, uz; | ||
1777 | // float vx, vy, vz; | ||
1778 | // float wx, wy, wz; | ||
1779 | 1603 | ||
1780 | // ux = t.v1.X; | 1604 | int i = 0; |
1781 | // uy = t.v1.Y; | 1605 | foreach (Triangle t in mesh.triangles) |
1782 | // uz = t.v1.Z; | 1606 | { |
1607 | float ux, uy, uz; | ||
1608 | float vx, vy, vz; | ||
1609 | float wx, wy, wz; | ||
1783 | 1610 | ||
1784 | // vx = t.v2.X; | 1611 | ux = t.v1.X; |
1785 | // vy = t.v2.Y; | 1612 | uy = t.v1.Y; |
1786 | // vz = t.v2.Z; | 1613 | uz = t.v1.Z; |
1787 | 1614 | ||
1788 | // wx = t.v3.X; | 1615 | vx = t.v2.X; |
1789 | // wy = t.v3.Y; | 1616 | vy = t.v2.Y; |
1790 | // wz = t.v3.Z; | 1617 | vz = t.v2.Z; |
1791 | 1618 | ||
1619 | wx = t.v3.X; | ||
1620 | wy = t.v3.Y; | ||
1621 | wz = t.v3.Z; | ||
1792 | 1622 | ||
1793 | // // Vectors for edges | ||
1794 | // float e1x, e1y, e1z; | ||
1795 | // float e2x, e2y, e2z; | ||
1796 | 1623 | ||
1797 | // e1x = ux - vx; | 1624 | // Vectors for edges |
1798 | // e1y = uy - vy; | 1625 | float e1x, e1y, e1z; |
1799 | // e1z = uz - vz; | 1626 | float e2x, e2y, e2z; |
1800 | 1627 | ||
1801 | // e2x = ux - wx; | 1628 | e1x = ux - vx; |
1802 | // e2y = uy - wy; | 1629 | e1y = uy - vy; |
1803 | // e2z = uz - wz; | 1630 | e1z = uz - vz; |
1804 | 1631 | ||
1632 | e2x = ux - wx; | ||
1633 | e2y = uy - wy; | ||
1634 | e2z = uz - wz; | ||
1805 | 1635 | ||
1806 | // // Cross product for normal | ||
1807 | // float nx, ny, nz; | ||
1808 | // nx = e1y*e2z - e1z*e2y; | ||
1809 | // ny = e1z*e2x - e1x*e2z; | ||
1810 | // nz = e1x*e2y - e1y*e2x; | ||
1811 | 1636 | ||
1812 | // // Length | 1637 | // Cross product for normal |
1813 | // float l = (float) Math.Sqrt(nx*nx + ny*ny + nz*nz); | 1638 | float nx, ny, nz; |
1639 | nx = e1y * e2z - e1z * e2y; | ||
1640 | ny = e1z * e2x - e1x * e2z; | ||
1641 | nz = e1x * e2y - e1y * e2x; | ||
1814 | 1642 | ||
1815 | // // Normalized "normal" | 1643 | // Length |
1816 | // nx /= l; | 1644 | float l = (float)Math.Sqrt(nx * nx + ny * ny + nz * nz); |
1817 | // ny /= l; | ||
1818 | // nz /= l; | ||
1819 | 1645 | ||
1820 | // //mesh.normals[i] = nx; | 1646 | // Normalized "normal" |
1821 | // //mesh.normals[i + 1] = ny; | 1647 | nx /= l; |
1822 | // //mesh.normals[i + 2] = nz; | 1648 | ny /= l; |
1649 | nz /= l; | ||
1823 | 1650 | ||
1824 | // i += 3; | 1651 | i += 3; |
1825 | // } | 1652 | } |
1826 | //} | 1653 | } |
1827 | 1654 | ||
1828 | public static Vertex midUnitRadialPoint(Vertex a, Vertex b, float radius) | 1655 | public static Vertex midUnitRadialPoint(Vertex a, Vertex b, float radius) |
1829 | { | 1656 | { |
@@ -1870,7 +1697,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
1870 | 1697 | ||
1871 | public Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) | 1698 | public Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) |
1872 | { | 1699 | { |
1873 | //reportPrimParams(primName, primShape); | ||
1874 | Mesh mesh = new Mesh(); | 1700 | Mesh mesh = new Mesh(); |
1875 | 1701 | ||
1876 | float pathShearX = primShape.PathShearX < 128 ? (float)primShape.PathShearX * 0.01f : (float)(primShape.PathShearX - 256) * 0.01f; | 1702 | float pathShearX = primShape.PathShearX < 128 ? (float)primShape.PathShearX * 0.01f : (float)(primShape.PathShearX - 256) * 0.01f; |
@@ -1896,7 +1722,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
1896 | profileBegin = 0.5f * profileBegin + 0.5f; | 1722 | profileBegin = 0.5f * profileBegin + 0.5f; |
1897 | profileEnd = 0.5f * profileEnd + 0.5f; | 1723 | profileEnd = 0.5f * profileEnd + 0.5f; |
1898 | 1724 | ||
1899 | //profileHollow = 0.0f; // debugging only | ||
1900 | } | 1725 | } |
1901 | 1726 | ||
1902 | int hollowSides = sides; | 1727 | int hollowSides = sides; |
@@ -1908,17 +1733,11 @@ namespace OpenSim.Region.Physics.Meshing | |||
1908 | hollowSides = 3; | 1733 | hollowSides = 3; |
1909 | 1734 | ||
1910 | PrimMesh primMesh = new PrimMesh(sides, profileBegin, profileEnd, profileHollow, hollowSides); | 1735 | PrimMesh primMesh = new PrimMesh(sides, profileBegin, profileEnd, profileHollow, hollowSides); |
1911 | //PrimMesh primMesh = new PrimMesh(sides, profileBegin, profileEnd, 0.0f, 4); | ||
1912 | |||
1913 | //Profile testProfile = new Profile(sides, profileBegin, profileEnd, profileHollow, hollowSides, true); | ||
1914 | //testProfile.DumpRaw(baseDir, primName, "Profile"); | ||
1915 | 1736 | ||
1916 | primMesh.topShearX = pathShearX; | 1737 | primMesh.topShearX = pathShearX; |
1917 | primMesh.topShearY = pathShearY; | 1738 | primMesh.topShearY = pathShearY; |
1918 | primMesh.pathCutBegin = pathBegin; | 1739 | primMesh.pathCutBegin = pathBegin; |
1919 | primMesh.pathCutEnd = pathEnd; | 1740 | primMesh.pathCutEnd = pathEnd; |
1920 | //primMesh.pathCutBegin = 0.0f; | ||
1921 | //primMesh.pathCutEnd = 1.0f; | ||
1922 | 1741 | ||
1923 | if (primShape.PathCurve == (byte)Extrusion.Straight) | 1742 | if (primShape.PathCurve == (byte)Extrusion.Straight) |
1924 | { | 1743 | { |
@@ -1943,7 +1762,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
1943 | } | 1762 | } |
1944 | else | 1763 | else |
1945 | { | 1764 | { |
1946 | //return null; | ||
1947 | primMesh.holeSizeX = (200 - primShape.PathScaleX) * 0.01f; | 1765 | primMesh.holeSizeX = (200 - primShape.PathScaleX) * 0.01f; |
1948 | primMesh.holeSizeY = (200 - primShape.PathScaleY) * 0.01f; | 1766 | primMesh.holeSizeY = (200 - primShape.PathScaleY) * 0.01f; |
1949 | primMesh.radius = 0.01f * primShape.PathRadiusOffset; | 1767 | primMesh.radius = 0.01f * primShape.PathRadiusOffset; |