Package cofh.repack.codechicken.lib.vec

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


    public static QBQuad restore(Rectangle4i flat, int side, double d, QBImage img) {

      QBQuad quad = new QBQuad(side);
      quad.image = img;

      Transformation t = new Scale(-1, 1, -1).with(Rotation.sideOrientation(side, 0)).with(new Translation(new Vector3().setSide(side, d)));
      quad.verts[0] = new Vertex5(flat.x, 0, flat.y, 0, 0);
      quad.verts[1] = new Vertex5(flat.x + flat.w, 0, flat.y, 1, 0);
      quad.verts[2] = new Vertex5(flat.x + flat.w, 0, flat.y + flat.h, 1, 1);
      quad.verts[3] = new Vertex5(flat.x, 0, flat.y + flat.h, 0, 1);
      for (Vertex5 vert : quad.verts) {
View Full Code Here


    }

    public Rectangle4i flatten() {

      Transformation t = Rotation.sideOrientation(side, 0).inverse().with(new Scale(-1, 0, -1));
      Vector3 vmin = verts[0].vec.copy().apply(t);
      Vector3 vmax = verts[2].vec.copy().apply(t);
      return new Rectangle4i((int) vmin.x, (int) vmin.z, (int) (vmax.x - vmin.x), (int) (vmax.z - vmin.z));
    }
View Full Code Here

  public Vector3 vec;
  public UV uv;

  public Vertex5() {

    this(new Vector3(), new UV());
  }
View Full Code Here

    this(x, y, z, u, v, 0);
  }

  public Vertex5(double x, double y, double z, double u, double v, int tex) {

    this(new Vector3(x, y, z), new UV(u, v));
  }
View Full Code Here

    }

    Vector3[] normals = getOrAllocate(CCRenderState.normalAttrib);
    for (int k = 0; k < length; k += vp) {
      int i = k + start;
      Vector3 diff1 = verts[i + 1].vec.copy().subtract(verts[i].vec);
      Vector3 diff2 = verts[i + vp - 1].vec.copy().subtract(verts[i].vec);
      normals[i] = diff1.crossProduct(diff2).normalize();
      for (int d = 1; d < vp; d++) {
        normals[i + d] = normals[i].copy();
      }
    }
View Full Code Here

  public CCModel smoothNormals() {

    ArrayList<PositionNormalEntry> map = new ArrayList<PositionNormalEntry>();
    Vector3[] normals = normals();
    nextvert: for (int k = 0; k < verts.length; k++) {
      Vector3 vec = verts[k].vec;
      for (PositionNormalEntry e : map) {
        if (e.positionEqual(vec)) {
          e.addNormal(normals[k]);
          continue nextvert;
        }
      }

      map.add(new PositionNormalEntry(vec).addNormal(normals[k]));
    }

    for (PositionNormalEntry e : map) {
      if (e.normals.size() <= 1) {
        continue;
      }

      Vector3 new_n = new Vector3();
      for (Vector3 n : e.normals) {
        new_n.add(n);
      }

      new_n.normalize();
      for (Vector3 n : e.normals) {
        n.set(new_n);
      }
    }
View Full Code Here

    return this;
  }

  public void render(double x, double y, double z, double u, double v) {

    render(new Vector3(x, y, z).translation(), new UVTranslation(u, v));
  }
View Full Code Here

    render(new Vector3(x, y, z).translation(), new UVTranslation(u, v));
  }

  public void render(double x, double y, double z, UVTransformation u) {

    render(new Vector3(x, y, z).translation(), u);
  }
View Full Code Here

      if (line.startsWith("v ")) {
        assertMatch(vertMatcher, line);
        double[] values = parseDoubles(line.substring(2), " ");
        illegalAssert(values.length >= 3, "Vertices must have x, y and z components");
        Vector3 vert = new Vector3(values[0], values[1], values[2]);
        coordSystem.apply(vert);
        verts.add(vert);
        continue;
      }
      if (line.startsWith("vt ")) {
        assertMatch(uvwMatcher, line);
        double[] values = parseDoubles(line.substring(3), " ");
        illegalAssert(values.length >= 2, "Tex Coords must have u, and v components");
        uvs.add(new Vector3(values[0], 1 - values[1], 0));
        continue;
      }
      if (line.startsWith("vn ")) {
        assertMatch(normalMatcher, line);
        double[] values = parseDoubles(line.substring(3), " ");
        illegalAssert(values.length >= 3, "Normals must have x, y and z components");
        Vector3 norm = new Vector3(values[0], values[1], values[2]).normalize();
        coordSystem.applyN(norm);
        normals.add(norm);
        continue;
      }
      if (line.startsWith("f ")) {
View Full Code Here

      model.getOrAllocate(CCRenderState.normalAttrib);
    }

    for (int i = 0; i < polys.size(); i++) {
      int[] ai = polys.get(i);
      Vector3 vert = verts.get(ai[0] - 1).copy();
      Vector3 uv = ai[1] <= 0 ? new Vector3() : uvs.get(ai[1] - 1).copy();
      if (ai[2] > 0 != hasNormals) {
        throw new IllegalArgumentException("Normals are an all or nothing deal here.");
      }

      model.verts[i] = new Vertex5(vert, uv.x, uv.y);
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.