artofillusion.texture
Class TextureMapping

java.lang.Object
  extended by artofillusion.texture.TextureMapping
Direct Known Subclasses:
LayeredMapping, Mapping2D, Mapping3D, UniformMapping

public abstract class TextureMapping
extends java.lang.Object

A TextureMapping describes the mapping of a Texture's texture coordinates to points on the surface of an object. It operates in two ways. First, it generates RenderingTriangles whic contain the necessary information to be rendered. Second, since some renderers can directly render certain objects without ever breaking them into triangles, it must be able to directly calculate the material properties for a point in space.

This is an abstract class. Its subclasses describe various types of mappings which are appropriate for various types of objects and materials.


Field Summary
static short BACK_ONLY
           
static short FRONT_AND_BACK
           
static short FRONT_ONLY
           
 
Constructor Summary
TextureMapping()
           
 
Method Summary
 short appliesTo()
          Determine whether this texture is applied to front faces, back faces, or both.
 boolean appliesToFace(boolean front)
          Determine whether this texture is applied to front (or back) faces.
abstract  void copy(TextureMapping map)
          Make this mapping identical to another one.
abstract  TextureMapping duplicate()
          Create a new TextureMapping which is identical to this one.
abstract  TextureMapping duplicate(Object3D obj, Texture tex)
          Create a new TextureMapping which is identical to this one, but for a different object and texture.
abstract  double getDisplacement(Vec3 pos, double size, double t, double[] param)
          Given a point on the surface, evaluate the displacement function.
abstract  Widget getEditingPanel(Object3D obj, MaterialPreviewer preview)
          This method should return a Widget in which the user can edit the mapping.
static java.lang.String getName()
          Get the name of this type of mapping.
abstract  Object3D getObject()
          Get the object this mapping is applied to.
 TextureParameter[] getParameters()
          Get the list of texture parameters associated with this mapping and its texture.
abstract  Texture getTexture()
          Get the Texture associated with this TextureMapping.
abstract  void getTextureSpec(Vec3 pos, TextureSpec spec, double angle, double size, double t, double[] param)
          Given a point on the surface for which this mapping is being used, find the corresponding surface properties.
abstract  void getTransparency(Vec3 pos, RGBColor trans, double angle, double size, double t, double[] param)
          Same as above, except only return the transparent color.
 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 setAppliesTo(short whichFaces)
          Set whether this texture should apply to front faces, back faces, or both.
 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.
abstract  void writeToFile(java.io.DataOutputStream out)
          Every subclass of TextureMapping must define a constructor which takes a Texture and an Object3D as its arguments:
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FRONT_AND_BACK

public static final short FRONT_AND_BACK
See Also:
Constant Field Values

FRONT_ONLY

public static final short FRONT_ONLY
See Also:
Constant Field Values

BACK_ONLY

public static final short BACK_ONLY
See Also:
Constant Field Values
Constructor Detail

TextureMapping

public TextureMapping()
Method Detail

writeToFile

public abstract void writeToFile(java.io.DataOutputStream out)
                          throws java.io.IOException
Every subclass of TextureMapping must define a constructor which takes a Texture and an Object3D as its arguments:

public MappingSubclass(Object3D obj, Texture texture)

In addition, every subclass must include a method of the form

public static boolean legalMapping(Object3D obj, Texture texture)

which returns true if the mapping can be used with the specified object and Texture. Finally, every subclass must include a constructor with the signature

public MappingSubclass(DataInputStream in, Object3D obj, Texture texture) throws IOException, InvalidObjectException

which reconstructs the mapping by reading its data from an input stream. The following method writes the object's data to an output stream.

Throws:
java.io.IOException

getTexture

public abstract Texture getTexture()
Get the Texture associated with this TextureMapping.


getObject

public abstract Object3D getObject()
Get the object this mapping is applied to.


getName

public static java.lang.String getName()
Get the name of this type of mapping. Subclasses should override this method to return an appropriate name.


mapTriangle

public 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. 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.


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. If necessary, subclasses can override this to take appropriate action.


getTextureSpec

public abstract void getTextureSpec(Vec3 pos,
                                    TextureSpec spec,
                                    double angle,
                                    double size,
                                    double t,
                                    double[] param)
Given a point on the surface for which this mapping is being used, find the corresponding surface properties. The properties should be averaged over a region around the point.

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

getTransparency

public abstract void getTransparency(Vec3 pos,
                                     RGBColor trans,
                                     double angle,
                                     double size,
                                     double t,
                                     double[] param)
Same as above, except only return the transparent color. This can save time in cases where only the transparency is required, for example, when tracing shadow rays.


getDisplacement

public abstract double getDisplacement(Vec3 pos,
                                       double size,
                                       double t,
                                       double[] param)
Given a point on the surface, evaluate the displacement function. All parameters are the same as for getTextureSpec().


duplicate

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


duplicate

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


copy

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


getParameters

public TextureParameter[] getParameters()
Get the list of texture parameters associated with this mapping and its texture. Subclasses that define their own parameters should override this to add them to the list.


appliesTo

public short appliesTo()
Determine whether this texture is applied to front faces, back faces, or both.


appliesToFace

public final boolean appliesToFace(boolean front)
Determine whether this texture is applied to front (or back) faces.


setAppliesTo

public void setAppliesTo(short whichFaces)
Set whether this texture should apply to front faces, back faces, or both.


getEditingPanel

public abstract Widget getEditingPanel(Object3D obj,
                                       MaterialPreviewer preview)
This method should return a Widget in which the user can edit the mapping. The parameters are the object whose mapping is being edited, and a MaterialPreviewer which should be rendered whenever one of the mapping's parameters changes.



Copyright © 1999-2011 by Peter Eastman.