de.jreality.shader
Class TextureUtility

java.lang.Object
  extended by de.jreality.shader.TextureUtility

public class TextureUtility
extends Object

A bunch of factory methods that create Textures and ReflectionMaps. Other shader related stuff should follow.

Author:
Steffen Weissman

Field Summary
static String[] STANDARD_CUBEMAP_PARTS
          {"bk","ft","dn","up","lf","rt"}
 
Method Summary
static CubeMap createCubeMap(Appearance app, String prefix, ImageData[] imgs)
          method to create a reflectionMap for the 6 given images (as ImageData).
static CubeMap createCubeMap(Appearance app, String prefix, String resourcePrefix, String[] sides, String resourceEnding)
          Convienience Method to load all 6 images for a ReflectionMap.
static ImageData[] createCubeMapData(Input zipFile)
           
static ImageData[] createCubeMapData(String resourcePrefix, String[] sides, String resourceEnding)
          Convienience Method to load 6 images for a CubeMap.
static ImageData createPointSprite(int textureSize, double[] lightDirection, Color diffuseColor, Color specularColor, double specularExponent)
           
static CubeMap createReflectionMap(Appearance app, String shader, ImageData... imgs)
          method to create a reflectionMap for the 6 given images (as ImageData).
static CubeMap createReflectionMap(Appearance app, String shader, Input[] data)
          method to create a reflectionMap for the 6 given images (as Inputs).
static CubeMap createReflectionMap(Appearance app, String shader, String resourcePrefix, String[] sides, String resourceEnding)
          Convienience Method to load all 6 images for a ReflectionMap.
static CubeMap createSkyBox(Appearance app, ImageData[] imgs)
          method to create a sky box for the 6 given images (as ImageData).
static CubeMap createSkyBox(Appearance app, Input[] data)
          method to create a sky box for the 6 given images (as Inputs).
static Texture2D createTexture(Appearance app, String shader, ImageData img)
           
static Texture2D createTexture(Appearance app, String shader, ImageData img, boolean readDefaults)
          method to create a reflectionMap for the given image (as ImageData).
static Texture2D createTexture(Appearance app, String shader, Input in)
           
static Texture2D createTexture(Appearance app, String shader, Input in, boolean readDefaults)
          method to create a reflectionMap for the given image (as ImageData).
static Texture2D createTexture(Appearance app, String shader, int i, ImageData img)
           
static Texture2D createTexture(Appearance app, String shader, int i, ImageData img, boolean readDefaults)
           
static Texture2D createTexture(Appearance app, String shader, String resourceName)
           
static Texture2D createTexture(Appearance app, String shader, String resourceName, boolean readDefaults)
          method to create a reflectionMap for the given image (as a String to locate as a resource)
static ImageData[] getCubeMapImages(CubeMap rm)
           
static boolean hasReflectionMap(Appearance app, String shader)
           
static boolean hasReflectionMap(EffectiveAppearance ea, String shader)
           
static void main(String[] args)
           
static CubeMap readReflectionMap(EffectiveAppearance app, String prefix)
          method to read the 6 sides of a ReflectionMap.
static void removeReflectionMap(Appearance app, String shader)
           
static void removeTexture(Appearance app, String shader)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STANDARD_CUBEMAP_PARTS

public static final String[] STANDARD_CUBEMAP_PARTS
{"bk","ft","dn","up","lf","rt"}

Method Detail

createTexture

public static Texture2D createTexture(Appearance app,
                                      String shader,
                                      ImageData img,
                                      boolean readDefaults)
method to create a reflectionMap for the given image (as ImageData).

Parameters:
app - the appearance where to create the Texture2D
shader - the name of the shader, should be null, "", "polygonShader" maybe "lineShader" works also
img - the ImageData
readDefaults - true for the Texture2D to return default values, if false it returns null for unset values
Returns:
a proxy implementation of Texture2D

createTexture

public static Texture2D createTexture(Appearance app,
                                      String shader,
                                      int i,
                                      ImageData img,
                                      boolean readDefaults)

createTexture

public static Texture2D createTexture(Appearance app,
                                      String shader,
                                      ImageData img)

createTexture

public static Texture2D createTexture(Appearance app,
                                      String shader,
                                      int i,
                                      ImageData img)

createTexture

public static Texture2D createTexture(Appearance app,
                                      String shader,
                                      Input in,
                                      boolean readDefaults)
                               throws IOException
method to create a reflectionMap for the given image (as ImageData).

Parameters:
app - the appearance where to create the Texture2D
shader - the name of the shader, should be null, "", "polygonShader" maybe "lineShader" works also
in - an Input to load the ImageData from
Returns:
a proxy implementation of Texture2D
Throws:
IOException

createTexture

public static Texture2D createTexture(Appearance app,
                                      String shader,
                                      Input in)
                               throws IOException
Throws:
IOException

createTexture

public static Texture2D createTexture(Appearance app,
                                      String shader,
                                      String resourceName,
                                      boolean readDefaults)
                               throws IOException
method to create a reflectionMap for the given image (as a String to locate as a resource)

Parameters:
app - the appearance where to create the Texture2D
shader - the name of the shader, should be null, "", "polygonShader" maybe "lineShader" works also
resourceName -
Returns:
a proxy implementation of Texture2D
Throws:
IOException - if the resource fails to load
See Also:
Readers.getInput()

createTexture

public static Texture2D createTexture(Appearance app,
                                      String shader,
                                      String resourceName)
                               throws IOException
Throws:
IOException

createReflectionMap

public static CubeMap createReflectionMap(Appearance app,
                                          String shader,
                                          ImageData... imgs)
