示例#1
0
  @Test
  public void borderCalculation() {
    WorldBuilder worldBuilder = new WorldBuilder(12L);
    worldBuilder.addProvider(new Facet1Provider());
    worldBuilder.addProvider(new Facet2Provider());

    World world = worldBuilder.build();
    Region3i regionToGenerate = Region3i.createFromCenterExtents(new Vector3i(), 1);
    Region regionData = world.getWorldData(regionToGenerate);

    Facet1 facet1 = regionData.getFacet(Facet1.class);
    assertEquals(regionToGenerate, facet1.getWorldRegion());

    Facet2 facet2 = regionData.getFacet(Facet2.class);
    assertEquals(
        Region3i.createFromMinAndSize(new Vector3i(-3, -1, -3), new Vector3i(7, 3, 7)),
        facet2.getWorldRegion());
  }
 public void selectPointedObject() {
   SimpleVector ray =
       Interact2D.reproject2D3DWS(camera, buffer, this.getWidth() / 2, this.getHeight() / 2)
           .normalize();
   Object[] res = world.calcMinDistanceAndObject3D(camera.getPosition(), ray, 10000F);
   if (res == null || res[1] == null || res[0] == (Object) Object3D.RAY_MISSES_BOX) {
     selectedObject = null;
   }
   selectedObject = (Cell) res[1];
   if (selectedObject != null) {
     wb.toggle(selectedObject);
   }
 }
  protected void loop() throws Exception {
    while (isShowing()) {
      if (!paused) {
        buffer.clear(java.awt.Color.BLACK);
        world.renderScene(buffer);
        world.draw(buffer);

        camera.performMovement();
        buffer.update();
        buffer.display(canvas.getGraphics());
        canvas.repaint();

        if (System.currentTimeMillis() - startTime >= delay) {
          startTime = System.currentTimeMillis();
          wb.update();
        }
      }
      this.requestFocus();
    }
    buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
    buffer.dispose();
    dispose();
    System.exit(0);
  }