@ -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 )