com.jme3.scene.plugins.blender.textures
Class TextureHelper

java.lang.Object
  extended by com.jme3.scene.plugins.blender.AbstractBlenderHelper
      extended by com.jme3.scene.plugins.blender.textures.TextureHelper

public class TextureHelper
extends AbstractBlenderHelper

A class that is used in texture calculations.


Field Summary
static int TEX_BLEND
           
static int TEX_CLOUDS
           
static int TEX_DISTNOISE
           
static int TEX_ENVMAP
           
static int TEX_IMAGE
           
static int TEX_MAGIC
           
static int TEX_MARBLE
           
static int TEX_MUSGRAVE
           
static int TEX_NOISE
           
static int TEX_NONE
           
static int TEX_PLUGIN
           
static int TEX_POINTDENSITY
           
static int TEX_STUCCI
           
static int TEX_VORONOI
           
static int TEX_VOXELDATA
           
static int TEX_WOOD
           
 
Fields inherited from class com.jme3.scene.plugins.blender.AbstractBlenderHelper
blenderVersion, fixUpAxis, upAxisRotationQuaternion
 
Constructor Summary
TextureHelper(java.lang.String blenderVersion, boolean fixUpAxis)
          This constructor parses the given blender version and stores the result.
 
Method Summary
 Image convertToNormalMapTexture(Image source, float strengthFactor)
          This method converts the given texture into normal-map texture.
 Image decompress(Image image)
          This method decompresses the given image.
protected  int getHeight(java.awt.image.BufferedImage image, int x, int y)
          This method returns the height represented by the specified pixel in the given texture.
 Texture getTexture(Structure tex, Structure mTex, BlenderContext blenderContext)
          This class returns a texture read from the file or from packed blender data.
 Texture getTextureFromImage(Structure image, BlenderContext blenderContext)
          This class returns a texture read from the file or from packed blender data.
protected  Texture loadTextureFromFile(java.lang.String name, BlenderContext blenderContext)
          This method loads the textre from outside the blend file.
 boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext)
          This method analyzes the given structure and the data contained within blender context and decides if the feature should be loaded.
protected  int vectorToColor(float x, float y, float z)
          This method transforms given vector's coordinates into ARGB color (A is always = 255).
 
Methods inherited from class com.jme3.scene.plugins.blender.AbstractBlenderHelper
applyProperties, clearState, isBlank, loadProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEX_NONE

public static final int TEX_NONE
See Also:
Constant Field Values

TEX_CLOUDS

public static final int TEX_CLOUDS
See Also:
Constant Field Values

TEX_WOOD

public static final int TEX_WOOD
See Also:
Constant Field Values

TEX_MARBLE

public static final int TEX_MARBLE
See Also:
Constant Field Values

TEX_MAGIC

public static final int TEX_MAGIC
See Also:
Constant Field Values

TEX_BLEND

public static final int TEX_BLEND
See Also:
Constant Field Values

TEX_STUCCI

public static final int TEX_STUCCI
See Also:
Constant Field Values

TEX_NOISE

public static final int TEX_NOISE
See Also:
Constant Field Values

TEX_IMAGE

public static final int TEX_IMAGE
See Also:
Constant Field Values

TEX_PLUGIN

public static final int TEX_PLUGIN
See Also:
Constant Field Values

TEX_ENVMAP

public static final int TEX_ENVMAP
See Also:
Constant Field Values

TEX_MUSGRAVE

public static final int TEX_MUSGRAVE
See Also:
Constant Field Values

TEX_VORONOI

public static final int TEX_VORONOI
See Also:
Constant Field Values

TEX_DISTNOISE

public static final int TEX_DISTNOISE
See Also:
Constant Field Values

TEX_POINTDENSITY

public static final int TEX_POINTDENSITY
See Also:
Constant Field Values

TEX_VOXELDATA

public static final int TEX_VOXELDATA
See Also:
Constant Field Values
Constructor Detail

TextureHelper

public TextureHelper(java.lang.String blenderVersion,
                     boolean fixUpAxis)
This constructor parses the given blender version and stores the result. It creates noise generator and texture generators.

Parameters:
blenderVersion - the version read from the blend file
fixUpAxis - a variable that indicates if the Y asxis is the UP axis or not
Method Detail

getTexture

public Texture getTexture(Structure tex,
                          Structure mTex,
                          BlenderContext blenderContext)
                   throws BlenderFileException
This class returns a texture read from the file or from packed blender data. The returned texture has the name set to the value of its blender type.

Parameters:
tex - texture structure filled with data
blenderContext - the blender context
Returns:
the texture that can be used by JME engine
Throws:
BlenderFileException - this exception is thrown when the blend file structure is somehow invalid or corrupted

convertToNormalMapTexture

public Image convertToNormalMapTexture(Image source,
                                       float strengthFactor)
This method converts the given texture into normal-map texture.

Parameters:
source - the source texture
strengthFactor - the normal strength factor
Returns:
normal-map texture

decompress

public Image decompress(Image image)
This method decompresses the given image. If the given image is already decompressed nothing happens and it is simply returned.

Parameters:
image - the image to decompress
Returns:
the decompressed image

getHeight

protected int getHeight(java.awt.image.BufferedImage image,
                        int x,
                        int y)
This method returns the height represented by the specified pixel in the given texture. The given texture should be a height-map.

Parameters:
image - the height-map texture
x - pixel's X coordinate
y - pixel's Y coordinate
Returns:
height reprezented by the given texture in the specified location

vectorToColor

protected int vectorToColor(float x,
                            float y,
                            float z)
This method transforms given vector's coordinates into ARGB color (A is always = 255).

Parameters:
x - X factor of the vector
y - Y factor of the vector
z - Z factor of the vector
Returns:
color representation of the given vector

getTextureFromImage

public Texture getTextureFromImage(Structure image,
                                   BlenderContext blenderContext)
                            throws BlenderFileException
This class returns a texture read from the file or from packed blender data.

Parameters:
image - image structure filled with data
blenderContext - the blender context
Returns:
the texture that can be used by JME engine
Throws:
BlenderFileException - this exception is thrown when the blend file structure is somehow invalid or corrupted

loadTextureFromFile

protected Texture loadTextureFromFile(java.lang.String name,
                                      BlenderContext blenderContext)
This method loads the textre from outside the blend file.

Parameters:
name - the path to the image
blenderContext - the blender context
Returns:
the loaded image or null if the image cannot be found

shouldBeLoaded

public boolean shouldBeLoaded(Structure structure,
                              BlenderContext blenderContext)
Description copied from class: AbstractBlenderHelper
This method analyzes the given structure and the data contained within blender context and decides if the feature should be loaded.

Specified by:
shouldBeLoaded in class AbstractBlenderHelper
Parameters:
structure - structure to be analyzed
blenderContext - the blender context
Returns:
true if the feature should be loaded and false otherwise