Added an action in the Model Editor for converting DDS to TXTR
This commit is contained in:
parent
6ceb1b9230
commit
2adddad4b6
|
@ -14,6 +14,7 @@
|
||||||
#include <Resource/factory/CMaterialLoader.h>
|
#include <Resource/factory/CMaterialLoader.h>
|
||||||
#include <Resource/factory/CTextureDecoder.h>
|
#include <Resource/factory/CTextureDecoder.h>
|
||||||
#include <Resource/cooker/CModelCooker.h>
|
#include <Resource/cooker/CModelCooker.h>
|
||||||
|
#include <Resource/cooker/CTextureEncoder.h>
|
||||||
#include "WColorPicker.h"
|
#include "WColorPicker.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -832,3 +833,28 @@ void CModelEditorWindow::on_CameraModeButton_clicked()
|
||||||
pCam->SetOrbitDistance(Pos.Distance(Target));
|
pCam->SetOrbitDistance(Pos.Distance(Target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CModelEditorWindow::on_actionConvert_DDS_to_TXTR_triggered()
|
||||||
|
{
|
||||||
|
QString Input = QFileDialog::getOpenFileName(this, "DirectDraw Surface (*.dds)", "", "*.dds");
|
||||||
|
if (Input.isEmpty()) return;
|
||||||
|
|
||||||
|
TString TexFilename = TO_TSTRING(Input);
|
||||||
|
CTexture *Tex = CTextureDecoder::LoadDDS(CFileInStream(TexFilename.ToStdString(), IOUtil::LittleEndian));
|
||||||
|
TString OutName = TexFilename.GetFilePathWithoutExtension() + ".txtr";
|
||||||
|
|
||||||
|
if ((Tex->TexelFormat() != eDXT1) || (Tex->NumMipMaps() > 1))
|
||||||
|
QMessageBox::warning(this, "Error", "Can't convert DDS to TXTR! Save your texture as a DXT1 DDS with no mipmaps, then try again.");
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CFileOutStream Out(OutName.ToStdString(), IOUtil::BigEndian);
|
||||||
|
if (!Out.IsValid()) QMessageBox::warning(this, "Error", "Couldn't open output TXTR!");
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CTextureEncoder::EncodeTXTR(Out, Tex, eGX_CMPR);
|
||||||
|
QMessageBox::information(this, "Success", "Successfully converted to TXTR!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -117,6 +117,8 @@ private slots:
|
||||||
|
|
||||||
void on_CameraModeButton_clicked();
|
void on_CameraModeButton_clicked();
|
||||||
|
|
||||||
|
void on_actionConvert_DDS_to_TXTR_triggered();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void Closed();
|
void Closed();
|
||||||
};
|
};
|
||||||
|
|
|
@ -2443,6 +2443,7 @@
|
||||||
<string>Textures</string>
|
<string>Textures</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionConvert_to_DDS"/>
|
<addaction name="actionConvert_to_DDS"/>
|
||||||
|
<addaction name="actionConvert_DDS_to_TXTR"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuWindow">
|
<widget class="QMenu" name="menuWindow">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -2504,6 +2505,11 @@
|
||||||
<string>Save as...</string>
|
<string>Save as...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionConvert_DDS_to_TXTR">
|
||||||
|
<property name="text">
|
||||||
|
<string>Convert DDS to TXTR</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
Loading…
Reference in New Issue