|
|
@ -30,6 +30,8 @@
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "../../pipeline/pipeline_service/tool_logger.h"
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace std;
|
|
|
@ -39,8 +41,9 @@ using namespace NLMISC;
|
|
|
|
//char sExeDir[MAX_PATH];
|
|
|
|
//char sExeDir[MAX_PATH];
|
|
|
|
std::string sExeDir;
|
|
|
|
std::string sExeDir;
|
|
|
|
NLMISC::CApplicationContext _ApplicationContext;
|
|
|
|
NLMISC::CApplicationContext _ApplicationContext;
|
|
|
|
|
|
|
|
PIPELINE::CToolLogger ToolLogger;
|
|
|
|
|
|
|
|
|
|
|
|
void outString (const string &sText)
|
|
|
|
void outString(const string &sText)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string sCurDir = CPath::getCurrentPath();
|
|
|
|
std::string sCurDir = CPath::getCurrentPath();
|
|
|
|
CPath::setCurrentPath(sExeDir.c_str());
|
|
|
|
CPath::setCurrentPath(sExeDir.c_str());
|
|
|
@ -196,15 +199,6 @@ int main(int nNbArg, char **ppArgs)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//GetCurrentDirectory (MAX_PATH, sExeDir);
|
|
|
|
//GetCurrentDirectory (MAX_PATH, sExeDir);
|
|
|
|
sExeDir = CPath::getCurrentPath();
|
|
|
|
sExeDir = CPath::getCurrentPath();
|
|
|
|
|
|
|
|
|
|
|
|
if (nNbArg < 3)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
outString ("ERROR : Wrong number of arguments\n");
|
|
|
|
|
|
|
|
outString ("USAGE : build_interface [-s<existing_uv_txt_name>] <out_tga_name> <path_maps1> [path_maps2] [path_maps3] ....\n");
|
|
|
|
|
|
|
|
outString (" -s : build a subset of an existing interface definition while preserving the existing texture ids,");
|
|
|
|
|
|
|
|
outString (" to support freeing up VRAM by switching to the subset without rebuilding the entire interface\n");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// build as a subset of existing interface
|
|
|
|
// build as a subset of existing interface
|
|
|
|
bool buildSubset = false;
|
|
|
|
bool buildSubset = false;
|
|
|
@ -219,7 +213,13 @@ int main(int nNbArg, char **ppArgs)
|
|
|
|
case 'S':
|
|
|
|
case 'S':
|
|
|
|
case 's':
|
|
|
|
case 's':
|
|
|
|
buildSubset = true;
|
|
|
|
buildSubset = true;
|
|
|
|
existingUVfilename = string( ppArgs[i]+2 );
|
|
|
|
existingUVfilename = string(ppArgs[i] + 2);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'd':
|
|
|
|
|
|
|
|
ToolLogger.initDepend(string(ppArgs[i] + 2));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'e':
|
|
|
|
|
|
|
|
ToolLogger.initError(string(ppArgs[i] + 2));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -229,14 +229,24 @@ int main(int nNbArg, char **ppArgs)
|
|
|
|
inputDirs.push_back(ppArgs[i]);
|
|
|
|
inputDirs.push_back(ppArgs[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string fmtName;
|
|
|
|
uint iNumDirs = (uint)inputDirs.size();
|
|
|
|
uint iNumDirs = (uint)inputDirs.size();
|
|
|
|
if (iNumDirs < 2)
|
|
|
|
if( iNumDirs )
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fmtName = inputDirs.front();
|
|
|
|
outString ("ERROR : Wrong number of arguments\n");
|
|
|
|
inputDirs.pop_front();
|
|
|
|
outString ("USAGE : build_interface [-s<existing_uv_txt_name>] [-d<depend_log_file>] [-e<error_log_file>] <out_tga_name> <path_maps1> [path_maps2] [path_maps3] ....\n");
|
|
|
|
--iNumDirs;
|
|
|
|
outString (" -s : build a subset of an existing interface definition while preserving the existing texture ids,");
|
|
|
|
|
|
|
|
outString (" to support freeing up VRAM by switching to the subset without rebuilding the entire interface\n");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string tgaName = inputDirs.front();
|
|
|
|
|
|
|
|
inputDirs.pop_front();
|
|
|
|
|
|
|
|
--iNumDirs;
|
|
|
|
|
|
|
|
if (tgaName.rfind('.') == string::npos)
|
|
|
|
|
|
|
|
tgaName += ".tga";
|
|
|
|
|
|
|
|
std::string uvName = tgaName.substr(0, tgaName.rfind('.'));
|
|
|
|
|
|
|
|
uvName += ".txt";
|
|
|
|
|
|
|
|
|
|
|
|
vector<string> AllMapNames;
|
|
|
|
vector<string> AllMapNames;
|
|
|
|
list<string>::iterator it = inputDirs.begin();
|
|
|
|
list<string>::iterator it = inputDirs.begin();
|
|
|
|
list<string>::iterator itEnd = inputDirs.end();
|
|
|
|
list<string>::iterator itEnd = inputDirs.end();
|
|
|
@ -245,7 +255,9 @@ int main(int nNbArg, char **ppArgs)
|
|
|
|
string sDir = *it++;
|
|
|
|
string sDir = *it++;
|
|
|
|
if( !CFile::isDirectory(sDir) )
|
|
|
|
if( !CFile::isDirectory(sDir) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
outString (string("ERROR : directory ") + sDir + " does not exist\n");
|
|
|
|
outString(string("ERROR : directory ") + sDir + " does not exist\n");
|
|
|
|
|
|
|
|
ToolLogger.writeError(PIPELINE::ERROR, sDir, "Directory does not exist.");
|
|
|
|
|
|
|
|
ToolLogger.release();
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CPath::getPathContent(sDir, false, false, true, AllMapNames);
|
|
|
|
CPath::getPathContent(sDir, false, false, true, AllMapNames);
|
|
|
@ -270,6 +282,8 @@ int main(int nNbArg, char **ppArgs)
|
|
|
|
catch (const NLMISC::Exception &e)
|
|
|
|
catch (const NLMISC::Exception &e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
outString (string("ERROR :") + e.what());
|
|
|
|
outString (string("ERROR :") + e.what());
|
|
|
|
|
|
|
|
ToolLogger.writeError(PIPELINE::ERROR, AllMapNames[i], e.what());
|
|
|
|
|
|
|
|
ToolLogger.release();
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -362,12 +376,10 @@ int main(int nNbArg, char **ppArgs)
|
|
|
|
CPath::setCurrentPath(sExeDir.c_str());
|
|
|
|
CPath::setCurrentPath(sExeDir.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
NLMISC::COFile outTga;
|
|
|
|
NLMISC::COFile outTga;
|
|
|
|
if (fmtName.rfind('.') == string::npos)
|
|
|
|
if (outTga.open(tgaName))
|
|
|
|
fmtName += ".tga";
|
|
|
|
|
|
|
|
if (outTga.open(fmtName))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string ext;
|
|
|
|
std::string ext;
|
|
|
|
if (toLower(fmtName).find(".png") != string::npos)
|
|
|
|
if (toLower(tgaName).find(".png") != string::npos)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ext = "png";
|
|
|
|
ext = "png";
|
|
|
|
GlobalTexture.writePNG (outTga, 32);
|
|
|
|
GlobalTexture.writePNG (outTga, 32);
|
|
|
@ -379,19 +391,20 @@ int main(int nNbArg, char **ppArgs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
outTga.close();
|
|
|
|
outTga.close();
|
|
|
|
outString (toString("Writing %s file : %s\n", ext.c_str(), fmtName.c_str()));
|
|
|
|
outString (toString("Writing %s file : %s\n", ext.c_str(), tgaName.c_str()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
outString (string("ERROR: Cannot write tga file : ") + fmtName + "\n");
|
|
|
|
outString (string("ERROR: Cannot write tga or png file : ") + tgaName + "\n");
|
|
|
|
|
|
|
|
ToolLogger.writeError(PIPELINE::ERROR, tgaName, "Cannot write tga or png file.");
|
|
|
|
|
|
|
|
ToolLogger.release();
|
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Write UV text file
|
|
|
|
// Write UV text file
|
|
|
|
if( !buildSubset )
|
|
|
|
if( !buildSubset )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fmtName = fmtName.substr(0, fmtName.rfind('.'));
|
|
|
|
FILE *f = fopen (uvName.c_str(), "wt");
|
|
|
|
fmtName += ".txt";
|
|
|
|
|
|
|
|
FILE *f = fopen (fmtName.c_str(), "wt");
|
|
|
|
|
|
|
|
if (f != NULL)
|
|
|
|
if (f != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (i = 0; i < mapSize; ++i)
|
|
|
|
for (i = 0; i < mapSize; ++i)
|
|
|
@ -402,11 +415,14 @@ int main(int nNbArg, char **ppArgs)
|
|
|
|
UVMax[i].U, UVMax[i].V);
|
|
|
|
UVMax[i].U, UVMax[i].V);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose (f);
|
|
|
|
fclose (f);
|
|
|
|
outString (string("Writing UV file : ") + fmtName + "\n");
|
|
|
|
outString (string("Writing UV file : ") + uvName + "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
outString (string("ERROR: Cannot write UV file : ") + fmtName + "\n");
|
|
|
|
outString (string("ERROR: Cannot write UV file : ") + uvName + "\n");
|
|
|
|
|
|
|
|
ToolLogger.writeError(PIPELINE::ERROR, uvName, "Cannot write UV file.");
|
|
|
|
|
|
|
|
ToolLogger.release();
|
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // build as a subset
|
|
|
|
else // build as a subset
|
|
|
@ -417,18 +433,20 @@ int main(int nNbArg, char **ppArgs)
|
|
|
|
if( (filename == "") || (!iFile.open(filename)) )
|
|
|
|
if( (filename == "") || (!iFile.open(filename)) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
outString (string("ERROR : could not open file ") + existingUVfilename + "\n");
|
|
|
|
outString (string("ERROR : could not open file ") + existingUVfilename + "\n");
|
|
|
|
return -1;
|
|
|
|
ToolLogger.writeError(PIPELINE::ERROR, existingUVfilename, "Could not open file.");
|
|
|
|
|
|
|
|
ToolLogger.release();
|
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Write subset UV text file
|
|
|
|
// Write subset UV text file
|
|
|
|
fmtName = fmtName.substr(0, fmtName.rfind('.'));
|
|
|
|
FILE *f = fopen (uvName.c_str(), "wt");
|
|
|
|
fmtName += ".txt";
|
|
|
|
|
|
|
|
FILE *f = fopen (fmtName.c_str(), "wt");
|
|
|
|
|
|
|
|
if (f == NULL)
|
|
|
|
if (f == NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
outString (string("ERROR: Cannot write UV file : ") + fmtName + "\n");
|
|
|
|
outString (string("ERROR: Cannot write UV file : ") + uvName + "\n");
|
|
|
|
|
|
|
|
ToolLogger.writeError(PIPELINE::ERROR, uvName, "Cannot write UV file.");
|
|
|
|
|
|
|
|
ToolLogger.release();
|
|
|
|
// fclose (iFile);
|
|
|
|
// fclose (iFile);
|
|
|
|
return -1;
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char bufTmp[256], tgaName[256];
|
|
|
|
char bufTmp[256], tgaName[256];
|
|
|
@ -467,8 +485,9 @@ int main(int nNbArg, char **ppArgs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// fclose (iFile);
|
|
|
|
// fclose (iFile);
|
|
|
|
fclose (f);
|
|
|
|
fclose (f);
|
|
|
|
outString (string("Writing UV file : ") + fmtName + "\n");
|
|
|
|
outString (string("Writing UV file : ") + uvName + "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
ToolLogger.release();
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|