Пример #1
0
        public override void AddTexture(string texture)
        {
            int        index      = ParentLayout.AddTexture(texture);
            TextureRef textureRef = new TextureRef();

            textureRef.ID   = (short)index;
            textureRef.Name = texture;
            TextureMaps     = TextureMaps.AddToArray(textureRef);
            TexCoordGens.Add(new TexCoordGenEntry()
            {
                Type         = TexCoordGenTypes.GX_TG_MTX2x4,
                MatrixSource = TexCoordGenMatrixSource.GX_DTTMTX9 + (TexCoordGens.Count * 4),
                Source       = TexCoordGenSource.GX_TG_TEX0
            });
            TextureTransforms = TextureTransforms.AddToArray(new BxlytTextureTransform());
        }
Пример #2
0
 public Material(string name, BxlytHeader header)
 {
     ParentLayout          = header;
     Name                  = name;
     TextureMaps           = new TextureRef[0];
     TextureTransforms     = new BxlytTextureTransform[0];
     TexCoordGens          = new List <TexCoordGenEntry>();
     IndirectTexTransforms = new List <BxlytTextureTransform>();
     IndirectStages        = new List <IndirectStage>();
     TevSwapModeTable      = new TevSwapModeTable();
     ChanControl           = new ChanCtrl();
     BlackColor            = new STColor8(0, 0, 0, 0);
     WhiteColor            = STColor8.White;
     ColorRegister3        = STColor8.White;
     TevColor1             = STColor8.White;
     TevColor2             = STColor8.White;
     TevColor3             = STColor8.White;
     TevColor4             = STColor8.White;
     TevStages             = new TevStage[0];
     BlendMode             = new BxlytBlendMode();
     AlphaCompare          = new AlphaCompare();
 }
Пример #3
0
        public Material(FileReader reader, BxlytHeader header) : base()
        {
            ParentLayout = header;

            BlendMode             = new BxlytBlendMode();
            AlphaCompare          = new AlphaCompare();
            TexCoordGens          = new List <TexCoordGenEntry>();
            IndirectTexTransforms = new List <BxlytTextureTransform>();
            IndirectStages        = new List <IndirectStage>();

            Name = reader.ReadString(0x14, true);

            BlackColor     = reader.ReadColor16RGBA().ToColor8();
            WhiteColor     = reader.ReadColor16RGBA().ToColor8();
            ColorRegister3 = reader.ReadColor16RGBA().ToColor8();
            TevColor1      = reader.ReadColor8RGBA();
            TevColor2      = reader.ReadColor8RGBA();
            TevColor3      = reader.ReadColor8RGBA();
            TevColor4      = reader.ReadColor8RGBA();
            flags          = reader.ReadUInt32();

            HasMaterialColor  = Convert.ToBoolean(ExtractBits(flags, 1, 4));
            HasChannelControl = Convert.ToBoolean(ExtractBits(flags, 1, 6));
            HasBlendMode      = Convert.ToBoolean(ExtractBits(flags, 1, 7));
            HasAlphaCompare   = Convert.ToBoolean(ExtractBits(flags, 1, 8));
            uint tevStagesCount   = ExtractBits(flags, 5, 9);
            uint indTexOrderCount = ExtractBits(flags, 2, 16);
            uint indSrtCount      = ExtractBits(flags, 2, 17);

            HasTevSwapTable = Convert.ToBoolean(ExtractBits(flags, 1, 19));
            uint texCoordGenCount = ExtractBits(flags, 4, 20);
            uint mtxCount         = ExtractBits(flags, 4, 24);
            uint texCount         = ExtractBits(flags, 4, 28);

            Console.WriteLine($"HasMaterialColor {HasMaterialColor}");
            Console.WriteLine($"HasChannelControl {HasChannelControl}");
            Console.WriteLine($"HasBlendMode {HasBlendMode}");
            Console.WriteLine($"HasAlphaCompare {HasAlphaCompare}");
            Console.WriteLine($"tevStagesCount {tevStagesCount}");
            Console.WriteLine($"indTexOrderCount {indTexOrderCount}");
            Console.WriteLine($"indSrtCount {indSrtCount}");
            Console.WriteLine($"HasTevSwapTable {HasTevSwapTable}");
            Console.WriteLine($"texCoordGenCount {texCoordGenCount}");
            Console.WriteLine($"mtxCount {mtxCount}");
            Console.WriteLine($"texCount {texCount}");

            TextureMaps       = new TextureRef[texCount];
            TevStages         = new TevStage[tevStagesCount];
            TextureTransforms = new BxlytTextureTransform[mtxCount];

            for (int i = 0; i < texCount; i++)
            {
                TextureMaps[i] = new TextureRef(reader, header);
            }

            for (int i = 0; i < mtxCount; i++)
            {
                TextureTransforms[i] = new BxlytTextureTransform(reader);
            }

            for (int i = 0; i < texCoordGenCount; i++)
            {
                TexCoordGens.Add(new TexCoordGenEntry(reader));
            }

            if (HasChannelControl)
            {
                ChanControl = new ChanCtrl(reader);
            }

            if (HasMaterialColor)
            {
                MatColor = reader.ReadColor8RGBA();
            }

            if (HasTevSwapTable)
            {
                TevSwapModeTable = new TevSwapModeTable(reader);
            }

            for (int i = 0; i < indSrtCount; i++)
            {
                IndirectTexTransforms.Add(new BxlytTextureTransform(reader));
            }

            for (int i = 0; i < indTexOrderCount; i++)
            {
                IndirectStages.Add(new IndirectStage(reader));
            }

            for (int i = 0; i < tevStagesCount; i++)
            {
                TevStages[i] = new TevStage(reader, header);
            }

            if (HasAlphaCompare)
            {
                AlphaCompare = new AlphaCompare(reader);
            }

            if (HasBlendMode)
            {
                BlendMode = new BxlytBlendMode(reader, header);
            }
        }