void hkvExternalToolWiiUTexConv2::determineCommandLineParameters(
  const hkvTextureTransformationSettings& settings, const char* sourceFile, const char* targetFile)
{
  // Build the command line argument string
  hkStringBuf sourceFileBuf(sourceFile);
  sourceFileBuf.replace('/', '\\');

  hkStringBuf targetFileBuf(targetFile);
  targetFileBuf.replace('/', '\\');

  hkStringBuf paramBuf;

  paramBuf.appendJoin(" -i \"", sourceFileBuf.cString(), "\"");
  paramBuf.appendJoin(" -o \"", targetFileBuf.cString(), "\"");

  if (settings.getCreateMipMaps())
  {
    paramBuf.append(" -minmip 1 -mipFilter box");
  }

  paramBuf.append(" -align");
  
  // Enable the following line to get extended information back 
  // from the conversion tool
  //paramBuf.append(" -printinfo");

  m_commandLine = paramBuf;
}
void hkvExternalToolNvDxt::determineCommandLineParameters(
  const hkvTextureTransformationSettings& settings, const char* sourceFile, const char* targetFile)
{
  // Build the command line argument string
  hkStringBuf sourceFileBuf(sourceFile);
  sourceFileBuf.replace('/', '\\');
  hkStringBuf targetFileBuf(targetFile);
  targetFileBuf.replace('/', '\\');

  hkStringBuf paramBuf;
  paramBuf.appendJoin(" -file \"", sourceFileBuf, "\"");
  paramBuf.appendJoin(" -output \"", targetFileBuf, "\"");

  hkvTextureDataFormat dataFormat = settings.getTargetDataFormat();
  VASSERT_MSG(hkvNvDxtFormatStrings[dataFormat].m_format == dataFormat, "nvDXT format string lookup is inconsistent with defined texture data formats!");
  paramBuf.appendJoin(" -", hkvNvDxtFormatStrings[dataFormat].m_string);

  if (!settings.getCreateMipMaps())
  {
    paramBuf.appendJoin(" -nomipmap");
  }

  if ((settings.getTargetWidth() != settings.getSourceWidth()) || (settings.getTargetHeight() != settings.getSourceHeight()))
  {
    paramBuf.appendPrintf(" -prescale %i %i", settings.getTargetWidth(), settings.getTargetHeight());
  }

  m_commandLine = paramBuf;
}
void hkvExternalToolPvrTexTool::determineCommandLineParameters(
  const hkvTextureTransformationSettings& settings, const char* sourceFile, const char* targetFile)
{
  // Build the command line argument string
  hkStringBuf sourceFileBuf(sourceFile);
  sourceFileBuf.replace('/', '\\');
  hkStringBuf targetFileBuf(targetFile);
  targetFileBuf.replace('/', '\\');

  hkStringBuf paramBuf;
  paramBuf.appendJoin(" -i \"", sourceFileBuf, "\"");
  paramBuf.appendJoin(" -o \"", targetFileBuf, "\"");

  hkvTextureDataFormat dataFormat = settings.getTargetDataFormat();
  VASSERT_MSG(hkvPvrTexToolFormatStrings[dataFormat].m_format == dataFormat, "PVRTexTool format string lookup is inconsistent with defined texture formats!");
  paramBuf.appendJoin(" -f ", hkvPvrTexToolFormatStrings[dataFormat].m_string);

  switch (settings.getTargetFileFormat())
  {
  case HKV_TEXTURE_FILE_FORMAT_DDS:
    {
      break;
    }
  case HKV_TEXTURE_FILE_FORMAT_ETC:
    {
      paramBuf.append(" -legacypvr");
      break;
    }
  case HKV_TEXTURE_FILE_FORMAT_PVR:
    {
      paramBuf.append(" -legacypvr");
      break;
    }
  }

  if (settings.getCreateMipMaps())
  {
    paramBuf.append(" -m");
    paramBuf.append(" -mfilter cubic");
  }

  if (settings.getTargetWidth() != settings.getSourceWidth() || settings.getTargetHeight() != settings.getSourceHeight())
  {
    paramBuf.appendPrintf(" -r %i,%i", settings.getTargetWidth(), settings.getTargetHeight());
    paramBuf.appendPrintf(" -rfilter cubic");
  }
  
  m_commandLine = paramBuf;
}
void hkvTextureTransformationSettings::assignFrom(const hkvTextureTransformationSettings& other, bool explicitSize)
{
  m_sourceHasAlpha = other.m_sourceHasAlpha;
  m_sourceWidth = other.m_sourceWidth;
  m_sourceHeight = other.m_sourceHeight;
  m_sourceSrgb = other.m_sourceSrgb;

  m_usage = other.m_usage;
  m_targetDataFormat = other.m_targetDataFormat;
  m_targetFileFormat = other.m_targetFileFormat;
  m_discardAlpha = other.m_discardAlpha;
  m_createMipMaps = other.m_createMipMaps;
  m_downscaleLevel = other.m_downscaleLevel;
  m_userMinSize = other.m_userMinSize;
  m_userMaxSize = other.m_userMaxSize;

  if (explicitSize)
  {
    setExplicitTargetSize(other.getTargetWidth(), other.getTargetHeight());
  }

  m_valid = false;
}
void hkvExternalToolTexConv::determineCommandLineParameters(
  const hkvTextureTransformationSettings& settings, const char* sourceFile, const char* targetFile)
{
  // Build the command line argument string
  hkStringBuf sourceFileBuf(sourceFile);
  sourceFileBuf.replace('/', '\\');

  hkStringBuf outFileDir(sourceFile);
  outFileDir.pathDirname();
  outFileDir.replace('/', '\\');

  hkStringBuf sourceFileBaseName(sourceFile);
  sourceFileBaseName.pathBasename();
  hkvStringHelper::pathNoExtension(sourceFileBaseName);

  hkStringBuf outFileName(outFileDir);
  outFileName.appendJoin("/", sourceFileBaseName, "_out.dds");
  setTargetFile(outFileName);

  hkStringBuf paramBuf;
  paramBuf.append(" -nologo");

  if(m_forceDxt10)
  {
    paramBuf.append(" -dx10");
  }

  if (settings.getTargetWidth() != settings.getSourceWidth())
  {
    paramBuf.appendPrintf(" -w %i", settings.getTargetWidth());
  }
  if (settings.getTargetHeight() != settings.getSourceHeight())
  {
    paramBuf.appendPrintf(" -h %i", settings.getTargetHeight());
  }

  if (settings.getCreateMipMaps())
  {
    paramBuf.append(" -m 0");
  }
  else
  {
    paramBuf.append(" -m 1");
  }

  paramBuf.append(" -sepalpha");

  hkvTextureDataFormat dataFormat = settings.getTargetDataFormat();
  VASSERT_MSG(hkvTexConvFormatStrings[dataFormat].m_format == dataFormat, "TexConv format string lookup is inconsistent with defined texture formats!");
  paramBuf.appendJoin(" -f ", hkvTexConvFormatStrings[dataFormat].m_string);

  paramBuf.append(" -if CUBIC");

  paramBuf.append(" -sx _out");

  paramBuf.appendJoin(" -o \"", outFileDir.cString(), "\"");

  paramBuf.append(" -ft DDS");

  paramBuf.appendJoin(" \"", sourceFileBuf.cString(), "\"");

  m_commandLine = paramBuf;
}
void hkvExternalToolPvrTexTool::determineCommandLineParameters(
  const hkvTextureTransformationSettings& settings, const char* sourceFile, const char* targetFile)
{
  // Build the command line argument string
  hkStringBuf sourceFileBuf(sourceFile);
  sourceFileBuf.replace('/', '\\');
  hkStringBuf targetFileBuf(targetFile);
  targetFileBuf.replace('/', '\\');

  hkStringBuf paramBuf;
  paramBuf.appendJoin(" -i \"", sourceFileBuf, "\"");
  paramBuf.appendJoin(" -o \"", targetFileBuf, "\"");

  //TODO: Add ETC2 and PVRTC2 support
  const char* dataFormatStr = NULL;
  switch (settings.getTargetDataFormat())
  {
  case HKV_IMAGE_DATA_FORMAT_PVRTC2:
    dataFormatStr = "PVRTC1_2";
    break;
  case HKV_IMAGE_DATA_FORMAT_PVRTC4:
    dataFormatStr = "PVRTC1_4";
    break;
  case HKV_IMAGE_DATA_FORMAT_ETC1:
    dataFormatStr = "ETC1";
    break;
  }

  if (dataFormatStr != NULL)
  {
    paramBuf.appendJoin(" -f ", dataFormatStr);
  }
  else
  {
    VASSERT_MSG(dataFormatStr != NULL, "Unsupported data format specified!");
  }

  switch (settings.getTargetFileFormat())
  {
  case HKV_IMAGE_FILE_FORMAT_DDS:
    {
      break;
    }
  case HKV_IMAGE_FILE_FORMAT_ETC:
  case HKV_IMAGE_FILE_FORMAT_PVR:
    {
      paramBuf.append(" -legacypvr");
      break;
    }
  }

  if (settings.getCreateMipMaps())
  {
    paramBuf.append(" -m");
    paramBuf.append(" -mfilter cubic");
  }

  if (settings.getTargetWidth() != settings.getSourceWidth() || settings.getTargetHeight() != settings.getSourceHeight())
  {
    paramBuf.appendPrintf(" -r %i,%i", settings.getTargetWidth(), settings.getTargetHeight());
    paramBuf.appendPrintf(" -rfilter cubic");
  }
  
  m_commandLine = paramBuf;
}