// NeL - MMORPG Framework
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
#include "hls_bank_maker.h"
#include "nel/3d/hls_texture_bank.h"
#include "../panoply_maker/hls_bank_texture_info.h"
#include "nel/misc/path.h"
#include "nel/misc/file.h"
#include
using namespace std;
using namespace NLMISC;
using namespace NL3D;
// ***************************************************************************
/*
Be aware that This project use and compile ../panoply_maker/hls_bank_texture_info.*
*/
// ***************************************************************************
void addTextToBank(CHLSBankTextureInfo &textInfo, CHLSTextureBank &textBank)
{
uint i;
// **** Build the color texture
CHLSColorTexture colText;
CBitmap bmp;
// set the DXTC5 bmp.
textInfo.SrcBitmap.buildBitmap(bmp);
colText.setBitmap(bmp);
// Add masks.
for(i=0;i cols;
cols.resize(instIn.Mods.size());
for(uint j=0;jaddNegativeFilter ("adding the path");
if (argc != 3)
{
nlwarning("usage : %s hlsinfo_dir output_name ", argv[0]);
exit(-1);
}
// get all .hlsinfo file in directory.
vector files;
vector hlsInfofiles;
NLMISC::CPath::getPathContent(argv[1], false, false, true, files);
hlsInfofiles.reserve(files.size());
uint k;
for (k = 0; k < files.size(); ++k)
{
std::string fileExt = NLMISC::strupr(NLMISC::CFile::getExtension(files[k]));
if(fileExt=="HLSINFO")
hlsInfofiles.push_back(files[k]);
}
// If none, quit.
if(hlsInfofiles.empty())
exit(-1);
// Concat all hlsinfo in a Bank
CHLSTextureBank textBank;
for (k = 0; k < hlsInfofiles.size(); ++k)
{
printf("HLSBank Process [%2d]\r", (uint)(100*k/hlsInfofiles.size()));
try
{
CIFile f(hlsInfofiles[k]);
CHLSBankTextureInfo textInfo;
f.serial(textInfo);
addTextToBank(textInfo, textBank);
}
catch(const Exception &e)
{
nlwarning("ERROR: Unable to process %s. Reason: %s. Processing next", hlsInfofiles[k].c_str(), e.what());
}
}
// compile it
textBank.compile();
// save the bank.
COFile fOut;
try
{
if(!fOut.open(argv[2]))
throw int(0);
fOut.serial(textBank);
fOut.close();
}
catch(const Exception &e)
{
nlwarning("ERROR: Unable to write HLS Bank %s: %s", argv[2], e.what());
exit(-1);
}
catch(...)
{
nlwarning("ERROR: Unable to write HLS Bank %s.", argv[2]);
exit(-1);
}
return 0;
}