method to create a reflectionMap for the 6 given images (as ImageData). The images are assumed to be in the following order: {"bk","ft","dn","up","lf","rt"}

Parameters:
app - the appearance where to create the ReflectionMap
shader - the name of the shader, should be null, "", "polygonShader" maybe "lineShader" works also
imgs -
Returns:
a proxy implementation of ReflectionMap

createReflectionMap

public static CubeMap createReflectionMap(Appearance app,
                                          String shader,
                                          Input[] data)
                                   throws IOException
method to create a reflectionMap for the 6 given images (as Inputs). The images are assumed to be in the following order: {"bk","ft","dn","up","lf","rt"}

Parameters:
app - the appearance where to create the ReflectionMap
shader - the name of the shader, should be null, "", "polygonShader" maybe "lineShader" works also
data - an array of 6 images
Returns:
a proxy implementation of ReflectionMap
Throws:
IOException - if data fails to load

createReflectionMap

public static CubeMap createReflectionMap(Appearance app,
                                          String shader,
                                          String resourcePrefix,
                                          String[] sides,
                                          String resourceEnding)
                                   throws IOException
Convienience Method to load all 6 images for a ReflectionMap. The 6 images are created by looking for the resources named
resourcePrefix+sides[i=0..5]+resourceEnding
The order of the 6 images is the same as for the other ReflectionMap methods: {"bk","ft","dn","up","lf","rt"}

Parameters:
app - the appearance where to create the ReflectionMap
shader - the name of the shader, should be null, "", "polygonShader" maybe "lineShader" works also
resourcePrefix - part of the resource names
sides - part of the resource names
resourceEnding - part of the resource names
Returns:
a proxy implementation of ReflectionMap
Throws:
IOException - if the resources fail to load

readReflectionMap

public static CubeMap readReflectionMap(EffectiveAppearance app,
                                        String prefix)
method to read the 6 sides of a ReflectionMap. Other than the create methods this method takes not only the shader name but the full string to the ReflectionMap Entity.

Parameters:
app - the ea to read from
prefix - the prefix under which the ReflectionMap is written to the appearance
Returns:
an array of 6 texture2d proxy implementations in the opengl order: {"bk","ft","dn","up","lf","rt"}

getCubeMapImages

public static ImageData[] getCubeMapImages(CubeMap rm)

createCubeMap

public static CubeMap createCubeMap(Appearance app,
                                    String prefix,
                                    ImageData[] imgs)
method to create a reflectionMap for the 6 given images (as ImageData). The images are assumed to be in the following order: {"bk","ft","dn","up","lf","rt"}

Parameters:
app - the appearance where to create the ReflectionMap
prefix - the prefix, i. e. "polygonShader.reflectionMap" or "skyBox", ...
imgs -
Returns:
a proxy implementation of ReflectionMap

createSkyBox

public static CubeMap createSkyBox(Appearance app,
                                   ImageData[] imgs)
method to create a sky box for the 6 given images (as ImageData). The images are assumed to be in the following order: {"bk","ft","dn","up","lf","rt"}

Parameters:
app - the appearance where to create the sky box
imgs -
Returns:
a proxy implementation of ReflectionMap

createSkyBox

public static CubeMap createSkyBox(Appearance app,
                                   Input[] data)
                            throws IOException
method to create a sky box for the 6 given images (as Inputs). The images are assumed to be in the following order: {"bk","ft","dn","up","lf","rt"}

Parameters:
app - the appearance where to create the sky box
data - an array of 6 images
Returns:
a proxy implementation of ReflectionMap
Throws:
IOException - if data fails to load

createCubeMap

public static CubeMap createCubeMap(Appearance app,
                                    String prefix,
                                    String resourcePrefix,
                                    String[] sides,
                                    String resourceEnding)
                             throws IOException
Convienience Method to load all 6 images for a ReflectionMap. The 6 images are created by looking for the resources named
resourcePrefix+sides[i=0..5]+resourceEnding
The order of the 6 images is the same as for the other ReflectionMap methods: {"bk","ft","dn","up","lf","rt"}

Parameters:
app - the appearance where to create the sky box
resourcePrefix - part of the resource names
sides - part of the resource names
resourceEnding - part of the resource names
Returns:
a proxy implementation of ReflectionMap
Throws:
IOException - if the resources fail to load

createCubeMapData

public static ImageData[] createCubeMapData(String resourcePrefix,
                                            String[] sides,
                                            String resourceEnding)
                                     throws IOException
Convienience Method to load 6 images for a CubeMap. The 6 images are created by looking for the resources named
resourcePrefix+sides[i=0..5]+resourceEnding
The order of the 6 images is the same as for the other CubeMap methods: {"bk","ft","dn","up","lf","rt"}

Parameters:
resourcePrefix - part of the resource names
sides - part of the resource names
resourceEnding - part of the resource names
Returns:
an array of length 6 containing all ImageDatas
Throws:
IOException - if the resources fail to load

createCubeMapData

public static ImageData[] createCubeMapData(Input zipFile)
                                     throws IOException
Throws:
IOException

createPointSprite

public static ImageData createPointSprite(int textureSize,
                                          double[] lightDirection,
                                          Color diffuseColor,
                                          Color specularColor,
                                          double specularExponent)

removeReflectionMap

public static void removeReflectionMap(Appearance app,
                                       String shader)

removeTexture

public static void removeTexture(Appearance app,
                                 String shader)

main

public static void main(String[] args)
                 throws IOException
Throws:
IOException

hasReflectionMap

public static boolean hasReflectionMap(EffectiveAppearance ea,
                                       String shader)

hasReflectionMap

public static boolean hasReflectionMap(Appearance app,
                                       String shader)