more GX material additions

This commit is contained in:
Jack Andersen 2015-07-25 12:59:39 -10:00
parent 4972c2ae95
commit c526c7df85
7 changed files with 437 additions and 132 deletions

View File

@ -1,4 +1,5 @@
add_library(DNACommon add_library(DNACommon
DNACommon.hpp DNACommon.cpp
GX.hpp
STRG.hpp STRG.cpp STRG.hpp STRG.cpp
TXTR.hpp TXTR.cpp TXTR.hpp TXTR.cpp)
DNACommon.hpp DNACommon.cpp)

View File

@ -127,95 +127,6 @@ public:
} }
}; };
/* RGBA8 structure (GXColor) */
struct GXColor : BigDNA
{
Value<atUint8> r;
Value<atUint8> g;
Value<atUint8> b;
Value<atUint8> a;
Delete expl;
void read(Athena::io::IStreamReader& reader)
{reader.readUBytesToBuf(&r, 4);}
void write(Athena::io::IStreamWriter& writer) const
{writer.writeUBytes(&r, 4);}
};
/* More GX structures */
enum GXAttrType
{
GX_NONE,
GX_DIRECT,
GX_INDEX8,
GX_INDEX16
};
enum GXTevColorArg {
GX_CC_CPREV = 0, /*!< Use the color value from previous TEV stage */
GX_CC_APREV = 1, /*!< Use the alpha value from previous TEV stage */
GX_CC_C0 = 2, /*!< Use the color value from the color/output register 0 */
GX_CC_A0 = 3, /*!< Use the alpha value from the color/output register 0 */
GX_CC_C1 = 4, /*!< Use the color value from the color/output register 1 */
GX_CC_A1 = 5, /*!< Use the alpha value from the color/output register 1 */
GX_CC_C2 = 6, /*!< Use the color value from the color/output register 2 */
GX_CC_A2 = 7, /*!< Use the alpha value from the color/output register 2 */
GX_CC_TEXC = 8, /*!< Use the color value from texture */
GX_CC_TEXA = 9, /*!< Use the alpha value from texture */
GX_CC_RASC = 10, /*!< Use the color value from rasterizer */
GX_CC_RASA = 11, /*!< Use the alpha value from rasterizer */
GX_CC_ONE = 12,
GX_CC_HALF = 13,
GX_CC_KONST = 14,
GX_CC_ZERO = 15 /*!< Use to pass zero value */
};
enum GXTevAlphaArg {
GX_CA_APREV = 0, /*!< Use the alpha value from previous TEV stage */
GX_CA_A0 = 1, /*!< Use the alpha value from the color/output register 0 */
GX_CA_A1 = 2, /*!< Use the alpha value from the color/output register 1 */
GX_CA_A2 = 3, /*!< Use the alpha value from the color/output register 2 */
GX_CA_TEXA = 4, /*!< Use the alpha value from texture */
GX_CA_RASA = 5, /*!< Use the alpha value from rasterizer */
GX_CA_KONST = 6,
GX_CA_ZERO = 7 /*!< Use to pass zero value */
};
enum GXTevOp {
GX_TEV_ADD = 0,
GX_TEV_SUB = 1,
GX_TEV_COMP_R8_GT = 8,
GX_TEV_COMP_R8_EQ = 9,
GX_TEV_COMP_GR16_GT = 10,
GX_TEV_COMP_GR16_EQ = 11,
GX_TEV_COMP_BGR24_GT = 12,
GX_TEV_COMP_BGR24_EQ = 13,
GX_TEV_COMP_RGB8_GT = 14,
GX_TEV_COMP_RGB8_EQ = 15,
GX_TEV_COMP_A8_GT = GX_TEV_COMP_RGB8_GT, // for alpha channel
GX_TEV_COMP_A8_EQ = GX_TEV_COMP_RGB8_EQ // for alpha channel
};
enum GXTevBias {
GX_TB_ZERO = 0,
GX_TB_ADDHALF = 1,
GX_TB_SUBHALF = 2,
};
enum GXTevScale {
GX_CS_SCALE_1 = 0,
GX_CS_SCALE_2 = 1,
GX_CS_SCALE_4 = 2,
GX_CS_DIVIDE_2 = 3
};
enum GXTevRegID {
GX_TEVPREV = 0,
GX_TEVREG0 = 1,
GX_TEVREG1 = 2,
GX_TEVREG2 = 3
};
/* Case-insensitive comparator for std::map sorting */ /* Case-insensitive comparator for std::map sorting */
struct CaseInsensitiveCompare struct CaseInsensitiveCompare
{ {

180
DataSpec/DNACommon/GX.hpp Normal file
View File

@ -0,0 +1,180 @@
#ifndef _DNACOMMON_GX_HPP_
#define _DNACOMMON_GX_HPP_
#include <Athena/DNA.hpp>
namespace GX
{
/* RGBA8 structure (GXColor) */
struct Color : Athena::io::DNA<Athena::BigEndian>
{
Value<atUint8> r;
Value<atUint8> g;
Value<atUint8> b;
Value<atUint8> a;
Delete expl;
void read(Athena::io::IStreamReader& reader)
{reader.readUBytesToBuf(&r, 4);}
void write(Athena::io::IStreamWriter& writer) const
{writer.writeUBytes(&r, 4);}
};
/* GX enums */
enum AttrType
{
GX_NONE,
GX_DIRECT,
GX_INDEX8,
GX_INDEX16
};
enum TevColorArg {
GX_CC_CPREV = 0, /*!< Use the color value from previous TEV stage */
GX_CC_APREV = 1, /*!< Use the alpha value from previous TEV stage */
GX_CC_C0 = 2, /*!< Use the color value from the color/output register 0 */
GX_CC_A0 = 3, /*!< Use the alpha value from the color/output register 0 */
GX_CC_C1 = 4, /*!< Use the color value from the color/output register 1 */
GX_CC_A1 = 5, /*!< Use the alpha value from the color/output register 1 */
GX_CC_C2 = 6, /*!< Use the color value from the color/output register 2 */
GX_CC_A2 = 7, /*!< Use the alpha value from the color/output register 2 */
GX_CC_TEXC = 8, /*!< Use the color value from texture */
GX_CC_TEXA = 9, /*!< Use the alpha value from texture */
GX_CC_RASC = 10, /*!< Use the color value from rasterizer */
GX_CC_RASA = 11, /*!< Use the alpha value from rasterizer */
GX_CC_ONE = 12,
GX_CC_HALF = 13,
GX_CC_KONST = 14,
GX_CC_ZERO = 15 /*!< Use to pass zero value */
};
enum TevAlphaArg {
GX_CA_APREV = 0, /*!< Use the alpha value from previous TEV stage */
GX_CA_A0 = 1, /*!< Use the alpha value from the color/output register 0 */
GX_CA_A1 = 2, /*!< Use the alpha value from the color/output register 1 */
GX_CA_A2 = 3, /*!< Use the alpha value from the color/output register 2 */
GX_CA_TEXA = 4, /*!< Use the alpha value from texture */
GX_CA_RASA = 5, /*!< Use the alpha value from rasterizer */
GX_CA_KONST = 6,
GX_CA_ZERO = 7 /*!< Use to pass zero value */
};
enum TevOp {
GX_TEV_ADD = 0,
GX_TEV_SUB = 1,
GX_TEV_COMP_R8_GT = 8,
GX_TEV_COMP_R8_EQ = 9,
GX_TEV_COMP_GR16_GT = 10,
GX_TEV_COMP_GR16_EQ = 11,
GX_TEV_COMP_BGR24_GT = 12,
GX_TEV_COMP_BGR24_EQ = 13,
GX_TEV_COMP_RGB8_GT = 14,
GX_TEV_COMP_RGB8_EQ = 15,
GX_TEV_COMP_A8_GT = GX_TEV_COMP_RGB8_GT, // for alpha channel
GX_TEV_COMP_A8_EQ = GX_TEV_COMP_RGB8_EQ // for alpha channel
};
enum TevBias {
GX_TB_ZERO = 0,
GX_TB_ADDHALF = 1,
GX_TB_SUBHALF = 2,
};
enum TevScale {
GX_CS_SCALE_1 = 0,
GX_CS_SCALE_2 = 1,
GX_CS_SCALE_4 = 2,
GX_CS_DIVIDE_2 = 3
};
enum TevRegID {
GX_TEVPREV = 0,
GX_TEVREG0 = 1,
GX_TEVREG1 = 2,
GX_TEVREG2 = 3
};
enum TexGenType
{
GX_TG_MTX3x4 = 0,
GX_TG_MTX2x4,
GX_TG_BUMP0,
GX_TG_BUMP1,
GX_TG_BUMP2,
GX_TG_BUMP3,
GX_TG_BUMP4,
GX_TG_BUMP5,
GX_TG_BUMP6,
GX_TG_BUMP7,
GX_TG_SRTG
};
enum TexGenSrc
{
GX_TG_POS = 0,
GX_TG_NRM,
GX_TG_BINRM,
GX_TG_TANGENT,
GX_TG_TEX0,
GX_TG_TEX1,
GX_TG_TEX2,
GX_TG_TEX3,
GX_TG_TEX4,
GX_TG_TEX5,
GX_TG_TEX6,
GX_TG_TEX7,
GX_TG_TEXCOORD0,
GX_TG_TEXCOORD1,
GX_TG_TEXCOORD2,
GX_TG_TEXCOORD3,
GX_TG_TEXCOORD4,
GX_TG_TEXCOORD5,
GX_TG_TEXCOORD6,
GX_TG_COLOR0,
GX_TG_COLOR1
};
enum TexMtx
{
GX_TEXMTX0 = 30,
GX_TEXMTX1 = 33,
GX_TEXMTX2 = 36,
GX_TEXMTX3 = 39,
GX_TEXMTX4 = 42,
GX_TEXMTX5 = 45,
GX_TEXMTX6 = 48,
GX_TEXMTX7 = 51,
GX_TEXMTX8 = 54,
GX_TEXMTX9 = 57,
GX_IDENTITY = 60
};
enum PTTexMtx
{
GX_PTTEXMTX0 = 64,
GX_PTTEXMTX1 = 67,
GX_PTTEXMTX2 = 70,
GX_PTTEXMTX3 = 73,
GX_PTTEXMTX4 = 76,
GX_PTTEXMTX5 = 79,
GX_PTTEXMTX6 = 82,
GX_PTTEXMTX7 = 85,
GX_PTTEXMTX8 = 88,
GX_PTTEXMTX9 = 91,
GX_PTTEXMTX10 = 94,
GX_PTTEXMTX11 = 97,
GX_PTTEXMTX12 = 100,
GX_PTTEXMTX13 = 103,
GX_PTTEXMTX14 = 106,
GX_PTTEXMTX15 = 109,
GX_PTTEXMTX16 = 112,
GX_PTTEXMTX17 = 115,
GX_PTTEXMTX18 = 118,
GX_PTTEXMTX19 = 121,
GX_PTIDENTITY = 125
};
}
#endif

View File

@ -2,9 +2,7 @@
#define _DNAMP1_CMDL_HPP_ #define _DNAMP1_CMDL_HPP_
#include "../DNACommon/DNACommon.hpp" #include "../DNACommon/DNACommon.hpp"
#ifndef __atdna__
#include "CMDLMaterials.hpp" #include "CMDLMaterials.hpp"
#endif
namespace Retro namespace Retro
{ {

View File

@ -2,16 +2,16 @@
#define _DNAMP1_CMDL_MATERIALS_HPP_ #define _DNAMP1_CMDL_MATERIALS_HPP_
#include "../DNACommon/DNACommon.hpp" #include "../DNACommon/DNACommon.hpp"
#include "../DNACommon/GX.hpp"
namespace Retro namespace Retro
{ {
namespace DNAMP1 namespace DNAMP1
{ {
struct CMDLMaterial : BigDNA struct MaterialSet : BigDNA
{ {
Delete expl; DECL_DNA
struct MaterialSetHead : BigDNA struct MaterialSetHead : BigDNA
{ {
DECL_DNA DECL_DNA
@ -51,39 +51,43 @@ struct CMDLMaterial : BigDNA
inline atUint16 textureSlots() const {return flags >> 16;} inline atUint16 textureSlots() const {return flags >> 16;}
inline void setTextureSlots(atUint16 texslots) {flags &= ~0xffff0000; flags |= (atUint32)texslots << 16;} inline void setTextureSlots(atUint16 texslots) {flags &= ~0xffff0000; flags |= (atUint32)texslots << 16;}
} flags; } flags;
Value<atUint32> textureCount; Value<atUint32> textureCount;
Vector<UniqueID32, DNA_COUNT(textureCount)> texureIdxs; Vector<UniqueID32, DNA_COUNT(textureCount)> texureIdxs;
struct VAFlags : BigDNA struct VAFlags : BigDNA
{ {
DECL_DNA DECL_DNA
Value<atUint32> vaFlags; Value<atUint32> vaFlags;
inline GXAttrType position() const {return GXAttrType(vaFlags & 0x3);} inline GX::AttrType position() const {return GX::AttrType(vaFlags & 0x3);}
inline void setPosition(GXAttrType val) {vaFlags &= ~0x3; vaFlags |= val;} inline void setPosition(GX::AttrType val) {vaFlags &= ~0x3; vaFlags |= val;}
inline GXAttrType normal() const {return GXAttrType(vaFlags >> 2 & 0x3);} inline GX::AttrType normal() const {return GX::AttrType(vaFlags >> 2 & 0x3);}
inline void setNormal(GXAttrType val) {vaFlags &= ~0xC; vaFlags |= val << 2;} inline void setNormal(GX::AttrType val) {vaFlags &= ~0xC; vaFlags |= val << 2;}
inline GXAttrType color0() const {return GXAttrType(vaFlags >> 4 & 0x3);} inline GX::AttrType color0() const {return GX::AttrType(vaFlags >> 4 & 0x3);}
inline void setColor0(GXAttrType val) {vaFlags &= ~0x30; vaFlags |= val << 4;} inline void setColor0(GX::AttrType val) {vaFlags &= ~0x30; vaFlags |= val << 4;}
inline GXAttrType color1() const {return GXAttrType(vaFlags >> 6 & 0x3);} inline GX::AttrType color1() const {return GX::AttrType(vaFlags >> 6 & 0x3);}
inline void setColor1(GXAttrType val) {vaFlags &= ~0xC0; vaFlags |= val << 6;} inline void setColor1(GX::AttrType val) {vaFlags &= ~0xC0; vaFlags |= val << 6;}
inline GXAttrType tex0() const {return GXAttrType(vaFlags >> 8 & 0x3);} inline GX::AttrType tex0() const {return GX::AttrType(vaFlags >> 8 & 0x3);}
inline void setTex0(GXAttrType val) {vaFlags &= ~0x300; vaFlags |= val << 8;} inline void setTex0(GX::AttrType val) {vaFlags &= ~0x300; vaFlags |= val << 8;}
inline GXAttrType tex1() const {return GXAttrType(vaFlags >> 10 & 0x3);} inline GX::AttrType tex1() const {return GX::AttrType(vaFlags >> 10 & 0x3);}
inline void setTex1(GXAttrType val) {vaFlags &= ~0xC00; vaFlags |= val << 10;} inline void setTex1(GX::AttrType val) {vaFlags &= ~0xC00; vaFlags |= val << 10;}
inline GXAttrType tex2() const {return GXAttrType(vaFlags >> 12 & 0x3);} inline GX::AttrType tex2() const {return GX::AttrType(vaFlags >> 12 & 0x3);}
inline void setTex2(GXAttrType val) {vaFlags &= ~0x3000; vaFlags |= val << 12;} inline void setTex2(GX::AttrType val) {vaFlags &= ~0x3000; vaFlags |= val << 12;}
inline GXAttrType tex3() const {return GXAttrType(vaFlags >> 14 & 0x3);} inline GX::AttrType tex3() const {return GX::AttrType(vaFlags >> 14 & 0x3);}
inline void setTex3(GXAttrType val) {vaFlags &= ~0xC000; vaFlags |= val << 14;} inline void setTex3(GX::AttrType val) {vaFlags &= ~0xC000; vaFlags |= val << 14;}
inline GXAttrType tex4() const {return GXAttrType(vaFlags >> 16 & 0x3);} inline GX::AttrType tex4() const {return GX::AttrType(vaFlags >> 16 & 0x3);}
inline void setTex4(GXAttrType val) {vaFlags &= ~0x30000; vaFlags |= val << 16;} inline void setTex4(GX::AttrType val) {vaFlags &= ~0x30000; vaFlags |= val << 16;}
inline GXAttrType tex5() const {return GXAttrType(vaFlags >> 18 & 0x3);} inline GX::AttrType tex5() const {return GX::AttrType(vaFlags >> 18 & 0x3);}
inline void setTex5(GXAttrType val) {vaFlags &= ~0xC0000; vaFlags |= val << 18;} inline void setTex5(GX::AttrType val) {vaFlags &= ~0xC0000; vaFlags |= val << 18;}
inline GXAttrType tex6() const {return GXAttrType(vaFlags >> 20 & 0x3);} inline GX::AttrType tex6() const {return GX::AttrType(vaFlags >> 20 & 0x3);}
inline void setTex6(GXAttrType val) {vaFlags &= ~0x300000; vaFlags |= val << 20;} inline void setTex6(GX::AttrType val) {vaFlags &= ~0x300000; vaFlags |= val << 20;}
} vaFlags; } vaFlags;
Value<atUint32> groupIdx; Value<atUint32> groupIdx;
Value<atUint32> konstCount; Value<atUint32> konstCount;
Vector<GXColor, DNA_COUNT(konstCount)> konstColors; Vector<GX::Color, DNA_COUNT(konstCount)> konstColors;
enum GXBlendFactor
/** Slightly modified blend enums in Retro's implementation */
enum BlendFactor
{ {
GX_BL_ZERO, GX_BL_ZERO,
GX_BL_ONE, GX_BL_ONE,
@ -94,9 +98,14 @@ struct CMDLMaterial : BigDNA
GX_BL_DSTALPHA, GX_BL_DSTALPHA,
GX_BL_INVDSTALPHA GX_BL_INVDSTALPHA
}; };
Value<atUint16> blendDstFac; Value<atUint16> _blendDstFac;
Value<atUint16> blendSrcFac; inline BlendFactor blendDestFactor() const {return BlendFactor(_blendDstFac);}
inline void setBlendDestFactor(BlendFactor fac) {_blendDstFac = fac;}
Value<atUint16> _blendSrcFac;
inline BlendFactor blendSrcFactor() const {return BlendFactor(_blendSrcFac);}
inline void setBlendSrcFactor(BlendFactor fac) {_blendSrcFac = fac;}
Vector<atUint32, DNA_COUNT(flags.samusReflectionIndirectTexture())> indTexSlot; Vector<atUint32, DNA_COUNT(flags.samusReflectionIndirectTexture())> indTexSlot;
Value<atUint32> colorChannelCount; Value<atUint32> colorChannelCount;
struct ColorChannel : BigDNA struct ColorChannel : BigDNA
{ {
@ -116,23 +125,161 @@ struct CMDLMaterial : BigDNA
inline void setAttenuationFn(atUint8 fn) {flags &= ~0x6000; flags |= (atUint32)fn << 13;} inline void setAttenuationFn(atUint8 fn) {flags &= ~0x6000; flags |= (atUint32)fn << 13;}
}; };
Vector<ColorChannel, DNA_COUNT(colorChannelCount)> colorChannels; Vector<ColorChannel, DNA_COUNT(colorChannelCount)> colorChannels;
Value<atUint32> tevStageCount; Value<atUint32> tevStageCount;
struct TEVStage : BigDNA struct TEVStage : BigDNA
{ {
DECL_DNA DECL_DNA
Value<atUint32> ciFlags;
Value<atUint32> aiFlags;
Value<atUint32> ccFlags;
Value<atUint32> acFlags;
Value<atUint8> pad;
Value<atUint8> kaInput;
Value<atUint8> kcInput;
Value<atUint8> rascInput;
inline GX::TevColorArg colorInA() const {return GX::TevColorArg(ciFlags & 0xf);}
inline void setColorInA(GX::TevColorArg val) {ciFlags &= ~0x1f; ciFlags |= val;}
inline GX::TevColorArg colorInB() const {return GX::TevColorArg(ciFlags >> 5 & 0xf);}
inline void setColorInB(GX::TevColorArg val) {ciFlags &= ~0x3e0; ciFlags |= val << 5;}
inline GX::TevColorArg colorInC() const {return GX::TevColorArg(ciFlags >> 10 & 0xf);}
inline void setColorInC(GX::TevColorArg val) {ciFlags &= ~0x7c00; ciFlags |= val << 10;}
inline GX::TevColorArg colorInD() const {return GX::TevColorArg(ciFlags >> 15 & 0xf);}
inline void setColorInD(GX::TevColorArg val) {ciFlags &= ~0xf8000; ciFlags |= val << 15;}
inline GX::TevAlphaArg alphaInA() const {return GX::TevAlphaArg(aiFlags & 0x7);}
inline void setAlphaInA(GX::TevAlphaArg val) {aiFlags &= ~0x1f; aiFlags |= val;}
inline GX::TevAlphaArg alphaInB() const {return GX::TevAlphaArg(aiFlags >> 5 & 0x7);}
inline void setAlphaInB(GX::TevAlphaArg val) {aiFlags &= ~0x3e0; aiFlags |= val << 5;}
inline GX::TevAlphaArg alphaInC() const {return GX::TevAlphaArg(aiFlags >> 10 & 0x7);}
inline void setAlphaInC(GX::TevAlphaArg val) {aiFlags &= ~0x7c00; aiFlags |= val << 10;}
inline GX::TevAlphaArg alphaInD() const {return GX::TevAlphaArg(aiFlags >> 15 & 0x7);}
inline void setAlphaInD(GX::TevAlphaArg val) {aiFlags &= ~0xf8000; aiFlags |= val << 15;}
inline GX::TevOp colorOp() const {return GX::TevOp(ccFlags & 0xf);}
inline void setColorOp(GX::TevOp val) {ccFlags &= ~0x1; ccFlags |= val;}
inline GX::TevBias colorOpBias() const {return GX::TevBias(ccFlags >> 4 & 0x3);}
inline void setColorOpBias(GX::TevBias val) {ccFlags &= ~0x30; ccFlags |= val << 4;}
inline GX::TevScale colorOpScale() const {return GX::TevScale(ccFlags >> 6 & 0x3);}
inline void setColorOpScale(GX::TevScale val) {ccFlags &= ~0xc0; ccFlags |= val << 6;}
inline bool colorOpClamp() const {return ccFlags >> 8 & 0x1;}
inline void setColorOpClamp(bool val) {ccFlags &= ~0x100; ccFlags |= val << 8;}
inline GX::TevRegID colorOpOutReg() const {return GX::TevRegID(ccFlags >> 9 & 0x3);}
inline void setColorOpOutReg(GX::TevRegID val) {ccFlags &= ~0x600; ccFlags |= val << 9;}
inline GX::TevOp alphaOp() const {return GX::TevOp(acFlags & 0xf);}
inline void setAlphaOp(GX::TevOp val) {acFlags &= ~0x1; acFlags |= val;}
inline GX::TevBias alphaOpBias() const {return GX::TevBias(acFlags >> 4 & 0x3);}
inline void setAlphaOpBias(GX::TevBias val) {acFlags &= ~0x30; acFlags |= val << 4;}
inline GX::TevScale alphaOpScale() const {return GX::TevScale(acFlags >> 6 & 0x3);}
inline void setAlphaOpScale(GX::TevScale val) {acFlags &= ~0xc0; acFlags |= val << 6;}
inline bool alphaOpClamp() const {return acFlags >> 8 & 0x1;}
inline void setAlphaOpClamp(bool val) {acFlags &= ~0x100; acFlags |= val << 8;}
inline GX::TevRegID alphaOpOutReg() const {return GX::TevRegID(acFlags >> 9 & 0x3);}
inline void setAlphaOpOutReg(GX::TevRegID val) {acFlags &= ~0x600; acFlags |= val << 9;}
}; };
Vector<TEVStage, DNA_COUNT(tevStageCount)> tevStages; Vector<TEVStage, DNA_COUNT(tevStageCount)> tevStages;
}; struct TEVStageTexInfo : BigDNA
{
DECL_DNA
Value<atUint16> pad;
Value<atUint8> texSlot;
Value<atUint8> tcgSlot;
};
Vector<TEVStageTexInfo, DNA_COUNT(tevStageCount)> tevStageTexInfo;
Value<atUint32> tcgCount;
struct TexCoordGen : BigDNA
{
DECL_DNA
Value<atUint32> flags;
inline GX::TexGenType type() const {return GX::TexGenType(flags & 0xf);}
inline void setType(GX::TexGenType val) {flags &= ~0xf; flags |= val;}
inline GX::TexGenSrc source() const {return GX::TexGenSrc(flags >> 4 & 0x1f);}
inline void setSource(GX::TexGenSrc val) {flags &= ~0x1f0; flags |= val << 4;}
inline GX::TexMtx mtxIdx() const {return GX::TexMtx(flags >> 9 & 0x1f + 30);}
inline void setMtxIdx(GX::TexMtx val) {flags &= ~0x3e00; flags |= (val-30) << 9;}
inline bool normalize() const {return flags >> 14 & 0x1;}
inline void setNormalize(bool val) {flags &= ~0x4000; flags |= val << 14;}
inline GX::PTTexMtx postMtxIdx() const {return GX::PTTexMtx(flags >> 15 & 0x3f + 64);}
inline void setPostMtxIdx(GX::PTTexMtx val) {flags &= ~0x1f8000; flags |= (val-64) << 15;}
};
Vector<TexCoordGen, DNA_COUNT(tcgCount)> tgcs;
Value<atUint32> uvAnimsSize;
Value<atUint32> uvAnimsCount;
struct UVAnimation : BigDNA
{
Delete expl;
enum Mode : atUint32
{
ANIM_MV_INV_NOTRANS,
ANIM_MV_INV,
ANIM_SCROLL,
ANIM_ROTATION,
ANIM_HSTRIP,
ANIM_VSTRIP,
ANIM_MODEL,
ANIM_MODE_WHO_MUST_NOT_BE_NAMED
} mode;
float vals[4];
void read(Athena::io::IStreamReader& reader)
{
reader.setEndian(Athena::BigEndian);
mode = Mode(reader.readUint32());
switch (mode)
{
case ANIM_MV_INV_NOTRANS:
case ANIM_MV_INV:
case ANIM_MODEL:
break;
case ANIM_SCROLL:
case ANIM_HSTRIP:
case ANIM_VSTRIP:
vals[0] = reader.readFloat();
vals[1] = reader.readFloat();
vals[2] = reader.readFloat();
vals[3] = reader.readFloat();
break;
case ANIM_ROTATION:
case ANIM_MODE_WHO_MUST_NOT_BE_NAMED:
vals[0] = reader.readFloat();
vals[1] = reader.readFloat();
break;
}
}
void write(Athena::io::IStreamWriter& writer) const
{
writer.setEndian(Athena::BigEndian);
writer.writeUint32(mode);
switch (mode)
{
case ANIM_MV_INV_NOTRANS:
case ANIM_MV_INV:
case ANIM_MODEL:
break;
case ANIM_SCROLL:
case ANIM_HSTRIP:
case ANIM_VSTRIP:
writer.writeFloat(vals[0]);
writer.writeFloat(vals[1]);
writer.writeFloat(vals[2]);
writer.writeFloat(vals[3]);
break;
case ANIM_ROTATION:
case ANIM_MODE_WHO_MUST_NOT_BE_NAMED:
writer.writeFloat(vals[0]);
writer.writeFloat(vals[1]);
break;
}
}
};
Vector<UVAnimation, DNA_COUNT(uvAnimsCount)> uvAnims;
};
Vector<Material, DNA_COUNT(head.materialCount)> materials;
void read(Athena::io::IStreamReader& reader)
{
head.read(reader);
}
void write(Athena::io::IStreamWriter& writer) const
{
head.write(writer);
}
}; };
} }

View File

@ -0,0 +1,67 @@
#ifndef _DNAMP2_CMDL_MATERIALS_HPP_
#define _DNAMP2_CMDL_MATERIALS_HPP_
#include "../DNACommon/DNACommon.hpp"
#include "../DNACommon/GX.hpp"
#include "../DNAMP1/CMDLMaterials.hpp"
namespace Retro
{
namespace DNAMP2
{
/* Structurally identical to DNAMP1::MaterialSet except unk0 and unk1 fields */
struct MaterialSet : BigDNA
{
DECL_DNA
DNAMP1::MaterialSet::MaterialSetHead head;
struct Material : BigDNA
{
DECL_DNA
DNAMP1::MaterialSet::Material::Flags flags;
Value<atUint32> textureCount;
Vector<UniqueID32, DNA_COUNT(textureCount)> texureIdxs;
DNAMP1::MaterialSet::Material::VAFlags vaFlags;
Value<atUint32> unk0; /* MP2 only */
Value<atUint32> unk1; /* MP2 only */
Value<atUint32> groupIdx;
Value<atUint32> konstCount;
Vector<GX::Color, DNA_COUNT(konstCount)> konstColors;
Value<atUint16> _blendDstFac;
inline DNAMP1::MaterialSet::Material::BlendFactor blendDestFactor() const
{return DNAMP1::MaterialSet::Material::BlendFactor(_blendDstFac);}
inline void setBlendDestFactor(DNAMP1::MaterialSet::Material::BlendFactor fac)
{_blendDstFac = fac;}
Value<atUint16> _blendSrcFac;
inline DNAMP1::MaterialSet::Material::BlendFactor blendSrcFactor() const
{return DNAMP1::MaterialSet::Material::BlendFactor(_blendSrcFac);}
inline void setBlendSrcFactor(DNAMP1::MaterialSet::Material::BlendFactor fac)
{_blendSrcFac = fac;}
Vector<atUint32, DNA_COUNT(flags.samusReflectionIndirectTexture())> indTexSlot;
Value<atUint32> colorChannelCount;
Vector<DNAMP1::MaterialSet::Material::ColorChannel, DNA_COUNT(colorChannelCount)> colorChannels;
Value<atUint32> tevStageCount;
Vector<DNAMP1::MaterialSet::Material::TEVStage, DNA_COUNT(tevStageCount)> tevStages;
Vector<DNAMP1::MaterialSet::Material::TEVStageTexInfo, DNA_COUNT(tevStageCount)> tevStageTexInfo;
Value<atUint32> tcgCount;
Vector<DNAMP1::MaterialSet::Material::TexCoordGen, DNA_COUNT(tcgCount)> tgcs;
Value<atUint32> uvAnimsSize;
Value<atUint32> uvAnimsCount;
Vector<DNAMP1::MaterialSet::Material::UVAnimation, DNA_COUNT(uvAnimsCount)> uvAnims;
};
Vector<Material, DNA_COUNT(head.materialCount)> materials;
};
}
}
#endif // _DNAMP2_CMDL_MATERIALS_HPP_

View File

@ -1,6 +1,7 @@
make_dnalist(liblist make_dnalist(liblist
MLVL MLVL
STRG) STRG
CMDLMaterials)
add_library(DNAMP2 add_library(DNAMP2
DNAMP2.hpp DNAMP2.cpp DNAMP2.hpp DNAMP2.cpp
${liblist} ${liblist}