From 3e22bb24f5aa75f568485ed35e644c6a5c37dfe3 Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 9 Nov 2009 18:43:09 -0800 Subject: add an overload to _SculptMesh for meshing from a list of coordinates add conditional compilation for System.Drawing dependency --- OpenSim/Region/Physics/Meshing/SculptMesh.cs | 49 ++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Physics/Meshing/SculptMesh.cs') 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 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// to build without references to System.Drawing, comment this out +#define SYSTEM_DRAWING + using System; using System.Collections.Generic; using System.Text; using System.IO; + +#if SYSTEM_DRAWING using System.Drawing; using System.Drawing.Imaging; +#endif namespace PrimMesher { @@ -83,6 +89,7 @@ namespace PrimMesher // return scaledImage; // } +#if SYSTEM_DRAWING public SculptMesh SculptMeshFromFile(string fileName, SculptType sculptType, int lod, bool viewerMode) { Bitmap bitmap = (Bitmap)Bitmap.FromFile(fileName); @@ -97,6 +104,7 @@ namespace PrimMesher _SculptMesh(bitmap, (SculptType)sculptType, lod, viewerMode != 0, mirror != 0, invert != 0); bitmap.Dispose(); } +#endif /// /// ** Experimental ** May disappear from future versions ** not recommeneded for use in applications @@ -201,6 +209,7 @@ namespace PrimMesher calcVertexNormals(SculptType.plane, numXElements, numYElements); } +#if SYSTEM_DRAWING public SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode) { _SculptMesh(sculptBitmap, sculptType, lod, viewerMode, false, false); @@ -210,9 +219,16 @@ namespace PrimMesher { _SculptMesh(sculptBitmap, sculptType, lod, viewerMode, mirror, invert); } +#endif + + public SculptMesh(List> rows, SculptType sculptType, bool viewerMode, bool mirror, bool invert) + { + _SculptMesh(rows, sculptType, viewerMode, mirror, invert); + } +#if SYSTEM_DRAWING /// - /// converts a bitmap to a list lists of coords, while scaling the image. + /// converts a bitmap to a list of lists of coords, while scaling the image. /// the scaling is done in floating point so as to allow for reduced vertex position /// quantization as the position will be averaged between pixel values. this routine will /// likely fail if the bitmap width and height are not powers of 2. @@ -267,6 +283,7 @@ namespace PrimMesher return rows; } + void _SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode, bool mirror, bool invert) { coords = new List(); @@ -285,13 +302,39 @@ namespace PrimMesher int scale = (int)(1.0f / sourceScaleFactor); if (scale < 1) scale = 1; - List> rows = bitmap2Coords(sculptBitmap, scale, mirror); + _SculptMesh(bitmap2Coords(sculptBitmap, scale, mirror), sculptType, viewerMode, mirror, invert); + } +#endif + + + void _SculptMesh(List> rows, SculptType sculptType, bool viewerMode, bool mirror, bool invert) + { + coords = new List(); + faces = new List(); + normals = new List(); + uvs = new List(); + + sculptType = (SculptType)(((int)sculptType) & 0x07); + + if (mirror) + if (sculptType == SculptType.plane) + invert = !invert; + + //float sourceScaleFactor = (float)(lod) / (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height); + + //int scale = (int)(1.0f / sourceScaleFactor); + //if (scale < 1) scale = 1; + + //List> rows = bitmap2Coords(sculptBitmap, scale, mirror); viewerFaces = new List(); - int width = sculptBitmap.Width / scale; + //int width = sculptBitmap.Width / scale; // int height = sculptBitmap.Height / scale; + int width = rows[0].Count; + int height = rows.Count; + int p1, p2, p3, p4; int imageX, imageY; -- cgit v1.1 From 6d88c96e01088edc9777a9fb0abfd58ff8c1d8c7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 11 Nov 2009 18:49:05 +0000 Subject: minor: remove mono compiler warning --- OpenSim/Region/Physics/Meshing/SculptMesh.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Physics/Meshing/SculptMesh.cs') diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs index 281ba12..a8f9ae5 100644 --- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs +++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs @@ -333,7 +333,7 @@ namespace PrimMesher // int height = sculptBitmap.Height / scale; int width = rows[0].Count; - int height = rows.Count; +// int height = rows.Count; int p1, p2, p3, p4; -- cgit v1.1 From 8ae3df22a2b1d235d4ffb04091656b5d16c50e68 Mon Sep 17 00:00:00 2001 From: dahlia Date: Wed, 11 Nov 2009 11:10:42 -0800 Subject: clean up some cruft --- OpenSim/Region/Physics/Meshing/SculptMesh.cs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Physics/Meshing/SculptMesh.cs') diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs index a8f9ae5..4dc6e2e 100644 --- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs +++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs @@ -52,6 +52,7 @@ namespace PrimMesher public enum SculptType { sphere = 1, torus = 2, plane = 3, cylinder = 4 }; +#if SYSTEM_DRAWING // private Bitmap ScaleImage(Bitmap srcImage, float scale) // { // int sourceWidth = srcImage.Width; @@ -89,7 +90,7 @@ namespace PrimMesher // return scaledImage; // } -#if SYSTEM_DRAWING + public SculptMesh SculptMeshFromFile(string fileName, SculptType sculptType, int lod, bool viewerMode) { Bitmap bitmap = (Bitmap)Bitmap.FromFile(fileName); @@ -320,20 +321,9 @@ namespace PrimMesher if (sculptType == SculptType.plane) invert = !invert; - //float sourceScaleFactor = (float)(lod) / (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height); - - //int scale = (int)(1.0f / sourceScaleFactor); - //if (scale < 1) scale = 1; - - //List> rows = bitmap2Coords(sculptBitmap, scale, mirror); - viewerFaces = new List(); - //int width = sculptBitmap.Width / scale; - // int height = sculptBitmap.Height / scale; - int width = rows[0].Count; -// int height = rows.Count; int p1, p2, p3, p4; -- cgit v1.1