public void Read(FileReader reader, Header header)
            {
                long pos = reader.Position;

                reader.Seek(56);
                uint NameOffset = reader.ReadUInt32();
                uint padding    = reader.ReadUInt32();

                if (NameOffset != PTCL.NullOffset)
                {
                    using (reader.TemporarySeek(header.EffectNameTableOffset + NameOffset, SeekOrigin.Begin))
                    {
                        Text = reader.ReadString(BinaryStringFormat.ZeroTerminated);
                    }
                }

                uint TextureAmount = 3;

                if (header.IsSPBD)
                {
                    TextureAmount = 2;
                }

                for (int i = 0; i < TextureAmount; i++) //Max of 3 or 2 textures depending on version. Seems to fill in texture info even if unused
                {
                    TextureInfo textureInfo = new TextureInfo();
                    textureInfo.Read(reader, header, Text);

                    if (!textureInfo.IsEmpty())
                    {
                        DrawableTex.Add(textureInfo);

                        bool HasImage = header.Textures.Any(item => item.DataPos == textureInfo.DataPos);
                        if (!HasImage)
                        {
                            header.Textures.Add(textureInfo);
                        }
                    }
                }
                if (header.IsSPBD)
                {
                    reader.Seek(pos + 1358, SeekOrigin.Begin);
                }
                else
                {
                    reader.Seek(pos + 1616, SeekOrigin.Begin);
                }
                ColorPosition = reader.Position;
                for (int i = 0; i < 8; i++)
                {
                    ColorData clr = new ColorData();
                    clr.R          = reader.ReadSingle();
                    clr.G          = reader.ReadSingle();
                    clr.B          = reader.ReadSingle();
                    clr.A          = reader.ReadSingle();
                    Color0Array[i] = clr;

                    int red   = Utils.FloatToIntClamp(clr.R);
                    int green = Utils.FloatToIntClamp(clr.G);
                    int blue  = Utils.FloatToIntClamp(clr.B);
                    int alpha = Utils.FloatToIntClamp(clr.A);

                    //          Console.WriteLine($"Color0 {i} R {R} G {G} B {B} A {A}");
                    //         Console.WriteLine($"Color0 {i} R {red} G {green} B {blue} A {alpha}");

                    Color0s[i] = Color.FromArgb(alpha, red, green, blue);
                }
                for (int i = 0; i < 8; i++)
                {
                    ColorData clr = new ColorData();
                    clr.R          = reader.ReadSingle();
                    clr.G          = reader.ReadSingle();
                    clr.B          = reader.ReadSingle();
                    clr.A          = reader.ReadSingle();
                    Color1Array[i] = clr;

                    int red   = Utils.FloatToIntClamp(clr.R);
                    int green = Utils.FloatToIntClamp(clr.G);
                    int blue  = Utils.FloatToIntClamp(clr.B);
                    int alpha = Utils.FloatToIntClamp(clr.A);

                    //      Console.WriteLine($"Color1 {i} R {R} G {G} B {B} A {A}");
                    //    Console.WriteLine($"Color1 {i} R {red} G {green} B {blue} A {alpha}");

                    Color1s[i] = Color.FromArgb(alpha, red, green, blue);
                }
            }
