Exemple #1
0
 public MaterialEntry(EndianBinaryReader er)
 {
     Name           = er.ReadString(Encoding.ASCII, 20).Replace("\0", "");
     BufferColor    = er.ReadColor8();
     ConstColors    = new Color[6];
     ConstColors[0] = er.ReadColor8();
     ConstColors[1] = er.ReadColor8();
     ConstColors[2] = er.ReadColor8();
     ConstColors[3] = er.ReadColor8();
     ConstColors[4] = er.ReadColor8();
     ConstColors[5] = er.ReadColor8();
     Flags          = er.ReadUInt32();
     //Material Flag:
     //  0-1: Nr texMap
     //  2-3: Nr texMatrix
     //  4-5: Nr texCoordGen
     //  6-8: Nr tevStage
     //    9: Has alphaCompare
     //   10: Has blendMode
     //   11: Use Texture Only
     //   12: Separate Blend Mode
     //   14: Has Indirect Parameter
     //15-16: Nr projectionTexGenParameter
     //   17: Has Font Shadow Parameter
     TexMaps = new TexMap[Flags & 3];
     for (int i = 0; i < (Flags & 3); i++)
     {
         TexMaps[i] = new TexMap(er);
     }
     TexMatrices = new TexMatrix[(Flags >> 2) & 3];
     for (int i = 0; i < ((Flags >> 2) & 3); i++)
     {
         TexMatrices[i] = new TexMatrix(er);
     }
     TexCoordGens = new TexCoordGen[(Flags >> 4) & 3];
     for (int i = 0; i < ((Flags >> 4) & 3); i++)
     {
         TexCoordGens[i] = new TexCoordGen(er);
     }
     TevStages = new TevStage[(Flags >> 6) & 7];
     for (int i = 0; i < ((Flags >> 6) & 7); i++)
     {
         TevStages[i] = new TevStage(er);
     }
     if (((Flags >> 9) & 1) == 1)
     {
         AlphaTest = new AlphaCompare(er);
     }
     if (((Flags >> 10) & 1) == 1)
     {
         ColorBlendMode = new BlendMode(er);
     }
     if (((Flags >> 12) & 1) == 1)
     {
         AlphaBlendMode = new BlendMode(er);
     }
     //Some more things
 }
 private void LoadTexMapFile()
 {
     if (File.Exists(LinkedTextureMapFile))
     {
         TexMap.Clear();
         foreach (var Line in File.ReadAllLines(LinkedTextureMapFile))
         {
             var Parts = Line.Split(new[] { " ", "\t" }, 2, StringSplitOptions.RemoveEmptyEntries);
             if (Parts.Length > 0)
             {
                 var CacheHash = Convert.ToUInt64(Parts[0], 16);
                 TexMap[CacheHash] = Parts[1].Trim();
             }
         }
     }
 }
Exemple #3
0
 public MaterialEntry(EndianBinaryReader er)
 {
     Name = er.ReadString(Encoding.ASCII, 20).Replace("\0", "");
     BufferColor = er.ReadColor8();
     ConstColors = new Color[6];
     ConstColors[0] = er.ReadColor8();
     ConstColors[1] = er.ReadColor8();
     ConstColors[2] = er.ReadColor8();
     ConstColors[3] = er.ReadColor8();
     ConstColors[4] = er.ReadColor8();
     ConstColors[5] = er.ReadColor8();
     Flags = er.ReadUInt32();
     //Material Flag:
     //  0-1: Nr texMap
     //  2-3: Nr texMatrix
     //  4-5: Nr texCoordGen
     //  6-8: Nr tevStage
     //    9: Has alphaCompare
     //   10: Has blendMode
     //   11: Use Texture Only
     //   12: Separate Blend Mode
     //   14: Has Indirect Parameter
     //15-16: Nr projectionTexGenParameter
     //   17: Has Font Shadow Parameter
     TexMaps = new TexMap[Flags & 3];
     for (int i = 0; i < (Flags & 3); i++)
     {
         TexMaps[i] = new TexMap(er);
     }
     TexMatrices = new TexMatrix[(Flags >> 2) & 3];
     for (int i = 0; i < ((Flags >> 2) & 3); i++)
     {
         TexMatrices[i] = new TexMatrix(er);
     }
     TexCoordGens = new TexCoordGen[(Flags >> 4) & 3];
     for (int i = 0; i < ((Flags >> 4) & 3); i++)
     {
         TexCoordGens[i] = new TexCoordGen(er);
     }
     TevStages = new TevStage[(Flags >> 6) & 7];
     for (int i = 0; i < ((Flags >> 6) & 7); i++)
     {
         TevStages[i] = new TevStage(er);
     }
     if (((Flags >> 9) & 1) == 1) AlphaTest = new AlphaCompare(er);
     if (((Flags >> 10) & 1) == 1) ColorBlendMode = new BlendMode(er);
     if (((Flags >> 12) & 1) == 1) AlphaBlendMode = new BlendMode(er);
     //Some more things
 }
