예제 #1
0
  public static void renderFacingQuad(
      double px,
      double py,
      double pz,
      float partialTicks,
      float scale,
      float angle,
      double u,
      double v,
      double uLength,
      double vLength) {
    float arX = ActiveRenderInfo.getRotationX();
    float arZ = ActiveRenderInfo.getRotationZ();
    float arYZ = ActiveRenderInfo.getRotationYZ();
    float arXY = ActiveRenderInfo.getRotationXY();
    float arXZ = ActiveRenderInfo.getRotationXZ();

    Entity e = Minecraft.getMinecraft().getRenderViewEntity();
    if (e == null) {
      e = Minecraft.getMinecraft().thePlayer;
    }
    double iPX = e.prevPosX + (e.posX - e.prevPosX) * partialTicks;
    double iPY = e.prevPosY + (e.posY - e.prevPosY) * partialTicks;
    double iPZ = e.prevPosZ + (e.posZ - e.prevPosZ) * partialTicks;

    Vector3 v1 =
        new Vector3(-arX * scale - arYZ * scale, -arXZ * scale, -arZ * scale - arXY * scale);
    Vector3 v2 =
        new Vector3(-arX * scale + arYZ * scale, arXZ * scale, -arZ * scale + arXY * scale);
    Vector3 v3 = new Vector3(arX * scale + arYZ * scale, arXZ * scale, arZ * scale + arXY * scale);
    Vector3 v4 = new Vector3(arX * scale - arYZ * scale, -arXZ * scale, arZ * scale - arXY * scale);
    if (angle != 0.0F) {
      Vector3 pvec = new Vector3(iPX, iPY, iPZ);
      Vector3 tvec = new Vector3(px, py, pz);
      Vector3 qvec = pvec.subtract(tvec).normalize();
      Vector3.Quat q = Vector3.Quat.aroundAxis(qvec, angle);
      q.rotate(v1);
      q.rotate(v2);
      q.rotate(v3);
      q.rotate(v4);
    }
    Tessellator t = Tessellator.getInstance();
    VertexBuffer vb = t.getBuffer();
    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
    vb.pos(px + v1.getX() - iPX, py + v1.getY() - iPY, pz + v1.getZ() - iPZ)
        .tex(u, v + vLength)
        .endVertex();
    vb.pos(px + v2.getX() - iPX, py + v2.getY() - iPY, pz + v2.getZ() - iPZ)
        .tex(u + uLength, v + vLength)
        .endVertex();
    vb.pos(px + v3.getX() - iPX, py + v3.getY() - iPY, pz + v3.getZ() - iPZ)
        .tex(u + uLength, v)
        .endVertex();
    vb.pos(px + v4.getX() - iPX, py + v4.getY() - iPY, pz + v4.getZ() - iPZ).tex(u, v).endVertex();
    t.draw();
  }
예제 #2
0
  public static void renderFacingQuadVB(
      VertexBuffer vb,
      double px,
      double py,
      double pz,
      float partialTicks,
      float scale,
      float angle,
      double u,
      double v,
      double uLength,
      double vLength,
      float colorRed,
      float colorGreen,
      float colorBlue,
      float alpha) {
    float arX = ActiveRenderInfo.getRotationX();
    float arZ = ActiveRenderInfo.getRotationZ();
    float arYZ = ActiveRenderInfo.getRotationYZ();
    float arXY = ActiveRenderInfo.getRotationXY();
    float arXZ = ActiveRenderInfo.getRotationXZ();

    Entity e = Minecraft.getMinecraft().getRenderViewEntity();
    if (e == null) {
      e = Minecraft.getMinecraft().thePlayer;
    }
    double iPX = e.prevPosX + (e.posX - e.prevPosX) * partialTicks;
    double iPY = e.prevPosY + (e.posY - e.prevPosY) * partialTicks;
    double iPZ = e.prevPosZ + (e.posZ - e.prevPosZ) * partialTicks;

    Vector3 v1 =
        new Vector3(-arX * scale - arYZ * scale, -arXZ * scale, -arZ * scale - arXY * scale);
    Vector3 v2 =
        new Vector3(-arX * scale + arYZ * scale, arXZ * scale, -arZ * scale + arXY * scale);
    Vector3 v3 = new Vector3(arX * scale + arYZ * scale, arXZ * scale, arZ * scale + arXY * scale);
    Vector3 v4 = new Vector3(arX * scale - arYZ * scale, -arXZ * scale, arZ * scale - arXY * scale);
    if (angle != 0.0F) {
      Vector3 pvec = new Vector3(iPX, iPY, iPZ);
      Vector3 tvec = new Vector3(px, py, pz);
      Vector3 qvec = pvec.subtract(tvec).normalize();
      Vector3.Quat q = Vector3.Quat.aroundAxis(qvec, angle);
      q.rotate(v1);
      q.rotate(v2);
      q.rotate(v3);
      q.rotate(v4);
    }
    vb.pos(px + v1.getX() - iPX, py + v1.getY() - iPY, pz + v1.getZ() - iPZ)
        .tex(u, v + vLength)
        .color(colorRed, colorGreen, colorBlue, alpha)
        .endVertex();
    vb.pos(px + v2.getX() - iPX, py + v2.getY() - iPY, pz + v2.getZ() - iPZ)
        .tex(u + uLength, v + vLength)
        .color(colorRed, colorGreen, colorBlue, alpha)
        .endVertex();
    vb.pos(px + v3.getX() - iPX, py + v3.getY() - iPY, pz + v3.getZ() - iPZ)
        .tex(u + uLength, v)
        .color(colorRed, colorGreen, colorBlue, alpha)
        .endVertex();
    vb.pos(px + v4.getX() - iPX, py + v4.getY() - iPY, pz + v4.getZ() - iPZ)
        .tex(u, v)
        .color(colorRed, colorGreen, colorBlue, alpha)
        .endVertex();
  }