Package cofh.repack.codechicken.lib.vec

Examples of cofh.repack.codechicken.lib.vec.Vector3


      }

      if (vStart < verts.size()) {
        p.println();
        for (int i = vStart; i < verts.size(); i++) {
          Vector3 v = verts.get(i);
          p.format("v %s %s %s\n", clean(v.x), clean(v.y), clean(v.z));
        }
      }
      if (uStart < uvs.size()) {
        p.println();
        for (int i = uStart; i < uvs.size(); i++) {
          UV uv = uvs.get(i);
          p.format("vt %s %s\n", clean(uv.u), clean(uv.v));
        }
      }
      if (nStart < normals.size()) {
        p.println();
        for (int i = nStart; i < normals.size(); i++) {
          Vector3 n = normals.get(i);
          p.format("vn %s %s %s\n", clean(n.x), clean(n.y), clean(n.z));
        }
      }

      p.println();
View Full Code Here


  /**
   * @return The average of all vertices, for bones.
   */
  public Vector3 collapse() {

    Vector3 v = new Vector3();
    for (Vertex5 vert : verts) {
      v.add(vert.vec);
    }
    v.multiply(1 / (double) verts.length);
    return v;
  }
View Full Code Here

  public CCModel zOffset(Cuboid6 offsets) {

    for (int k = 0; k < verts.length; k++) {
      Vertex5 vert = verts[k];
      Vector3 normal = normals()[k];
      switch (findSide(normal)) {
      case 0:
        vert.vec.y += offsets.min.y;
        break;
      case 1:
View Full Code Here

  /**
   * @return A Cuboid6 containing all the verts in this model
   */
  public Cuboid6 bounds() {

    Vector3 vec1 = verts[0].vec;
    Cuboid6 c = new Cuboid6(vec1.copy(), vec1.copy());
    for (int i = 1; i < verts.length; i++) {
      c.enclose(verts[i].vec);
    }
    return c;
  }
View Full Code Here

    return computeO(vec, side);
  }

  public LC computeO(Vector3 vec, int side) {

    Vector3 v1 = Rotation.axes[((side & 0xE) + 3) % 6];
    Vector3 v2 = Rotation.axes[((side & 0xE) + 5) % 6];
    float d1 = (float) vec.scalarProject(v1);
    float d2 = 1 - d1;
    float d3 = (float) vec.scalarProject(v2);
    float d4 = 1 - d3;
    return set(side, d2 * d4, d2 * d3, d1 * d4, d1 * d3);
 
View Full Code Here

  }

  private void traceSide(int side, Vector3 start, Vector3 end, Cuboid6 cuboid) {

    vec.set(start);
    Vector3 hit = null;
    switch (side) {
    case 0:
      hit = vec.XZintercept(end, cuboid.min.y);
      break;
    case 1:
View Full Code Here

      mop.typeOfHit = MovingObjectType.BLOCK;
      mop.blockX = pos.x;
      mop.blockY = pos.y;
      mop.blockZ = pos.z;
      if (block != null) {
        c_cuboid.add(new Vector3(-pos.x, -pos.y, -pos.z)).setBlockBounds(block);
      }
    }
    return mop;
  }
View Full Code Here

   *            The normal at the vertex
   * @return The lighting applied colour
   */
  public int apply(int colour, Vector3 normal) {

    Vector3 n_colour = ambient.copy();
    for (int l = 0; l < lightCount; l++) {
      Light light = lights[l];
      double n_l = light.position.dotProduct(normal);
      double f = n_l > 0 ? 1 : 0;
      n_colour.x += light.ambient.x + f * light.diffuse.x * n_l;
      n_colour.y += light.ambient.y + f * light.diffuse.y * n_l;
      n_colour.z += light.ambient.z + f * light.diffuse.z * n_l;
    }

    if (n_colour.x > 1) {
      n_colour.x = 1;
    }
    if (n_colour.y > 1) {
      n_colour.y = 1;
    }
    if (n_colour.z > 1) {
      n_colour.z = 1;
    }

    n_colour.multiply((colour >>> 24) / 255D, (colour >> 16 & 0xFF) / 255D, (colour >> 8 & 0xFF) / 255D);
    return (int) (n_colour.x * 255) << 24 | (int) (n_colour.y * 255) << 16 | (int) (n_colour.z * 255) << 8 | colour & 0xFF;
  }
View Full Code Here

        double ry = hlen - y;
        if (ry > res) {
          ry = res;
        }

        Vector3 dx1 = vectors[2].set(wide).multiply(x / wlen);
        Vector3 dx2 = vectors[3].set(wide).multiply((x + rx) / wlen);
        Vector3 dy1 = vectors[4].set(high).multiply(y / hlen);
        Vector3 dy2 = vectors[5].set(high).multiply((y + ry) / hlen);

        t.addVertexWithUV(base.x + dx1.x + dy2.x, base.y + dx1.y + dy2.y, base.z + dx1.z + dy2.z, u1, v2 - ry / res * dv);
        t.addVertexWithUV(base.x + dx1.x + dy1.x, base.y + dx1.y + dy1.y, base.z + dx1.z + dy1.z, u1, v2);
        t.addVertexWithUV(base.x + dx2.x + dy1.x, base.y + dx2.y + dy1.y, base.z + dx2.z + dy1.z, u1 + rx / res * du, v2);
        t.addVertexWithUV(base.x + dx2.x + dy2.x, base.y + dx2.y + dy2.y, base.z + dx2.z + dy2.z, u1 + rx / res * du, v2 - ry / res * dv);
 
View Full Code Here

  }

  public static void renderFluidCuboid(Cuboid6 bound, IIcon tex, double res) {

    renderFluidQuad(// bottom
        new Vector3(bound.min.x, bound.min.y, bound.min.z), new Vector3(bound.max.x, bound.min.y, bound.min.z), new Vector3(bound.max.x, bound.min.y,
            bound.max.z), new Vector3(bound.min.x, bound.min.y, bound.max.z), tex, res);
    renderFluidQuad(// top
        new Vector3(bound.min.x, bound.max.y, bound.min.z), new Vector3(bound.min.x, bound.max.y, bound.max.z), new Vector3(bound.max.x, bound.max.y,
            bound.max.z), new Vector3(bound.max.x, bound.max.y, bound.min.z), tex, res);
    renderFluidQuad(// -x
        new Vector3(bound.min.x, bound.max.y, bound.min.z), new Vector3(bound.min.x, bound.min.y, bound.min.z), new Vector3(bound.min.x, bound.min.y,
            bound.max.z), new Vector3(bound.min.x, bound.max.y, bound.max.z), tex, res);
    renderFluidQuad(// +x
        new Vector3(bound.max.x, bound.max.y, bound.max.z), new Vector3(bound.max.x, bound.min.y, bound.max.z), new Vector3(bound.max.x, bound.min.y,
            bound.min.z), new Vector3(bound.max.x, bound.max.y, bound.min.z), tex, res);
    renderFluidQuad(// -z
        new Vector3(bound.max.x, bound.max.y, bound.min.z), new Vector3(bound.max.x, bound.min.y, bound.min.z), new Vector3(bound.min.x, bound.min.y,
            bound.min.z), new Vector3(bound.min.x, bound.max.y, bound.min.z), tex, res);
    renderFluidQuad(// +z
        new Vector3(bound.min.x, bound.max.y, bound.max.z), new Vector3(bound.min.x, bound.min.y, bound.max.z), new Vector3(bound.max.x, bound.min.y,
            bound.max.z), new Vector3(bound.max.x, bound.max.y, bound.max.z), tex, res);
  }
View Full Code Here

TOP

Related Classes of cofh.repack.codechicken.lib.vec.Vector3

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.