artofillusion.texture
Class UVMapping

java.lang.Object
  extended by artofillusion.texture.TextureMapping
      extended by artofillusion.texture.Mapping2D
          extended by artofillusion.texture.UVMapping

public class UVMapping
extends Mapping2D

UVMapping is a Mapping2D which allows the user to specify the texture coordinates of each vertex by hand.


Field Summary
 
Fields inherited from class artofillusion.texture.TextureMapping
BACK_ONLY, FRONT_AND_BACK, FRONT_ONLY
 
Constructor Summary
UVMapping(java.io.DataInputStream in, Object3D theObject, Texture theTexture)
           
UVMapping(Object3D theObject, Texture theTexture)
           
 
Method Summary
 void copy(TextureMapping mapping)
          Make this mapping identical to another one.
 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 object and texture.
 Vec2[][] findFaceTextureCoordinates(FacetedMesh mesh)
          Given a FacetedMesh to which this mapping has been applied, return the texture coordinates at each vertex of each face.
 Vec2[] findTextureCoordinates(Mesh mesh)
          Given a Mesh to which this mapping has been applied, return the texture coordinates at each vertex.
 double getDisplacement(Vec3 pos, double size, double time, double[] param)
          This method should not generally be called.
 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()
           
 TextureParameter[] getParameters()
          Get the list of texture parameters associated with this mapping and its texture.
 void getTextureSpec(Vec3 pos, TextureSpec spec, double angle, double size, double time, double[] param)
          This method should not generally be called.
 void getTransparency(Vec3 pos, RGBColor trans, double angle, double size, double time, double[] param)
          This method should not generally be called.
 TextureParameter getUParameter()
          Get the TextureParameter which stores the U texture coordinate.
 TextureParameter getVParameter()
          Get the TextureParameter which stores the V texture coordinate.
 boolean isPerFaceVertex(FacetedMesh mesh)
          Given a faceted mesh to which this mapping has been applied, determined whether the mapping is per-face-vertex.
static boolean legalMapping(Object3D obj, Texture tex)
           
 RenderingTriangle mapTriangle(int v1, int v2, int v3, int n1, int n2, int n3, Vec3[] vert)
          Create a UV mapped triangle.
 void setFaceTextureCoordinates(Object3D obj, Vec2[][] uv)
          Given a triangle mesh to which this mapping has been applied and the desired texture coordinates at each vertex, set the texture parameters accordingly.
 void setFaceTextureCoordinates(Object3D obj, Vec2[][] uv, TextureParameter uParameter, TextureParameter vParameter)
          Given a triangle mesh to which this mapping has been applied and the desired texture coordinates at each vertex, set the texture parameters accordingly.
 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 setTextureCoordinates(Object3D obj, Vec2[] uv)
          Given an object to which this mapping has been applied and the desired texture coordinates at each vertex, set the texture parameters accordingly.
 void setTextureCoordinates(Object3D obj, Vec2[] uv, TextureParameter uParameter, TextureParameter vParameter)
          Given an object to which this mapping has been applied and the desired texture coordinates at each vertex, set the texture parameters accordingly.
 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 artofillusion.texture.Mapping2D
getObject, getTexture
 
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
 

Constructor Detail

UVMapping

public UVMapping(Object3D theObject,
                 Texture theTexture)

UVMapping

public UVMapping(java.io.DataInputStream in,
                 Object3D theObject,
                 Texture theTexture)
          throws java.io.IOException,
                 java.io.InvalidObjectException
Throws:
java.io.IOException
java.io.InvalidObjectException
Method Detail

getName

public static java.lang.String getName()

getUParameter

public TextureParameter getUParameter()
Get the TextureParameter which stores the U texture coordinate.


getVParameter

public TextureParameter getVParameter()
Get the TextureParameter which stores the V texture coordinate.


legalMapping

public static boolean legalMapping(Object3D obj,
                                   Texture tex)

mapTriangle

public RenderingTriangle mapTriangle(int v1,
                                     int v2,
                                     int v3,
                                     int n1,
                                     int n2,
                                     int n3,
                                     Vec3[] vert)
Create a UV mapped triangle.

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 time,
                           double[] param)
