|
|
@ -113,18 +113,17 @@ void putPixel(uint8 *dst, uint8 *src, bool alphaTransfert)
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
bool putIn (NLMISC::CBitmap *pSrc, NLMISC::CBitmap *pDst, sint32 x, sint32 y, bool alphaTransfert=true)
|
|
|
|
bool putIn (NLMISC::CBitmap *pSrc, NLMISC::CBitmap *pDst, sint32 x, sint32 y, bool alphaTransfert=true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint32 a, b;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8 *rSrcPix = &pSrc->getPixels()[0];
|
|
|
|
uint8 *rSrcPix = &pSrc->getPixels()[0];
|
|
|
|
uint8 *rDstPix = &pDst->getPixels()[0];
|
|
|
|
uint8 *rDstPix = &pDst->getPixels()[0];
|
|
|
|
|
|
|
|
|
|
|
|
uint wSrc= pSrc->getWidth();
|
|
|
|
uint wSrc= pSrc->getWidth();
|
|
|
|
uint hSrc= pSrc->getHeight();
|
|
|
|
uint hSrc= pSrc->getHeight();
|
|
|
|
for (b = 0; b < hSrc; ++b)
|
|
|
|
for (uint b = 0; b < hSrc; ++b)
|
|
|
|
for (a = 0; a < wSrc; ++a)
|
|
|
|
for (uint a = 0; a < wSrc; ++a)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (rDstPix[4*((x+a)+(y+b)*pDst->getWidth())+3] != 0)
|
|
|
|
if (rDstPix[4*((x+a)+(y+b)*pDst->getWidth())+3] != 0)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// write
|
|
|
|
// write
|
|
|
|
putPixel(rDstPix + 4*((x+a)+(y+b)*pDst->getWidth()), rSrcPix+ 4*(a+b*pSrc->getWidth()), alphaTransfert);
|
|
|
|
putPixel(rDstPix + 4*((x+a)+(y+b)*pDst->getWidth()), rSrcPix+ 4*(a+b*pSrc->getWidth()), alphaTransfert);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -135,9 +134,9 @@ bool putIn (NLMISC::CBitmap *pSrc, NLMISC::CBitmap *pDst, sint32 x, sint32 y, bo
|
|
|
|
// expand on W
|
|
|
|
// expand on W
|
|
|
|
if(wSrc<wSrc4)
|
|
|
|
if(wSrc<wSrc4)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for(a=wSrc;a<wSrc4;a++)
|
|
|
|
for(uint a=wSrc;a<wSrc4;a++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for(b=0;b<hSrc4;b++)
|
|
|
|
for(uint b=0;b<hSrc4;b++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
putPixel(rDstPix + 4*((x+a)+(y+b)*pDst->getWidth()), rDstPix + 4*((x+wSrc-1)+(y+b)*pDst->getWidth()), alphaTransfert);
|
|
|
|
putPixel(rDstPix + 4*((x+a)+(y+b)*pDst->getWidth()), rDstPix + 4*((x+wSrc-1)+(y+b)*pDst->getWidth()), alphaTransfert);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -146,9 +145,9 @@ bool putIn (NLMISC::CBitmap *pSrc, NLMISC::CBitmap *pDst, sint32 x, sint32 y, bo
|
|
|
|
// expand on H
|
|
|
|
// expand on H
|
|
|
|
if(hSrc<hSrc4)
|
|
|
|
if(hSrc<hSrc4)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for(b=hSrc;b<hSrc4;b++)
|
|
|
|
for(uint b=hSrc;b<hSrc4;b++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for(a=0;a<wSrc4;a++)
|
|
|
|
for(uint a=0;a<wSrc4;a++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
putPixel(rDstPix + 4*((x+a)+(y+b)*pDst->getWidth()), rDstPix + 4*((x+a)+(y+hSrc-1)*pDst->getWidth()), alphaTransfert);
|
|
|
|
putPixel(rDstPix + 4*((x+a)+(y+b)*pDst->getWidth()), rDstPix + 4*((x+a)+(y+hSrc-1)*pDst->getWidth()), alphaTransfert);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -252,30 +251,38 @@ int main(int nNbArg, char **ppArgs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vector<NLMISC::CBitmap*> AllMaps;
|
|
|
|
vector<NLMISC::CBitmap*> AllMaps;
|
|
|
|
sint32 i, j;
|
|
|
|
sint32 j;
|
|
|
|
|
|
|
|
|
|
|
|
// Load all maps
|
|
|
|
// Load all maps
|
|
|
|
sint32 mapSize = (sint32)AllMapNames.size();
|
|
|
|
sint32 mapSize = (sint32)AllMapNames.size();
|
|
|
|
AllMaps.resize( mapSize );
|
|
|
|
AllMaps.resize( mapSize );
|
|
|
|
for( i = 0; i < mapSize; ++i )
|
|
|
|
for(sint i = 0; i < mapSize; ++i )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
NLMISC::CBitmap *pBtmp = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NLMISC::CBitmap *pBtmp = new NLMISC::CBitmap;
|
|
|
|
pBtmp = new NLMISC::CBitmap;
|
|
|
|
NLMISC::CIFile inFile;
|
|
|
|
NLMISC::CIFile inFile;
|
|
|
|
inFile.open( AllMapNames[i] );
|
|
|
|
if (!inFile.open( AllMapNames[i] )) throw NLMISC::Exception("Unable to open " + AllMapNames[i]);
|
|
|
|
pBtmp->load(inFile);
|
|
|
|
|
|
|
|
|
|
|
|
uint8 colors = pBtmp->load(inFile);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (colors != 32) throw NLMISC::Exception(AllMapNames[i] + " is using " + toString(colors) + " bits colors, only 32 bit supported!");
|
|
|
|
|
|
|
|
|
|
|
|
AllMaps[i] = pBtmp;
|
|
|
|
AllMaps[i] = pBtmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const NLMISC::Exception &e)
|
|
|
|
catch (const NLMISC::Exception &e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (pBtmp) delete pBtmp;
|
|
|
|
|
|
|
|
|
|
|
|
outString (string("ERROR :") + e.what());
|
|
|
|
outString (string("ERROR :") + e.what());
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Sort all maps by decreasing size
|
|
|
|
// Sort all maps by decreasing size
|
|
|
|
for (i = 0; i < mapSize-1; ++i)
|
|
|
|
for (sint i = 0; i < mapSize-1; ++i)
|
|
|
|
for (j = i+1; j < mapSize; ++j)
|
|
|
|
for (j = i+1; j < mapSize; ++j)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NLMISC::CBitmap *pBI = AllMaps[i];
|
|
|
|
NLMISC::CBitmap *pBI = AllMaps[i];
|
|
|
@ -303,7 +310,7 @@ int main(int nNbArg, char **ppArgs)
|
|
|
|
vector<NLMISC::CUV> UVMin, UVMax;
|
|
|
|
vector<NLMISC::CUV> UVMin, UVMax;
|
|
|
|
UVMin.resize (mapSize, NLMISC::CUV(0.0f, 0.0f));
|
|
|
|
UVMin.resize (mapSize, NLMISC::CUV(0.0f, 0.0f));
|
|
|
|
UVMax.resize (mapSize, NLMISC::CUV(0.0f, 0.0f));
|
|
|
|
UVMax.resize (mapSize, NLMISC::CUV(0.0f, 0.0f));
|
|
|
|
for (i = 0; i < mapSize; ++i)
|
|
|
|
for (sint i = 0; i < mapSize; ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sint32 x, y;
|
|
|
|
sint32 x, y;
|
|
|
|
while (!tryAllPos(AllMaps[i], &GlobalMask, x, y))
|
|
|
|
while (!tryAllPos(AllMaps[i], &GlobalMask, x, y))
|
|
|
@ -349,7 +356,7 @@ int main(int nNbArg, char **ppArgs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Convert UV from pixel to ratio
|
|
|
|
// Convert UV from pixel to ratio
|
|
|
|
for (i = 0; i < mapSize; ++i)
|
|
|
|
for (sint i = 0; i < mapSize; ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
UVMin[i].U = UVMin[i].U / (float)GlobalTexture.getWidth();
|
|
|
|
UVMin[i].U = UVMin[i].U / (float)GlobalTexture.getWidth();
|
|
|
|
UVMin[i].V = UVMin[i].V / (float)GlobalTexture.getHeight();
|
|
|
|
UVMin[i].V = UVMin[i].V / (float)GlobalTexture.getHeight();
|
|
|
@ -394,7 +401,7 @@ int main(int nNbArg, char **ppArgs)
|
|
|
|
FILE *f = fopen (fmtName.c_str(), "wt");
|
|
|
|
FILE *f = fopen (fmtName.c_str(), "wt");
|
|
|
|
if (f != NULL)
|
|
|
|
if (f != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (i = 0; i < mapSize; ++i)
|
|
|
|
for (sint i = 0; i < mapSize; ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// get the string whitout path
|
|
|
|
// get the string whitout path
|
|
|
|
string fileName= CFile::getFilename(AllMapNames[i]);
|
|
|
|
string fileName= CFile::getFilename(AllMapNames[i]);
|
|
|
@ -442,6 +449,8 @@ int main(int nNbArg, char **ppArgs)
|
|
|
|
nlwarning("Can't parse %s", bufTmp);
|
|
|
|
nlwarning("Can't parse %s", bufTmp);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sint i;
|
|
|
|
|
|
|
|
|
|
|
|
sTGAname = toLower(string(tgaName));
|
|
|
|
sTGAname = toLower(string(tgaName));
|
|
|
|
string findTGAName;
|
|
|
|
string findTGAName;
|
|
|
|