Пример #2
0
            public void Read(FileReader reader, Header header)
            {
                long pos = reader.Position;

                if (header.Version <= 11)
                {
                    reader.Seek(12);
                }
                else
                {
                    reader.Seek(56);
                }

                uint NameOffset = reader.ReadUInt32();
                uint padding    = reader.ReadUInt32();

                if (NameOffset != PTCL.NullOffset)
                {
                    using (reader.TemporarySeek(header.EffectNameTableOffset + NameOffset, SeekOrigin.Begin))
                    {
                        Text = reader.ReadString(BinaryStringFormat.ZeroTerminated);
                    }
                }

                int TextureCount = 2;

                if (header.Version <= 11)
                {
                    TextureCount = 1;
                }

                for (int i = 0; i < TextureCount; i++) //Max of 2 textures. Any more and it'll overlap some data
                {
                    TextureInfo textureInfo = new TextureInfo();
                    textureInfo.Read(reader, header, Text);

                    if (!textureInfo.IsEmpty())
                    {
                        DrawableTex.Add(textureInfo);

                        bool HasImage = header.Textures.Any(item => item.DataPos == textureInfo.DataPos);
                        if (!HasImage)
                        {
                            header.Textures.Add(textureInfo);
                        }
                    }
                }

                if (header.Version <= 11)
                {
                    reader.Seek(pos + 120, SeekOrigin.Begin); //This is a guess
                }
                else
                {
                    reader.Seek(pos + 1072, SeekOrigin.Begin);
                }

                Color0KeyCount = 8;
                Alpha0KeyCount = 8;
                Color1KeyCount = 8;
                Alpha1KeyCount = 8;

                Color0Type = ColorType.Random;
                Color1Type = ColorType.Random;
                Alpha0Type = ColorType.Random;
                Alpha1Type = ColorType.Random;

                Color0Array      = new STColor[8];
                Color1Array      = new STColor[8];
                Color0AlphaArray = new STColor[8];
                Color1AlphaArray = new STColor[8];

                ColorPosition = reader.Position;
                for (int i = 0; i < 8; i++)
                {
                    STColor clr = new STColor();
                    clr.R = reader.ReadSingle();
                    clr.G = reader.ReadSingle();
                    clr.B = reader.ReadSingle();
                    float   A     = reader.ReadSingle();
                    STColor alpha = new STColor();
                    alpha.R             = A;
                    alpha.G             = A;
                    alpha.B             = A;
                    Color0AlphaArray[i] = alpha;
                    Color0Array[i]      = clr;
                }
                for (int i = 0; i < 8; i++)
                {
                    STColor clr = new STColor();
                    clr.R = reader.ReadSingle();
                    clr.G = reader.ReadSingle();
                    clr.B = reader.ReadSingle();
                    float   A     = reader.ReadSingle();
                    STColor alpha = new STColor();
                    alpha.R             = A;
                    alpha.G             = A;
                    alpha.B             = A;
                    Color1AlphaArray[i] = alpha;
                    Color1Array[i]      = clr;
                }
            }
Пример #3
0
            public void Read(FileReader reader, Header header)
            {
                Color0Array      = new STColor[8];
                Color1Array      = new STColor[8];
                Color0AlphaArray = new STColor[8];
                Color1AlphaArray = new STColor[8];
                ConstantColor0   = new STColor();
                ConstantColor1   = new STColor();

                Color0KeyCount = 8;
                Alpha0KeyCount = 8;
                Color1KeyCount = 8;
                Alpha1KeyCount = 8;

                Color0Type = ColorType.Random;
                Color1Type = ColorType.Random;
                Alpha0Type = ColorType.Random;
                Alpha1Type = ColorType.Random;

                long pos = reader.Position;

                reader.Seek(56);
                uint NameOffset = reader.ReadUInt32();
                uint padding    = reader.ReadUInt32();

                if (NameOffset != PTCL.NullOffset)
                {
                    using (reader.TemporarySeek(header.EffectNameTableOffset + NameOffset, SeekOrigin.Begin))
                    {
                        Text = reader.ReadString(BinaryStringFormat.ZeroTerminated);
                    }
                }

                uint TextureAmount = 3;

                if (header.IsSPBD)
                {
                    TextureAmount = 2;
                }

                for (int i = 0; i < TextureAmount; i++) //Max of 3 or 2 textures depending on version. Seems to fill in texture info even if unused
                {
                    TextureInfo textureInfo = new TextureInfo();
                    textureInfo.Read(reader, header, Text);

                    if (!textureInfo.IsEmpty())
                    {
                        DrawableTex.Add(textureInfo);

                        bool HasImage = header.Textures.Any(item => item.DataPos == textureInfo.DataPos);
                        if (!HasImage)
                        {
                            header.Textures.Add(textureInfo);
                        }
                    }
                }
                if (header.IsSPBD)
                {
                    reader.Seek(pos + 1358, SeekOrigin.Begin);
                }
                else
                {
                    reader.Seek(pos + 1616, SeekOrigin.Begin);
                }
                ColorPosition = reader.Position;
                for (int i = 0; i < 8; i++)
                {
                    STColor clr = new STColor();
                    clr.R = reader.ReadSingle();
                    clr.G = reader.ReadSingle();
                    clr.B = reader.ReadSingle();
                    float   A     = reader.ReadSingle();
                    STColor alpha = new STColor();
                    alpha.R             = A;
                    alpha.G             = A;
                    alpha.B             = A;
                    Color0Array[i]      = clr;
                    Color0AlphaArray[i] = alpha;
                }
                for (int i = 0; i < 8; i++)
                {
                    STColor clr = new STColor();
                    clr.R = reader.ReadSingle();
                    clr.G = reader.ReadSingle();
                    clr.B = reader.ReadSingle();
                    float A = reader.ReadSingle();

                    STColor alpha = new STColor();
                    alpha.R = A;
                    alpha.G = A;
                    alpha.B = A;

                    Color1Array[i]      = clr;
                    Color1AlphaArray[i] = alpha;
                }
            }