Changed: Minor changes

This commit is contained in:
kervala 2016-09-23 13:29:50 +02:00
parent b35b7325c9
commit 0baef7f715

View file

@ -147,11 +147,10 @@ bool putIn (NLMISC::CBitmap *pSrc, NLMISC::CBitmap *pDst, sint32 x, sint32 y, bo
// ***************************************************************************
string getBaseName(const string &fullname)
{
string sTmp2;
string basename;
string::size_type pos = fullname.rfind('_');
if (pos != string::npos)
sTmp2 = fullname.substr(0, pos+1);
return sTmp2;
if (pos != string::npos) basename = fullname.substr(0, pos+1);
return basename;
}
// ***************************************************************************
@ -221,6 +220,7 @@ int main(int argc, char **argv)
outString(toString("ERROR: directory %s does not exist", sDir.c_str()));
return -1;
}
CPath::getPathContent(sDir, false, false, true, AllMapNames);
}
@ -238,6 +238,7 @@ int main(int argc, char **argv)
{
pBtmp = new NLMISC::CBitmap;
NLMISC::CIFile inFile;
if (!inFile.open(AllMapNames[i])) throw NLMISC::Exception("Unable to open " + AllMapNames[i]);
uint8 colors = pBtmp->load(inFile);
@ -288,6 +289,7 @@ int main(int argc, char **argv)
vector<NLMISC::CUV> UVMin, UVMax;
UVMin.resize (mapSize, NLMISC::CUV(0.0f, 0.0f));
UVMax.resize (mapSize, NLMISC::CUV(0.0f, 0.0f));
for (sint i = 0; i < mapSize; ++i)
{
sint32 x, y;
@ -297,40 +299,20 @@ int main(int argc, char **argv)
enlargeCanvas (GlobalTexture);
enlargeCanvas (GlobalMask);
}
putIn (AllMaps[i], &GlobalTexture, x, y);
putIn (AllMaps[i], &GlobalMask, x, y, false);
UVMin[i].U = (float)x;
UVMin[i].V = (float)y;
UVMax[i].U = (float)x+AllMaps[i]->getWidth();
UVMax[i].V = (float)y+AllMaps[i]->getHeight();
/* // Do not remove this is useful for debugging
{
NLMISC::COFile outTga;
string fmtName = ppArgs[1];
if (fmtName.rfind('.') == string::npos)
fmtName += ".tga";
if (outTga.open(fmtName))
{
GlobalTexture.writeTGA (outTga, 32);
outTga.close();
}
}
{
NLMISC::COFile outTga;
string fmtName = ppArgs[1];
if (fmtName.rfind('.') == string::npos)
fmtName += "_msk.tga";
else
fmtName = fmtName.substr(0,fmtName.rfind('.')) + "_msk.tga";
if (outTga.open(fmtName))
{
GlobalMask.writeTGA (outTga, 32);
outTga.close();
}
}*/
#if 0
// Do not remove this is useful for debugging
writeFileDependingOnFilename(fmtName.substr(0, fmtName.rfind('.')) + "_txt.png", GlobalTexture);
writeFileDependingOnFilename(fmtName.substr(0, fmtName.rfind('.')) + "_msk.png", GlobalMask);
#endif
}
// Convert UV from pixel to ratio
@ -370,9 +352,9 @@ int main(int argc, char **argv)
{
// get the string whitout path
string fileName = CFile::getFilename(AllMapNames[i]);
fprintf (f, "%s %.12f %.12f %.12f %.12f\n", fileName.c_str(), UVMin[i].U, UVMin[i].V,
UVMax[i].U, UVMax[i].V);
fprintf (f, "%s %.12f %.12f %.12f %.12f\n", fileName.c_str(), UVMin[i].U, UVMin[i].V, UVMax[i].U, UVMax[i].V);
}
fclose (f);
outString(toString("Writing UV file %s", fmtName.c_str()));
@ -387,7 +369,8 @@ int main(int argc, char **argv)
// Load existing uv file
CIFile iFile;
string filename = CPath::lookup (existingUVfilename, false);
if( (filename == "") || (!iFile.open(filename)) )
if( filename.empty() || !iFile.open(filename) )
{
outString(toString("ERROR: Unable to open %s", existingUVfilename.c_str()));
return -1;
@ -440,7 +423,6 @@ int main(int argc, char **argv)
UVMax[i].U, UVMax[i].V);
}
}
// fclose (iFile);
fclose (f);
outString(toString("Writing UV file: %s", fmtName.c_str()));
}