Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork

avinationmerge
ubit 2012-08-05 14:00:00 +02:00
commit e5cce8468e
3 changed files with 78 additions and 15 deletions

View File

@ -314,6 +314,9 @@ namespace OpenSim.Region.Physics.Meshing
coords[f.v3].X, coords[f.v3].Y, coords[f.v3].Z));
}
coords.Clear();
faces.Clear();
return mesh;
}

View File

@ -56,11 +56,12 @@ namespace PrimMesher
int numLodPixels = lod * lod; // (32 * 2)^2 = 64^2 pixels for default sculpt map image
bool smallMap = bmW * bmH <= numLodPixels;
bool needsScaling = false;
bool smallMap = false;
width = bmW;
height = bmH;
while (width * height > numLodPixels * 4)
{
width >>= 1;
@ -81,9 +82,12 @@ namespace PrimMesher
if (width * height > numLodPixels)
{
smallMap = false;
width >>= 1;
height >>= 1;
}
else
smallMap = true;
int numBytes = (width + 1) * (height + 1);
redBytes = new byte[numBytes];
@ -91,21 +95,18 @@ namespace PrimMesher
blueBytes = new byte[numBytes];
int byteNdx = 0;
Color c;
try
{
for (int y = 0; y <= height; y++)
{
for (int x = 0; x <= width; x++)
for (int x = 0; x < width; x++)
{
Color c;
if (smallMap)
c = bm.GetPixel(x < width ? x : x - 1,
y < height ? y : y - 1);
c = bm.GetPixel(x, y < height ? y : y - 1);
else
c = bm.GetPixel(x < width ? x * 2 : x * 2 - 1,
y < height ? y * 2 : y * 2 - 1);
c = bm.GetPixel(x * 2, y < height ? y * 2 : y * 2 - 1);
redBytes[byteNdx] = c.R;
greenBytes[byteNdx] = c.G;
@ -113,6 +114,17 @@ namespace PrimMesher
++byteNdx;
}
if (smallMap)
c = bm.GetPixel(width - 1, y < height ? y : y - 1);
else
c = bm.GetPixel(width * 2 - 1, y < height ? y * 2 : y * 2 - 1);
redBytes[byteNdx] = c.R;
greenBytes[byteNdx] = c.G;
blueBytes[byteNdx] = c.B;
++byteNdx;
}
}
catch (Exception e)
@ -160,14 +172,25 @@ namespace PrimMesher
Bitmap scaledImage = new Bitmap(destWidth, destHeight, PixelFormat.Format24bppRgb);
Color c;
float xscale = srcImage.Width / destWidth;
float yscale = srcImage.Height / destHeight;
// will let last step to be eventually diferent, as seems to be in sl
float xscale = (float)srcImage.Width / (float)destWidth;
float yscale = (float)srcImage.Height / (float)destHeight;
int lastsx = srcImage.Width - 1;
int lastsy = srcImage.Height - 1;
int lastdx = destWidth - 1;
int lastdy = destHeight - 1;
float sy = 0.5f;
for (int y = 0; y < destHeight; y++)
float sx;
for (int y = 0; y < lastdy; y++)
{
float sx = 0.5f;
for (int x = 0; x < destWidth; x++)
sx = 0.5f;
for (int x = 0; x < lastdx; x++)
{
try
{
@ -177,11 +200,43 @@ namespace PrimMesher
catch (IndexOutOfRangeException)
{
}
sx += xscale;
}
try
{
c = srcImage.GetPixel(lastsx, (int)(sy));
scaledImage.SetPixel(lastdx, y, Color.FromArgb(c.R, c.G, c.B));
}
catch (IndexOutOfRangeException)
{
}
sy += yscale;
}
sx = 0.5f;
for (int x = 0; x < lastdx; x++)
{
try
{
c = srcImage.GetPixel((int)(sx), lastsy);
scaledImage.SetPixel(x, lastdy, Color.FromArgb(c.R, c.G, c.B));
}
catch (IndexOutOfRangeException)
{
}
sx += xscale;
}
sy += yscale;
try
{
c = srcImage.GetPixel(lastsx, lastsy);
scaledImage.SetPixel(lastdx, lastdy, Color.FromArgb(c.R, c.G, c.B));
}
catch (IndexOutOfRangeException)
{
}
srcImage.Dispose();
return scaledImage;
}

View File

@ -48,7 +48,12 @@ namespace PrimMesher
{
if (mirror)
invert = !invert;
_SculptMesh(new SculptMap(sculptBitmap, lod).ToRows(mirror), sculptType, invert);
SculptMap smap = new SculptMap(sculptBitmap, lod);
List<List<Coord>> rows = smap.ToRows(mirror);
_SculptMesh(rows, sculptType, invert);
}
private void _SculptMesh(List<List<Coord>> rows, SculptType sculptType, bool invert)