From 5f6dad55d75cbe146ff7fefc899a02ccd39078ba Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 7 Oct 2010 15:56:13 +0200 Subject: initial commit -- everything compiles except for material.cpp. the material system still needs quite a bit of work; this will come in due time --- lyt/materials/material.h | 183 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 lyt/materials/material.h (limited to 'lyt/materials/material.h') diff --git a/lyt/materials/material.h b/lyt/materials/material.h new file mode 100644 index 0000000..73a0e57 --- /dev/null +++ b/lyt/materials/material.h @@ -0,0 +1,183 @@ +#ifndef LYTMATERIAL_H +#define LYTMATERIAL_H + +#include +#include +#include +#include + +#include "../common.h" +#include "texmap.h" + +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); } +}; + + + +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); + 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 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); + void readFromDataStream(QDataStream &in); + + void dumpToDebug(); + +}; + +class LYTTevStage { +public: + void writeToDataStream(QDataStream &out); + void readFromDataStream(QDataStream &in); + + void dumpToDebug(); + +}; + +class LYTAlphaCompare { +public: + void writeToDataStream(QDataStream &out); + void readFromDataStream(QDataStream &in); + + void dumpToDebug(); + +}; + +class LYTBlendMode { +public: + void writeToDataStream(QDataStream &out); + void readFromDataStream(QDataStream &in); + + void dumpToDebug(); + +}; + + + + +class LYTMaterial { +public: + LYTMaterial(LYTLayout &layout); + ~LYTMaterial(); + + + void writeToDataStream(QDataStream &out); + void readFromDataStream(QDataStream &in); + + void dumpToDebug(); + + LYTLayout &layout() const; + + QString name; + + QColor colours[3]; + QColor tevKColour[4]; + + QList texMaps; + QList texSRTs; + QList texCoordGens; + + bool hasChanCtrl; + LYTChanCtrl chanCtrl; + + bool hasMatCol; + QColor matCol; + + bool hasTevSwapTable; + LYTTevSwapMode tevSwapTable; + + bool hasAlphaCompare; + LYTAlphaCompare alphaCompare; + + bool hasBlendMode; + LYTBlendMode blendMode; + + QList indTexStages; + QList indTexSRTs; + + QList tevStages; + + + +protected: + LYTLayout &m_layout; + + 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); +}; + +#endif // LYTMATERIAL_H -- cgit v1.2.3