artofillusion.texture
Class LayeredMapping

java.lang.Object
  extended by artofillusion.texture.TextureMapping
      extended by artofillusion.texture.LayeredMapping

public class LayeredMapping
extends TextureMapping

LayeredMapping is the TextureMapping corresponding to LayeredTextures. It allows multiple textures to be layered on top of each other. Most of the actual work is done by this class, rather than LayeredTexture.


Field Summary
static int BLEND
           
static int OVERLAY_ADD_BUMPS
           
static int OVERLAY_BLEND_BUMPS
           
 
Fields inherited from class artofillusion.texture.TextureMapping
BACK_ONLY, FRONT_AND_BACK, FRONT_ONLY
 
Constructor Summary
LayeredMapping(Object3D obj, Texture tex)
           
 
Method Summary
 void addLayer(int index, Texture tex, TextureMapping map, int mode)
          Add a layer to the texture.
 void addLayer(Texture tex)
          Deprecated. Use addLayer(int, Texture, TextureMapping, int) instead.
 void copy(TextureMapping theMap)
          Make this mapping identical to another one.
 void deleteLayer(int which)
          Delete a layer from the texture.
 TextureMapping duplicate()
          Create a new TextureMapping which is identical to this one.
 TextureMapping duplicate(Object3D obj, Texture tex)
          Create a new TextureMapping which is identical to this one, but for a different Texture.
 void getAverageSpec(TextureSpec spec, double time, double[] param)
          Estimate the average surface properties by adding up the average properties of all of the layers.
 double getDisplacement(Vec3 pos, double size, double t, double[] param)
          Determine the displacement height by adding up all of the layers.
 Widget getEditingPanel(Object3D obj, MaterialPreviewer preview)
          There is no editing panel for layered mappings, since this is handled directly by the object texture dialog.
 Texture getLayer(int which)
          Get a particular layer.
 TextureParameter getLayerBlendingParameter(int layer)
          Get the parameter which specifies the blending fraction for a layer.
 TextureMapping getLayerMapping(int which)
          Get the mapping for a particular layer.
 int getLayerMode(int which)
          Get the blend mode for a particular layer.
 TextureParameter[] getLayerParameters(int which)
          Get the list of texture parameters for a particular layer.
 Texture[] getLayers()
          Get the list of layers for this texture.
static java.lang.String getName()
           
 int getNumLayers()
          Get the number of layers.
 Object3D getObject()
          Get the object this mapping is applied to.
 TextureParameter getParameterForLayer(TextureParameter parameter, int layer)
          Get the parameter corresponding to a parameter of one of the layer textures or mappings.
 TextureParameter[] getParameters()
          Get the list of texture parameters.
 Texture getTexture()
          Get the LayeredTexture object this mapping is associated with
 void getTextureSpec(Vec3 pos, TextureSpec spec, double angle, double size, double t, double[] param)
          Determine the surface properties by adding up the properties of all of the layers.
 void getTransparency(Vec3 pos, RGBColor trans, double angle, double size, double t, double[] param)
          Determine the transparency by adding up all of the layers.
 RenderingTriangle mapTriangle(int v1, int v2, int v3, int n1, int n2, int n3, Vec3[] vert)
          Given the vertices to be mapped and their normal vectors, generate a RenderingTriangle.
 void moveLayer(int which, int pos)
          Move a layer to a new position.
 void readFromFile(java.io.DataInputStream in, Scene theScene)
          Loading and saving of layered mappings works a bit differently from other mappings, since it needs to refer other textures in the scene.
 void setLayer(int which, Texture tex)
          Set a particular layer.
 void setLayerMapping(int which, TextureMapping map)
          Set the mapping for a particular layer.
 void setLayerMode(int which, int mode)
          Set the blend mode for a particular layer.
 void setParameters(RenderingTriangle tri, double[] p1, double[] p2, double[] p3, RenderingMesh mesh)
          This method is called once the texture parameters for the vertices of a triangle are known.
 void writeToFile(java.io.DataOutputStream out)
          This form of writeToFile() is never used, and should never be called.
 void writeToFile(java.io.DataOutputStream out, Scene theScene)
           
 
Methods inherited from class artofillusion.texture.TextureMapping
appliesTo, appliesToFace, setAppliesTo
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLEND

public static final int BLEND
See Also:
Constant Field Values

OVERLAY_BLEND_BUMPS

public static final int OVERLAY_BLEND_BUMPS
See Also:
Constant Field Values

OVERLAY_ADD_BUMPS

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

LayeredMapping

public LayeredMapping(Object3D obj,
                      Texture tex)
Method Detail

getNumLayers

public int getNumLayers()
Get the number of layers.


getLayers

public Texture[] getLayers()
Get the list of layers for this texture.


getLayer

public Texture getLayer(int which)
Get a particular layer.


setLayer

public void setLayer(int which,
                     Texture tex)
Set a particular layer.


getLayerMapping

public TextureMapping getLayerMapping(int which)
Get the mapping for a particular layer.


setLayerMapping

public void setLayerMapping(int which,
                            TextureMapping map)
Set the mapping for a particular layer.


getLayerMode

public int getLayerMode(int which)
Get the blend mode for a particular layer.


setLayerMode

public void setLayerMode(int which,
                         int mode)
Set the blend mode for a particular layer.


getParameters

public TextureParameter[] getParameters()
Get the list of texture parameters.

Overrides:
getParameters in class TextureMapping

getLayerParameters

