    001    package net.minecraft.client.model;
    002
    003    import cpw.mods.fml.relauncher.Side;
    004    import cpw.mods.fml.relauncher.SideOnly;
    005    import net.minecraft.client.renderer.Tessellator;
    006    import net.minecraft.util.Vec3;
    007
    008    public class TexturedQuad
    009    {
    010        public PositionTextureVertex[] vertexPositions;
    011        public int nVertices;
    012        private boolean invertNormal;
    013
    014        public TexturedQuad(PositionTextureVertex[] par1ArrayOfPositionTextureVertex)
    015        {
    016            this.nVertices = 0;
    017            this.invertNormal = false;
    018            this.vertexPositions = par1ArrayOfPositionTextureVertex;
    019            this.nVertices = par1ArrayOfPositionTextureVertex.length;
    020        }
    021
    022        public TexturedQuad(PositionTextureVertex[] par1ArrayOfPositionTextureVertex, int par2, int par3, int par4, int par5, float par6, float par7)
    023        {
    024            this(par1ArrayOfPositionTextureVertex);
    025            float var8 = 0.0F / par6;
    026            float var9 = 0.0F / par7;
    027            par1ArrayOfPositionTextureVertex[0] = par1ArrayOfPositionTextureVertex[0].setTexturePosition((float)par4 / par6 - var8, (float)par3 / par7 + var9);
    028            par1ArrayOfPositionTextureVertex[1] = par1ArrayOfPositionTextureVertex[1].setTexturePosition((float)par2 / par6 + var8, (float)par3 / par7 + var9);
    029            par1ArrayOfPositionTextureVertex[2] = par1ArrayOfPositionTextureVertex[2].setTexturePosition((float)par2 / par6 + var8, (float)par5 / par7 - var9);
    030            par1ArrayOfPositionTextureVertex[3] = par1ArrayOfPositionTextureVertex[3].setTexturePosition((float)par4 / par6 - var8, (float)par5 / par7 - var9);
    031        }
    032
    033        public void flipFace()
    034        {
    035            PositionTextureVertex[] var1 = new PositionTextureVertex[this.vertexPositions.length];
    036
    037            for (int var2 = 0; var2 < this.vertexPositions.length; ++var2)
    038            {
    039                var1[var2] = this.vertexPositions[this.vertexPositions.length - var2 - 1];
    040            }
    041
    042            this.vertexPositions = var1;
    043        }
    044
    045        public void draw(Tessellator par1Tessellator, float par2)
    046        {
    047            Vec3 var3 = this.vertexPositions[1].vector3D.subtract(this.vertexPositions[0].vector3D);
    048            Vec3 var4 = this.vertexPositions[1].vector3D.subtract(this.vertexPositions[2].vector3D);
    049            Vec3 var5 = var4.crossProduct(var3).normalize();
    050            par1Tessellator.startDrawingQuads();
    051
    052            if (this.invertNormal)
    053            {
    054                par1Tessellator.setNormal(-((float)var5.xCoord), -((float)var5.yCoord), -((float)var5.zCoord));
    055            }
    056            else
    057            {
    058                par1Tessellator.setNormal((float)var5.xCoord, (float)var5.yCoord, (float)var5.zCoord);
    059            }
    060
    061            for (int var6 = 0; var6 < 4; ++var6)
    062            {
    063                PositionTextureVertex var7 = this.vertexPositions[var6];
    064                par1Tessellator.addVertexWithUV((double)((float)var7.vector3D.xCoord * par2), (double)((float)var7.vector3D.yCoord * par2), (double)((float)var7.vector3D.zCoord * par2), (double)var7.texturePositionX, (double)var7.texturePositionY);
    065            }
    066
    067            par1Tessellator.draw();
    068        }
    069    }