Added: #1440 TextureDDS plugin using tga2dds tool

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent 3b9d2ee306
commit a01eeb9a45

@ -33,6 +33,7 @@
// NeL includes // NeL includes
#include <nel/misc/debug.h> #include <nel/misc/debug.h>
#include <nel/misc/path.h>
// Project includes // Project includes
@ -41,10 +42,92 @@ using namespace std;
namespace PIPELINE { namespace PIPELINE {
void CProcessTextureDDS::buildDDS(const std::string &dependLog, const std::string &errorLog, const std::string &srcFile, const std::string &dstFile, const std::string &algorithm, bool createMipMap, uint reduceFactor, bool checkUserColor)
{
nldebug("Build: DDS '%s'", dstFile.c_str());
std::vector<std::string> arguments;
arguments.push_back(srcFile);
arguments.push_back("-o");
arguments.push_back(dstFile);
if (!algorithm.empty())
{
arguments.push_back("-a");
arguments.push_back(algorithm);
}
if (createMipMap)
arguments.push_back("-m");
if (reduceFactor)
{
std::stringstream ss;
ss << "-r" << reduceFactor;
arguments.push_back(ss.str());
}
if (!checkUserColor)
arguments.push_back("-nousercolor");
arguments.push_back("-f");
arguments.push_back("-d");
arguments.push_back(dependLog);
arguments.push_back("-e");
arguments.push_back(errorLog);
m_PipelineProcess->runConsoleTool(m_PipelineProcess->getConfig("ToolTga2Dds"), arguments);
}
void CProcessTextureDDS::build() void CProcessTextureDDS::build()
{ {
nldebug("Build process plugin: CProcessTextureDDS"); nldebug("Build process plugin: CProcessTextureDDS");
m_PipelineProcess->setExit(FINISH_ERROR, "Not implemented");
std::string tempDir = m_PipelineProcess->getTempDirectory();
std::string dependLog = tempDir + "depend.log";
std::string errorLog = tempDir + "error.log";
{
uint nb;
if (m_PipelineProcess->getValueNb(nb, "Texture.DDS"))
{
for (uint i = 0; i < nb; ++i)
{
std::string root;
{
std::stringstream ss;
ss << "Texture.DDS[" << i << "].";
root = ss.str();
}
std::vector<std::string> srcDirectories;
if (!m_PipelineProcess->getValues(srcDirectories, root + "SrcDirectories")) break;
std::string dstDirectory;
if (!m_PipelineProcess->getValue(dstDirectory, root + "DstDirectory")) break;
std::string algorithm;
if (!m_PipelineProcess->getValue(algorithm, root + "Algorithm")) algorithm = "";
bool createMipMap;
if (!m_PipelineProcess->getValue(createMipMap, root + "CreateMipMap")) createMipMap = false;
uint reduceFactor;
if (!m_PipelineProcess->getValue(reduceFactor, root + "ReduceFactor")) reduceFactor = 0;
bool checkUserColor;
if (!m_PipelineProcess->getValue(checkUserColor, root + "CheckUserColor")) checkUserColor = false;
for (std::vector<std::string>::iterator it = srcDirectories.begin(), end = srcDirectories.end(); it != end; ++it)
{
std::vector<std::string> srcFiles;
NLMISC::CPath::getPathContent(*it, false, false, true, srcFiles);
for (std::vector<std::string>::iterator itf = srcFiles.begin(), endf = srcFiles.end(); itf != endf; ++itf)
{
const std::string &srcFile = *itf;
std::string dstFile = dstDirectory + NLMISC::CFile::getFilenameWithoutExtension(NLMISC::CFile::getFilename(srcFile)) + ".dds";
// TODO: PARAMETER inputDepends = checkUserColor (because there can be additional inputs depending on the input & depend file of the existing output) (expected input that is waited for must be in the depend log even if it doesn't exist yet!)
if (m_PipelineProcess->needsToBeRebuilt(srcFile, dstFile))
{
m_PipelineProcess->makePaths(dstFile);
buildDDS(dependLog, errorLog, srcFile, dstFile, algorithm, createMipMap, reduceFactor, checkUserColor);
if (m_PipelineProcess->needsExit()) return;
m_PipelineProcess->parseToolLog(dependLog, errorLog, false);
}
if (m_PipelineProcess->needsExit()) return;
}
}
}
}
}
m_PipelineProcess->deleteDirectoryIfEmpty(tempDir);
} }
void CProcessTextureDDSInfo::getDependentDirectories(std::vector<std::string> &resultAppend) void CProcessTextureDDSInfo::getDependentDirectories(std::vector<std::string> &resultAppend)

@ -51,7 +51,7 @@ public:
CProcessTextureDDS() { } CProcessTextureDDS() { }
virtual ~CProcessTextureDDS() { } virtual ~CProcessTextureDDS() { }
void buildAtlas(const std::string &dependLog, const std::string &errorLog, const std::vector<std::string> &srcDirectories, const std::string &dstFile); void buildDDS(const std::string &dependLog, const std::string &errorLog, const std::string &srcFile, const std::string &dstFile, const std::string &algorithm, bool createMipMap, uint reduceFactor, bool checkUserColor);
virtual void build(); virtual void build();

@ -41,6 +41,7 @@ PrimitivesDirectory = SharedLeveldesign + "/primitives";
// ToolSuffix = ".exe"; // ToolSuffix = ".exe";
ToolBuildInterface = "build_interface"; ToolBuildInterface = "build_interface";
ToolTga2Dds = "tga2dds";
// Ignored process plugins, like CProcessMaxShape, which should be completely ignored by the master service, even if they are configured to be used inside the process sheets. // Ignored process plugins, like CProcessMaxShape, which should be completely ignored by the master service, even if they are configured to be used inside the process sheets.
// MasterIgnoreProcessPlugins = { }; // Only used by the master service. NOT USED, USE WORKSPACE INTEAD! // MasterIgnoreProcessPlugins = { }; // Only used by the master service. NOT USED, USE WORKSPACE INTEAD!

@ -636,7 +636,7 @@ public:
CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_BUILD_TASK); CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_BUILD_TASK);
} }
void finishedTask(TProcessResult errorLevel, const std::string &errorMessage) void finishedTask(TProcessResult errorLevel, std::string errorMessage)
{ {
nlinfo("errorLevel: %i, errorMessage: %s", (uint32)errorLevel, errorMessage.c_str()); nlinfo("errorLevel: %i, errorMessage: %s", (uint32)errorLevel, errorMessage.c_str());
clearActiveProcess(); clearActiveProcess();

@ -66,6 +66,11 @@ bool CPipelineProject::getValue(std::string &result, const std::string &name)
nlwarning("Node '%s' not found in '%s'", name.c_str(), m_Form->getFilename().c_str()); nlwarning("Node '%s' not found in '%s'", name.c_str(), m_Form->getFilename().c_str());
return false; return false;
} }
if (!valueElm)
{
nlwarning("Node '%s' not found in '%s', valueElm returned NULL, probably using default value", name.c_str(), m_Form->getFilename().c_str());
return false;
}
std::string value; std::string value;
if (!valueElm->getValue(value)) if (!valueElm->getValue(value))
{ {

@ -71,7 +71,7 @@
<ATOM Value="[$DatabaseDirectory]/interfaces/v3_quick_help/graph"/> <ATOM Value="[$DatabaseDirectory]/interfaces/v3_quick_help/graph"/>
<ATOM Value="[$DatabaseDirectory]/interfaces/r2_decals"/> <ATOM Value="[$DatabaseDirectory]/interfaces/r2_decals"/>
</ARRAY> </ARRAY>
<ATOM Name="DstDirectory" Value="[!OutputDirectory]/interface_3d"/> <ATOM Name="DstDirectory" Value="[!OutputDirectory]/interface_fullscreen"/>
<ATOM Name="Algorithm" Value="5"/> <ATOM Name="Algorithm" Value="5"/>
</STRUCT> </STRUCT>
</ARRAY> </ARRAY>

Loading…
Cancel
Save