Added a possibility to resize env cameras. (#699)

fix-456
Alexandr Brui 7 years ago committed by Rémy Bouquet
parent 6e5e85f7ac
commit 6785087057
  1. 35
      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 Vector3f position = new Vector3f();
protected ColorRGBA backGroundColor; protected ColorRGBA backGroundColor;
/**
* The size of environment cameras.
*/
protected int size = 128; protected int size = 128;
private final List<SnapshotJob> jobs = new ArrayList<SnapshotJob>(); private final List<SnapshotJob> jobs = new ArrayList<SnapshotJob>();
@ -194,10 +197,38 @@ public class EnvironmentCamera extends BaseAppState {
jobs.remove(0); jobs.remove(0);
} }
/**
* Gets the size of environment cameras.
*
* @return the size of environment cameras.
*/
public int getSize() { public int getSize() {
return size; 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() { public Vector3f getPosition() {
return position; return position;
} }
@ -224,8 +255,7 @@ public class EnvironmentCamera extends BaseAppState {
this.backGroundColor = app.getViewPort().getBackgroundColor(); this.backGroundColor = app.getViewPort().getBackgroundColor();
final Camera[] cameras = new Camera[6]; final Camera[] cameras = new Camera[6];
final Texture2D[] textures = new Texture2D[6];
Texture2D[] textures = new Texture2D[6];
viewports = new ViewPort[6]; viewports = new ViewPort[6];
framebuffers = new FrameBuffer[6]; framebuffers = new FrameBuffer[6];
@ -241,6 +271,7 @@ public class EnvironmentCamera extends BaseAppState {
} }
} }
@Override @Override
protected void cleanup(Application app) { protected void cleanup(Application app) {
this.backGroundColor = null; this.backGroundColor = null;

Loading…
Cancel
Save