/** * Create a sky using the given cubemap or spheremap texture. * * @param assetManager from which to load materials * @param texture to use * @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, EnvMapType envMapType) { return createSky(assetManager, texture, Vector3f.UNIT_XYZ, envMapType); }
private static void checkImagesForCubeMap(Image... images) { if (images.length == 1) { return; } Format fmt = images[0].getFormat(); int width = images[0].getWidth(); int height = images[0].getHeight(); ByteBuffer data = images[0].getData(0); int size = data != null ? data.capacity() : 0; checkImage(images[0]); for (int i = 1; i < images.length; i++) { Image image = images[i]; checkImage(images[i]); if (image.getFormat() != fmt) { throw new IllegalArgumentException("Images must have same format"); } if (image.getWidth() != width || image.getHeight() != height) { throw new IllegalArgumentException("Images must have same resolution"); } ByteBuffer data2 = image.getData(0); if (data2 != null){ if (data2.capacity() != size) { throw new IllegalArgumentException("Images must have same size"); } } } }
Image downImg = down.getImage(); checkImagesForCubeMap(westImg, eastImg, northImg, southImg, upImg, downImg); return createSky(assetManager, cubeMap, normalScale, EnvMapType.CubeMap, sphereRadius);
Image downImg = down.getImage(); checkImagesForCubeMap(westImg, eastImg, northImg, southImg, upImg, downImg);
Image downImg = down.getImage(); checkImagesForCubeMap(westImg, eastImg, northImg, southImg, upImg, downImg); return createSky(assetManager, cubeMap, normalScale, EnvMapType.CubeMap, sphereRadius);
/** * Create a cube-mapped sky using six textures. * * @param assetManager from which to load materials * @param west texture for the western face of the cube * @param east texture for the eastern face of the cube * @param north texture for the northern face of the cube * @param south texture for the southern face of the cube * @param up texture for the top face of the cube * @param down texture for the bottom face of the cube * * @return a new spatial representing the sky, ready to be attached to the * scene graph */ public static Spatial createSky(AssetManager assetManager, Texture west, Texture east, Texture north, Texture south, Texture up, Texture down) { return createSky(assetManager, west, east, north, south, up, down, Vector3f.UNIT_XYZ); } }
private static void checkImagesForCubeMap(Image... images) { if (images.length == 1) { return; } Format fmt = images[0].getFormat(); int width = images[0].getWidth(); int height = images[0].getHeight(); ByteBuffer data = images[0].getData(0); int size = data != null ? data.capacity() : 0; checkImage(images[0]); for (int i = 1; i < images.length; i++) { Image image = images[i]; checkImage(images[i]); if (image.getFormat() != fmt) { throw new IllegalArgumentException("Images must have same format"); } if (image.getWidth() != width || image.getHeight() != height) { throw new IllegalArgumentException("Images must have same resolution"); } ByteBuffer data2 = image.getData(0); if (data2 != null){ if (data2.capacity() != size) { throw new IllegalArgumentException("Images must have same size"); } } } }
/** * 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 frustum. * * @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); } /**
private static void checkImagesForCubeMap(Image... images) { if (images.length == 1) { return; } Format fmt = images[0].getFormat(); int width = images[0].getWidth(); int height = images[0].getHeight(); ByteBuffer data = images[0].getData(0); int size = data != null ? data.capacity() : 0; checkImage(images[0]); for (int i = 1; i < images.length; i++) { Image image = images[i]; checkImage(images[i]); if (image.getFormat() != fmt) { throw new IllegalArgumentException("Images must have same format"); } if (image.getWidth() != width || image.getHeight() != height) { throw new IllegalArgumentException("Images must have same resolution"); } ByteBuffer data2 = image.getData(0); if (data2 != null){ if (data2.capacity() != size) { throw new IllegalArgumentException("Images must have same size"); } } } }
/** * Create a cube-mapped sky with radius=10 using six textures. * * For the sky to be visible, its radius must fall between the near and far * planes of the camera's frustum. * * @param assetManager from which to load materials * @param west texture for the western face of the cube * @param east texture for the eastern face of the cube * @param north texture for the northern face of the cube * @param south texture for the southern face of the cube * @param up texture for the top face of the cube * @param down texture for the bottom face of the cube * @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. * @return a new spatial representing the sky, ready to be attached to the * scene graph */ public static Spatial createSky(AssetManager assetManager, Texture west, Texture east, Texture north, Texture south, Texture up, Texture down, Vector3f normalScale) { return createSky(assetManager, west, east, north, south, up, down, normalScale, 10); }
/** * 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:<br> * <ul> * <li>true: The texture is a Texture2D with the pixels arranged for * <a href="http://en.wikipedia.org/wiki/Sphere_mapping">sphere * mapping</a>.</li> * <li>false: The texture is either a TextureCubeMap or Texture2D. If it is * a Texture2D then the image is taken from it and is inserted into a * TextureCubeMap</li> * </ul> * @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, boolean sphereMap) { return createSky(assetManager, texture, Vector3f.UNIT_XYZ, sphereMap?EnvMapType.SphereMap:EnvMapType.CubeMap); }
/** * Create a sky using the given cubemap or spheremap texture. * * @param assetManager from which to load materials * @param textureName the path to the texture asset to use * @param sphereMap determines how the texture is used:<br> * <ul> * <li>true: The texture is a Texture2D with the pixels arranged for * <a href="http://en.wikipedia.org/wiki/Sphere_mapping">sphere * mapping</a>.</li> * <li>false: The texture is either a TextureCubeMap or Texture2D. If it is * a Texture2D then the image is taken from it and is inserted into a * TextureCubeMap</li> * </ul> * @return a new spatial representing the sky, ready to be attached to the * scene graph * @deprecated use {@link SkyFactory#createSky(com.jme3.asset.AssetManager, java.lang.String, com.jme3.math.Vector3f, com.jme3.util.SkyFactory.EnvMapType)} */ @Deprecated public static Spatial createSky(AssetManager assetManager, String textureName, boolean sphereMap) { return createSky(assetManager, textureName, sphereMap?EnvMapType.SphereMap:EnvMapType.CubeMap); }
/** * 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 frustum. * * @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 sphereMap determines how the texture is used:<br> * <ul> * <li>true: The texture is a Texture2D with the pixels arranged for * <a href="http://en.wikipedia.org/wiki/Sphere_mapping">sphere * mapping</a>.</li> * <li>false: The texture is either a TextureCubeMap or Texture2D. If it is * a Texture2D then the image is taken from it and is inserted into a * TextureCubeMap</li> * </ul> * @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 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 sphereMap determines how the texture is used:<br> * <ul> * <li>true: The texture is a Texture2D with the pixels arranged for * <a href="http://en.wikipedia.org/wiki/Sphere_mapping">sphere * mapping</a>.</li> * <li>false: The texture is either a TextureCubeMap or Texture2D. If it is * a Texture2D then the image is taken from it and is inserted into a * TextureCubeMap</li> * </ul> * @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 * frustum * @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); }
private void createSky() { rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", SkyFactory.EnvMapType.CubeMap)); }
public void setupSkyBox() { rootNode.attachChild(SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", SkyFactory.EnvMapType.CubeMap)); } DirectionalLight dl;
public void setupSkyBox() { rootNode.attachChild(SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", SkyFactory.EnvMapType.CubeMap)); } DirectionalLight dl;
public void setupSkyBox(){ Texture envMap; if (renderer.getCaps().contains(Caps.FloatTexture)){ envMap = assetManager.loadTexture("Textures/Sky/St Peters/StPeters.hdr"); }else{ envMap = assetManager.loadTexture("Textures/Sky/St Peters/StPeters.jpg"); } rootNode.attachChild(SkyFactory.createSky(assetManager, envMap, new Vector3f(-1,-1,-1), SkyFactory.EnvMapType.SphereMap)); }
public void setupSkyBox() { Texture envMap; if (renderer.getCaps().contains(Caps.FloatTexture)) { envMap = assetManager.loadTexture("Textures/Sky/St Peters/StPeters.hdr"); } else { envMap = assetManager.loadTexture("Textures/Sky/St Peters/StPeters.jpg"); } Spatial sky = SkyFactory.createSky(assetManager, envMap, new Vector3f(-1f, -1f, -1f), EnvMapType.SphereMap); rootNode.attachChild(sky); }
/** * Create a sky using the given cubemap or spheremap texture. * * @param assetManager from which to load materials * @param textureName the path to the texture asset to use * @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, String textureName, EnvMapType envMapType) { TextureKey key = new TextureKey(textureName, true); key.setGenerateMips(false); if (envMapType == EnvMapType.CubeMap) { key.setTextureTypeHint(Texture.Type.CubeMap); } Texture tex = assetManager.loadTexture(key); return createSky(assetManager, tex, envMapType); }