Material lookup by name + minor fixes

This commit is contained in:
parax0 2015-08-08 11:21:49 -04:00
parent 9157acd164
commit 8d90cd7e01
9 changed files with 33 additions and 35 deletions

View File

@ -211,7 +211,7 @@ namespace StringUtil
int CodePoint; int CodePoint;
// One byte // One byte
if ((cstr[0] & 0x80000000) == 0) if ((cstr[0] & 0x80) == 0)
{ {
CodePoint = cstr[0] & 0x7FFFFFFF; CodePoint = cstr[0] & 0x7FFFFFFF;
cstr++; cstr++;

View File

@ -1,20 +1,8 @@
#include <QApplication> #include <QApplication>
#include <UI/CStartWindow.h> #include <UI/CStartWindow.h>
#include <UI/CWorldEditorWindow.h>
#include <UI/CModelEditorWindow.h>
#include <UI/TestDialog.h>
#include <Common/CTimer.h>
#include <iostream>
#include <QStyleFactory> #include <QStyleFactory>
#include <UI/CDarkStyle.h> #include <UI/CDarkStyle.h>
#include <time.h>
#include <Resource/factory/CTextureDecoder.h>
#include <Resource/cooker/CTextureEncoder.h>
#include <Common/CMatrix4f.h>
#include <Resource/factory/CTemplateLoader.h> #include <Resource/factory/CTemplateLoader.h>
#include <Common/StringUtil.h>
#include <QDir>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@ -24,8 +12,6 @@ int main(int argc, char *argv[])
w.show(); w.show();
CTemplateLoader::LoadGameList(); CTemplateLoader::LoadGameList();
//CTexture *pTex = CTextureDecoder::LoadDDS(CFileInStream("E:/34f7c12211777ce8.dds", IOUtil::LittleEndian));
//CTextureEncoder::EncodeTXTR(CFileOutStream("E:/Unpacked/Metroid Prime 3 Dolphin/Metroid4-pak/34f7c12211777ce8.TXTR", IOUtil::BigEndian), pTex);
app.setStyle(new CDarkStyle); app.setStyle(new CDarkStyle);
qApp->setStyle(QStyleFactory::create("Fusion")); qApp->setStyle(QStyleFactory::create("Fusion"));

View File

@ -132,7 +132,8 @@ SOURCES += \
Resource/factory/CScanLoader.cpp \ Resource/factory/CScanLoader.cpp \
UI/WStringPreviewPanel.cpp \ UI/WStringPreviewPanel.cpp \
UI/WScanPreviewPanel.cpp \ UI/WScanPreviewPanel.cpp \
UI/WIntegralSpinBox.cpp UI/WIntegralSpinBox.cpp \
UI/CAboutDialog.cpp
HEADERS += \ HEADERS += \
Common/AnimUtil.h \ Common/AnimUtil.h \
@ -278,7 +279,8 @@ HEADERS += \
Resource/factory/CScanLoader.h \ Resource/factory/CScanLoader.h \
UI/WStringPreviewPanel.h \ UI/WStringPreviewPanel.h \
UI/WScanPreviewPanel.h \ UI/WScanPreviewPanel.h \
UI/WIntegralSpinBox.h UI/WIntegralSpinBox.h \
UI/CAboutDialog.h
FORMS += \ FORMS += \
UI/CWorldEditorWindow.ui \ UI/CWorldEditorWindow.ui \
@ -292,7 +294,8 @@ FORMS += \
UI/WorldEditor/WModifyTab.ui \ UI/WorldEditor/WModifyTab.ui \
UI/WorldEditor/WInstancesTab.ui \ UI/WorldEditor/WInstancesTab.ui \
UI/WorldEditor/CLayerEditor.ui \ UI/WorldEditor/CLayerEditor.ui \
UI/WScanPreviewPanel.ui UI/WScanPreviewPanel.ui \
UI/CAboutDialog.ui
INCLUDEPATH += E:\C++\Libraries\glm\glm .\ INCLUDEPATH += E:\C++\Libraries\glm\glm .\
@ -338,3 +341,4 @@ DISTFILES += \
RESOURCES += \ RESOURCES += \
Icons.qrc Icons.qrc

View File

@ -40,3 +40,10 @@ CMaterial* CMaterialSet::MaterialByName(const std::string &name)
if ((*it)->Name() == name) return *it; if ((*it)->Name() == name) return *it;
return nullptr; return nullptr;
} }
u32 CMaterialSet::MaterialIndexByName(const std::string& name)
{
for (u32 iMat = 0; iMat < mMaterials.size(); iMat++)
if (mMaterials[iMat]->Name() == name) return iMat;
return -1;
}

