Пример #1
0
 public void update(float deltaTime) {
   camera.update();
   if (DebugViewSettings.drawModels) {
     drawShadowBatch();
     viewport.apply();
     modelBatch.begin(camera);
     modelBatch.render(engine.getModelCache(), environment);
     for (GameModel mdl : engine.getDynamicModels()) {
       if (isVisible(camera, mdl)) {
         modelBatch.render(mdl.modelInstance, environment);
       }
     }
     if (markerBillboard != null && isVisible(camera, markerBillboard)) {
       modelBatch.render(markerBillboard.modelInstance, environment);
     }
     modelBatch.end();
   }
   if (DebugViewSettings.drawArmature) {
     shapeRenderer.setProjectionMatrix(viewport.getCamera().combined);
     armatureDebugDrawer.drawArmature(shapeRenderer, selectedCharacter, "armature");
   }
   if (DebugViewSettings.drawSteering) {
     drawSteering();
   }
   if (DebugViewSettings.drawNavmesh) {
     shapeRenderer.setProjectionMatrix(viewport.getCamera().combined);
     navMeshDebugDrawer.drawNavMesh(
         shapeRenderer,
         spriteBatch,
         engine.getScene().navMesh,
         selectedCharacter,
         visibleLayers,
         viewport.getCamera(),
         font);
   }
   if (DebugViewSettings.drawMouseNavMeshPos) {
     shapeRenderer.setProjectionMatrix(viewport.getCamera().combined);
     drawMouseWorldAxis();
   }
 }
Пример #2
0
  public void draw() {
    Camera camera = viewport.getCamera();
    camera.update();

    if (!root.isVisible()) return;

    Batch batch = this.batch;
    if (batch != null) {
      batch.setProjectionMatrix(camera.combined);
      batch.begin();
      root.draw(batch, 1);
      batch.end();
    }

    if (debug) drawDebug();
  }
Пример #3
0
  public void render(float delta) {
    if (cameraCache != viewport.getCamera())
      cameraCache = (OrthographicCamera) viewport.getCamera();

    viewport.getCamera().position.add(speed.x * delta, speed.y * delta, 0f);
    for (int i = 0; i < layers.length; i++) {

      cameraProjectionCache.set(viewport.getCamera().projection);
      cameraProjectionCache.scl(cameraCache.zoom);

      batch.setProjectionMatrix(cameraProjectionCache);
      batch.begin();
      float currentX =
          -viewport.getCamera().position.x
              * layers[i].parallaxRatio.x
              % (layers[i].region.getRegionWidth() + layers[i].padding.x);

      if (speed.x < 0) currentX += -(layers[i].region.getRegionWidth() + layers[i].padding.x);
      do {
        /* Y REPEATING DISABLED:
        float currentY = -viewport.getCamera().position.y * layers[i].parallaxRatio.y % (layers[i].region.getRegionHeight() + layers[i].padding.y);

        if (speed.y < 0)
            currentY += -(layers[i].region.getRegionHeight() + layers[i].padding.y);

        do {
            batch.draw(layers[i].region,
                    -viewport.getCamera().viewportWidth / 2 + currentX + layers[i].startPosition.x,
                    -viewport.getCamera().viewportHeight / 2 + currentY + layers[i].startPosition.y);

            currentY += (layers[i].region.getRegionHeight() + layers[i].padding.y);
        } while (currentY < viewport.getCamera().viewportHeight);*/

        batch.draw(
            layers[i].region,
            -viewport.getCamera().viewportWidth / 2 + currentX + layers[i].startPosition.x,
            -viewport.getCamera().viewportHeight / 2 + layers[i].startPosition.y);

        currentX += (layers[i].region.getRegionWidth() + layers[i].padding.x);
      } while (currentX < viewport.getCamera().viewportWidth);
      batch.end();
    }
  }
Пример #4
0
  private void drawDebug() {
    if (debugShapes == null) {
      debugShapes = new ShapeRenderer();
      debugShapes.setAutoShapeType(true);
    }

    if (debugUnderMouse || debugParentUnderMouse || debugTableUnderMouse != Debug.none) {
      screenToStageCoordinates(tempCoords.set(Gdx.input.getX(), Gdx.input.getY()));
      Actor actor = hit(tempCoords.x, tempCoords.y, true);
      if (actor == null) return;

      if (debugParentUnderMouse && actor.parent != null) actor = actor.parent;

      if (debugTableUnderMouse == Debug.none) actor.setDebug(true);
      else {
        while (actor != null) {
          if (actor instanceof Table) break;
          actor = actor.parent;
        }
        if (actor == null) return;
        ((Table) actor).debug(debugTableUnderMouse);
      }

      if (debugAll && actor instanceof Group) ((Group) actor).debugAll();

      disableDebug(root, actor);
    } else {
      if (debugAll) root.debugAll();
    }

    Gdx.gl.glEnable(GL20.GL_BLEND);
    debugShapes.setProjectionMatrix(viewport.getCamera().combined);
    debugShapes.begin();
    root.drawDebug(debugShapes);
    debugShapes.end();
  }
Пример #5
0
 /** The viewport's camera. */
 public Camera getCamera() {
   return viewport.getCamera();
 }