aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authordahlia2009-11-09 18:43:09 -0800
committerdahlia2009-11-09 18:44:03 -0800
commit3e22bb24f5aa75f568485ed35e644c6a5c37dfe3 (patch)
tree3823922abd2c35d0306fbaf0eaa4fb5e1aebf7ea
parent* Removing the redundant SendPrimitiveTerseData.State field, it duplicates At... (diff)
downloadopensim-SC_OLD-3e22bb24f5aa75f568485ed35e644c6a5c37dfe3.zip
opensim-SC_OLD-3e22bb24f5aa75f568485ed35e644c6a5c37dfe3.tar.gz
opensim-SC_OLD-3e22bb24f5aa75f568485ed35e644c6a5c37dfe3.tar.bz2
opensim-SC_OLD-3e22bb24f5aa75f568485ed35e644c6a5c37dfe3.tar.xz
add an overload to _SculptMesh for meshing from a list of coordinates
add conditional compilation for System.Drawing dependency
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/Meshing/SculptMesh.cs49
1 files changed, 46 insertions, 3 deletions
diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs
index f1dd586..281ba12 100644
--- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs
+++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs
@@ -25,12 +25,18 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28// to build without references to System.Drawing, comment this out
29#define SYSTEM_DRAWING
30
28using System; 31using System;
29using System.Collections.Generic; 32using System.Collections.Generic;
30using System.Text; 33using System.Text;
31using System.IO; 34using System.IO;
35
36#if SYSTEM_DRAWING
32using System.Drawing; 37using System.Drawing;
33using System.Drawing.Imaging; 38using System.Drawing.Imaging;
39#endif
34 40
35namespace PrimMesher 41namespace PrimMesher
36{ 42{
@@ -83,6 +89,7 @@ namespace PrimMesher
83 // return scaledImage; 89 // return scaledImage;
84 // } 90 // }
85 91
92#if SYSTEM_DRAWING
86 public SculptMesh SculptMeshFromFile(string fileName, SculptType sculptType, int lod, bool viewerMode) 93 public SculptMesh SculptMeshFromFile(string fileName, SculptType sculptType, int lod, bool viewerMode)
87 { 94 {
88 Bitmap bitmap = (Bitmap)Bitmap.FromFile(fileName); 95 Bitmap bitmap = (Bitmap)Bitmap.FromFile(fileName);
@@ -97,6 +104,7 @@ namespace PrimMesher
97 _SculptMesh(bitmap, (SculptType)sculptType, lod, viewerMode != 0, mirror != 0, invert != 0); 104 _SculptMesh(bitmap, (SculptType)sculptType, lod, viewerMode != 0, mirror != 0, invert != 0);
98 bitmap.Dispose(); 105 bitmap.Dispose();
99 } 106 }
107#endif
100 108
101 /// <summary> 109 /// <summary>
102 /// ** Experimental ** May disappear from future versions ** not recommeneded for use in applications 110 /// ** Experimental ** May disappear from future versions ** not recommeneded for use in applications
@@ -201,6 +209,7 @@ namespace PrimMesher
201 calcVertexNormals(SculptType.plane, numXElements, numYElements); 209 calcVertexNormals(SculptType.plane, numXElements, numYElements);
202 } 210 }
203 211
212#if SYSTEM_DRAWING
204 public SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode) 213 public SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode)
205 { 214 {
206 _SculptMesh(sculptBitmap, sculptType, lod, viewerMode, false, false); 215 _SculptMesh(sculptBitmap, sculptType, lod, viewerMode, false, false);
@@ -210,9 +219,16 @@ namespace PrimMesher
210 { 219 {
211 _SculptMesh(sculptBitmap, sculptType, lod, viewerMode, mirror, invert); 220 _SculptMesh(sculptBitmap, sculptType, lod, viewerMode, mirror, invert);
212 } 221 }
222#endif
223
224 public SculptMesh(List<List<Coord>> rows, SculptType sculptType, bool viewerMode, bool mirror, bool invert)
225 {
226 _SculptMesh(rows, sculptType, viewerMode, mirror, invert);
227 }
213 228
229#if SYSTEM_DRAWING
214 /// <summary> 230 /// <summary>
215 /// converts a bitmap to a list lists of coords, while scaling the image. 231 /// converts a bitmap to a list of lists of coords, while scaling the image.
216 /// the scaling is done in floating point so as to allow for reduced vertex position 232 /// the scaling is done in floating point so as to allow for reduced vertex position
217 /// quantization as the position will be averaged between pixel values. this routine will 233 /// quantization as the position will be averaged between pixel values. this routine will
218 /// likely fail if the bitmap width and height are not powers of 2. 234 /// likely fail if the bitmap width and height are not powers of 2.
@@ -267,6 +283,7 @@ namespace PrimMesher
267 return rows; 283 return rows;
268 } 284 }
269 285
286
270 void _SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode, bool mirror, bool invert) 287 void _SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode, bool mirror, bool invert)
271 { 288 {
272 coords = new List<Coord>(); 289 coords = new List<Coord>();
@@ -285,13 +302,39 @@ namespace PrimMesher
285 int scale = (int)(1.0f / sourceScaleFactor); 302 int scale = (int)(1.0f / sourceScaleFactor);
286 if (scale < 1) scale = 1; 303 if (scale < 1) scale = 1;
287 304
288 List<List<Coord>> rows = bitmap2Coords(sculptBitmap, scale, mirror); 305 _SculptMesh(bitmap2Coords(sculptBitmap, scale, mirror), sculptType, viewerMode, mirror, invert);
306 }
307#endif
308
309
310 void _SculptMesh(List<List<Coord>> rows, SculptType sculptType, bool viewerMode, bool mirror, bool invert)
311 {
312 coords = new List<Coord>();
313 faces = new List<Face>();
314 normals = new List<Coord>();
315 uvs = new List<UVCoord>();
316
317 sculptType = (SculptType)(((int)sculptType) & 0x07);
318
319 if (mirror)
320 if (sculptType == SculptType.plane)
321 invert = !invert;
322
323 //float sourceScaleFactor = (float)(lod) / (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height);
324
325 //int scale = (int)(1.0f / sourceScaleFactor);
326 //if (scale < 1) scale = 1;
327
328 //List<List<Coord>> rows = bitmap2Coords(sculptBitmap, scale, mirror);
289 329
290 viewerFaces = new List<ViewerFace>(); 330 viewerFaces = new List<ViewerFace>();
291 331
292 int width = sculptBitmap.Width / scale; 332 //int width = sculptBitmap.Width / scale;
293 // int height = sculptBitmap.Height / scale; 333 // int height = sculptBitmap.Height / scale;
294 334
335 int width = rows[0].Count;
336 int height = rows.Count;
337
295 int p1, p2, p3, p4; 338 int p1, p2, p3, p4;
296 339
297 int imageX, imageY; 340 int imageX, imageY;