This method should not generally be called. The mapping is undefined without knowing the texture coordinates for a particular triangle.

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
time - the time at which to evaluate the surface properties
param - the texture parameter values at the point

getTransparency

public void getTransparency(Vec3 pos,
                            RGBColor trans,
                            double angle,
                            double size,
                            double time,
                            double[] param)
This method should not generally be called. The mapping is undefined without knowing the texture coordinates for a particular triangle.

Specified by:
getTransparency in class TextureMapping

getDisplacement

public double getDisplacement(Vec3 pos,
                              double size,
                              double time,
                              double[] param)
This method should not generally be called. The mapping is undefined without knowing the texture coordinates for a particular triangle.

Specified by:
getDisplacement in class TextureMapping

findTextureCoordinates

public Vec2[] findTextureCoordinates(Mesh mesh)
Given a Mesh to which this mapping has been applied, return the texture coordinates at each vertex.

Specified by:
findTextureCoordinates in class Mapping2D

findFaceTextureCoordinates

public Vec2[][] findFaceTextureCoordinates(FacetedMesh mesh)
Given a FacetedMesh to which this mapping has been applied, return the texture coordinates at each vertex of each face. The return value is an array of size [# faces][# vertices/face] containing the face-vertex texture coordinates.


setTextureCoordinates

public void setTextureCoordinates(Object3D obj,
                                  Vec2[] uv)
Given an object to which this mapping has been applied and the desired texture coordinates at each vertex, set the texture parameters accordingly.


setTextureCoordinates

public void setTextureCoordinates(Object3D obj,
                                  Vec2[] uv,
                                  TextureParameter uParameter,
                                  TextureParameter vParameter)
Given an object to which this mapping has been applied and the desired texture coordinates at each vertex, set the texture parameters accordingly.

In most cases, you can call setTextureCoordinates(artofillusion.object.Object3D, artofillusion.math.Vec2[]) instead, since the mapping already knows what parameters correspond to the U and V coordinates. This version is necessary when this mapping is part of a LayeredMapping, since the LayeredMapping will have created new parameters that must be used in place of the original ones.


setFaceTextureCoordinates

public void setFaceTextureCoordinates(Object3D obj,
                                      Vec2[][] uv)
Given a triangle mesh to which this mapping has been applied and the desired texture coordinates at each vertex, set the texture parameters accordingly. uv is an array of size [# faces][# vertices/face] containing the face-vertex texture coordinates.


setFaceTextureCoordinates

public void setFaceTextureCoordinates(Object3D obj,
                                      Vec2[][] uv,
                                      TextureParameter uParameter,
                                      TextureParameter vParameter)
Given a triangle mesh to which this mapping has been applied and the desired texture coordinates at each vertex, set the texture parameters accordingly. uv is an array of size [# faces][# vertices/face] containing the face-vertex texture coordinates.

In most cases, you can call setFaceTextureCoordinates(artofillusion.object.Object3D, artofillusion.math.Vec2[][]) instead, since the mapping already knows what parameters correspond to the U and V coordinates. This version is necessary when this mapping is part of a LayeredMapping, since the LayeredMapping will have created new parameters that must be used in place of the original ones.


isPerFaceVertex

public boolean isPerFaceVertex(FacetedMesh mesh)
Given a faceted mesh to which this mapping has been applied, determined whether the mapping is per-face-vertex.


duplicate

public TextureMapping duplicate()
Description copied from class: TextureMapping
Create a new TextureMapping which is identical to this one.

Specified by:
duplicate in class TextureMapping

duplicate

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

Specified by:
duplicate in class TextureMapping

copy

public void copy(TextureMapping mapping)
Description copied from class: TextureMapping
Make this mapping identical to another one.

Specified by:
copy in class TextureMapping

getParameters

public TextureParameter[] getParameters()
Description copied from class: TextureMapping
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.

Overrides:
getParameters in class TextureMapping

getEditingPanel

public Widget getEditingPanel(Object3D obj,
                              MaterialPreviewer preview)
Description copied from class: TextureMapping
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.

Specified by:
getEditingPanel in class TextureMapping

writeToFile

public void writeToFile(java.io.DataOutputStream out)
                 throws java.io.IOException
Description copied from class: TextureMapping
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.

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


Copyright © 1999-2011 by Peter Eastman.