/** * Cleans up all translations, scaling and rotation */ private void undoTransformations() { if (rotation != 0f) { camera.rotateAround(new Vector3(rotationX, rotationY, 0), new Vector3(0, 0, 1), rotation); } camera.update(); if (translationX != 0f || translationY != 0f) { camera.translate(-translationX, -translationY); } camera.update(); }
/** * Applies all translation, scaling and rotation to the {@link SpriteBatch} */ private void applyTransformations() { float viewportWidth = MathUtils.round(windowWidth / scaleX); float viewportHeight = MathUtils.round(windowHeight / scaleY); camera.setToOrtho(true, viewportWidth, viewportHeight); if (translationX != 0f || translationY != 0f) { camera.translate(translationX, translationY); } camera.update(); if (rotation != 0f) { camera.rotateAround(new Vector3(rotationX, rotationY, 0), new Vector3(0, 0, 1), -rotation); } camera.update(); spriteBatch.setProjectionMatrix(camera.combined); shapeRenderer.setProjectionMatrix(camera.combined); polygonSpriteBatch.setProjectionMatrix(camera.combined); }