From 532859713aaf0fdf482ee7d68676f6927a800eeb Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 7 Oct 2010 23:48:57 +0200 Subject: implemented some more material stuff; added readme --- lyt/materials/material.cpp | 17 +++++++++++++++-- lyt/materials/material.h | 28 ++-------------------------- lyt/materials/texcoordgen.cpp | 27 +++++++++++++++++++++++++++ lyt/materials/texcoordgen.h | 21 +++++++++++++++++++++ lyt/materials/texsrt.cpp | 31 +++++++++++++++++++++++++++++++ lyt/materials/texsrt.h | 23 +++++++++++++++++++++++ 6 files changed, 119 insertions(+), 28 deletions(-) create mode 100644 lyt/materials/texcoordgen.cpp create mode 100644 lyt/materials/texcoordgen.h create mode 100644 lyt/materials/texsrt.cpp create mode 100644 lyt/materials/texsrt.h (limited to 'lyt') diff --git a/lyt/materials/material.cpp b/lyt/materials/material.cpp index a23534c..d09614a 100644 --- a/lyt/materials/material.cpp +++ b/lyt/materials/material.cpp @@ -44,7 +44,7 @@ void LYTMaterial::readFromDataStream(QDataStream &in) { } // TexSRT - /*texSRTs.clear(); + texSRTs.clear(); for (int i = 0; i < resourceNum.getTexSRTNum(); i++) { this->readTexSRT(in); @@ -58,7 +58,7 @@ void LYTMaterial::readFromDataStream(QDataStream &in) { } // ChanCtrl - if (resourceNum.hasChanCtrl()) { + /*if (resourceNum.hasChanCtrl()) { this->hasChanCtrl = true; this->readChanCtrl(in); } else { @@ -124,4 +124,17 @@ void LYTMaterial::readFromDataStream(QDataStream &in) { void LYTMaterial::readTexMap(QDataStream &in) { this->texMaps.append(LYTTexMap()); this->texMaps.last().readFromDataStream(in, m_layout); + this->texMaps.last().dumpToDebug(); +} + +void LYTMaterial::readTexSRT(QDataStream &in) { + this->texSRTs.append(LYTTexSRT()); + this->texSRTs.last().readFromDataStream(in); + this->texSRTs.last().dumpToDebug(); +} + +void LYTMaterial::readTexCoordGen(QDataStream &in) { + this->texCoordGens.append(LYTTexCoordGen()); + this->texCoordGens.last().readFromDataStream(in); + this->texCoordGens.last().dumpToDebug(); } diff --git a/lyt/materials/material.h b/lyt/materials/material.h index 73a0e57..643f656 100644 --- a/lyt/materials/material.h +++ b/lyt/materials/material.h @@ -8,6 +8,8 @@ #include "../common.h" #include "texmap.h" +#include "texsrt.h" +#include "texcoordgen.h" class LYTLayout; @@ -31,18 +33,6 @@ public: -class LYTTexCoordGen { -public: - void writeToDataStream(QDataStream &out); - void readFromDataStream(QDataStream &in); - - void dumpToDebug(); - - quint8 genType; - quint8 src; - quint8 mtx; -}; - class LYTChanCtrl { public: void writeToDataStream(QDataStream &out); @@ -67,20 +57,6 @@ public: int alpha; }; -class LYTTexSRT { -public: - void writeToDataStream(QDataStream &out); - void readFromDataStream(QDataStream &in); - - void dumpToDebug(); - - float xTrans; - float yTrans; - float rotate; - float xScale; - float yScale; -}; - class LYTIndirectStage { public: void writeToDataStream(QDataStream &out); diff --git a/lyt/materials/texcoordgen.cpp b/lyt/materials/texcoordgen.cpp new file mode 100644 index 0000000..9a47479 --- /dev/null +++ b/lyt/materials/texcoordgen.cpp @@ -0,0 +1,27 @@ +#include "texcoordgen.h" +#include "../layout.h" + +LYTTexCoordGen::LYTTexCoordGen() { +} + +void LYTTexCoordGen::dumpToDebug() { + qDebug() << "LYTTexCoordGen @" << (void*)this; + qDebug() << "GenType:" << genType << "- Mtx:" << mtx << "- Src:" << src; +} + + +void LYTTexCoordGen::writeToDataStream(QDataStream &out) { + out << (quint8)genType; + out << (quint8)src; + out << (quint8)mtx; + out.skipRawData(1); // padding +} + + +void LYTTexCoordGen::readFromDataStream(QDataStream &in) { + in >> (quint8&)genType; + in >> (quint8&)src; + in >> (quint8&)mtx; + in.skipRawData(1); // padding +} + diff --git a/lyt/materials/texcoordgen.h b/lyt/materials/texcoordgen.h new file mode 100644 index 0000000..5e66b8e --- /dev/null +++ b/lyt/materials/texcoordgen.h @@ -0,0 +1,21 @@ +#ifndef LYTTEXCOORDGEN_H +#define LYTTEXCOORDGEN_H + +#include "../common.h" +#include + +class LYTTexCoordGen { +public: + LYTTexCoordGen(); + + void writeToDataStream(QDataStream &out); + void readFromDataStream(QDataStream &in); + + void dumpToDebug(); + + quint8 genType; + quint8 src; + quint8 mtx; +}; + +#endif // LYTTEXCOORDGEN_H diff --git a/lyt/materials/texsrt.cpp b/lyt/materials/texsrt.cpp new file mode 100644 index 0000000..25e28ca --- /dev/null +++ b/lyt/materials/texsrt.cpp @@ -0,0 +1,31 @@ +#include "texsrt.h" +#include "../layout.h" + +LYTTexSRT::LYTTexSRT() { +} + +void LYTTexSRT::dumpToDebug() { + qDebug() << "LYTTexSRT @" << (void*)this; + qDebug() << "Scale:" << xScale << "," << yScale; + qDebug() << "Rotation:" << rotate; + qDebug() << "Translation:" << xTrans << "," << yTrans; +} + + +void LYTTexSRT::writeToDataStream(QDataStream &out) { + out << (float)xTrans; + out << (float)yTrans; + out << (float)rotate; + out << (float)xScale; + out << (float)yScale; +} + + +void LYTTexSRT::readFromDataStream(QDataStream &in) { + in >> (float&)xTrans; + in >> (float&)yTrans; + in >> (float&)rotate; + in >> (float&)xScale; + in >> (float&)yScale; +} + diff --git a/lyt/materials/texsrt.h b/lyt/materials/texsrt.h new file mode 100644 index 0000000..ad5e470 --- /dev/null +++ b/lyt/materials/texsrt.h @@ -0,0 +1,23 @@ +#ifndef LYTTEXSRT_H +#define LYTTEXSRT_H + +#include "../common.h" +#include + +class LYTTexSRT { +public: + LYTTexSRT(); + + void writeToDataStream(QDataStream &out); + void readFromDataStream(QDataStream &in); + + void dumpToDebug(); + + float xTrans; + float yTrans; + float rotate; + float xScale; + float yScale; +}; + +#endif // LYTTEXSRT_H -- cgit v1.2.3