Пример #1
0
 public void renderChildren(Context c) {
   c.setProjection(1);
   GL11.glEnable(GL11.GL_DEPTH_TEST);
   GL11.glDepthFunc(GL11.GL_GREATER);
   super.renderChildren(c);
   GL11.glDisable(GL11.GL_DEPTH_TEST);
   c.setProjection(0);
 }
Пример #2
0
 public void act(int dt) {
   blinkTime = (blinkTime + dt) % blinkPeriod;
   if (runningInteractiveProgram) {
     if (interactiveProgram.isRunning()) {
       interactiveProgram.act(dt);
     } else {
       runningInteractiveProgram = false;
       interactiveProgram = null;
       newPrompt();
     }
   } else if (runningRenderedProgram) {
     if (renderedProgram.isRunning()) {
       renderedProgram.act(dt);
     } else {
       runningRenderedProgram = false;
       renderedProgram = null;
       newPrompt();
     }
   }
   super.act(dt);
 }
Пример #3
0
  public void act(int dt) {
    z = new float[(int) spacing.getTotalWidth()][(int) spacing.getTotalHeight()];
    List<RenderedWire> newWires = new ArrayList<>();
    List<RenderedWire> oldWires = new ArrayList<>();

    List<PlacedItem> itemSet = new ArrayList<>();
    for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
        if (items[x][y] != null) {
          PlacedItem newItem = new PlacedItem(items[x][y], new Coord(x, y));
          if (!itemSet.contains(newItem)) {
            itemSet.add(newItem);
          }
        }
      }
    }
    List<PlacedPin> pinSet = new ArrayList<>();
    for (PlacedItem i : itemSet) {
      for (Pin p : i.i.getPins()) {
        if (p.getAttatched() != null) {
          pinSet.add(new PlacedPin(p, i));
        }
      }
    }
    while (pinSet.size() > 0) {
      PlacedPin p0 = pinSet.remove(0);
      if (p0.p.getAttatched() != null) {
        boolean flag = true;
        if (p0.p.getAttatched().isAttatchedOnBothSides()) {
          flag = false;
          Pin other = p0.p.getAttatched().getOtherEnd(p0.p);
          PlacedPin p1 =
              pinSet.stream().filter(placedPin -> placedPin.p == other).findAny().orElse(null);
          if (p1 != null) {
            pinSet.remove(p1);
            RenderedWire testWire = new RenderedWire(p0, p1);
            if (wires.contains(testWire)) {
              oldWires.add(testWire);
            } else {
              newWires.add(testWire);
            }
          } else {
            flag = true;
          }
        }
        if (flag) // p0.p is not attached on both sides, or it is attached to something not in the
        // grid.
        {
          RenderedWire testWire = new RenderedWire(p0, null);
          if (wires.contains(testWire)) {
            oldWires.add(testWire);
          } else {
            newWires.add(testWire);
          }
        }
      }
    }
    for (RenderedWire w : wires) {
      if (oldWires.contains(w)) {
        addDepthInfo(w.path);
      } else {
        removeWire(w.path);
      }
    }
    for (RenderedWire w : newWires) {
      if (w.end != null) {
        w.setWirePath(addWire(w.start, w.end));
      } else {
        w.setWirePath(addUnfinishedWire(w.start));
      }
    }

    wires.retainAll(oldWires);
    wires.addAll(newWires);

    super.act(dt);
  }