예제 #1
0
  public UFace[] connected() {
    if (edge == null) {
      logErr("UFace.connected: Edges not calculated");
      return null;
    }

    if (connected == null) {
      connected = new UFace[3];
      for (int i = 0; i < edge.length; i++) {
        if (edge[i] != null) {
          ArrayList<UFace> ef = edge[i].getF();
          UFace ff = null;
          if (ef.size() > 0) {
            ff = ef.get(0);
            if (ff.equals(this) && ef.size() > 1) {
              ff = edge[i].faces.get(1);
            }
            if (ff.equals(this)) ff = null;
          }

          connected[i] = ff;
        }
      }
    }

    return connected;
  }
예제 #2
0
  public boolean equals(Object o) {
    UFace of = (UFace) o;
    of.getV();
    if (parent != null && (of.parent != null && parent == of.parent)) {
      return (vID[0] == of.vID[0] && vID[1] == of.vID[1] && vID[2] == of.vID[2]);
    } else {
      if (!v[0].equals(of.v[0])) return false;
      if (!v[1].equals(of.v[1])) return false;
      if (!v[2].equals(of.v[2])) return false;
    }

    return true;
  }
예제 #3
0
  public boolean facingSameWay(UFace ff) {
    UVertex n = normal();
    UVertex n2 = ff.normal();

    int cnt = 0;
    cnt += sign(n.x) == sign(n2.x) ? 1 : 0;
    cnt += sign(n.y) == sign(n2.y) ? 1 : 0;
    cnt += sign(n.z) == sign(n2.z) ? 1 : 0;

    return cnt == 3;
  }
예제 #4
0
  public boolean equalsVID(UFace f) {

    if (f.vIDSorted == null) {
      int id[] = new int[3];
      System.arraycopy(f.vID, 0, id, 0, 3);
      Arrays.sort(id);
      f.vIDSorted = id;
    }
    if (vIDSorted == null) {
      int id[] = new int[3];
      System.arraycopy(vID, 0, id, 0, 3);
      Arrays.sort(id);
      vIDSorted = id;
    }

    if (vIDSorted[0] == f.vIDSorted[0]
        && vIDSorted[1] == f.vIDSorted[1]
        && vIDSorted[2] == f.vIDSorted[2]) return true;

    return false;
  }
  public void init() {
    if (main.nav == null) main.nav = new UNav3D();
    UVertex v = new UVertex(1000, 0, 0);
    f = new UFace().set(v.copy(), v.copy().rotY(120 * DEG_TO_RAD), v.copy().rotY(240 * DEG_TO_RAD));
    f.reverse();
    UVertex.rotX(f.getV(), PI / 6);
    UVertex.rotZ(f.getV(), PI * 0.33f);

    UMB.log(f.getV());
    f.rotX(f.rnd(TWO_PI)).rotZ(f.rnd(TWO_PI));
    fv = UIntersections.faceYPlane(f, 0);
    lines = null;
    UMB.log(UMB.str(fv, ' ', null));

    plane = UGeoGenerator.meshPlane(2000, 2000, 20).rotX(HALF_PI);
  }
  public void draw() {

    p.translate(p.width / 2, p.height / 2);
    p.lights();
    main.nav.doTransforms();

    p.stroke(255);
    //    UMB.ppush().protX(HALF_PI).prect(1000,1000).ppop();
    p.noFill();

    if (f != null) {
      UMB.ppush();
      f.draw().drawNormal(100);
      //      f.pline(f.getV()[0], f.centroid());
      //      f.pline(f.getV()[1], f.centroid());
      //      f.pline(f.getV()[2], f.centroid());
      UMB.ppop();
    }

    if (fv != null) {
      int cnt = 0;
      for (UVertex vv : fv)
        if (vv != null) {
          UMB.pstroke(p.color(255, (cnt++) % 2 * 255, 0));
          UMB.pline(vv, new UVertex());

          UMB.ppush().pstroke(0xffffffff).pfill(0xffff000).pellipse(vv, R, R).ppop();
        }
    }

    plane.draw();
    if (lines != null) drawLines();
    else {

    }
  }