diff options
Diffstat (limited to '')
-rw-r--r-- | lyt/materials/indirectstage.h | 8 | ||||
-rw-r--r-- | lyt/materials/material.cpp | 101 | ||||
-rw-r--r-- | lyt/materials/material.h | 49 |
3 files changed, 98 insertions, 60 deletions
diff --git a/lyt/materials/indirectstage.h b/lyt/materials/indirectstage.h index 30c6f9d..8f381bf 100644 --- a/lyt/materials/indirectstage.h +++ b/lyt/materials/indirectstage.h @@ -30,10 +30,10 @@ public: void dumpToDebug(); - int texCoord; - int texMap; - int wrap_s; - int wrap_t; + quint8 texCoord; + quint8 texMap; + quint8 wrap_s; + quint8 wrap_t; }; diff --git a/lyt/materials/material.cpp b/lyt/materials/material.cpp index f79fd08..a4498c5 100644 --- a/lyt/materials/material.cpp +++ b/lyt/materials/material.cpp @@ -31,8 +31,61 @@ 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 + + for (int i = 0; i < 3; i++) + qDebug() << "Colour" << i << ":" << colours[i]; + + for (int i = 0; i < 4; i++) + qDebug() << "TEV Constant Colour" << i << ":" << tevKColour[i]; + + qDebug() << "TexMaps:" << texMaps.count(); + foreach (LYTTexMap texMap, texMaps) + texMap.dumpToDebug(); + + qDebug() << "TexSRTs:" << texSRTs.count(); + foreach (LYTTexSRT texSRT, texSRTs) + texSRT.dumpToDebug(); + + qDebug() << "TexCoordGens:" << texCoordGens.count(); + foreach (LYTTexCoordGen texCoordGen, texCoordGens) + texCoordGen.dumpToDebug(); + + if (hasChanCtrl) + chanCtrl.dumpToDebug(); + else + qDebug() << "ChanCtrl: none"; + + if (hasMatCol) + qDebug() << "MatCol:" << matCol; + else + qDebug() << "MatCol: none"; + + if (hasTevSwapTable) + tevSwapTable.dumpToDebug(); + else + qDebug() << "TevSwapTable: none"; + + qDebug() << "IndTexSRTs:" << indTexSRTs.count(); + foreach (LYTTexSRT indTexSRT, indTexSRTs) + indTexSRT.dumpToDebug(); + + qDebug() << "IndirectStages:" << indTexStages.count(); + foreach (LYTIndirectStage indTexStage, indTexStages) + indTexStage.dumpToDebug(); + + qDebug() << "TevStages:" << tevStages.count(); + foreach (LYTTevStage tevStage, tevStages) + tevStage.dumpToDebug(); + + if (hasAlphaCompare) + alphaCompare.dumpToDebug(); + else + qDebug() << "AlphaCompare: none"; + + if (hasBlendMode) + blendMode.dumpToDebug(); + else + qDebug() << "BlendMode: none"; } @@ -51,8 +104,9 @@ void LYTMaterial::readFromDataStream(QDataStream &in) { ReadRGBA8Color(this->tevKColour[i], in); - LYTMaterialResourceNum resourceNum; - in >> (quint32&)resourceNum.value; + quint32 resNumValue; + in >> (quint32&)resNumValue; + LYTMaterialResourceNum resourceNum(resNumValue); // this is really complicated -_- // first off: TexMap @@ -79,7 +133,7 @@ void LYTMaterial::readFromDataStream(QDataStream &in) { // ChanCtrl if (resourceNum.hasChanCtrl()) { this->hasChanCtrl = true; - this->readChanCtrl(in); + this->chanCtrl.readFromDataStream(in); } else { this->hasChanCtrl = false; } @@ -87,7 +141,7 @@ void LYTMaterial::readFromDataStream(QDataStream &in) { // MatCol if (resourceNum.hasMatCol()) { this->hasMatCol = true; - this->readMatCol(in); + ReadRGBA8Color(this->matCol, in); } else { this->hasMatCol = false; } @@ -95,7 +149,7 @@ void LYTMaterial::readFromDataStream(QDataStream &in) { // TevSwapTable if (resourceNum.hasTevSwapTable()) { this->hasTevSwapTable = true; - this->readTevSwapTable(in); + this->tevSwapTable.readFromDataStream(in); } else { this->hasTevSwapTable = false; } @@ -124,7 +178,7 @@ void LYTMaterial::readFromDataStream(QDataStream &in) { // AlphaCompare if (resourceNum.hasAlphaCompare()) { this->hasAlphaCompare = true; - this->readAlphaCompare(in); + this->alphaCompare.readFromDataStream(in); } else { this->hasAlphaCompare = false; } @@ -132,7 +186,7 @@ void LYTMaterial::readFromDataStream(QDataStream &in) { // BlendMode if (resourceNum.hasBlendMode()) { this->hasBlendMode = true; - this->readBlendMode(in); + this->blendMode.readFromDataStream(in); } else { this->hasBlendMode = false; } @@ -143,60 +197,31 @@ 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(); -} - -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(); } void LYTMaterial::readTevStage(QDataStream &in) { this->tevStages.append(LYTTevStage()); this->tevStages.last().readFromDataStream(in); - this->tevStages.last().dumpToDebug(); } -void LYTMaterial::readAlphaCompare(QDataStream &in) { - this->alphaCompare.readFromDataStream(in); - this->alphaCompare.dumpToDebug(); -} - -void LYTMaterial::readBlendMode(QDataStream &in) { - this->blendMode.readFromDataStream(in); - this->blendMode.dumpToDebug(); -} diff --git a/lyt/materials/material.h b/lyt/materials/material.h index bfdf80b..d605244 100644 --- a/lyt/materials/material.h +++ b/lyt/materials/material.h @@ -40,19 +40,37 @@ class LYTLayout; class LYTMaterialResourceNum { public: - quint32 value; - - inline int getTexMapNum() { return BitExtract(value, 4, 28); } - inline int getTexSRTNum() { return BitExtract(value, 4, 24); } - inline int getTexCoordGenNum() { return BitExtract(value, 4, 20); } - inline bool hasChanCtrl() { return BitExtract(value, 1, 6); } - inline bool hasMatCol() { return BitExtract(value, 1, 4); } - inline bool hasTevSwapTable() { return BitExtract(value, 1, 19); } - inline bool hasAlphaCompare() { return BitExtract(value, 1, 8); } - inline bool hasBlendMode() { return BitExtract(value, 1, 7); } - inline int getIndTexSRTNum() { return BitExtract(value, 2, 17); } - inline int getIndTexStageNum() { return BitExtract(value, 3, 14); } - inline int getTevStageNum() { return BitExtract(value, 5, 9); } + LYTMaterialResourceNum() : m_value(0) { } + LYTMaterialResourceNum(int initValue) : m_value(initValue) { } + + quint32 value() { return m_value; } + + int getTexMapNum() { return BitExtract(m_value, 4, 28); } + int getTexSRTNum() { return BitExtract(m_value, 4, 24); } + int getTexCoordGenNum() { return BitExtract(m_value, 4, 20); } + bool hasChanCtrl() { return BitExtract(m_value, 1, 6); } + bool hasMatCol() { return BitExtract(m_value, 1, 4); } + bool hasTevSwapTable() { return BitExtract(m_value, 1, 19); } + bool hasAlphaCompare() { return BitExtract(m_value, 1, 8); } + bool hasBlendMode() { return BitExtract(m_value, 1, 7); } + int getIndTexSRTNum() { return BitExtract(m_value, 2, 17); } + int getIndTexStageNum() { return BitExtract(m_value, 3, 14); } + int getTevStageNum() { return BitExtract(m_value, 5, 9); } + + void setTexMapNum(int v) { m_value = BitInsert(m_value, v, 4, 28); } + void setTexSRTNum(int v) { m_value = BitInsert(m_value, v, 4, 24); } + void setTexCoordGenNum(int v) { m_value = BitInsert(m_value, v, 4, 20); } + void setHasChanCtrl(bool v) { m_value = BitInsert(m_value, v, 1, 6); } + void setHasMatCol(bool v) { m_value = BitInsert(m_value, v, 1, 4); } + void setHasTevSwapTable(bool v) { m_value = BitInsert(m_value, v, 1, 19); } + void setHasAlphaCompare(bool v) { m_value = BitInsert(m_value, v, 1, 8); } + void setHasBlendMode(bool v) { m_value = BitInsert(m_value, v, 1, 7); } + void setIndTexSRTNum(int v) { m_value = BitInsert(m_value, v, 2, 17); } + void setIndTexStageNum(int v) { m_value = BitInsert(m_value, v, 3, 14); } + void setTevStageNum(int v) { m_value = BitInsert(m_value, v, 5, 9); } + +private: + quint32 m_value; }; @@ -109,11 +127,6 @@ protected: void readTexMap(QDataStream &in); void readTexSRT(QDataStream &in); void readTexCoordGen(QDataStream &in); - void readChanCtrl(QDataStream &in); - void readMatCol(QDataStream &in); - void readTevSwapTable(QDataStream &in); - void readAlphaCompare(QDataStream &in); - void readBlendMode(QDataStream &in); void readIndirectStage(QDataStream &in); void readIndTexSRT(QDataStream &in); void readTevStage(QDataStream &in); |