Namespacing tweaks

This commit is contained in:
Jack Andersen 2015-08-02 13:51:30 -10:00
parent abfbec1563
commit 7b1ec6c4b9
2 changed files with 242 additions and 243 deletions

View File

@ -24,229 +24,229 @@ struct Color : Athena::io::DNA<Athena::BigEndian>
enum AttrType enum AttrType
{ {
GX_NONE, NONE,
GX_DIRECT, DIRECT,
GX_INDEX8, INDEX8,
GX_INDEX16 INDEX16
}; };
enum TevColorArg { enum TevColorArg {
GX_CC_CPREV = 0, /*!< Use the color value from previous TEV stage */ CC_CPREV = 0, /*!< Use the color value from previous TEV stage */
GX_CC_APREV = 1, /*!< Use the alpha value from previous TEV stage */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ CC_A2 = 7, /*!< Use the alpha value from the color/output register 2 */
GX_CC_TEXC = 8, /*!< Use the color value from texture */ CC_TEXC = 8, /*!< Use the color value from texture */
GX_CC_TEXA = 9, /*!< Use the alpha value from texture */ CC_TEXA = 9, /*!< Use the alpha value from texture */
GX_CC_RASC = 10, /*!< Use the color value from rasterizer */ CC_RASC = 10, /*!< Use the color value from rasterizer */
GX_CC_RASA = 11, /*!< Use the alpha value from rasterizer */ CC_RASA = 11, /*!< Use the alpha value from rasterizer */
GX_CC_ONE = 12, CC_ONE = 12,
GX_CC_HALF = 13, CC_HALF = 13,
GX_CC_KONST = 14, CC_KONST = 14,
GX_CC_ZERO = 15 /*!< Use to pass zero value */ CC_ZERO = 15 /*!< Use to pass zero value */
}; };
enum TevAlphaArg { enum TevAlphaArg {
GX_CA_APREV = 0, /*!< Use the alpha value from previous TEV stage */ 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 */ 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 */ 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 */ CA_A2 = 3, /*!< Use the alpha value from the color/output register 2 */
GX_CA_TEXA = 4, /*!< Use the alpha value from texture */ CA_TEXA = 4, /*!< Use the alpha value from texture */
GX_CA_RASA = 5, /*!< Use the alpha value from rasterizer */ CA_RASA = 5, /*!< Use the alpha value from rasterizer */
GX_CA_KONST = 6, CA_KONST = 6,
GX_CA_ZERO = 7 /*!< Use to pass zero value */ CA_ZERO = 7 /*!< Use to pass zero value */
}; };
enum TevKColorSel enum TevKColorSel
{ {
GX_TEV_KCSEL_8_8 = 0x00, TEV_KCSEL_8_8 = 0x00,
GX_TEV_KCSEL_7_8 = 0x01, TEV_KCSEL_7_8 = 0x01,
GX_TEV_KCSEL_6_8 = 0x02, TEV_KCSEL_6_8 = 0x02,
GX_TEV_KCSEL_5_8 = 0x03, TEV_KCSEL_5_8 = 0x03,
GX_TEV_KCSEL_4_8 = 0x04, TEV_KCSEL_4_8 = 0x04,
GX_TEV_KCSEL_3_8 = 0x05, TEV_KCSEL_3_8 = 0x05,
GX_TEV_KCSEL_2_8 = 0x06, TEV_KCSEL_2_8 = 0x06,
GX_TEV_KCSEL_1_8 = 0x07, TEV_KCSEL_1_8 = 0x07,
GX_TEV_KCSEL_1 = GX_TEV_KCSEL_8_8, TEV_KCSEL_1 = TEV_KCSEL_8_8,
GX_TEV_KCSEL_3_4 = GX_TEV_KCSEL_6_8, TEV_KCSEL_3_4 = TEV_KCSEL_6_8,
GX_TEV_KCSEL_1_2 = GX_TEV_KCSEL_4_8, TEV_KCSEL_1_2 = TEV_KCSEL_4_8,
GX_TEV_KCSEL_1_4 = GX_TEV_KCSEL_2_8, TEV_KCSEL_1_4 = TEV_KCSEL_2_8,
GX_TEV_KCSEL_K0 = 0x0C, TEV_KCSEL_K0 = 0x0C,
GX_TEV_KCSEL_K1 = 0x0D, TEV_KCSEL_K1 = 0x0D,
GX_TEV_KCSEL_K2 = 0x0E, TEV_KCSEL_K2 = 0x0E,
GX_TEV_KCSEL_K3 = 0x0F, TEV_KCSEL_K3 = 0x0F,
GX_TEV_KCSEL_K0_R = 0x10, TEV_KCSEL_K0_R = 0x10,
GX_TEV_KCSEL_K1_R = 0x11, TEV_KCSEL_K1_R = 0x11,
GX_TEV_KCSEL_K2_R = 0x12, TEV_KCSEL_K2_R = 0x12,
GX_TEV_KCSEL_K3_R = 0x13, TEV_KCSEL_K3_R = 0x13,
GX_TEV_KCSEL_K0_G = 0x14, TEV_KCSEL_K0_G = 0x14,
GX_TEV_KCSEL_K1_G = 0x15, TEV_KCSEL_K1_G = 0x15,
GX_TEV_KCSEL_K2_G = 0x16, TEV_KCSEL_K2_G = 0x16,
GX_TEV_KCSEL_K3_G = 0x17, TEV_KCSEL_K3_G = 0x17,
GX_TEV_KCSEL_K0_B = 0x18, TEV_KCSEL_K0_B = 0x18,
GX_TEV_KCSEL_K1_B = 0x19, TEV_KCSEL_K1_B = 0x19,
GX_TEV_KCSEL_K2_B = 0x1A, TEV_KCSEL_K2_B = 0x1A,
GX_TEV_KCSEL_K3_B = 0x1B, TEV_KCSEL_K3_B = 0x1B,
GX_TEV_KCSEL_K0_A = 0x1C, TEV_KCSEL_K0_A = 0x1C,
GX_TEV_KCSEL_K1_A = 0x1D, TEV_KCSEL_K1_A = 0x1D,
GX_TEV_KCSEL_K2_A = 0x1E, TEV_KCSEL_K2_A = 0x1E,
GX_TEV_KCSEL_K3_A = 0x1F TEV_KCSEL_K3_A = 0x1F
}; };
enum TevKAlphaSel enum TevKAlphaSel
{ {
GX_TEV_KASEL_8_8 = 0x00, TEV_KASEL_8_8 = 0x00,
GX_TEV_KASEL_7_8 = 0x01, TEV_KASEL_7_8 = 0x01,
GX_TEV_KASEL_6_8 = 0x02, TEV_KASEL_6_8 = 0x02,
GX_TEV_KASEL_5_8 = 0x03, TEV_KASEL_5_8 = 0x03,
GX_TEV_KASEL_4_8 = 0x04, TEV_KASEL_4_8 = 0x04,
GX_TEV_KASEL_3_8 = 0x05, TEV_KASEL_3_8 = 0x05,
GX_TEV_KASEL_2_8 = 0x06, TEV_KASEL_2_8 = 0x06,
GX_TEV_KASEL_1_8 = 0x07, TEV_KASEL_1_8 = 0x07,
GX_TEV_KASEL_1 = GX_TEV_KASEL_8_8, TEV_KASEL_1 = TEV_KASEL_8_8,
GX_TEV_KASEL_3_4 = GX_TEV_KASEL_6_8, TEV_KASEL_3_4 = TEV_KASEL_6_8,
GX_TEV_KASEL_1_2 = GX_TEV_KASEL_4_8, TEV_KASEL_1_2 = TEV_KASEL_4_8,
GX_TEV_KASEL_1_4 = GX_TEV_KASEL_2_8, TEV_KASEL_1_4 = TEV_KASEL_2_8,
GX_TEV_KASEL_K0_R = 0x10, TEV_KASEL_K0_R = 0x10,
GX_TEV_KASEL_K1_R = 0x11, TEV_KASEL_K1_R = 0x11,
GX_TEV_KASEL_K2_R = 0x12, TEV_KASEL_K2_R = 0x12,
GX_TEV_KASEL_K3_R = 0x13, TEV_KASEL_K3_R = 0x13,
GX_TEV_KASEL_K0_G = 0x14, TEV_KASEL_K0_G = 0x14,
GX_TEV_KASEL_K1_G = 0x15, TEV_KASEL_K1_G = 0x15,
GX_TEV_KASEL_K2_G = 0x16, TEV_KASEL_K2_G = 0x16,
GX_TEV_KASEL_K3_G = 0x17, TEV_KASEL_K3_G = 0x17,
GX_TEV_KASEL_K0_B = 0x18, TEV_KASEL_K0_B = 0x18,
GX_TEV_KASEL_K1_B = 0x19, TEV_KASEL_K1_B = 0x19,
GX_TEV_KASEL_K2_B = 0x1A, TEV_KASEL_K2_B = 0x1A,
GX_TEV_KASEL_K3_B = 0x1B, TEV_KASEL_K3_B = 0x1B,
GX_TEV_KASEL_K0_A = 0x1C, TEV_KASEL_K0_A = 0x1C,
GX_TEV_KASEL_K1_A = 0x1D, TEV_KASEL_K1_A = 0x1D,
GX_TEV_KASEL_K2_A = 0x1E, TEV_KASEL_K2_A = 0x1E,
GX_TEV_KASEL_K3_A = 0x1F TEV_KASEL_K3_A = 0x1F
}; };
enum TevOp { enum TevOp {
GX_TEV_ADD = 0, TEV_ADD = 0,
GX_TEV_SUB = 1, TEV_SUB = 1,
GX_TEV_COMP_R8_GT = 8, TEV_COMP_R8_GT = 8,
GX_TEV_COMP_R8_EQ = 9, TEV_COMP_R8_EQ = 9,
GX_TEV_COMP_GR16_GT = 10, TEV_COMP_GR16_GT = 10,
GX_TEV_COMP_GR16_EQ = 11, TEV_COMP_GR16_EQ = 11,
GX_TEV_COMP_BGR24_GT = 12, TEV_COMP_BGR24_GT = 12,
GX_TEV_COMP_BGR24_EQ = 13, TEV_COMP_BGR24_EQ = 13,
GX_TEV_COMP_RGB8_GT = 14, TEV_COMP_RGB8_GT = 14,
GX_TEV_COMP_RGB8_EQ = 15, TEV_COMP_RGB8_EQ = 15,
GX_TEV_COMP_A8_GT = GX_TEV_COMP_RGB8_GT, // for alpha channel TEV_COMP_A8_GT = TEV_COMP_RGB8_GT, // for alpha channel
GX_TEV_COMP_A8_EQ = GX_TEV_COMP_RGB8_EQ // for alpha channel TEV_COMP_A8_EQ = TEV_COMP_RGB8_EQ // for alpha channel
}; };
enum TevBias { enum TevBias {
GX_TB_ZERO = 0, TB_ZERO = 0,
GX_TB_ADDHALF = 1, TB_ADDHALF = 1,
GX_TB_SUBHALF = 2, TB_SUBHALF = 2,
}; };
enum TevScale { enum TevScale {
GX_CS_SCALE_1 = 0, CS_SCALE_1 = 0,
GX_CS_SCALE_2 = 1, CS_SCALE_2 = 1,
GX_CS_SCALE_4 = 2, CS_SCALE_4 = 2,
GX_CS_DIVIDE_2 = 3 CS_DIVIDE_2 = 3
}; };
enum TevRegID { enum TevRegID {
GX_TEVPREV = 0, TEVPREV = 0,
GX_TEVREG0 = 1, TEVREG0 = 1,
GX_TEVREG1 = 2, TEVREG1 = 2,
GX_TEVREG2 = 3 TEVREG2 = 3
}; };
enum TexGenType enum TexGenType
{ {
GX_TG_MTX3x4 = 0, TG_MTX3x4 = 0,
GX_TG_MTX2x4, TG_MTX2x4,
GX_TG_BUMP0, TG_BUMP0,
GX_TG_BUMP1, TG_BUMP1,
GX_TG_BUMP2, TG_BUMP2,
GX_TG_BUMP3, TG_BUMP3,
GX_TG_BUMP4, TG_BUMP4,
GX_TG_BUMP5, TG_BUMP5,
GX_TG_BUMP6, TG_BUMP6,
GX_TG_BUMP7, TG_BUMP7,
GX_TG_SRTG TG_SRTG
}; };
enum TexGenSrc enum TexGenSrc
{ {
GX_TG_POS = 0, TG_POS = 0,
GX_TG_NRM, TG_NRM,
GX_TG_BINRM, TG_BINRM,
GX_TG_TANGENT, TG_TANGENT,
GX_TG_TEX0, TG_TEX0,
GX_TG_TEX1, TG_TEX1,
GX_TG_TEX2, TG_TEX2,
GX_TG_TEX3, TG_TEX3,
GX_TG_TEX4, TG_TEX4,
GX_TG_TEX5, TG_TEX5,
GX_TG_TEX6, TG_TEX6,
GX_TG_TEX7, TG_TEX7,
GX_TG_TEXCOORD0, TG_TEXCOORD0,
GX_TG_TEXCOORD1, TG_TEXCOORD1,
GX_TG_TEXCOORD2, TG_TEXCOORD2,
GX_TG_TEXCOORD3, TG_TEXCOORD3,
GX_TG_TEXCOORD4, TG_TEXCOORD4,
GX_TG_TEXCOORD5, TG_TEXCOORD5,
GX_TG_TEXCOORD6, TG_TEXCOORD6,
GX_TG_COLOR0, TG_COLOR0,
GX_TG_COLOR1 TG_COLOR1
}; };
enum TexMtx enum TexMtx
{ {
GX_TEXMTX0 = 30, TEXMTX0 = 30,
GX_TEXMTX1 = 33, TEXMTX1 = 33,
GX_TEXMTX2 = 36, TEXMTX2 = 36,
GX_TEXMTX3 = 39, TEXMTX3 = 39,
GX_TEXMTX4 = 42, TEXMTX4 = 42,
GX_TEXMTX5 = 45, TEXMTX5 = 45,
GX_TEXMTX6 = 48, TEXMTX6 = 48,
GX_TEXMTX7 = 51, TEXMTX7 = 51,
GX_TEXMTX8 = 54, TEXMTX8 = 54,
GX_TEXMTX9 = 57, TEXMTX9 = 57,
GX_IDENTITY = 60 IDENTITY = 60
}; };
enum PTTexMtx enum PTTexMtx
{ {
GX_PTTEXMTX0 = 64, PTTEXMTX0 = 64,
GX_PTTEXMTX1 = 67, PTTEXMTX1 = 67,
GX_PTTEXMTX2 = 70, PTTEXMTX2 = 70,
GX_PTTEXMTX3 = 73, PTTEXMTX3 = 73,
GX_PTTEXMTX4 = 76, PTTEXMTX4 = 76,
GX_PTTEXMTX5 = 79, PTTEXMTX5 = 79,
GX_PTTEXMTX6 = 82, PTTEXMTX6 = 82,
GX_PTTEXMTX7 = 85, PTTEXMTX7 = 85,
GX_PTTEXMTX8 = 88, PTTEXMTX8 = 88,
GX_PTTEXMTX9 = 91, PTTEXMTX9 = 91,
GX_PTTEXMTX10 = 94, PTTEXMTX10 = 94,
GX_PTTEXMTX11 = 97, PTTEXMTX11 = 97,
GX_PTTEXMTX12 = 100, PTTEXMTX12 = 100,
GX_PTTEXMTX13 = 103, PTTEXMTX13 = 103,
GX_PTTEXMTX14 = 106, PTTEXMTX14 = 106,
GX_PTTEXMTX15 = 109, PTTEXMTX15 = 109,
GX_PTTEXMTX16 = 112, PTTEXMTX16 = 112,
GX_PTTEXMTX17 = 115, PTTEXMTX17 = 115,
GX_PTTEXMTX18 = 118, PTTEXMTX18 = 118,
GX_PTTEXMTX19 = 121, PTTEXMTX19 = 121,
GX_PTIDENTITY = 125 PTIDENTITY = 125
}; };
} }
#endif #endif // _DNACOMMON_GX_HPP_

