summaryrefslogtreecommitdiff
path: root/lyt
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2010-10-08 04:53:53 +0200
committerTreeki <treeki@gmail.com>2010-10-08 04:53:53 +0200
commitd74825ae7be1cee0cfd625a79289e9494fcda661 (patch)
treef3b9a19c76734802697a6d053e24dab4a4708f38 /lyt
parente813d6ede6bed1e69d749bb32529d657a9d96173 (diff)
downloadLayoutStudio-d74825ae7be1cee0cfd625a79289e9494fcda661.tar.gz
LayoutStudio-d74825ae7be1cee0cfd625a79289e9494fcda661.zip
added a short-term todo list to the readme, and some more material code. three structs left! hopefully I'll have materials done tomorrow :D
Diffstat (limited to 'lyt')
-rw-r--r--lyt/materials/chanctrl.cpp42
-rw-r--r--lyt/materials/chanctrl.h37
-rw-r--r--lyt/materials/indirectstage.cpp47
-rw-r--r--lyt/materials/indirectstage.h36
-rw-r--r--lyt/materials/material.cpp32
-rw-r--r--lyt/materials/material.h39
-rw-r--r--lyt/materials/tevswaptable.cpp60
-rw-r--r--lyt/materials/tevswaptable.h43
8 files changed, 300 insertions, 36 deletions
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