diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs index f1dd586b28..281ba12f1e 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;