aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Meshing
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/Meshing')
-rw-r--r--OpenSim/Region/Physics/Meshing/PrimMesher.cs29
-rw-r--r--OpenSim/Region/Physics/Meshing/SculptMesh.cs84
2 files changed, 65 insertions, 48 deletions
diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs
index 2a213c3..932943c 100644
--- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs
+++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs
@@ -827,15 +827,16 @@ namespace PrimMesher
827 827
828 if (createFaces) 828 if (createFaces)
829 { 829 {
830 int numOuterVerts = this.coords.Count; 830 //int numOuterVerts = this.coords.Count;
831 int numHollowVerts = hollowCoords.Count; 831 //numOuterVerts = this.coords.Count;
832 int numTotalVerts = numOuterVerts + numHollowVerts; 832 //int numHollowVerts = hollowCoords.Count;
833 int numTotalVerts = this.numOuterVerts + this.numHollowVerts;
833 834
834 if (numOuterVerts == numHollowVerts) 835 if (this.numOuterVerts == this.numHollowVerts)
835 { 836 {
836 Face newFace = new Face(); 837 Face newFace = new Face();
837 838
838 for (int coordIndex = 0; coordIndex < numOuterVerts - 1; coordIndex++) 839 for (int coordIndex = 0; coordIndex < this.numOuterVerts - 1; coordIndex++)
839 { 840 {
840 newFace.v1 = coordIndex; 841 newFace.v1 = coordIndex;
841 newFace.v2 = coordIndex + 1; 842 newFace.v2 = coordIndex + 1;
@@ -850,12 +851,12 @@ namespace PrimMesher
850 } 851 }
851 else 852 else
852 { 853 {
853 if (numOuterVerts < numHollowVerts) 854 if (this.numOuterVerts < this.numHollowVerts)
854 { 855 {
855 Face newFace = new Face(); 856 Face newFace = new Face();
856 int j = 0; // j is the index for outer vertices 857 int j = 0; // j is the index for outer vertices
857 int maxJ = numOuterVerts - 1; 858 int maxJ = this.numOuterVerts - 1;
858 for (int i = 0; i < numHollowVerts; i++) // i is the index for inner vertices 859 for (int i = 0; i < this.numHollowVerts; i++) // i is the index for inner vertices
859 { 860 {
860 if (j < maxJ) 861 if (j < maxJ)
861 if (angles.angles[j + 1].angle - hollowAngles.angles[i].angle < hollowAngles.angles[i].angle - angles.angles[j].angle + 0.000001f) 862 if (angles.angles[j + 1].angle - hollowAngles.angles[i].angle < hollowAngles.angles[i].angle - angles.angles[j].angle + 0.000001f)
@@ -879,8 +880,8 @@ namespace PrimMesher
879 { 880 {
880 Face newFace = new Face(); 881 Face newFace = new Face();
881 int j = 0; // j is the index for inner vertices 882 int j = 0; // j is the index for inner vertices
882 int maxJ = numHollowVerts - 1; 883 int maxJ = this.numHollowVerts - 1;
883 for (int i = 0; i < numOuterVerts; i++) 884 for (int i = 0; i < this.numOuterVerts; i++)
884 { 885 {
885 if (j < maxJ) 886 if (j < maxJ)
886 if (hollowAngles.angles[j + 1].angle - angles.angles[i].angle < angles.angles[i].angle - hollowAngles.angles[j].angle + 0.000001f) 887 if (hollowAngles.angles[j + 1].angle - angles.angles[i].angle < angles.angles[i].angle - hollowAngles.angles[j].angle + 0.000001f)
@@ -981,7 +982,7 @@ namespace PrimMesher
981 int startVert = hasProfileCut && !hasHollow ? 1 : 0; 982 int startVert = hasProfileCut && !hasHollow ? 1 : 0;
982 if (startVert > 0) 983 if (startVert > 0)
983 this.faceNumbers.Add(-1); 984 this.faceNumbers.Add(-1);
984 for (int i = 0; i < numOuterVerts - 1; i++) 985 for (int i = 0; i < this.numOuterVerts - 1; i++)
985 this.faceNumbers.Add(sides < 5 ? faceNum++ : faceNum); 986 this.faceNumbers.Add(sides < 5 ? faceNum++ : faceNum);
986 987
987 //if (!hasHollow && !hasProfileCut) 988 //if (!hasHollow && !hasProfileCut)
@@ -994,7 +995,7 @@ namespace PrimMesher
994 995
995 if (hasHollow) 996 if (hasHollow)
996 { 997 {
997 for (int i = 0; i < numHollowVerts; i++) 998 for (int i = 0; i < this.numHollowVerts; i++)
998 this.faceNumbers.Add(faceNum); 999 this.faceNumbers.Add(faceNum);
999 1000
1000 faceNum++; 1001 faceNum++;
@@ -1019,7 +1020,7 @@ namespace PrimMesher
1019 { 1020 {
1020 this.faceUVs = new List<UVCoord>(); 1021 this.faceUVs = new List<UVCoord>();
1021 foreach (Coord c in this.coords) 1022 foreach (Coord c in this.coords)
1022 this.faceUVs.Add(new UVCoord(1.0f - (0.5f + c.X), 1.0f - (0.5f - c.Y))); 1023 this.faceUVs.Add(new UVCoord(0.5f + c.X, 0.5f - c.Y));
1023 } 1024 }
1024 1025
1025 internal Profile Copy() 1026 internal Profile Copy()
@@ -1348,7 +1349,6 @@ namespace PrimMesher
1348 float stepSize = twoPi / this.stepsPerRevolution; 1349 float stepSize = twoPi / this.stepsPerRevolution;
1349 1350
1350 int step = (int)(startAngle / stepSize); 1351 int step = (int)(startAngle / stepSize);
1351// int firstStep = step;
1352 float angle = startAngle; 1352 float angle = startAngle;
1353 1353
1354 bool done = false; 1354 bool done = false;
@@ -1738,7 +1738,6 @@ namespace PrimMesher
1738 // append this layer 1738 // append this layer
1739 1739
1740 int coordsLen = this.coords.Count; 1740 int coordsLen = this.coords.Count;
1741// int lastCoordsLen = coordsLen;
1742 newLayer.AddValue2FaceVertexIndices(coordsLen); 1741 newLayer.AddValue2FaceVertexIndices(coordsLen);
1743 1742
1744 this.coords.AddRange(newLayer.coords); 1743 this.coords.AddRange(newLayer.coords);
diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs
index 4dc6e2e..ebc5be6 100644
--- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs
+++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs
@@ -53,42 +53,49 @@ namespace PrimMesher
53 public enum SculptType { sphere = 1, torus = 2, plane = 3, cylinder = 4 }; 53 public enum SculptType { sphere = 1, torus = 2, plane = 3, cylinder = 4 };
54 54
55#if SYSTEM_DRAWING 55#if SYSTEM_DRAWING
56 // private Bitmap ScaleImage(Bitmap srcImage, float scale) 56 private Bitmap ScaleImage(Bitmap srcImage, float scale, bool removeAlpha)
57 // { 57 {
58 // int sourceWidth = srcImage.Width; 58 int sourceWidth = srcImage.Width;
59 // int sourceHeight = srcImage.Height; 59 int sourceHeight = srcImage.Height;
60 // int sourceX = 0; 60 int sourceX = 0;
61 // int sourceY = 0; 61 int sourceY = 0;
62
63 int destX = 0;
64 int destY = 0;
65 int destWidth = (int)(srcImage.Width * scale);
66 int destHeight = (int)(srcImage.Height * scale);
62 67
63 // int destX = 0; 68 Bitmap scaledImage;
64 // int destY = 0;
65 // int destWidth = (int)(srcImage.Width * scale);
66 // int destHeight = (int)(srcImage.Height * scale);
67 69
68 // if (srcImage.PixelFormat == PixelFormat.Format32bppArgb) 70 if (removeAlpha)
69 // for (int y = 0; y < srcImage.Height; y++) 71 {
70 // for (int x = 0; x < srcImage.Width; x++) 72 if (srcImage.PixelFormat == PixelFormat.Format32bppArgb)
71 // { 73 for (int y = 0; y < srcImage.Height; y++)
72 // Color c = srcImage.GetPixel(x, y); 74 for (int x = 0; x < srcImage.Width; x++)
73 // srcImage.SetPixel(x, y, Color.FromArgb(255, c.R, c.G, c.B)); 75 {
74 // } 76 Color c = srcImage.GetPixel(x, y);
77 srcImage.SetPixel(x, y, Color.FromArgb(255, c.R, c.G, c.B));
78 }
75 79
76 // Bitmap scaledImage = new Bitmap(destWidth, destHeight, 80 scaledImage = new Bitmap(destWidth, destHeight,
77 // PixelFormat.Format24bppRgb); 81 PixelFormat.Format24bppRgb);
82 }
83 else
84 scaledImage = new Bitmap(srcImage, destWidth, destHeight);
78 85
79 // scaledImage.SetResolution(96.0f, 96.0f); 86 scaledImage.SetResolution(96.0f, 96.0f);
80 87
81 // Graphics grPhoto = Graphics.FromImage(scaledImage); 88 Graphics grPhoto = Graphics.FromImage(scaledImage);
82 // grPhoto.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low; 89 grPhoto.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low;
83 90
84 // grPhoto.DrawImage(srcImage, 91 grPhoto.DrawImage(srcImage,
85 // new Rectangle(destX, destY, destWidth, destHeight), 92 new Rectangle(destX, destY, destWidth, destHeight),
86 // new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight), 93 new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),
87 // GraphicsUnit.Pixel); 94 GraphicsUnit.Pixel);
88 95
89 // grPhoto.Dispose(); 96 grPhoto.Dispose();
90 // return scaledImage; 97 return scaledImage;
91 // } 98 }
92 99
93 100
94 public SculptMesh SculptMeshFromFile(string fileName, SculptType sculptType, int lod, bool viewerMode) 101 public SculptMesh SculptMeshFromFile(string fileName, SculptType sculptType, int lod, bool viewerMode)
@@ -268,6 +275,11 @@ namespace PrimMesher
268 for (imageY = imageYStart; imageY < imageYEnd; imageY++) 275 for (imageY = imageYStart; imageY < imageYEnd; imageY++)
269 { 276 {
270 Color c = bitmap.GetPixel(imageX, imageY); 277 Color c = bitmap.GetPixel(imageX, imageY);
278 if (c.A != 255)
279 {
280 bitmap.SetPixel(imageX, imageY, Color.FromArgb(255, c.R, c.G, c.B));
281 c = bitmap.GetPixel(imageX, imageY);
282 }
271 rSum += c.R; 283 rSum += c.R;
272 gSum += c.G; 284 gSum += c.G;
273 bSum += c.B; 285 bSum += c.B;
@@ -298,12 +310,18 @@ namespace PrimMesher
298 if (sculptType == SculptType.plane) 310 if (sculptType == SculptType.plane)
299 invert = !invert; 311 invert = !invert;
300 312
301 float sourceScaleFactor = (float)(lod) / (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height); 313 float sculptBitmapLod = (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height);
314
315 float sourceScaleFactor = (float)(lod) / sculptBitmapLod;
302 316
303 int scale = (int)(1.0f / sourceScaleFactor); 317 float fScale = 1.0f / sourceScaleFactor;
304 if (scale < 1) scale = 1;
305 318
306 _SculptMesh(bitmap2Coords(sculptBitmap, scale, mirror), sculptType, viewerMode, mirror, invert); 319 int iScale = (int)fScale;
320 if (iScale < 1) iScale = 1;
321 if (iScale > 2 && iScale % 2 == 0)
322 _SculptMesh(bitmap2Coords(ScaleImage(sculptBitmap, 64.0f / sculptBitmapLod, true), 64 / lod, mirror), sculptType, viewerMode, mirror, invert);
323 else
324 _SculptMesh(bitmap2Coords(sculptBitmap, iScale, mirror), sculptType, viewerMode, mirror, invert);
307 } 325 }
308#endif 326#endif
309 327