summaryrefslogtreecommitdiff
path: root/lyt/materials/texmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lyt/materials/texmap.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/lyt/materials/texmap.cpp b/lyt/materials/texmap.cpp
new file mode 100644
index 0000000..1bb416b
--- /dev/null
+++ b/lyt/materials/texmap.cpp
@@ -0,0 +1,41 @@
+#include "texmap.h"
+#include "../layout.h"
+
+LYTTexMap::LYTTexMap() {
+}
+
+void LYTTexMap::dumpToDebug() {
+ qDebug() << "LYTTexMap @" << (void*)this << ":" << textureName;
+ qDebug() << "- wrap_s:" << wrap_s << "- wrap_t:" << wrap_t;
+ qDebug() << "- mag_filter:" << mag_filter << "- min_filter:" << min_filter;
+}
+
+
+void LYTTexMap::writeToDataStream(QDataStream &out, LYTLayout &layout) {
+ quint16 texNum = layout.m_textureRefs.indexOf(textureName);
+ out << (quint16)texNum;
+
+ quint8 var1, var2;
+ var1 = wrap_s | (((min_filter + 7) & 7) << 2);
+ var2 = wrap_t | (((mag_filter + 1) & 1) << 2);
+ out << (quint8)var1;
+ out << (quint8)var2;
+}
+
+
+void LYTTexMap::readFromDataStream(QDataStream &in, LYTLayout &layout) {
+ quint16 texNum;
+ in >> (quint16&)texNum;
+
+ textureName = layout.m_textureRefs[texNum];
+
+ quint8 var1, var2;
+ in >> (quint8&)var1;
+ in >> (quint8&)var2;
+
+ wrap_s = BitExtract(var1, 2, 30);
+ wrap_t = BitExtract(var2, 2, 30);
+
+ min_filter = (BitExtract(var1, 3, 27) + 1) & 7;
+ mag_filter = (BitExtract(var2, 1, 29) + 1) & 1;
+}