Package crazypants.vecmath

Examples of crazypants.vecmath.Vector2f


      float cm = RenderUtil.getColorMultiplierForFace(face);
      tes.setColorOpaque_F(cm, cm, cm);
    }

    float scaleFactor = 15f / 16f;
    Vector2f uv = new Vector2f();
    for (ForgeDirection edge : edges) {

      float xLen = 1 - Math.abs(edge.offsetX) * scaleFactor;
      float yLen = 1 - Math.abs(edge.offsetY) * scaleFactor;
      float zLen = 1 - Math.abs(edge.offsetZ) * scaleFactor;
 
View Full Code Here


  public List<Vertex> getCornersWithUvForFace(ForgeDirection face, float minU, float maxU, float minV, float maxV) {
    List<Vertex> result = new ArrayList<Vertex>(4);
    switch (face) {
    case NORTH:
      result.add(new Vertex(new Vector3d(maxX, minY, minZ), new Vector3f(0, 0, -1), new Vector2f(minU, minV)));
      result.add(new Vertex(new Vector3d(minX, minY, minZ), new Vector3f(0, 0, -1), new Vector2f(maxU, minV)));
      result.add(new Vertex(new Vector3d(minX, maxY, minZ), new Vector3f(0, 0, -1), new Vector2f(maxU, maxV)));
      result.add(new Vertex(new Vector3d(maxX, maxY, minZ), new Vector3f(0, 0, -1), new Vector2f(minU, maxV)));
      break;
    case SOUTH:
      result.add(new Vertex(new Vector3d(minX, minY, maxZ), new Vector3f(0, 0, 1), new Vector2f(maxU, minV)));
      result.add(new Vertex(new Vector3d(maxX, minY, maxZ), new Vector3f(0, 0, 1), new Vector2f(minU, minV)));
      result.add(new Vertex(new Vector3d(maxX, maxY, maxZ), new Vector3f(0, 0, 1), new Vector2f(minU, maxV)));
      result.add(new Vertex(new Vector3d(minX, maxY, maxZ), new Vector3f(0, 0, 1), new Vector2f(maxU, maxV)));
      break;
    case EAST:
      result.add(new Vertex(new Vector3d(maxX, maxY, minZ), new Vector3f(1, 0, 0), new Vector2f(maxU, maxV)));
      result.add(new Vertex(new Vector3d(maxX, maxY, maxZ), new Vector3f(1, 0, 0), new Vector2f(minU, maxV)));
      result.add(new Vertex(new Vector3d(maxX, minY, maxZ), new Vector3f(1, 0, 0), new Vector2f(minU, minV)));
      result.add(new Vertex(new Vector3d(maxX, minY, minZ), new Vector3f(1, 0, 0), new Vector2f(maxU, minV)));
      break;
    case WEST:
      result.add(new Vertex(new Vector3d(minX, minY, minZ), new Vector3f(-1, 0, 0), new Vector2f(maxU, minV)));
      result.add(new Vertex(new Vector3d(minX, minY, maxZ), new Vector3f(-1, 0, 0), new Vector2f(minU, minV)));
      result.add(new Vertex(new Vector3d(minX, maxY, maxZ), new Vector3f(-1, 0, 0), new Vector2f(minU, maxV)));
      result.add(new Vertex(new Vector3d(minX, maxY, minZ), new Vector3f(-1, 0, 0), new Vector2f(maxU, maxV)));
      break;
    case UP:
      result.add(new Vertex(new Vector3d(maxX, maxY, maxZ), new Vector3f(0, 1, 0), new Vector2f(minU, minV)));
      result.add(new Vertex(new Vector3d(maxX, maxY, minZ), new Vector3f(0, 1, 0), new Vector2f(minU, maxV)));
      result.add(new Vertex(new Vector3d(minX, maxY, minZ), new Vector3f(0, 1, 0), new Vector2f(maxU, maxV)));
      result.add(new Vertex(new Vector3d(minX, maxY, maxZ), new Vector3f(0, 1, 0), new Vector2f(maxU, minV)));
      break;
    case DOWN: //
    case UNKNOWN:
    default:
      result.add(new Vertex(new Vector3d(minX, minY, minZ), new Vector3f(0, -1, 0), new Vector2f(maxU, maxV)));
      result.add(new Vertex(new Vector3d(maxX, minY, minZ), new Vector3f(0, -1, 0), new Vector2f(minU, maxV)));
      result.add(new Vertex(new Vector3d(maxX, minY, maxZ), new Vector3f(0, -1, 0), new Vector2f(minU, minV)));
      result.add(new Vertex(new Vector3d(minX, minY, maxZ), new Vector3f(0, -1, 0), new Vector2f(maxU, minV)));
      break;
    }
    return result;
  }
View Full Code Here

      }

      List<ForgeDirection> allEdges = RenderUtil.getEdgesForFace(face);

      float scaleFactor = 15f / 16f;
      Vector2f uv = new Vector2f();

      //for each that needs a border, add a geom for the border and move in the 'centre' of the face
      //so there is no overlap
      for (ForgeDirection edge : edges) {

        //We need to move the 'centre' of the face so it doesn't overlap with the border
        moveCorners(refVertices, edge, 1 - scaleFactor);

        //Now create the geometry for this edge of the border
        float xLen = 1 - Math.abs(edge.offsetX) * scaleFactor;
        float yLen = 1 - Math.abs(edge.offsetY) * scaleFactor;
        float zLen = 1 - Math.abs(edge.offsetZ) * scaleFactor;

        BoundingBox bb = BoundingBox.UNIT_CUBE.scale(xLen, yLen, zLen);

        List<Vector3d> corners = bb.getCornersForFaceD(face);
        for (Vector3d corner : corners) {
          if(translateToXYZ) {
            corner.x += x;
            corner.y += y;
            corner.z += z;
          }
          corner.x += (float) (edge.offsetX * 0.5) - Math.signum(edge.offsetX) * xLen / 2f;
          corner.y += (float) (edge.offsetY * 0.5) - Math.signum(edge.offsetY) * yLen / 2f;
          corner.z += (float) (edge.offsetZ * 0.5) - Math.signum(edge.offsetZ) * zLen / 2f;
        }

        int[] indices = new int[] { 0, 1, 2, 3 };
        for (int index : indices) {
          Vector3d corner = corners.get(index);
          if(translateToXYZ) {
            RenderUtil.getUvForCorner(uv, corner, (int) x, (int) y, (int) z, face, texture);
          } else {
            RenderUtil.getUvForCorner(uv, corner, 0, 0, 0, face, texture);
          }
          Vertex vertex = new Vertex();
          vertex.xyz.set(corner);
          //vertex.xyz.add(ForgeDirectionOffsets.offsetScaled(face, 0.00005));
          vertex.uv = new Vector2f(uv);
          applyLighting(vertex, corner, refVertices);
          finalVerts.add(vertex);
        }
      }

      for (int i = 0; i < allEdges.size(); i++) {
        ForgeDirection dir = allEdges.get(i);
        ForgeDirection dir2 = i + 1 < allEdges.size() ? allEdges.get(i + 1) : allEdges.get(0);
        if(needsCorner(dir, dir2, edges, face, par1Block, x, y, z, rb.blockAccess)) {

          Vertex v = new Vertex();
          v.uv = new Vector2f();
          v.xyz.set(ForgeDirectionOffsets.forDir(dir));
          v.xyz.add(ForgeDirectionOffsets.forDir(dir2));
          //TODO: dodgy hack to just move the corner forward a bit         
          v.xyz.add(ForgeDirectionOffsets.offsetScaled(face, 0.001f));
          v.xyz.x = Math.max(-0.001, v.xyz.x);
View Full Code Here

  private void addVertexForCorner(ForgeDirection face, double x, double y, double z, IIcon texture, boolean translateToXYZ, List<Vertex> vertices,
      ForgeDirection dir, ForgeDirection dir2, Vector3d corner) {
    float scale = 1 / 16f;
    Vertex vert = new Vertex();
    vert.uv = new Vector2f();
    vert.xyz.set(corner);
    vert.xyz.sub(ForgeDirectionOffsets.offsetScaled(dir, scale));
    if(dir2 != null) {
      vert.xyz.sub(ForgeDirectionOffsets.offsetScaled(dir2, scale));
    }
View Full Code Here

      return res;
    }

    private void renderGaugeOnFace(GaugeBounds gb, IIcon icon, List<Vertex> vertices, double x, double y, double z) {
      Tessellator tes = Tessellator.instance;
      Vector2f u = gb.getMinMaxU(icon);
      List<Vertex> corners = gb.bb.getCornersWithUvForFace(gb.face, u.x, u.y, icon.getMinV(), icon.getMaxV());
      for (Vertex coord : corners) {
        coord.xyz.add(ForgeDirectionOffsets.offsetScaled(gb.face, 0.001f));
        Vector3d xyz = new Vector3d(coord.xyz);
        xyz.x += x;
View Full Code Here

      double maxY = (yPos.fillOffset * PIXEL_SIZE) + (fillPixels * PIXEL_SIZE);
      float vWidth = icon.getMaxV() - icon.getMinV();
      float maxV = icon.getMinV() + ((float) maxY * vWidth);

      Tessellator tes = Tessellator.instance;
      Vector2f u = gb.getMinMaxU(icon);
      List<crazypants.vecmath.Vertex> corners = gb.bb.getCornersWithUvForFace(gb.face, u.x, u.y, icon.getMinV(), maxV);
      for (Vertex coord : corners) {
        coord.xyz.add(ForgeDirectionOffsets.offsetScaled(gb.face, 0.002f));

        Vector3d xyz = new Vector3d(coord.xyz);
View Full Code Here

  }

  private void renderGaugeOnFace(GaugeBounds gb, IIcon icon) {
    Tessellator tes = Tessellator.instance;
    tes.setNormal(gb.face.offsetX, gb.face.offsetY, gb.face.offsetZ);
    Vector2f u = gb.getMinMaxU(icon);
    List<Vertex> corners = gb.bb.getCornersWithUvForFace(gb.face, u.x, u.y, icon.getMinV(), icon.getMaxV());
    for (Vertex coord : corners) {
      tes.setNormal(coord.nx(), coord.ny(), coord.nz());
      if(coord.uv != null) {
        tes.addVertexWithUV(coord.x(), coord.y(), coord.z(), coord.u(), coord.v());
View Full Code Here

    float vWidth = icon.getMaxV() - icon.getMinV();
    float maxV = icon.getMinV() + ((float) maxY * vWidth);

    Tessellator tes = Tessellator.instance;
    tes.setNormal(gb.face.offsetX, gb.face.offsetY, gb.face.offsetZ);
    Vector2f u = gb.getMinMaxU(icon);
    List<crazypants.vecmath.Vertex> corners = gb.bb.getCornersWithUvForFace(gb.face, u.x, u.y, icon.getMinV(), maxV);
    for (Vertex coord : corners) {
      if(coord.uv != null) {
        tes.addVertexWithUV(coord.x(), Math.min(coord.y(), maxY), coord.z(), coord.u(), coord.v());
      } else {
View Full Code Here

      VPos yPos = vInfo.pos;
      float uWidth = icon.getMaxU() - icon.getMinU();
      float uOffset = yPos.uOffset * uWidth;
      float minU = icon.getMinU() + uOffset;
      float maxU = minU + (uWidth * 0.25f);
      return new Vector2f(minU, maxU);
    }
View Full Code Here

    VPos yPos = vInfo.pos;
    float uWidth = icon.getMaxU() - icon.getMinU();
    float uOffset = yPos.uOffset * uWidth;
    float minU = icon.getMinU() + uOffset;
    float maxU = minU + (uWidth * 0.25f);
    return new Vector2f(minU, maxU);
  }
View Full Code Here

TOP

Related Classes of crazypants.vecmath.Vector2f

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.