예제 #1
0
        private static TexMatrix ReadTexMatrix(EndianBinaryReader stream)
        {
            var retVal = new TexMatrix();

            retVal.Projection = stream.ReadByte();
            retVal.Type       = stream.ReadByte();
            Trace.Assert(stream.ReadUInt16() == 0xFFFF); // Padding
            retVal.CenterS  = stream.ReadSingle();
            retVal.CenterT  = stream.ReadSingle();
            retVal.Unknown0 = stream.ReadSingle();
            retVal.ScaleS   = stream.ReadSingle();
            retVal.ScaleT   = stream.ReadSingle();
            retVal.Rotation = stream.ReadInt16() * (180 / 32768f);
            Trace.Assert(stream.ReadUInt16() == 0xFFFF); // Padding
            retVal.TranslateS = stream.ReadSingle();
            retVal.TranslateT = stream.ReadSingle();
            retVal.PreMatrix  = new float[4, 4];
            for (int y = 0; y < 4; y++)
            {
                for (int x = 0; x < 4; x++)
                {
                    retVal.PreMatrix[x, y] = stream.ReadSingle();
                }
            }

            return(retVal);
        }
예제 #2
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
 }
예제 #3
0
        private void GenerateScaleCommands(Material mat)
        {
            for (int i = 0; i < 10; i++)
            {
                if (mat.TexMatrix1[i] == null)
                {
                    break;
                }
                TexMatrix matrix = mat.TexMatrix1[i].Value;
                if (matrix.Projection != TexGenType.Matrix2x4)
                {
                    // Unsupported
                    continue;
                }
                if (matrix.Scale.X == 1.0 && matrix.Scale.Y == 1.0)
                {
                    // Scale commands are unnecessary when the scale is (1.0, 1.0).
                    continue;
                }

                XFCommand posMatricesCommand = new XFCommand((XFRegister)(0x0078 + i * 12));

                int scaleX = BitConverter.ToInt32(BitConverter.GetBytes(matrix.Scale.X), 0);
                int scaleY = BitConverter.ToInt32(BitConverter.GetBytes(matrix.Scale.Y), 0);

                posMatricesCommand.Args.Add(new XFCommandArgument(scaleX));
                posMatricesCommand.Args.Add(new XFCommandArgument());
                posMatricesCommand.Args.Add(new XFCommandArgument());
                posMatricesCommand.Args.Add(new XFCommandArgument());
                posMatricesCommand.Args.Add(new XFCommandArgument());
                posMatricesCommand.Args.Add(new XFCommandArgument(scaleY));
                posMatricesCommand.Args.Add(new XFCommandArgument());
                posMatricesCommand.Args.Add(new XFCommandArgument());

                XFCommands.Add(posMatricesCommand);
            }
        }
예제 #4
0
파일: Tile.cs 프로젝트: DaKook/OpGL
        public override void ChangeTexture(Texture texture)
        {
            int tileX = TextureX;
            int tileY = TextureY;

            base.ChangeTexture(texture);
            Animation = Animation.Static(tileX, tileY, texture);
            TexMatrix.Translate(tileX, tileY, 0);
            if (Texture.TileSolidStates.Length > 0 && Texture.TileSolidStates.GetLength(0) > tileX && Texture.TileSolidStates.GetLength(1) > tileY)
            {
                int ss = (int)Texture.TileSolidStates[tileX, tileY];
                if (ss > (int)SolidState.NonSolid)
                {
                    ss         -= (int)SolidState.NonSolid + 1;
                    KillCrewmen = true;
                }
                Solid = (SolidState)ss;
            }
            if (Texture.TileSizeX != 8 / Size || Texture.TileSizeY != 8 / Size)
            {
                Size = 8f / Texture.TileSizeX;
            }
            ResetAnimation();
        }
예제 #5
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
 }