Пример #1
0
        public Material()
        {
            TextureMaps       = new TextureRef[0];
            TextureTransforms = new BxlytTextureTransform[0];
            TexCoordGens      = new TexCoordGen[0];
            TevStages         = new TevStage[0];
            ProjTexGenParams  = new ProjectionTexGenParam[0];

            BlackColor = new STColor8(0, 0, 0, 0);
            WhiteColor = STColor8.White;
        }
Пример #2
0
        public override void AddTexture(string texture)
        {
            Console.WriteLine("TextureMaps AddTexture");

            int        index      = ParentLayout.AddTexture(texture);
            TextureRef textureRef = new TextureRef();

            textureRef.ID     = (short)index;
            textureRef.Name   = texture;
            TextureMaps       = TextureMaps.AddToArray(textureRef);
            TextureTransforms = TextureTransforms.AddToArray(new BxlytTextureTransform());
        }
Пример #3
0
        public Material(string name, BxlytHeader header)
        {
            ParentLayout      = header;
            Name              = name;
            TextureMaps       = new TextureRef[0];
            TextureTransforms = new BxlytTextureTransform[0];
            TexCoordGens      = new TexCoordGen[0];
            TevStages         = new TevStage[0];
            ProjTexGenParams  = new ProjectionTexGenParam[0];

            BlackColor = new STColor8(0, 0, 0, 0);
            WhiteColor = STColor8.White;
        }
Пример #4
0
        public Material(FileReader reader, Header header) : base()
        {
            ParentLayout = header;

            Name = reader.ReadString(0x1C, true);
            Name = Name.Replace("\x01", string.Empty);
            Name = Name.Replace("\x04", string.Empty);

            if (header.VersionMajor >= 8)
            {
                flags      = reader.ReadUInt32();
                unknown    = reader.ReadInt32();
                BlackColor = STColor8.FromBytes(reader.ReadBytes(4));
                WhiteColor = STColor8.FromBytes(reader.ReadBytes(4));
            }
            else
            {
                BlackColor = STColor8.FromBytes(reader.ReadBytes(4));
                WhiteColor = STColor8.FromBytes(reader.ReadBytes(4));
                flags      = reader.ReadUInt32();
            }

            uint texCount         = Convert.ToUInt32(flags & 3);
            uint mtxCount         = Convert.ToUInt32(flags >> 2) & 3;
            uint texCoordGenCount = Convert.ToUInt32(flags >> 4) & 3;
            uint tevStageCount    = Convert.ToUInt32(flags >> 6) & 0x7;

            EnableAlphaCompare = Convert.ToBoolean((flags >> 9) & 0x1);
            EnableBlend        = Convert.ToBoolean((flags >> 10) & 0x1);
            var useTextureOnly = Convert.ToBoolean((flags >> 11) & 0x1);

            EnableBlendLogic = Convert.ToBoolean((flags >> 12) & 0x1);
            EnableIndParams  = Convert.ToBoolean((flags >> 14) & 0x1);
            var projTexGenParamCount = Convert.ToUInt32((flags >> 15) & 0x3);

            EnableFontShadowParams = Convert.ToBoolean((flags >> 17) & 0x1);
            AlphaInterpolation     = Convert.ToBoolean((flags >> 18) & 0x1);


            Console.WriteLine($"MAT1 {Name}");
            Console.WriteLine($"texCount {texCount}");
            Console.WriteLine($"mtxCount {mtxCount}");
            Console.WriteLine($"texCoordGenCount {texCoordGenCount}");
            Console.WriteLine($"tevStageCount {tevStageCount}");
            Console.WriteLine($"hasAlphaCompare {EnableAlphaCompare}");
            Console.WriteLine($"hasBlendMode {EnableBlend}");
            Console.WriteLine($"useTextureOnly {useTextureOnly}");
            Console.WriteLine($"seperateBlendMode {EnableBlendLogic}");
            Console.WriteLine($"hasIndParam {EnableIndParams}");
            Console.WriteLine($"projTexGenParamCount {projTexGenParamCount}");
            Console.WriteLine($"hasFontShadowParam {EnableFontShadowParams}");
            Console.WriteLine($"AlphaInterpolation {AlphaInterpolation}");


            TextureMaps       = new TextureRef[texCount];
            TextureTransforms = new BxlytTextureTransform[mtxCount];
            TexCoordGens      = new TexCoordGen[texCoordGenCount];
            TevStages         = new TevStage[tevStageCount];
            ProjTexGenParams  = new ProjectionTexGenParam[projTexGenParamCount];

            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[i] = new TexCoordGen(reader, header);
            }

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

            if (EnableAlphaCompare)
            {
                AlphaCompare = new BxlytAlphaCompare(reader, header);
            }
            if (EnableBlend)
            {
                BlendMode = new BxlytBlendMode(reader, header);
            }
            if (EnableBlendLogic)
            {
                BlendModeLogic = new BxlytBlendMode(reader, header);
            }
            if (EnableIndParams)
            {
                IndParameter = new IndirectParameter(reader, header);
            }

            for (int i = 0; i < projTexGenParamCount; i++)
            {
                ProjTexGenParams[i] = new ProjectionTexGenParam(reader, header);
            }

            if (EnableFontShadowParams)
            {
                FontShadowParameter = new FontShadowParameter(reader, header);
            }
        }