From 67850870579266dac6e07870e12e0154bd83014f Mon Sep 17 00:00:00 2001 From: Alexandr Brui Date: Sat, 5 Aug 2017 17:01:50 +0300 Subject: [PATCH] Added a possibility to resize env cameras. (#699) --- .../jme3/environment/EnvironmentCamera.java | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/environment/EnvironmentCamera.java b/jme3-core/src/main/java/com/jme3/environment/EnvironmentCamera.java index 66fcce0be..4773b9639 100644 --- a/jme3-core/src/main/java/com/jme3/environment/EnvironmentCamera.java +++ b/jme3-core/src/main/java/com/jme3/environment/EnvironmentCamera.java @@ -108,6 +108,9 @@ public class EnvironmentCamera extends BaseAppState { protected Vector3f position = new Vector3f(); protected ColorRGBA backGroundColor; + /** + * The size of environment cameras. + */ protected int size = 128; private final List jobs = new ArrayList(); @@ -194,10 +197,38 @@ public class EnvironmentCamera extends BaseAppState { jobs.remove(0); } + /** + * Gets the size of environment cameras. + * + * @return the size of environment cameras. + */ public int getSize() { return size; } + /** + * Sets the size of environment cameras and rebuild this state if it was initialized. + * + * @param size the size of environment cameras. + */ + public void setSize(final int size) { + this.size = size; + rebuild(); + } + + /** + * Rebuild all environment cameras. + */ + protected void rebuild() { + + if (!isInitialized()) { + return; + } + + cleanup(getApplication()); + initialize(getApplication()); + } + public Vector3f getPosition() { return position; } @@ -224,8 +255,7 @@ public class EnvironmentCamera extends BaseAppState { this.backGroundColor = app.getViewPort().getBackgroundColor(); final Camera[] cameras = new Camera[6]; - - Texture2D[] textures = new Texture2D[6]; + final Texture2D[] textures = new Texture2D[6]; viewports = new ViewPort[6]; framebuffers = new FrameBuffer[6]; @@ -241,6 +271,7 @@ public class EnvironmentCamera extends BaseAppState { } } + @Override protected void cleanup(Application app) { this.backGroundColor = null;