View File

@ -2,7 +2,6 @@
#include "../DNAMP2/CMDLMaterials.hpp" #include "../DNAMP2/CMDLMaterials.hpp"
using Stream = HECL::BlenderConnection::PyOutStream; using Stream = HECL::BlenderConnection::PyOutStream;
using namespace GX;
namespace Retro namespace Retro
{ {
@ -22,7 +21,7 @@ void MaterialSet::RegisterMaterialProps(Stream& out)
"\n"; "\n";
} }
static void AddTexture(Stream& out, TexGenSrc type, int mtxIdx, uint32_t texIdx) static void AddTexture(Stream& out, GX::TexGenSrc type, int mtxIdx, uint32_t texIdx)
{ {
char mtxLabel[64]; char mtxLabel[64];
if (mtxIdx == -1) if (mtxIdx == -1)
@ -46,12 +45,12 @@ static void AddTexture(Stream& out, TexGenSrc type, int mtxIdx, uint32_t texIdx)
out.format("tex_node.texture = tex_maps[%u]\n", out.format("tex_node.texture = tex_maps[%u]\n",
texIdx); texIdx);
if (type == GX_TG_POS) if (type == GX::TG_POS)
out.format("tex_links.append(new_nodetree.links.new(tex_uv_node.outputs['View'], tex_node.inputs['Vector']))\n"); out.format("tex_links.append(new_nodetree.links.new(tex_uv_node.outputs['View'], tex_node.inputs['Vector']))\n");
else if (type == GX_TG_NRM) else if (type == GX::TG_NRM)
out.format("tex_links.append(new_nodetree.links.new(tex_uv_node.outputs['Normal'], tex_node.inputs['Vector']))\n"); out.format("tex_links.append(new_nodetree.links.new(tex_uv_node.outputs['Normal'], tex_node.inputs['Vector']))\n");
else if (type >= GX_TG_TEX0 && type <= GX_TG_TEX7) { else if (type >= GX::TG_TEX0 && type <= GX::TG_TEX7) {
uint8_t texIdx = type - GX_TG_TEX0; uint8_t texIdx = type - GX::TG_TEX0;
out.format("tex_links.append(new_nodetree.links.new(tex_uv_node.outputs['UV'], tex_node.inputs['Vector']))\n" out.format("tex_links.append(new_nodetree.links.new(tex_uv_node.outputs['UV'], tex_node.inputs['Vector']))\n"
"tex_uv_node.uv_layer = 'UV_%u'\n", texIdx); "tex_uv_node.uv_layer = 'UV_%u'\n", texIdx);
} }
@ -205,7 +204,7 @@ static void AddTextureAnim(Stream& out,
} }
} }
static void AddKcolor(Stream& out, const Color& col, unsigned idx) static void AddKcolor(Stream& out, const GX::Color& col, unsigned idx)
{ {
out.format("# KColor\n" out.format("# KColor\n"
"kc_node = new_nodetree.nodes.new('ShaderNodeRGB')\n" "kc_node = new_nodetree.nodes.new('ShaderNodeRGB')\n"
@ -340,33 +339,33 @@ static void AddLightmap(Stream& out, const char* tex, unsigned& c_combiner_idx)
c_combiner_idx += 2; c_combiner_idx += 2;
} }
static void TranslateColorSocket(char* socketOut, TevColorArg arg, static void TranslateColorSocket(char* socketOut, GX::TevColorArg arg,
TevKColorSel kcolor, GX::TevKColorSel kcolor,
const MaterialSet::Material::TEVStageTexInfo& stageTex, const MaterialSet::Material::TEVStageTexInfo& stageTex,
char c_regs[4][64], char a_regs[4][64]) { char c_regs[4][64], char a_regs[4][64]) {
if (arg == GX_CC_ZERO) if (arg == GX::CC_ZERO)
strcpy(socketOut, "ZERO"); strcpy(socketOut, "ZERO");
else if (arg == GX_CC_HALF) else if (arg == GX::CC_HALF)
strcpy(socketOut, "HALF"); strcpy(socketOut, "HALF");
else if (arg == GX_CC_ONE) else if (arg == GX::CC_ONE)
strcpy(socketOut, "ONE"); strcpy(socketOut, "ONE");
else if (arg == GX_CC_TEXC) { else if (arg == GX::CC_TEXC) {
if (stageTex.tcgSlot == 0xff) if (stageTex.tcgSlot == 0xff)
strcpy(socketOut, "ONE"); strcpy(socketOut, "ONE");
else else
sprintf(socketOut, "texture_nodes[%u].outputs['Color']", stageTex.tcgSlot); sprintf(socketOut, "texture_nodes[%u].outputs['Color']", stageTex.tcgSlot);
} else if (arg == GX_CC_TEXA) { } else if (arg == GX::CC_TEXA) {
if (stageTex.tcgSlot == 0xff) if (stageTex.tcgSlot == 0xff)
strcpy(socketOut, "ONE"); strcpy(socketOut, "ONE");
else else
sprintf(socketOut, "texture_nodes[%u].outputs['Value']", stageTex.tcgSlot); sprintf(socketOut, "texture_nodes[%u].outputs['Value']", stageTex.tcgSlot);
} else if (arg == GX_CC_RASC) } else if (arg == GX::CC_RASC)
strcpy(socketOut, "material_node.outputs['Color']"); strcpy(socketOut, "material_node.outputs['Color']");
else if (arg == GX_CC_RASA) { else if (arg == GX::CC_RASA) {
strcpy(socketOut, "material_node.outputs['Alpha']"); strcpy(socketOut, "material_node.outputs['Alpha']");
} else if (arg == GX_CC_KONST) { } else if (arg == GX::CC_KONST) {
int kreg = (kcolor - GX_TEV_KCSEL_K0) % 4; int kreg = (kcolor - GX::TEV_KCSEL_K0) % 4;
if (kcolor < GX_TEV_KCSEL_K0) if (kcolor < GX::TEV_KCSEL_K0)
strcpy(socketOut, "ONE"); strcpy(socketOut, "ONE");
else if (kreg == 0) else if (kreg == 0)
strcpy(socketOut, "kcolor_nodes[0][0].outputs[0]"); strcpy(socketOut, "kcolor_nodes[0][0].outputs[0]");
@ -378,40 +377,40 @@ static void TranslateColorSocket(char* socketOut, TevColorArg arg,
strcpy(socketOut, "kcolor_nodes[3][0].outputs[0]"); strcpy(socketOut, "kcolor_nodes[3][0].outputs[0]");
else else
strcpy(socketOut, "ONE"); strcpy(socketOut, "ONE");
} else if (arg == GX_CC_CPREV) } else if (arg == GX::CC_CPREV)
strcpy(socketOut, c_regs[GX_TEVPREV]); strcpy(socketOut, c_regs[GX::TEVPREV]);
else if (arg == GX_CC_APREV) { else if (arg == GX::CC_APREV) {
strcpy(socketOut, a_regs[GX_TEVPREV]); strcpy(socketOut, a_regs[GX::TEVPREV]);
} else if (arg == GX_CC_C0) } else if (arg == GX::CC_C0)
strcpy(socketOut, c_regs[GX_TEVREG0]); strcpy(socketOut, c_regs[GX::TEVREG0]);
else if (arg == GX_CC_A0) { else if (arg == GX::CC_A0) {
strcpy(socketOut, a_regs[GX_TEVREG0]); strcpy(socketOut, a_regs[GX::TEVREG0]);
} else if (arg == GX_CC_C1) } else if (arg == GX::CC_C1)
strcpy(socketOut, c_regs[GX_TEVREG1]); strcpy(socketOut, c_regs[GX::TEVREG1]);
else if (arg == GX_CC_A1) { else if (arg == GX::CC_A1) {
strcpy(socketOut, a_regs[GX_TEVREG1]); strcpy(socketOut, a_regs[GX::TEVREG1]);
} else if (arg == GX_CC_C2) } else if (arg == GX::CC_C2)
strcpy(socketOut, c_regs[GX_TEVREG2]); strcpy(socketOut, c_regs[GX::TEVREG2]);
else if (arg == GX_CC_A2) { else if (arg == GX::CC_A2) {
strcpy(socketOut, a_regs[GX_TEVREG2]); strcpy(socketOut, a_regs[GX::TEVREG2]);
} }
} }
static void TranslateAlphaSocket(char* socketOut, TevAlphaArg arg, static void TranslateAlphaSocket(char* socketOut, GX::TevAlphaArg arg,
TevKAlphaSel kalpha, GX::TevKAlphaSel kalpha,
const MaterialSet::Material::TEVStageTexInfo& stageTex, const MaterialSet::Material::TEVStageTexInfo& stageTex,
char a_regs[4][64]) { char a_regs[4][64]) {
if (arg == GX_CA_ZERO) if (arg == GX::CA_ZERO)
strcpy(socketOut, "ZERO"); strcpy(socketOut, "ZERO");
else if (arg == GX_CA_TEXA) { else if (arg == GX::CA_TEXA) {
if (stageTex.tcgSlot == 0xff) if (stageTex.tcgSlot == 0xff)
strcpy(socketOut, "ONE"); strcpy(socketOut, "ONE");
else else
sprintf(socketOut, "texture_nodes[%u].outputs['Value']", stageTex.tcgSlot); sprintf(socketOut, "texture_nodes[%u].outputs['Value']", stageTex.tcgSlot);
} else if (arg == GX_CA_RASA) } else if (arg == GX::CA_RASA)
strcpy(socketOut, "material_node.outputs['Alpha']"); strcpy(socketOut, "material_node.outputs['Alpha']");
else if (arg == GX_CA_KONST) { else if (arg == GX::CA_KONST) {
int kreg = kalpha - GX_TEV_KASEL_K0_A; int kreg = kalpha - GX::TEV_KASEL_K0_A;
if (kreg == 0) if (kreg == 0)
strcpy(socketOut, "kcolor_nodes[0][1].outputs[0]"); strcpy(socketOut, "kcolor_nodes[0][1].outputs[0]");
else if (kreg == 1) else if (kreg == 1)
@ -422,14 +421,14 @@ static void TranslateAlphaSocket(char* socketOut, TevAlphaArg arg,
strcpy(socketOut, "kcolor_nodes[3][1].outputs[0]"); strcpy(socketOut, "kcolor_nodes[3][1].outputs[0]");
else else
strcpy(socketOut, "ONE"); strcpy(socketOut, "ONE");
} else if (arg == GX_CA_APREV) } else if (arg == GX::CA_APREV)
strcpy(socketOut, a_regs[GX_TEVPREV]); strcpy(socketOut, a_regs[GX::TEVPREV]);
else if (arg == GX_CA_A0) else if (arg == GX::CA_A0)
strcpy(socketOut, a_regs[GX_TEVREG0]); strcpy(socketOut, a_regs[GX::TEVREG0]);
else if (arg == GX_CA_A1) else if (arg == GX::CA_A1)
strcpy(socketOut, a_regs[GX_TEVREG1]); strcpy(socketOut, a_regs[GX::TEVREG1]);
else if (arg == GX_CA_A2) else if (arg == GX::CA_A2)
strcpy(socketOut, a_regs[GX_TEVREG2]); strcpy(socketOut, a_regs[GX::TEVREG2]);
} }
static void AddTEVStage(Stream& out, const MaterialSet::Material::TEVStage& stage, static void AddTEVStage(Stream& out, const MaterialSet::Material::TEVStage& stage,
@ -457,13 +456,13 @@ static void AddTEVStage(Stream& out, const MaterialSet::Material::TEVStage& stag
/* Apply color optimizations */ /* Apply color optimizations */
unsigned c_tev_opts = 0; unsigned c_tev_opts = 0;
if (stage.colorInA() == GX_CC_ZERO || stage.colorInC() == GX_CC_ONE) if (stage.colorInA() == GX::CC_ZERO || stage.colorInC() == GX::CC_ONE)
c_tev_opts |= 1; c_tev_opts |= 1;
if (stage.colorInB() == GX_CC_ZERO || stage.colorInC() == GX_CC_ZERO) if (stage.colorInB() == GX::CC_ZERO || stage.colorInC() == GX::CC_ZERO)
c_tev_opts |= 2; c_tev_opts |= 2;
if (c_tev_opts & 1 || c_tev_opts & 2) if (c_tev_opts & 1 || c_tev_opts & 2)
c_tev_opts |= 4; c_tev_opts |= 4;
if (stage.colorInD() == GX_CC_ZERO || (c_tev_opts & 7) == 7) if (stage.colorInD() == GX::CC_ZERO || (c_tev_opts & 7) == 7)
c_tev_opts |= 8; c_tev_opts |= 8;
if (!(c_tev_opts & 1)) if (!(c_tev_opts & 1))
@ -498,13 +497,13 @@ static void AddTEVStage(Stream& out, const MaterialSet::Material::TEVStage& stag
/* Apply alpha optimizations */ /* Apply alpha optimizations */
unsigned a_tev_opts = 0; unsigned a_tev_opts = 0;
if (stage.alphaInA() == GX_CA_ZERO) if (stage.alphaInA() == GX::CA_ZERO)
a_tev_opts |= 1; a_tev_opts |= 1;
if (stage.alphaInB() == GX_CA_ZERO || stage.alphaInC() == GX_CA_ZERO) if (stage.alphaInB() == GX::CA_ZERO || stage.alphaInC() == GX::CA_ZERO)
a_tev_opts |= 2; a_tev_opts |= 2;
if (a_tev_opts & 1 || a_tev_opts & 2) if (a_tev_opts & 1 || a_tev_opts & 2)
a_tev_opts |= 4; a_tev_opts |= 4;
if (stage.alphaInD() == GX_CA_ZERO || (a_tev_opts & 7) == 7) if (stage.alphaInD() == GX::CA_ZERO || (a_tev_opts & 7) == 7)
a_tev_opts |= 8; a_tev_opts |= 8;
if (!(a_tev_opts & 1)) if (!(a_tev_opts & 1))
@ -539,13 +538,13 @@ static void AddTEVStage(Stream& out, const MaterialSet::Material::TEVStage& stag
/* Update TEV regs */ /* Update TEV regs */
if (c_tev_opts == 0xf) if (c_tev_opts == 0xf)
{ {
if (stage.colorInD() != GX_CC_ZERO) if (stage.colorInD() != GX::CC_ZERO)
strncpy(c_regs[stage.colorOpOutReg()], cd, 64); strncpy(c_regs[stage.colorOpOutReg()], cd, 64);
} else } else
snprintf(c_regs[stage.colorOpOutReg()], 64, "color_combiner_nodes[%u].outputs[0]", c_combiner_idx - 1); snprintf(c_regs[stage.colorOpOutReg()], 64, "color_combiner_nodes[%u].outputs[0]", c_combiner_idx - 1);
if (a_tev_opts == 0xf) if (a_tev_opts == 0xf)
{ {
if (stage.alphaInD() != GX_CA_ZERO) if (stage.alphaInD() != GX::CA_ZERO)
strncpy(a_regs[stage.alphaOpOutReg()], ad, 64); strncpy(a_regs[stage.alphaOpOutReg()], ad, 64);
} else } else
snprintf(a_regs[stage.alphaOpOutReg()], 64, "alpha_combiner_nodes[%u].outputs[0]", a_combiner_idx - 1); snprintf(a_regs[stage.alphaOpOutReg()], 64, "alpha_combiner_nodes[%u].outputs[0]", a_combiner_idx - 1);
@ -635,7 +634,7 @@ void _ConstructMaterial(Stream& out,
if (material.flags.konstValuesEnabled()) if (material.flags.konstValuesEnabled())
{ {
unsigned i=0; unsigned i=0;
for (const Color& col : material.konstColors) for (const GX::Color& col : material.konstColors)
AddKcolor(out, col, i++); AddKcolor(out, col, i++);
} }
@ -670,10 +669,10 @@ void _ConstructMaterial(Stream& out,
!(addedTcgs >> material.tevStageTexInfo[i].tcgSlot & 1)) !(addedTcgs >> material.tevStageTexInfo[i].tcgSlot & 1))
{ {
const MaterialSet::Material::TexCoordGen& tcg = material.tcgs[material.tevStageTexInfo[i].tcgSlot]; const MaterialSet::Material::TexCoordGen& tcg = material.tcgs[material.tevStageTexInfo[i].tcgSlot];
TexMtx mtx = tcg.mtx(); GX::TexMtx mtx = tcg.mtx();
int mtxIdx = -1; int mtxIdx = -1;
if (mtx >= GX_TEXMTX0 && mtx <= GX_TEXMTX9) if (mtx >= GX::TEXMTX0 && mtx <= GX::TEXMTX9)
mtxIdx = (mtx - GX_TEXMTX0) / 3; mtxIdx = (mtx - GX::TEXMTX0) / 3;
AddTexture(out, tcg.source(), mtxIdx, material.tevStageTexInfo[i].texSlot); AddTexture(out, tcg.source(), mtxIdx, material.tevStageTexInfo[i].texSlot);
addedTcgs |= 1 << material.tevStageTexInfo[i].tcgSlot; addedTcgs |= 1 << material.tevStageTexInfo[i].tcgSlot;
} }
@ -688,13 +687,13 @@ void _ConstructMaterial(Stream& out,
char a_regs[4][64] = {"ONE", "ONE", "ONE", "ONE"}; char a_regs[4][64] = {"ONE", "ONE", "ONE", "ONE"};
/* Has Lightmap? */ /* Has Lightmap? */
if (material.tevStages[0].colorInB() == GX_CC_C1) if (material.tevStages[0].colorInB() == GX::CC_C1)
{ {
if (material.tevStageTexInfo[0].texSlot != 0xff) if (material.tevStageTexInfo[0].texSlot != 0xff)
out << "new_material.rwk_lightmap = tex_maps[0].name\n" out << "new_material.rwk_lightmap = tex_maps[0].name\n"
"tex_maps[0].image.use_fake_user = True\n"; "tex_maps[0].image.use_fake_user = True\n";
AddLightmap(out, "texture_nodes[0].outputs['Color']", c_combiner_idx); AddLightmap(out, "texture_nodes[0].outputs['Color']", c_combiner_idx);
strncpy(c_regs[GX_TEVREG1], "world_light_node.outputs[0]", 64); strncpy(c_regs[GX::TEVREG1], "world_light_node.outputs[0]", 64);
} }
/* Add TEV stages */ /* Add TEV stages */
@ -706,11 +705,11 @@ void _ConstructMaterial(Stream& out,
} }
/* Connect final prev register */ /* Connect final prev register */
out.format("new_nodetree.links.new(%s, final_node.inputs['Color'])\n", c_regs[GX_TEVPREV]); out.format("new_nodetree.links.new(%s, final_node.inputs['Color'])\n", c_regs[GX::TEVPREV]);
if (!strcmp(a_regs[GX_TEVPREV], "ONE")) if (!strcmp(a_regs[GX::TEVPREV], "ONE"))
out << "final_node.inputs['Alpha'].default_value = 1.0\n"; out << "final_node.inputs['Alpha'].default_value = 1.0\n";
else else
out.format("new_nodetree.links.new(%s, final_node.inputs['Alpha'])\n", a_regs[GX_TEVPREV]); out.format("new_nodetree.links.new(%s, final_node.inputs['Alpha'])\n", a_regs[GX::TEVPREV]);
/* Texmtx Animation Section */ /* Texmtx Animation Section */
i=0; i=0;