public BPCommand(BPRegister register, int value) { Register = register; Value = value; }
private void GenerateTextureCommands(Material mat, List <BinaryTextureImage> textures) { BPRegister[] texInfoRegs = new BPRegister[] { BPRegister.TX_SETIMAGE0_I0, BPRegister.TX_SETIMAGE0_I1, BPRegister.TX_SETIMAGE0_I2, BPRegister.TX_SETIMAGE0_I3, BPRegister.TX_SETIMAGE0_I4, BPRegister.TX_SETIMAGE0_I5, BPRegister.TX_SETIMAGE0_I6, BPRegister.TX_SETIMAGE0_I7 }; BPRegister[] texIndexRegs = new BPRegister[] { BPRegister.TX_SETIMAGE3_I0, BPRegister.TX_SETIMAGE3_I1, BPRegister.TX_SETIMAGE3_I2, BPRegister.TX_SETIMAGE3_I3, BPRegister.TX_SETIMAGE3_I4, BPRegister.TX_SETIMAGE3_I5, BPRegister.TX_SETIMAGE3_I6, BPRegister.TX_SETIMAGE3_I7 }; BPRegister[] texMode0Regs = new BPRegister[] { BPRegister.TX_SET_MODE0_I0, BPRegister.TX_SET_MODE0_I1, BPRegister.TX_SET_MODE0_I2, BPRegister.TX_SET_MODE0_I3, BPRegister.TX_SET_MODE0_I4, BPRegister.TX_SET_MODE0_I5, BPRegister.TX_SET_MODE0_I6, BPRegister.TX_SET_MODE0_I7 }; BPRegister[] texMode1Regs = new BPRegister[] { BPRegister.TX_SET_MODE1_I0, BPRegister.TX_SET_MODE1_I1, BPRegister.TX_SET_MODE1_I2, BPRegister.TX_SET_MODE1_I3, BPRegister.TX_SET_MODE1_I4, BPRegister.TX_SET_MODE1_I5, BPRegister.TX_SET_MODE1_I6, BPRegister.TX_SET_MODE1_I7 }; for (int i = 0; i < 8; i++) { if (mat.TextureIndices[i] == -1) { continue; } BinaryTextureImage curTex = textures[mat.TextureIndices[i]]; // Records width, height, and format BPCommand texInfo = new BPCommand() { Register = texInfoRegs[i] }; texInfo.SetBits(curTex.Width - 1, 0, 10); texInfo.SetBits(curTex.Height - 1, 10, 10); texInfo.SetBits((int)curTex.Format, 20, 4); // Records the index of the texture BPCommand texIndex = new BPCommand() { Register = texIndexRegs[i] }; texIndex.SetBits(mat.TextureIndices[i], 0, 24); BPCommand mode0 = new BPCommand() { Register = texMode0Regs[i] }; mode0.SetBits((int)curTex.WrapS, 0, 2); mode0.SetBits((int)curTex.WrapT, 2, 2); mode0.SetBits((int)curTex.MagFilter, 4, 1); switch (curTex.MinFilter) { case BinaryTextureImage.FilterMode.Nearest: mode0.SetBits(0, 5, 3); break; case BinaryTextureImage.FilterMode.Linear: mode0.SetBits(4, 5, 3); break; case BinaryTextureImage.FilterMode.NearestMipmapNearest: mode0.SetBits(1, 5, 3); break; case BinaryTextureImage.FilterMode.NearestMipmapLinear: mode0.SetBits(2, 5, 3); break; case BinaryTextureImage.FilterMode.LinearMipmapNearest: mode0.SetBits(5, 5, 3); break; case BinaryTextureImage.FilterMode.LinearMipmapLinear: mode0.SetBits(6, 5, 3); break; } // Unimplemented: mode0.SetFlag(true, 8); // Edge LOD (diag_lod) mode0.SetBits(0, 9, 8); // LoDBias (lod_bias) mode0.SetBits(0, 19, 2); // Max aniso (max_aniso) mode0.SetFlag(false, 21); // Bias Clamp (lod_clamp) // MinLOD // MaxLOD BPCommand mode1 = new BPCommand() { Register = texMode1Regs[i] }; BPCommands.Add(texIndex); BPCommands.Add(texInfo); BPCommands.Add(mode0); BPCommands.Add(mode1); } }