diff --git a/jme3-core/src/main/java/com/jme3/util/SkyFactory.java b/jme3-core/src/main/java/com/jme3/util/SkyFactory.java
index 7fb70e76f..6104141aa 100644
--- a/jme3-core/src/main/java/com/jme3/util/SkyFactory.java
+++ b/jme3-core/src/main/java/com/jme3/util/SkyFactory.java
@@ -55,6 +55,32 @@ import java.util.ArrayList;
*/
public class SkyFactory {
+
+ /**
+ * The type of map fed to the shader
+ */
+ public enum EnvMapType{
+ /**
+ * The env map is a cube map see {@link TextureCubeMap} or 6 separate images that form a cube map
+ * The texture is either a {@link TextureCubeMap} or 6 {@link Texture2D}.
+ * In the latter case, a TextureCubeMap is build from the 6 2d maps.
+ */
+ CubeMap,
+ /**
+ * The env map is a Sphere map. The texture is a Texture2D with the pixels arranged for
+ * sphere
+ * mapping.
+ */
+ SphereMap,
+ /**
+ * The env map is an Equirectangular map. A 2D textures with pixels
+ * arranged for equirectangular
+ * projection mapping..
+ *
+ */
+ EquirectMap
+ }
+
/**
* Create a sky with radius=10 using the given cubemap or spheremap texture.
*
@@ -77,12 +103,33 @@ public class SkyFactory {
*
* @return a new spatial representing the sky, ready to be attached to the
* scene graph
+ * @deprecated use {@link SkyFactory#createSky(com.jme3.asset.AssetManager, com.jme3.texture.Texture, com.jme3.math.Vector3f, com.jme3.util.SkyFactory.EnvMapType)}
*/
+ @Deprecated
public static Spatial createSky(AssetManager assetManager, Texture texture,
Vector3f normalScale, boolean sphereMap) {
return createSky(assetManager, texture, normalScale, sphereMap, 10);
}
+ /**
+ * Create a sky with radius=10 using the given cubemap or spheremap texture.
+ *
+ * For the sky to be visible, its radius must fall between the near and far
+ * planes of the camera's frustrum.
+ *
+ * @param assetManager from which to load materials
+ * @param texture to use
+ * @param normalScale The normal scale is multiplied by the 3D normal to get
+ * a texture coordinate. Use Vector3f.UNIT_XYZ to not apply and
+ * transformation to the normal.
+ * @param envMapType see {@link EnvMapType}
+ * @return a new spatial representing the sky, ready to be attached to the
+ * scene graph
+ */
+ public static Spatial createSky(AssetManager assetManager, Texture texture,
+ Vector3f normalScale, EnvMapType envMapType) {
+ return createSky(assetManager, texture, normalScale, envMapType, 10);
+ }
/**
* Create a sky using the given cubemap or spheremap texture.
*
@@ -105,9 +152,31 @@ public class SkyFactory {
* frustrum
* @return a new spatial representing the sky, ready to be attached to the
* scene graph
+ * @deprecated use {@link SkyFactory#createSky(com.jme3.asset.AssetManager, com.jme3.texture.Texture, com.jme3.math.Vector3f, com.jme3.util.SkyFactory.EnvMapType, int)}
*/
+ @Deprecated
public static Spatial createSky(AssetManager assetManager, Texture texture,
Vector3f normalScale, boolean sphereMap, int sphereRadius) {
+ return createSky(assetManager, texture, normalScale, sphereMap?EnvMapType.SphereMap:EnvMapType.CubeMap, sphereRadius);
+ }
+
+ /**
+ * Create a sky using the given cubemap or spheremap texture.
+ *
+ * @param assetManager from which to load materials
+ * @param texture to use
+ * @param normalScale The normal scale is multiplied by the 3D normal to get
+ * a texture coordinate. Use Vector3f.UNIT_XYZ to not apply and
+ * transformation to the normal.
+ * @param envMapType see {@link EnvMapType}
+ * @param sphereRadius the sky sphere's radius: for the sky to be visible,
+ * its radius must fall between the near and far planes of the camera's
+ * frustrum
+ * @return a new spatial representing the sky, ready to be attached to the
+ * scene graph
+ */
+ public static Spatial createSky(AssetManager assetManager, Texture texture,
+ Vector3f normalScale, EnvMapType envMapType, int sphereRadius) {
if (texture == null) {
throw new IllegalArgumentException("texture cannot be null");
}
@@ -121,13 +190,19 @@ public class SkyFactory {
Material skyMat = new Material(assetManager, "Common/MatDefs/Misc/Sky.j3md");
skyMat.setVector3("NormalScale", normalScale);
- if (sphereMap) {
- skyMat.setBoolean("SphereMap", sphereMap);
- } else if (!(texture instanceof TextureCubeMap)) {
- // make sure its a cubemap
- Image img = texture.getImage();
- texture = new TextureCubeMap();
- texture.setImage(img);
+ switch (envMapType){
+ case CubeMap :
+ // make sure its a cubemap
+ Image img = texture.getImage();
+ texture = new TextureCubeMap();
+ texture.setImage(img);
+ break;
+ case SphereMap :
+ skyMat.setBoolean("SphereMap", true);
+ break;
+ case EquirectMap :
+ skyMat.setBoolean("EquirectMap", true);
+ break;
}
texture.setMagFilter(Texture.MagFilter.Bilinear);
texture.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
@@ -136,6 +211,84 @@ public class SkyFactory {
return sky;
}
+
+ /**
+ * Create a sky using the given cubemap or spheremap texture.
+ *
+ * @param assetManager from which to load materials
+ * @param texture to use *
+ * @param sphereMap determines how the texture is used:
+ *