public TextureParameter[] getLayerParameters(int which)
Get the list of texture parameters for a particular layer.


getLayerBlendingParameter

public TextureParameter getLayerBlendingParameter(int layer)
Get the parameter which specifies the blending fraction for a layer.


getParameterForLayer

public TextureParameter getParameterForLayer(TextureParameter parameter,
                                             int layer)
Get the parameter corresponding to a parameter of one of the layer textures or mappings.

A LayeredMapping creates a new TextureParameter corresponding to each parameter of its component Textures and TextureMappings. This is necessary because a single Texture might be used for multiple layers, so there must be multiple parameters corresponding to each parameter of that Texture.

Parameters:
parameter - a parameter defined by a layer's Texture or TextureMapping
layer - the layer for which to get the parameter
Returns:
the parameter of this LayeredMapping corresponding to the specified parameter, or null if the specified parameter does not belong to the Texture or TextureMapping of the specified layer

addLayer

public void addLayer(Texture tex)
Deprecated. Use addLayer(int, Texture, TextureMapping, int) instead.

Add a layer to the texture.


addLayer

public void addLayer(int index,
                     Texture tex,
                     TextureMapping map,
                     int mode)
Add a layer to the texture.

Parameters:
index - the position at which the new layer should be added, where layer 0 is the topmost layer (the one visible over all others)
tex - the Texture of the new layer
map - the TextureMapping of the new layer
mode - the blending mode of the new layer (BLEND, OVERLAY_BLEND_BUMPS, or OVERLAY_ADD_BUMPS)

deleteLayer

public void deleteLayer(int which)
Delete a layer from the texture.


moveLayer

public void moveLayer(int which,
                      int pos)
Move a layer to a new position.


readFromFile

public void readFromFile(java.io.DataInputStream in,
                         Scene theScene)
                  throws java.io.IOException,
                         java.io.InvalidObjectException
Loading and saving of layered mappings works a bit differently from other mappings, since it needs to refer other textures in the scene.

Throws:
java.io.IOException
java.io.InvalidObjectException

writeToFile

public void writeToFile(java.io.DataOutputStream out,
                        Scene theScene)
                 throws java.io.IOException
Throws:
java.io.IOException

writeToFile

public void writeToFile(java.io.DataOutputStream out)
                 throws java.io.IOException
This form of writeToFile() is never used, and should never be called.

Specified by:
writeToFile in class TextureMapping
Throws:
java.io.IOException

getName

public static java.lang.String getName()

mapTriangle

public RenderingTriangle mapTriangle(int v1,
                                     int v2,
                                     int v3,
                                     int n1,
                                     int n2,
                                     int n3,
                                     Vec3[] vert)
Description copied from class: TextureMapping
Given the vertices to be mapped and their normal vectors, generate a RenderingTriangle. Most subclasses will override this method. However, some mappings which require more information than just the vertex coordinates may instead define new methods which replace this one.

Overrides:
mapTriangle in class TextureMapping

setParameters

public void setParameters(RenderingTriangle tri,
                          double[] p1,
                          double[] p2,
                          double[] p3,
                          RenderingMesh mesh)
This method is called once the texture parameters for the vertices of a triangle are known.

Overrides:
setParameters in class TextureMapping

getTextureSpec

public void getTextureSpec(Vec3 pos,
                           TextureSpec spec,
                           double angle,
                           double size,
                           double t,
                           double[] param)
Determine the surface properties by adding up the properties of all of the layers.

Specified by:
getTextureSpec in class TextureMapping
Parameters:
pos - the point at which to evaluate the texture
spec - the surface properties will be stored in this
angle - the dot product of the view direction with the surface normal
size - the width of the region over which to average the surface properties
t - the time at which to evaluate the surface properties
param - the texture parameter values at the point

getAverageSpec

public void getAverageSpec(TextureSpec spec,
                           double time,
                           double[] param)
Estimate the average surface properties by adding up the average properties of all of the layers.


getTransparency

public void getTransparency(Vec3 pos,
                            RGBColor trans,
                            double angle,
                            double size,
                            double t,
                            double[] param)
Determine the transparency by adding up all of the layers.

Specified by:
getTransparency in class TextureMapping

getDisplacement

public double getDisplacement(Vec3 pos,
                              double size,
                              double t,
                              double[] param)
Determine the displacement height by adding up all of the layers.

Specified by:
getDisplacement in class TextureMapping

getTexture

public Texture getTexture()
Get the LayeredTexture object this mapping is associated with

Specified by:
getTexture in class TextureMapping

getObject

public Object3D getObject()
Description copied from class: TextureMapping
Get the object this mapping is applied to.

Specified by:
getObject in class TextureMapping

duplicate

public TextureMapping duplicate()
Create a new TextureMapping which is identical to this one.

Specified by:
duplicate in class TextureMapping

duplicate

public TextureMapping duplicate(Object3D obj,
                                Texture tex)
Create a new TextureMapping which is identical to this one, but for a different Texture.

Specified by:
duplicate in class TextureMapping

copy

public void copy(TextureMapping theMap)
Make this mapping identical to another one.

Specified by:
copy in class TextureMapping

getEditingPanel

public Widget getEditingPanel(Object3D obj,
                              MaterialPreviewer preview)
There is no editing panel for layered mappings, since this is handled directly by the object texture dialog.

Specified by:
getEditingPanel in class TextureMapping


Copyright © 1999-2011 by Peter Eastman.