Exemple #4
0
                public Material(ref BinaryStream s)
                {
                    name = Encoding.ASCII.GetString(s.ReadBytes(28)).Replace("\0", "");

                    flag    = s.ReadUInt32();
                    unknown = s.ReadUInt32();

                    byte[] black = s.ReadBytes(4), white = s.ReadBytes(4);
                    blackColor = Color.FromArgb(black[3], black[0], black[1], black[2]);
                    whiteColor = Color.FromArgb(white[3], white[0], black[1], black[2]);

                    texMapCount                    = (uint)(flag & 0x03);
                    texSRTCount                    = (uint)((flag >> 2) & 0x03);
                    texCoordGenCount               = (uint)((flag >> 4) & 0x03);
                    tevStageCount                  = (uint)((flag >> 6) & 0x07);
                    hasAlphaCompare                = ((flag >> 9) & 0x01) == 1;
                    hasBlendMode                   = ((flag >> 10) & 0x01) == 1;
                    useTextureOnly                 = ((flag >> 11) & 0x01) == 1;
                    seperateBlendMode              = ((flag >> 12) & 0x01) == 1;
                    hasIndirectParameter           = ((flag >> 14) & 0x01) == 1;
                    projectionTexGenParameterCount = (uint)((flag >> 15) & 0x03);
                    hasFontShadowParameter         = ((flag >> 17) & 0x01) == 1;
                    thresholingAlphaInterpolation  = ((flag >> 18) & 0x01) == 1;

                    texMaps = new TexMap[texMapCount];
                    for (int i = 0; i < texMapCount; i++)
                    {
                        texMaps[i] = new TexMap(ref s);
                    }

                    texSRTs = new TexSRT[texSRTCount];
                    for (int i = 0; i < texSRTCount; i++)
                    {
                        texSRTs[i] = new TexSRT(ref s);
                    }

                    texCoords = new TexCoordGen[texCoordGenCount];
                    for (int i = 0; i < texCoordGenCount; i++)
                    {
                        texCoords[i] = new TexCoordGen(ref s);
                    }

                    tevStages = new TevStage[tevStageCount];
                    for (int i = 0; i < tevStageCount; i++)
                    {
                        tevStages[i] = new TevStage(ref s);
                    }

                    if (hasAlphaCompare)
                    {
                        alphaCompare = new AlphaCompare(ref s);
                    }

                    if (hasBlendMode)
                    {
                        blendMode = new BlendMode(ref s);
                    }

                    if (seperateBlendMode)
                    {
                        blendAlpha = new BlendMode(ref s);
                    }

                    if (hasIndirectParameter)
                    {
                        indirectParameter = new IndirectParameter(ref s);
                    }

                    projectionTexGenParameters = new ProjectionTexGenParameters[projectionTexGenParameterCount];
                    for (int i = 0; i < projectionTexGenParameterCount; i++)
                    {
                        projectionTexGenParameters[i] = new ProjectionTexGenParameters(ref s);
                    }

                    if (hasFontShadowParameter)
                    {
                        fontShadowParameter = new FontShadowParameter(ref s);
                    }

                    //System.Windows.Forms.MessageBox.Show($"[{s.BaseStream.Position}] mat end");
                }