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