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