aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Meshing
diff options
context:
space:
mode:
authorDahlia Trimble2009-05-15 03:14:04 +0000
committerDahlia Trimble2009-05-15 03:14:04 +0000
commit14c1e991c6687c1ce0914a1ab21a7b52a96f9fb4 (patch)
tree002889332d0699ee74ad8eb5018c598413474a29 /OpenSim/Region/Physics/Meshing
parentRemove all messages from the groups module that would be output when it is (diff)
downloadopensim-SC-14c1e991c6687c1ce0914a1ab21a7b52a96f9fb4.zip
opensim-SC-14c1e991c6687c1ce0914a1ab21a7b52a96f9fb4.tar.gz
opensim-SC-14c1e991c6687c1ce0914a1ab21a7b52a96f9fb4.tar.bz2
opensim-SC-14c1e991c6687c1ce0914a1ab21a7b52a96f9fb4.tar.xz
some sculpted prim geometry accuracy and meshing speed improvements
Diffstat (limited to 'OpenSim/Region/Physics/Meshing')
-rw-r--r--OpenSim/Region/Physics/Meshing/SculptMesh.cs29
1 files changed, 7 insertions, 22 deletions
diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs
index 77b1771..315ec53 100644
--- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs
+++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs
@@ -45,7 +45,7 @@ namespace PrimMesher
45 public List<UVCoord> uvs; 45 public List<UVCoord> uvs;
46 46
47 public enum SculptType { sphere = 1, torus = 2, plane = 3, cylinder = 4 }; 47 public enum SculptType { sphere = 1, torus = 2, plane = 3, cylinder = 4 };
48 private const float pixScale = 0.00390625f; // 1.0 / 256 48 private static float pixScale = 1.0f / 255;
49 49
50 private Bitmap ScaleImage(Bitmap srcImage, float scale) 50 private Bitmap ScaleImage(Bitmap srcImage, float scale)
51 { 51 {
@@ -73,7 +73,7 @@ namespace PrimMesher
73 scaledImage.SetResolution(96.0f, 96.0f); 73 scaledImage.SetResolution(96.0f, 96.0f);
74 74
75 Graphics grPhoto = Graphics.FromImage(scaledImage); 75 Graphics grPhoto = Graphics.FromImage(scaledImage);
76 grPhoto.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bilinear; 76 grPhoto.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
77 77
78 grPhoto.DrawImage(srcImage, 78 grPhoto.DrawImage(srcImage,
79 new Rectangle(destX, destY, destWidth, destHeight), 79 new Rectangle(destX, destY, destWidth, destHeight),
@@ -217,7 +217,6 @@ namespace PrimMesher
217 if (sculptType == SculptType.plane) 217 if (sculptType == SculptType.plane)
218 invert = !invert; 218 invert = !invert;
219 219
220 //float sourceScaleFactor = (float)lod / (float)Math.Max(sculptBitmap.Width, sculptBitmap.Height);
221 float sourceScaleFactor = (float)(lod) / (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height); 220 float sourceScaleFactor = (float)(lod) / (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height);
222 bool scaleSourceImage = sourceScaleFactor < 1.0f ? true : false; 221 bool scaleSourceImage = sourceScaleFactor < 1.0f ? true : false;
223 222
@@ -242,26 +241,12 @@ namespace PrimMesher
242 int imageX, imageY; 241 int imageX, imageY;
243 242
244 if (sculptType == SculptType.sphere) 243 if (sculptType == SculptType.sphere)
245 { // average the top and bottom row pixel values so the resulting vertices appear to converge 244 {
246 int lastRow = height - 1; 245 int lastRow = height - 1;
247 int r1 = 0, g1 = 0, b1 = 0;
248 int r2 = 0, g2 = 0, b2 = 0;
249 for (imageX = 0; imageX < width; imageX++)
250 {
251 Color c1 = bitmap.GetPixel(imageX, 0);
252 Color c2 = bitmap.GetPixel(imageX, lastRow);
253
254 r1 += c1.R;
255 g1 += c1.G;
256 b1 += c1.B;
257
258 r2 += c2.R;
259 g2 += c2.G;
260 b2 += c2.B;
261 }
262 246
263 Color newC1 = Color.FromArgb(r1 / width, g1 / width, b1 / width); 247 // poles of sphere mesh are the center pixels of the top and bottom rows
264 Color newC2 = Color.FromArgb(r2 / width, g2 / width, b2 / width); 248 Color newC1 = bitmap.GetPixel(width / 2, 0);
249 Color newC2 = bitmap.GetPixel(width / 2, lastRow);
265 250
266 for (imageX = 0; imageX < width; imageX++) 251 for (imageX = 0; imageX < width; imageX++)
267 { 252 {
@@ -272,8 +257,8 @@ namespace PrimMesher
272 } 257 }
273 258
274 259
260 int pixelsDown = sculptType == SculptType.plane ? height : height + 1;
275 int pixelsAcross = sculptType == SculptType.plane ? width : width + 1; 261 int pixelsAcross = sculptType == SculptType.plane ? width : width + 1;
276 int pixelsDown = sculptType == SculptType.sphere || sculptType == SculptType.cylinder ? height + 1 : height;
277 262
278 for (imageY = 0; imageY < pixelsDown; imageY++) 263 for (imageY = 0; imageY < pixelsDown; imageY++)
279 { 264 {