diff options
Diffstat (limited to '')
-rw-r--r-- | LayoutStudio.pro | 10 | ||||
-rw-r--r-- | README.markdown | 10 | ||||
-rw-r--r-- | lyt/materials/chanctrl.cpp | 42 | ||||
-rw-r--r-- | lyt/materials/chanctrl.h | 37 | ||||
-rw-r--r-- | lyt/materials/indirectstage.cpp | 47 | ||||
-rw-r--r-- | lyt/materials/indirectstage.h | 36 | ||||
-rw-r--r-- | lyt/materials/material.cpp | 32 | ||||
-rw-r--r-- | lyt/materials/material.h | 39 | ||||
-rw-r--r-- | lyt/materials/tevswaptable.cpp | 60 | ||||
-rw-r--r-- | lyt/materials/tevswaptable.h | 43 |
10 files changed, 317 insertions, 39 deletions
diff --git a/LayoutStudio.pro b/LayoutStudio.pro index a1423b7..cce0778 100644 --- a/LayoutStudio.pro +++ b/LayoutStudio.pro @@ -22,7 +22,10 @@ SOURCES += main.cpp \ lyt/group.cpp \ lyt/materials/texmap.cpp \ lyt/materials/texsrt.cpp \ - lyt/materials/texcoordgen.cpp + lyt/materials/texcoordgen.cpp \ + lyt/materials/chanctrl.cpp \ + lyt/materials/tevswaptable.cpp \ + lyt/materials/indirectstage.cpp HEADERS += lsmainwindow.h \ lsglobals.h \ lyt/packagebase.h \ @@ -40,7 +43,10 @@ HEADERS += lsmainwindow.h \ lyt/group.h \ lyt/materials/texmap.h \ lyt/materials/texsrt.h \ - lyt/materials/texcoordgen.h + lyt/materials/texcoordgen.h \ + lyt/materials/chanctrl.h \ + lyt/materials/tevswaptable.h \ + lyt/materials/indirectstage.h FORMS += lsmainwindow.ui RESOURCES += resources.qrc diff --git a/README.markdown b/README.markdown index e035b9e..635bd2a 100644 --- a/README.markdown +++ b/README.markdown @@ -1,5 +1,5 @@ LayoutStudio Readme -------------------- +=================== LayoutStudio is a work-in-progress application written by Treeki which plans to offer graphical editing of Wii NW4R layouts/banners (.brlyt/.brlan files) with @@ -23,8 +23,16 @@ GX GPU emulation in the [Dolphin][dol] GameCube/Wii emulator. - BRLAN reading/writing - Graphical interface for editing layouts and animations - Rendering of layouts using OpenGL and Dolphin's GX emulation +- BRFNT support +### Current (Short-Term) TODO ### +- Disassemble code that sets up indirect textures for materials +- Finish other material structs (plus writing) +- Add LYTLayout packing +- Add U8 archive support +- Add TPL file support + Other Stuff ----------- diff --git a/lyt/materials/chanctrl.cpp b/lyt/materials/chanctrl.cpp new file mode 100644 index 0000000..5f32e65 --- /dev/null +++ b/lyt/materials/chanctrl.cpp @@ -0,0 +1,42 @@ +/******************************************************************************* + This file is part of LayoutStudio (http://github.com/Treeki/LayoutStudio) + Copyright (c) 2010 Treeki (treeki@gmail.com) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 2.0. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License 2.0 for more details. + + You should have received a copy of the GNU General Public License 2.0 + along with this program. If not, see <http://www.gnu.org/licenses/>. +*******************************************************************************/ + +#include "chanctrl.h" +#include "../layout.h" + +LYTChanCtrl::LYTChanCtrl() { +} + +void LYTChanCtrl::dumpToDebug() { + qDebug() << "LYTChanCtrl @" << (void*)this; + qDebug() << "ColourMatSrc:" << colourMatSrc << "- AlphaMatSrc:" << alphaMatSrc; +} + + +void LYTChanCtrl::writeToDataStream(QDataStream &out) { + out << (quint8)colourMatSrc; + out << (quint8)alphaMatSrc; + out.skipRawData(2); // padding +} + + +void LYTChanCtrl::readFromDataStream(QDataStream &in) { + in >> (quint8&)colourMatSrc; + in >> (quint8&)alphaMatSrc; + in.skipRawData(2); // padding +} + diff --git a/lyt/materials/chanctrl.h b/lyt/materials/chanctrl.h new file mode 100644 index 0000000..f0183e1 --- /dev/null +++ b/lyt/materials/chanctrl.h @@ -0,0 +1,37 @@ +/******************************************************************************* + This file is part of LayoutStudio (http://github.com/Treeki/LayoutStudio) + Copyright (c) 2010 Treeki (treeki@gmail.com) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 2.0. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License 2.0 for more details. + + You should have received a copy of the GNU General Public License 2.0 + along with this program. If not, see <http://www.gnu.org/licenses/>. +*******************************************************************************/ + +#ifndef LYTCHANCTRL_H +#define LYTCHANCTRL_H + +#include "../common.h" +#include "QtCore/QDataStream" + +class LYTChanCtrl { +public: + LYTChanCtrl(); + + void writeToDataStream(QDataStream &out); + void readFromDataStream(QDataStream &in); + + void dumpToDebug(); + + quint8 colourMatSrc; + quint8 alphaMatSrc; +}; + +#endif // LYTCHANCTRL_H diff --git a/lyt/materials/indirectstage.cpp b/lyt/materials/indirectstage.cpp new file mode 100644 index 0000000..c1e6d87 --- /dev/null +++ b/lyt/materials/indirectstage.cpp @@ -0,0 +1,47 @@ +/******************************************************************************* + This file is part of LayoutStudio (http://github.com/Treeki/LayoutStudio) + Copyright (c) 2010 Treeki (treeki@gmail.com) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 2.0. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License 2.0 for more details. + + You should have received a copy of the GNU General Public License 2.0 + along with this program. If not, see <http://www.gnu.org/licenses/>. +*******************************************************************************/ + +#include "indirectstage.h" +#include "../layout.h" + +LYTIndirectStage::LYTIndirectStage() { +} + +void LYTIndirectStage::dumpToDebug() { + qDebug() << "LYTIndirectStage @" << (void*)this; + qDebug() << "texCoord:" << this->texCoord << "- texMap:" << this->texMap; + qDebug() << "wrap_s:" << this->wrap_s << "- wrap_t:" << this->wrap_t; +} + + +void LYTIndirectStage::writeToDataStream(QDataStream &out) { + out << (quint8)texCoord; + out << (quint8)texMap; + out << (quint8)wrap_s; + out << (quint8)wrap_t; +} + + +void LYTIndirectStage::readFromDataStream(QDataStream &in) { + in >> (quint8&)texCoord; + in >> (quint8&)texMap; + in >> (quint8&)wrap_s; + in >> (quint8&)wrap_t; +} + + + diff --git a/lyt/materials/indirectstage.h b/lyt/materials/indirectstage.h new file mode 100644 index 0000000..2b4bd5f --- /dev/null +++ b/lyt/materials/indirectstage.h @@ -0,0 +1,36 @@ +/******************************************************************************* + This file is part of LayoutStudio (http://github.com/Treeki/LayoutStudio) + Copyright (c) 2010 Treeki (treeki@gmail.com) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 2.0. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License 2.0 for more details. + + You should have received a copy of the GNU General Public License 2.0 + along with this program. If not, see <http://www.gnu.org/licenses/>. +*******************************************************************************/ + +#ifndef LYTINDIRECTSTAGE_H +#define LYTINDIRECTSTAGE_H + +#include "../common.h" +#include <QtCore/QDataStream> + +class LYTIndirectStage { +public: + LYTIndirectStage(); + + void writeToDataStream(QDataStream &out); + void readFromDataStream(QDataStream &in); + + void dumpToDebug(); + +}; + + +#endif // LYTINDIRECTSTAGE_H diff --git a/lyt/materials/material.cpp b/lyt/materials/material.cpp index eee9c65..1c89ae8 100644 --- a/lyt/materials/material.cpp +++ b/lyt/materials/material.cpp @@ -31,6 +31,8 @@ LYTLayout &LYTMaterial::layout() const { void LYTMaterial::dumpToDebug() { qDebug() << "LYTMaterial" << name << "@" << (void*)this; + // todo: move dumpToDebug calls for the various Material structs out of + // LYTMaterial::read...() and put them here, since it makes more sense } @@ -75,7 +77,7 @@ void LYTMaterial::readFromDataStream(QDataStream &in) { } // ChanCtrl - /*if (resourceNum.hasChanCtrl()) { + if (resourceNum.hasChanCtrl()) { this->hasChanCtrl = true; this->readChanCtrl(in); } else { @@ -112,7 +114,7 @@ void LYTMaterial::readFromDataStream(QDataStream &in) { this->readIndirectStage(in); } - // TevStage + /*// TevStage tevStages.clear(); for (int i = 0; i < resourceNum.getTevStageNum(); i++) { @@ -155,3 +157,29 @@ void LYTMaterial::readTexCoordGen(QDataStream &in) { this->texCoordGens.last().readFromDataStream(in); this->texCoordGens.last().dumpToDebug(); } + +void LYTMaterial::readChanCtrl(QDataStream &in) { + this->chanCtrl.readFromDataStream(in); + this->chanCtrl.dumpToDebug(); +} + +void LYTMaterial::readMatCol(QDataStream &in) { + ReadRGBA8Color(this->matCol, in); +} + +void LYTMaterial::readTevSwapTable(QDataStream &in) { + this->tevSwapTable.readFromDataStream(in); + this->tevSwapTable.dumpToDebug(); +} + +void LYTMaterial::readIndTexSRT(QDataStream &in) { + this->indTexSRTs.append(LYTTexSRT()); + this->indTexSRTs.last().readFromDataStream(in); + this->indTexSRTs.last().dumpToDebug(); +} + +void LYTMaterial::readIndirectStage(QDataStream &in) { + this->indTexStages.append(LYTIndirectStage()); + this->indTexStages.last().readFromDataStream(in); + this->indTexStages.last().dumpToDebug(); +} diff --git a/lyt/materials/material.h b/lyt/materials/material.h index 19cd9c5..f881803 100644 --- a/lyt/materials/material.h +++ b/lyt/materials/material.h @@ -27,6 +27,10 @@ #include "texmap.h" #include "texsrt.h" #include "texcoordgen.h" +#include "chanctrl.h" +#include "tevswaptable.h" +#include "indtexstage.h" + class LYTLayout; @@ -50,39 +54,6 @@ public: -class LYTChanCtrl { -public: - void writeToDataStream(QDataStream &out); - void readFromDataStream(QDataStream &in); - - void dumpToDebug(); - - quint8 colourMatSrc; - quint8 alphaMatSrc; -}; - -class LYTTevSwapMode { -public: - void writeToDataStream(QDataStream &out); - void readFromDataStream(QDataStream &in); - - void dumpToDebug(); - - int red; - int green; - int blue; - int alpha; -}; - -class LYTIndirectStage { -public: - void writeToDataStream(QDataStream &out); - void readFromDataStream(QDataStream &in); - - void dumpToDebug(); - -}; - class LYTTevStage { public: void writeToDataStream(QDataStream &out); @@ -142,7 +113,7 @@ public: QColor matCol; bool hasTevSwapTable; - LYTTevSwapMode tevSwapTable; + LYTTevSwapTable tevSwapTable; bool hasAlphaCompare; LYTAlphaCompare alphaCompare; diff --git a/lyt/materials/tevswaptable.cpp b/lyt/materials/tevswaptable.cpp new file mode 100644 index 0000000..05ed497 --- /dev/null +++ b/lyt/materials/tevswaptable.cpp @@ -0,0 +1,60 @@ +/******************************************************************************* + This file is part of LayoutStudio (http://github.com/Treeki/LayoutStudio) + Copyright (c) 2010 Treeki (treeki@gmail.com) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 2.0. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License 2.0 for more details. + + You should have received a copy of the GNU General Public License 2.0 + along with this program. If not, see <http://www.gnu.org/licenses/>. +*******************************************************************************/ + +#include "tevswaptable.h" +#include "../layout.h" + +LYTTevSwapTable::LYTTevSwapTable() { +} + +void LYTTevSwapTable::dumpToDebug() { + qDebug() << "LYTTevSwapTable @" << (void*)this; + + for (int i = 0; i < 4; i++) { + LYTTevSwapMode *m = &mode[i]; + qDebug() << i << ":" << m->red << "," << m->green << "," << m->blue << "," << m->alpha; + } +} + + + +void LYTTevSwapTable::writeToDataStream(QDataStream &out) { + for (int i = 0; i < 4; i++) { + quint8 val = 0; + val |= mode[i].red; + val |= (mode[i].green) << 2; + val |= (mode[i].blue) << 4; + val |= (mode[i].alpha) << 6; + + out << (quint8)val; + } +} + + +void LYTTevSwapTable::readFromDataStream(QDataStream &in) { + for (int i = 0; i < 4; i++) { + quint8 val; + in >> (quint8&)val; + + mode[i].red = BitExtract(val, 2, 32 - 8); + mode[i].green = BitExtract(val, 2, 32 - 6); + mode[i].blue = BitExtract(val, 2, 32 - 4); + mode[i].alpha = BitExtract(val, 2, 32 - 2); + } +} + + diff --git a/lyt/materials/tevswaptable.h b/lyt/materials/tevswaptable.h new file mode 100644 index 0000000..a73facf --- /dev/null +++ b/lyt/materials/tevswaptable.h @@ -0,0 +1,43 @@ +/******************************************************************************* + This file is part of LayoutStudio (http://github.com/Treeki/LayoutStudio) + Copyright (c) 2010 Treeki (treeki@gmail.com) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 2.0. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License 2.0 for more details. + + You should have received a copy of the GNU General Public License 2.0 + along with this program. If not, see <http://www.gnu.org/licenses/>. +*******************************************************************************/ + +#ifndef LYTTEVSWAPTABLE_H +#define LYTTEVSWAPTABLE_H + +#include "../common.h" +#include <QtCore/QDataStream> + +struct LYTTevSwapMode { + int red; + int green; + int blue; + int alpha; +}; + +class LYTTevSwapTable { +public: + LYTTevSwapTable(); + + void writeToDataStream(QDataStream &out); + void readFromDataStream(QDataStream &in); + + void dumpToDebug(); + + LYTTevSwapMode mode[4]; +}; + +#endif // LYTTEVSWAPTABLE_H |