View File

@ -20,6 +20,7 @@ public:
u32 NumMaterials(); u32 NumMaterials();
CMaterial* MaterialByIndex(u32 index); CMaterial* MaterialByIndex(u32 index);
CMaterial* MaterialByName(const std::string& name); CMaterial* MaterialByName(const std::string& name);
u32 MaterialIndexByName(const std::string& name);
}; };
#endif // CMATERIALSET_H #endif // CMATERIALSET_H

View File

@ -15,21 +15,6 @@ CMaterialLoader::~CMaterialLoader()
{ {
} }
CMaterialSet* CMaterialLoader::LoadMaterialSet(CInputStream& Mat, EGame Version)
{
CMaterialLoader Loader;
Loader.mpSet = new CMaterialSet();
Loader.mpFile = &Mat;
Loader.mVersion = Version;
if ((Version >= ePrimeKioskDemo) && (Version <= eEchoes))
Loader.ReadPrimeMatSet();
else
Loader.ReadCorruptionMatSet();
return Loader.mpSet;
}
void CMaterialLoader::ReadPrimeMatSet() void CMaterialLoader::ReadPrimeMatSet()
{ {
// Textures // Textures
@ -590,3 +575,19 @@ void CMaterialLoader::CreateCorruptionPasses(CMaterial *pMat)
} }
} }
} }
// ************ STATIC ************
CMaterialSet* CMaterialLoader::LoadMaterialSet(CInputStream& Mat, EGame Version)
{
CMaterialLoader Loader;
Loader.mpSet = new CMaterialSet();
Loader.mpFile = &Mat;
Loader.mVersion = Version;
if ((Version >= ePrimeKioskDemo) && (Version <= eEchoes))
Loader.ReadPrimeMatSet();
else
Loader.ReadCorruptionMatSet();
return Loader.mpSet;
}

View File

@ -32,6 +32,7 @@ class CMaterialLoader
CMaterial* ReadCorruptionMaterial(); CMaterial* ReadCorruptionMaterial();
void CreateCorruptionPasses(CMaterial *pMat); void CreateCorruptionPasses(CMaterial *pMat);
// Static
public: public:
static CMaterialSet* LoadMaterialSet(CInputStream& Mat, EGame Version); static CMaterialSet* LoadMaterialSet(CInputStream& Mat, EGame Version);
}; };

View File

@ -1,7 +1,6 @@
#ifndef CMODELLOADER_H #ifndef CMODELLOADER_H
#define CMODELLOADER_H #define CMODELLOADER_H
#include "../model/SModelData.h"
#include "../model/CBasicModel.h" #include "../model/CBasicModel.h"
#include "../model/CModel.h" #include "../model/CModel.h"
#include "../EFormatVersion.h" #include "../EFormatVersion.h"

View File

@ -2,7 +2,6 @@
#define CMODEL_H #define CMODEL_H
#include "CBasicModel.h" #include "CBasicModel.h"
#include "SModelData.h"
#include "SSurface.h" #include "SSurface.h"
#include "../CMaterialSet.h" #include "../CMaterialSet.h"